qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r561869 - in /incubator/qpid/trunk/qpid/cpp: ./ rubygen/ rubygen/templates/ src/ src/tests/
Date Wed, 01 Aug 2007 16:50:37 GMT
Author: aconway
Date: Wed Aug  1 09:50:33 2007
New Revision: 561869

URL: http://svn.apache.org/viewvc?view=rev&rev=561869
Log:

	* src/generate.sh: Moved requirements test to configure.ac

	* rubygen: Cleanup and improvements, template for cluster work.

	* configure.ac:
	 - support for ruby code generator + cleanup.
	 - moved "can generate" tests to configure.ac
	 - removed redundant APR stuff.

	* bootstrap: Remove codegen from bootstrap, all in config/make.

	* src/Makefile.am (libqpidcommon_la_LIBADD):
	 - Ruby code generator.
	 - Improvements to existing generator rules.
	 - Removed APR stuff.

	* configure.ac (CPPUNIT_CXXFLAGS): Removed APR stuff.

Added:
    incubator/qpid/trunk/qpid/cpp/rubygen/generate   (with props)
    incubator/qpid/trunk/qpid/cpp/rubygen/templates/
    incubator/qpid/trunk/qpid/cpp/rubygen/templates/frame_body_lists.rb   (with props)
Modified:
    incubator/qpid/trunk/qpid/cpp/bootstrap
    incubator/qpid/trunk/qpid/cpp/configure.ac
    incubator/qpid/trunk/qpid/cpp/rubygen/README
    incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb
    incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb
    incubator/qpid/trunk/qpid/cpp/src/Makefile.am
    incubator/qpid/trunk/qpid/cpp/src/generate.sh
    incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
    incubator/qpid/trunk/qpid/cpp/src/tests/ais_check
    incubator/qpid/trunk/qpid/cpp/src/tests/cluster.mk

Modified: incubator/qpid/trunk/qpid/cpp/bootstrap
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/bootstrap?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/bootstrap (original)
+++ incubator/qpid/trunk/qpid/cpp/bootstrap Wed Aug  1 09:50:33 2007
@@ -14,12 +14,8 @@
   perl -ne '/^(include |if |else|endif)/ or print' Makefile.am \
       | make -f - abs_srcdir=`dirname $(pwd)` gen.mk > /dev/null )
 
-# Bootstrap generated code.
-(cd src; ./generate.sh)
-
 automake
 autoconf
-
 
 if [ "$1" = "-build" -o "$1" = "--build" ] ; then
     shift

Modified: incubator/qpid/trunk/qpid/cpp/configure.ac
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/configure.ac?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/configure.ac (original)
+++ incubator/qpid/trunk/qpid/cpp/configure.ac Wed Aug  1 09:50:33 2007
@@ -90,28 +90,7 @@
 AC_SUBST(CPPUNIT_LIBS)
 AC_SUBST(CPPUNIT_CXXFLAGS)
 
-AC_ARG_ENABLE([apr-platform],
-  [AS_HELP_STRING([--enable-apr-platform],
-    [use the Apache Portable Runtime library for platform (default no)])],
-  [case $enableval in
-    yes|no) enable_APR_PLATFORM=$enableval;;
-    *) AC_MSG_ERROR([Invalid value for --enable-apr-platform: $enableval]);;
-   esac],
-  [enable_APR_PLATFORM=no]
-)
-AM_CONDITIONAL([USE_APR_PLATFORM], [test x$enable_APR_PLATFORM = xyes])
-
-APR_MINIMUM_VERSION=1.2.2
-AC_SUBST(APR_MINIMUM_VERSION)
-AC_SUBST(APR_CXXFLAGS)
-AC_SUBST(USE_APR_PLATFORM)
-
-if test "$enable_APR_PLATFORM" = yes; then
-  PKG_CHECK_MODULES([APR], [apr-1 >= $APR_MINIMUM_VERSION])
-  APR_CXXFLAGS="$APR_CFLAGS -DUSE_APR_PLATFORM=1"
-  USE_APR_PLATFORM=1
-fi
-
+# Enable Valgrind	
 AC_ARG_ENABLE([valgrind],
   [AS_HELP_STRING([--enable-valgrind],
     [run valgrind memory checker on tests, if available (default yes)])],
@@ -131,6 +110,22 @@
 # If rpmlint is availalbe we'll run it when building RPMs.
 AC_CHECK_PROG([RPMLINT], [rpmlint], [rpmlint])
 AM_CONDITIONAL([HAS_RPMLINT], [test -n "$RPMLINT"])
+
+# Code generation: generated code is included in the distribution
+# so code generation is only required in an svn checkout.
+# It requires several external tools and files, which we check for here.
+
+AC_CHECK_PROG([RUBY], [ruby], [ruby])
+AC_CHECK_PROG([JAVA], [java], [java])
+AC_CHECK_PROG([JAVAC], [javac], [javc])
+test -n "$RUBY" -a -n "$JAVA" -a -n "$JAVAC" && generate=yes
+
+specdir=`pwd`/$srcdir/../specs  
+AMQP_XML=$specdir/amqp-transitional.0-10.xml
+AC_SUBST(AMQP_XML)
+ls $AMQP_XML >/dev/null 2>&1 || generate=no
+
+AM_CONDITIONAL([GENERATE], [test x$generate = xyes])
 
 # URL and download URL for the package.
 URL=http://rhm.et.redhat.com/qpidc

Modified: incubator/qpid/trunk/qpid/cpp/rubygen/README
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/README?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/README (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/README Wed Aug  1 09:50:33 2007
@@ -1,16 +1,13 @@
 RUBY CODE GENERATOR
 
-amqpgen.rb: builds an AMQP model from XML files and provides generic code generation functions
(e.g. capitalization of names etc)
+Run ./generate for usage.
+Examples in samples/
 
-cppgen.rb: C++ specific code generation functions.
+For example:
+ ./generate . ../../specs/amqp.0-9.xml samples/Proxy.rb 
+will generate
 
-A template is a ruby file that generates one or more source files.
 
-For an example run
- samples/runme test <amqp.xml files>
-
-The first argument is a directory for generated files, remaining arguments
-are xml files.
 
 
 

Modified: incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/amqpgen.rb Wed Aug  1 09:50:33 2007
@@ -135,12 +135,13 @@
   def classes()
     @cache_classes ||= elements.collect("class") { |c| AmqpClass.new(c,self) }.sort_by_name
   end
-
+  
+  # Return all methods on all classes.
+  def methods() classes.collect { |c| c.methods }.flatten;  end
+  
   # Return all methods on chassis for all classes.
   def methods_on(chassis)
-    classes.collect { |c|
-      c.methods_on(chassis)
-    }.flatten
+    classes.collect { |c| c.methods_on(chassis) }.flatten
   end
 
   # Merge contents of elements.
@@ -188,6 +189,12 @@
     }
     # Note if we stopped mid-line
     @midline = /[^\n]\z/ === str
+  end
+
+  # Append str + '\n' to generated code.
+  def genl(str="")
+    gen str
+    gen "\n"
   end
 
   # Generate code with added prefix.

Modified: incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/cppgen.rb Wed Aug  1 09:50:33 2007
@@ -105,6 +105,7 @@
 
   # Write a header file. 
   def h_file(path)
+    path = (/\.h$/ === path ? path : path+".h")
     guard=path.upcase.tr('./-','_')
     file(path) { 
       gen "#ifndef #{guard}\n"
@@ -122,5 +123,29 @@
       yield
     end
   end
+
+  def include(header) genl "#include \"#{header}\""; end
+
+  def scope(open="{",close="}", &block) 
+    genl open; indent(&block); genl close
+  end
+
+  def namespace(name, &block) 
+    names = name.split("::")
+    names.each { |n| genl "namespace #{n} {" }
+    yield
+    genl('}'*names.size+" // "+name)
+  end
+
+  def struct_class(type, name, *bases, &block)
+    gen "#{type} #{name}"
+    gen ": #{bases.join(', ')}" unless bases.empty
+    genl "{"
+    yield
+    genl "};"
+  end
+
+  def struct(name, *bases, &block) struc_class("struct", bases, &block); end
+  def class_(name, *bases, &block) struc_class("struct", bases, &block); end
 end
 

Added: incubator/qpid/trunk/qpid/cpp/rubygen/generate
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/generate?view=auto&rev=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/generate (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/generate Wed Aug  1 09:50:33 2007
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+require 'amqpgen'
+
+#
+# Run a set of code generation templates.
+#
+
+if ARGV.size < 3
+  puts <<EOS
+Usage: #{ARGV[0]} OUTDIR  SPEC.xml [ ... ] TEMPLATE.rb [ ... ]
+Parse all SPEC.xml files to create an AMQP model, run each TEMPLATE
+putting the resulting files under OUTDIR. Prints a list of files
+generated to standard output.
+
+If OUTDIR is '-'  then just prints file list without generating files.
+EOS
+  exit 1
+end
+outdir=ARGV[0]
+specs=ARGV.grep(/\.xml$/)
+templates=ARGV.grep(/\.rb$/)
+Amqp=AmqpRoot.new(*specs)
+templates.each { |t| require t }

Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/generate
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/qpid/trunk/qpid/cpp/rubygen/templates/frame_body_lists.rb
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/templates/frame_body_lists.rb?view=auto&rev=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/templates/frame_body_lists.rb (added)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/templates/frame_body_lists.rb Wed Aug  1 09:50:33
2007
@@ -0,0 +1,31 @@
+$: << ".."                      # Include .. in load path
+require 'cppgen'
+
+class FrameBodyListsGen < CppGen
+    
+  def initialize(outdir, amqp) 
+    super(outdir, amqp); 
+  end
+
+  def generate
+    h_file("qpid/framing/frame_body_lists.h") {
+      gen <<EOS
+/**@file
+ * Macro lists of frame body classes, used to generate Visitors
+ */
+EOS
+      gen "#define METHOD_BODIES() "
+      @amqp.methods.each { |m| gen "\\\n    (#{m.body_name}) " }
+      gen <<EOS
+
+
+#define OTHER_BODIES() (AMQContentBody)(AMQHeaderBody)(AMQHeartbeatBody))
+
+EOS
+    }
+  end
+end
+
+FrameBodyListsGen.new(ARGV[0], Amqp).generate;
+
+    

Propchange: incubator/qpid/trunk/qpid/cpp/rubygen/templates/frame_body_lists.rb
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Wed Aug  1 09:50:33 2007
@@ -1,31 +1,75 @@
 SUBDIRS = . tests
 
-# Generated code
--include generate.mk
+## Generated code
 
-generate.mk $(generated_cpp) $(generated_h): gen/timestamp
+# Note: generated soure and makefiles included in distribution so a
+# distribution can be built without code generation tools and XML
+# sources.
 
-gen/timestamp: generate.sh $(generator)
-	$(srcdir)/generate.sh
-	touch $@
+EXTRA_DIST= $(platform_dist) 
+
+EXTRA_DIST += gen/generate.mk generate.sh $(generated_cpp) $(generated_h) \
+  rubygen.mk $(rgen_srcs) 
+
+# AMQP_XML is defined in ../configure.ac
+specs=@AMQP_XML@ $(top_srcdir)/xml/cluster.xml
+
+# Makefiles are either generated or copied from $srcdir.
+sinclude gen/generate.mk
+sinclude rubygen.mk
+
+DISTCLEANFILES=gen/generate.mk rubygen.mk
+
+if GENERATE
+
+# Java code generator.
+# Must generate into a separate gen directory because otherwise
+# there's no way to figure out which files are generated.
+
+gentools_dir=$(top_srcdir)/gentools
+
+gen/generate.mk: generate.sh $(specs) $(generator)
+	env gentools_dir=$(gentools_dir) specs="$(specs)" $(srcdir)/generate.sh
+
+gen $(generated_cpp) $(generated_h): gen/generate.mk
 
 # Empty rule in case a generator file is renamed/removed.
 $(generator):
 
-DISTCLEANFILES=generate.mk
-
-clean-gen:
+maintainer-clean-local:
 	rm -rf gen
 
-maintainer-clean-local:
-	clean-gen
+# Ruby generator.
+
+rgen_dir=$(top_srcdir)/rubygen
+rgen_tdir=$(rgen_dir)/templates
+rgen_script=$(rgen_dir)/generate
+rgen_cmd=ruby -I $(rgen_dir) $(rgen_script)
+
+rgen_templates=$(rgen_tdir)/frame_body_lists.rb
+
+rubygen.mk: $(rgen_script) $(specs) $(rgen_templates)
+	echo rgen_srcs=`$(rgen_cmd) - $(specs) $(rgen_templates)` > $@
+	echo rgen_srcs=`$(rgen_cmd) . $(specs) $(rgen_templates)` 
 
-EXTRA_DIST=generate.sh $(generated_cpp) $(generated_h) $(platform_dist)
+$(rgen_srcs): rubygen.mk
 
-AM_CXXFLAGS = $(WARNING_CFLAGS) $(APR_CXXFLAGS)
+else				# !GENERATE
+# If not generating, copy generated makefiles from source dir to build dir.
+gen/generate.mk:
+	cp $(srcdir)/$@ $@
+rubygen.mk:
+	cp $(srcdir)/$@ $@
+endif				# GENERATE
+
+## Compiler flags
+
+AM_CXXFLAGS = $(WARNING_CFLAGS)
 AM_LDFLAGS = -version-info $(LIBTOOL_VERSION_INFO_ARG)
 INCLUDES = -Igen -I$(srcdir)/gen
 
+## Automake macros to build libraries and executables.
+
 qpidd_LDADD =					\
   libqpidbroker.la				\
   libqpidcommon.la
@@ -33,21 +77,6 @@
 sbin_PROGRAMS = qpidd
 qpidd_SOURCES = qpidd.cpp
 
-apr_plat_src = \
-  qpid/sys/apr/APRBase.cpp \
-  qpid/sys/apr/APRPool.cpp \
-  qpid/sys/apr/Socket.cpp \
-  qpid/sys/apr/Time.cpp \
-  qpid/sys/apr/Thread.cpp \
-  qpid/sys/apr/Shlib.cpp
-
-apr_plat_hdr = \
-  qpid/sys/apr/APRBase.h \
-  qpid/sys/apr/APRPool.h \
-  qpid/sys/apr/Condition.h \
-  qpid/sys/apr/Mutex.h \
-  qpid/sys/apr/Thread.h
-
 posix_plat_src = \
   qpid/sys/epoll/EpollPoller.cpp \
   qpid/sys/posix/check.cpp \
@@ -64,15 +93,8 @@
   qpid/sys/posix/Mutex.h \
   qpid/sys/posix/Thread.h
 
-if USE_APR_PLATFORM
- platform_dist=$(posix_plat_src) $(posix_plat_hdr)
- platform_src = $(apr_plat_src)
- platform_hdr = $(apr_plat_hdr)
-else
- platform_dist=$(apr_plat_src) $(apr_plat_hdr)
- platform_src = $(posix_plat_src)
- platform_hdr = $(posix_plat_hdr)
-endif
+platform_src = $(posix_plat_src)
+platform_hdr = $(posix_plat_hdr)
 
 lib_LTLIBRARIES = libqpidcommon.la libqpidbroker.la libqpidclient.la
 
@@ -91,7 +113,6 @@
   -lboost_program_options \
   -luuid \
   libLogger.la \
-  $(APR_LIBS) \
   $(LIB_DLOPEN) \
   $(LIB_CLOCK_GETTIME)
 

Modified: incubator/qpid/trunk/qpid/cpp/src/generate.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/generate.sh?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/generate.sh (original)
+++ incubator/qpid/trunk/qpid/cpp/src/generate.sh Wed Aug  1 09:50:33 2007
@@ -1,19 +1,19 @@
 # !/bin/sh
 # Generate code from AMQP specification.
-# srcdir must 
+# specs and gentools_dir are set by Makefile
 # 
-srcdir=`dirname $0`
 set -e
 
-gentools_dir="$srcdir/../gentools"
-specs_dir="$srcdir/../../specs"
-specs="$specs_dir/amqp-transitional.0-10.xml $srcdir/../xml/cluster.xml"
-
 test -z "$JAVA" && JAVA=java ; 
-test -z "$JAVAC" && JAVAC=javac ; 
+test -z "$JAVAC" && JAVAC=javac ;
+
+checkspecs() {
+    for s in $specs; do test -f $s || return 1; done
+    return 0
+}
 
 # Can we generate code?
-if { test -d $gentools_dir && test -d $specs_dir && \
+if { test -d $gentools_dir && checkspecs &&
     which $JAVA && which $JAVAC; } > /dev/null;
 then
     echo "Generating code."
@@ -40,8 +40,8 @@
 	make_assign "generator" "" $specs \
 	    `find ../gentools \( -name '*.java' -o -name '*.tmpl' \) -print`
     fi
-) > generate.mk-t
-mv generate.mk-t generate.mk
+) > gen/generate.mk-t
+mv gen/generate.mk-t gen/generate.mk
 
 
 

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am Wed Aug  1 09:50:33 2007
@@ -14,6 +14,7 @@
 check_LTLIBRARIES=
 TESTS=
 EXTRA_DIST=
+CLEANFILES=
 
 #
 # Unit test programs.
@@ -171,7 +172,7 @@
 # ltmain invocations, one may corrupt the temporaries of the other.
 .NOTPARALLEL:
 
-CLEANFILES=valgrind.out *.log *.vglog .valgrindrc .valgrind.supp dummy_test $(unit_wrappers)
+CLEANFILES+=valgrind.out *.log *.vglog .valgrindrc .valgrind.supp dummy_test $(unit_wrappers)
 MAINTAINERCLEANFILES=gen.mk
 
 interop_runner_SOURCES = 	\

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/ais_check
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/ais_check?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/ais_check (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/ais_check Wed Aug  1 09:50:33 2007
@@ -34,6 +34,6 @@
 
 FAILED=0
 for test in `cat ais_tests`; do
-    $srcdir/$test || FAILED=`expr $FAILED + 1`
+    ./$test || FAILED=`expr $FAILED + 1`
 done
 exit $FAILED

Modified: incubator/qpid/trunk/qpid/cpp/src/tests/cluster.mk
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/cluster.mk?view=diff&rev=561869&r1=561868&r2=561869
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/cluster.mk (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/cluster.mk Wed Aug  1 09:50:33 2007
@@ -21,6 +21,7 @@
 ais_check: ais_tests
 ais_tests:
 	echo $(AIS_TESTS) >$@
+CLEANFILES+=ais_tests
 
 AIS_TESTS+=Cpg
 check_PROGRAMS+=Cpg



Mime
View raw message