From 77e93f5453f3b9878c3e27b0e99a365356c5264c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 27 Jul 2009 21:32:16 +0000 Subject: Separate generated public header files from non-public headers, generated code re-organization. The gen/ directory has been removed, code is now generated into: $(builddir)/src - all .cpp files and non-public .h files. $(builddir)/include - all public .h files. The gen/ directory was originally intended to separate generated code from hand-written code. However both automake and cmake allow you to direct all build output, including generated code, into a separate build directory. In fact both recommend you build this way. Keeping the gen/ directory meant there would have been a total of 8 places to look for header files, all the combinations of builddir/srcdir, src/include and gen/no-gen. This was a mess, 4 is bad enough. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@798291 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/rubygen/amqpgen.rb | 31 +++++++++++++++------------ cpp/rubygen/framing.0-10/Operations.rb | 6 +++--- cpp/rubygen/framing.0-10/OperationsInvoker.rb | 6 +++--- cpp/rubygen/framing.0-10/Session.rb | 12 ++++++----- cpp/rubygen/framing.0-10/constants.rb | 10 ++++++--- cpp/rubygen/framing.0-10/frame_body_lists.rb | 2 +- cpp/rubygen/framing.0-10/structs.rb | 6 ++++-- cpp/rubygen/generate | 23 ++++++++++---------- 8 files changed, 54 insertions(+), 42 deletions(-) (limited to 'cpp/rubygen') diff --git a/cpp/rubygen/amqpgen.rb b/cpp/rubygen/amqpgen.rb index 802f934c7a..69e65a4056 100755 --- a/cpp/rubygen/amqpgen.rb +++ b/cpp/rubygen/amqpgen.rb @@ -318,7 +318,7 @@ class AmqpFakeMethod < AmqpMethod def content() return "1" if @action.is_a? AmqpCommand and @action.segments end def index() @action.code end def code() @action.code end - def synchronous() end # FIXME aconway 2008-04-10: ??? + def synchronous() end def on_chassis?(chassis) @action.received_by?(chassis) end @@ -464,9 +464,12 @@ end # Collect information about generated files. class GenFiles - @@files = Set.new - def GenFiles.add(f) @@files.add f; end + @@files = Set.new + @@public_api = [] + def GenFiles.add(f) @@files.add(f); end def GenFiles.get() @@files; end + def GenFiles.public_api(file) @@public_api << file; end + def GenFiles.public_api?(file) @@public_api.find { |f| f == file }; end end # Base class for code generators. @@ -476,27 +479,27 @@ class Generator # Takes directory for output or "-", meaning print file names that # would be generated. def initialize (outdir, amqp) + @outdir=outdir[0] + @apidir=outdir[1] @amqp=amqp - @outdir=outdir + raise "outdir is not an array" unless outdir.class == Array @prefix=[''] # For indentation or comments. @indentstr=' ' # One indent level. @outdent=2 - Pathname.new(@outdir).mkpath unless @outdir=="-" end + # Declare next file to be public API + def public_api(file) GenFiles.public_api(file); end + # Create a new file, set @out. def file(file, &block) - GenFiles.add file - if (@outdir != "-") - @path=Pathname.new "#{@outdir}/#{file}" + GenFiles.add(file) + dir = GenFiles.public_api?(file) ? @apidir : @outdir + if (dir != "-") + @path=Pathname.new "#{dir}/#{file}" @path.parent.mkpath @out=String.new # Generate in memory first - if block then yield; endfile; end - end - end - - def endfile() - if @outdir != "-" + yield if block if @path.exist? and @path.read == @out puts "Skipped #{@path} - unchanged" # Dont generate if unchanged else diff --git a/cpp/rubygen/framing.0-10/Operations.rb b/cpp/rubygen/framing.0-10/Operations.rb index c217926a66..cd6a363c56 100755 --- a/cpp/rubygen/framing.0-10/Operations.rb +++ b/cpp/rubygen/framing.0-10/Operations.rb @@ -115,7 +115,7 @@ EOS end end -OperationsGen.new("client",ARGV[0], $amqp).generate() -OperationsGen.new("server",ARGV[0], $amqp).generate() -OperationsGen.new("all",ARGV[0], $amqp).generate() +OperationsGen.new("client",$outdir, $amqp).generate() +OperationsGen.new("server",$outdir, $amqp).generate() +OperationsGen.new("all",$outdir, $amqp).generate() diff --git a/cpp/rubygen/framing.0-10/OperationsInvoker.rb b/cpp/rubygen/framing.0-10/OperationsInvoker.rb index 6e3b79e51e..f9b6cac76b 100755 --- a/cpp/rubygen/framing.0-10/OperationsInvoker.rb +++ b/cpp/rubygen/framing.0-10/OperationsInvoker.rb @@ -112,6 +112,6 @@ class OperationsInvokerGen < CppGen end end -OperationsInvokerGen.new("client",ARGV[0], $amqp).generate() -OperationsInvokerGen.new("server",ARGV[0], $amqp).generate() -OperationsInvokerGen.new("all",ARGV[0], $amqp).generate() +OperationsInvokerGen.new("client",$outdir, $amqp).generate() +OperationsInvokerGen.new("server",$outdir, $amqp).generate() +OperationsInvokerGen.new("all",$outdir, $amqp).generate() diff --git a/cpp/rubygen/framing.0-10/Session.rb b/cpp/rubygen/framing.0-10/Session.rb index 7b92a17f41..61f0e03a8b 100755 --- a/cpp/rubygen/framing.0-10/Session.rb +++ b/cpp/rubygen/framing.0-10/Session.rb @@ -136,6 +136,7 @@ class SessionNoKeywordGen < CppGen end def generate() + public_api("#{@file}.h") h_file(@file) { include "qpid/client/#{@version_base}.h" include "qpid/client/ClientImportExport.h" @@ -222,6 +223,7 @@ class SessionGen < CppGen keyword_methods=session_methods(sync_default).reject { |m| m.fields_c.empty? } max_arity = keyword_methods.map{ |m| m.fields_c.size }.max + public_api("qpid/client/arg.h") h_file("qpid/client/arg.h") { # Generate keyword tag declarations. genl "#define BOOST_PARAMETER_MAX_ARITY #{max_arity}" @@ -231,7 +233,7 @@ class SessionGen < CppGen genl "BOOST_PARAMETER_KEYWORD(keyword_tags, #{k})" }} } - + public_api("#{@fqclass.file}.h") h_file(@fqclass.file) { include @fqbase.file include "qpid/client/arg" @@ -408,8 +410,8 @@ EOS end end -SessionNoKeywordGen.new(ARGV[0], $amqp, true).generate() -SessionNoKeywordGen.new(ARGV[0], $amqp, false).generate() -SessionGen.new(ARGV[0], $amqp, true).generate() -SessionGen.new(ARGV[0], $amqp, false).generate() +SessionNoKeywordGen.new($outdir, $amqp, true).generate() +SessionNoKeywordGen.new($outdir, $amqp, false).generate() +SessionGen.new($outdir, $amqp, true).generate() +SessionGen.new($outdir, $amqp, false).generate() diff --git a/cpp/rubygen/framing.0-10/constants.rb b/cpp/rubygen/framing.0-10/constants.rb index ea74c82f73..5c1c1047f7 100755 --- a/cpp/rubygen/framing.0-10/constants.rb +++ b/cpp/rubygen/framing.0-10/constants.rb @@ -29,7 +29,8 @@ class ConstantsGen < CppGen end def constants_h() - h_file("#{@dir}/constants") { + public_api("#{@dir}/constants.h") + h_file("#{@dir}/constants.h") { namespace(@namespace) { # Constants for class/method names. scope("enum AmqpConstant {","};") { @@ -50,6 +51,7 @@ class ConstantsGen < CppGen def typecode_h_cpp path="#{@dir}/TypeCode" + public_api(path+".h") h_file(path) { include("") include("\"qpid/sys/IntegerTypes.h\"") @@ -104,7 +106,8 @@ EOS end def enum_h() - h_file("#{@dir}/enum") { + public_api("#{@dir}/enum.h") + h_file("#{@dir}/enum.h") { # Constants for enum domains. namespace(@namespace) { @amqp.domains.each { |d| declare_enum(d.enum) if d.enum } @@ -161,7 +164,8 @@ EOS end def reply_exceptions_h() - h_file("#{@dir}/reply_exceptions") { + public_api("#{@dir}/reply_exceptions.h") + h_file("#{@dir}/reply_exceptions.h") { include "qpid/Exception" include "qpid/sys/ExceptionHolder" include "qpid/framing/enum" diff --git a/cpp/rubygen/framing.0-10/frame_body_lists.rb b/cpp/rubygen/framing.0-10/frame_body_lists.rb index 541fddbca2..4f1b976032 100644 --- a/cpp/rubygen/framing.0-10/frame_body_lists.rb +++ b/cpp/rubygen/framing.0-10/frame_body_lists.rb @@ -44,6 +44,6 @@ EOS end end -FrameBodyListsGen.new(ARGV[0], $amqp).generate; +FrameBodyListsGen.new($outdir, $amqp).generate; diff --git a/cpp/rubygen/framing.0-10/structs.rb b/cpp/rubygen/framing.0-10/structs.rb index 823d062dd5..809e453381 100755 --- a/cpp/rubygen/framing.0-10/structs.rb +++ b/cpp/rubygen/framing.0-10/structs.rb @@ -383,7 +383,8 @@ EOS end end - h_file("qpid/framing/#{classname}.h") { + public_api("qpid/framing/#{classname}.h") + h_file("qpid/framing/#{classname}.h") { if (s.kind_of? AmqpMethod) gen <