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/bindings/qmf/python/Makefile.am | 2 +- cpp/bindings/qmf/ruby/Makefile.am | 2 +- cpp/configure.ac | 1 - cpp/docs/api/developer.doxygen.in | 2 +- cpp/docs/api/user.doxygen.in | 2 +- cpp/examples/CMakeLists.txt | 3 ++- cpp/examples/makedist.mk | 2 +- cpp/managementgen/qmfgen/generate.py | 4 ++-- 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 ++++++++++---------- cpp/src/CMakeLists.txt | 11 +++++----- cpp/src/Makefile.am | 6 +++--- cpp/src/tests/Makefile.am | 20 ++++++++++++++++- 19 files changed, 91 insertions(+), 60 deletions(-) (limited to 'cpp') diff --git a/cpp/bindings/qmf/python/Makefile.am b/cpp/bindings/qmf/python/Makefile.am index 42eead1a2e..9bb1b00d50 100644 --- a/cpp/bindings/qmf/python/Makefile.am +++ b/cpp/bindings/qmf/python/Makefile.am @@ -19,7 +19,7 @@ if HAVE_PYTHON_DEVEL -INCLUDES = -I$(top_srcdir)/src/qmf -I$(top_srcdir)/src -I$(top_builddir)/src/gen +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src/qmf -I$(top_srcdir)/src -I$(top_builddir)/src EXTRA_DIST = python.i diff --git a/cpp/bindings/qmf/ruby/Makefile.am b/cpp/bindings/qmf/ruby/Makefile.am index a550bd73fa..532fdb6875 100644 --- a/cpp/bindings/qmf/ruby/Makefile.am +++ b/cpp/bindings/qmf/ruby/Makefile.am @@ -19,7 +19,7 @@ if HAVE_RUBY_DEVEL -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/qmf -I$(top_srcdir)/src -I$(top_builddir)/src/gen -I$(top_srcdir)/src/gen +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/src/qmf -I$(top_srcdir)/src -I$(top_builddir)/src EXTRA_DIST = ruby.i BUILT_SOURCES = qmfengine.cpp diff --git a/cpp/configure.ac b/cpp/configure.ac index 8ce66cf743..6d7ed16871 100644 --- a/cpp/configure.ac +++ b/cpp/configure.ac @@ -237,7 +237,6 @@ AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test -f $PYTHON_INC/Python.h && test -n "$S specdir=`pwd`/$srcdir/../specs AMQP_FINAL_XML=$specdir/amqp.0-10-qpid-errata.xml -test -f $AMQP_FINAL_XML || test -d $srcdir/src/gen || AC_MSG_ERROR([Neither AMQP specs nor spec-generated code present; cannot build.]) AC_SUBST(AMQP_FINAL_XML) AM_CONDITIONAL([GENERATE], [test -f $AMQP_FINAL_XML]) diff --git a/cpp/docs/api/developer.doxygen.in b/cpp/docs/api/developer.doxygen.in index a8dfbb58ff..96d67c027f 100644 --- a/cpp/docs/api/developer.doxygen.in +++ b/cpp/docs/api/developer.doxygen.in @@ -464,7 +464,7 @@ WARN_LOGFILE = doxygen.log # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @top_srcdir@/include @top_srcdir@/src @top_builddir@/src/gen +INPUT = @top_srcdir@/include @top_srcdir@/src @top_builddir@/include @top_builddir@/src # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff --git a/cpp/docs/api/user.doxygen.in b/cpp/docs/api/user.doxygen.in index 1e10aebe14..6ade9ab846 100644 --- a/cpp/docs/api/user.doxygen.in +++ b/cpp/docs/api/user.doxygen.in @@ -456,7 +456,7 @@ WARN_LOGFILE = doxygen.log # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @top_srcdir@/include @top_builddir@/src/gen/qpid/client @top_builddir@/src/gen/qpid/framing +INPUT = @top_srcdir@/include @top_builddir@/include # If the value of the INPUT tag contains directories, you can use the diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt index 34dfa340ce..7d0a4d0d21 100644 --- a/cpp/examples/CMakeLists.txt +++ b/cpp/examples/CMakeLists.txt @@ -24,7 +24,8 @@ endif(COMMAND cmake_policy) # This will probably need some fiddling to get right for installed kits. get_directory_property(QPIDC_TOP PARENT_DIRECTORY) -include_directories(${QPIDC_TOP}/include ${CMAKE_CURRENT_BINARY_DIR}/../src/gen) +include_directories(${CMAKE_BINARY_DIR}/include) +include_directories(${CMAKE_SOURCE_DIR}/include) # Shouldn't need this... but there are still client header inclusions of Boost. include_directories( ${Boost_INCLUDE_DIR} ) diff --git a/cpp/examples/makedist.mk b/cpp/examples/makedist.mk index 9fd4ee6e28..0a7f18de76 100644 --- a/cpp/examples/makedist.mk +++ b/cpp/examples/makedist.mk @@ -1,6 +1,6 @@ # Settings to build the examples in automake AM_CXXFLAGS = $(WARNING_CFLAGS) -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/gen -I$(top_builddir)/src/gen +INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include CLIENT_LIB=$(top_builddir)/src/libqpidclient.la CONSOLE_LIB=$(top_builddir)/src/libqmfconsole.la CLIENTFLAGS=-lqpidclient diff --git a/cpp/managementgen/qmfgen/generate.py b/cpp/managementgen/qmfgen/generate.py index 44c434216e..4052b8c853 100755 --- a/cpp/managementgen/qmfgen/generate.py +++ b/cpp/managementgen/qmfgen/generate.py @@ -163,7 +163,7 @@ class Makefile: stream.write("dist_" + name + "_HEADERS = ") first = True for file in self.filelists["h"]: - if file.find("gen/qmf/" + package) == 0: + if file.find("qmf/" + package) == 0: if first: first = False else: @@ -243,7 +243,7 @@ class CMakeLists(Makefile): first = True for file in self.filelists["h"]: file = self.unNormCase(file) - if file.find("gen/qmf/" + package) == 0: + if file.find("qmf/" + package) == 0: if first: first = False else: 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 <