diff options
Diffstat (limited to 'cpp/rubygen/generate')
-rwxr-xr-x | cpp/rubygen/generate | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/cpp/rubygen/generate b/cpp/rubygen/generate index 836626cd7a..0ce1fec46a 100755 --- a/cpp/rubygen/generate +++ b/cpp/rubygen/generate @@ -26,7 +26,8 @@ require 'amqpgen' if ARGV.size < 3 puts <<EOS Usage: #{ARGV[0]} OUTDIR SPEC.xml [ ... ] TEMPLATE.rb [ ... ] -or: #{ARGV[0]} OUTDIR SPEC.xml [ ... ] all [ makefragment.mk ] +or: #{ARGV[0]} OUTDIR SPEC.xml [ ... ] all [ makefragment.mk | + makefragment.cmake ] Parse all SPEC.xml files to create an AMQP model, run each TEMPLATE putting the resulting files under OUTDIR. Prints a list of files @@ -76,16 +77,19 @@ templates.each { |t| end } +def cmake_continue(lines) lines.join(" \n "); end def make_continue(lines) lines.join(" \\\n "); end # Generate makefile makefile=ARGV.grep(/.mk$/)[0] -if makefile +cmakefile=ARGV.grep(/.cmake$/)[0] +if cmakefile || makefile dir=Dir.getwd Dir.chdir File.dirname(__FILE__) generator_files=Dir["**/*.rb"] << File.basename(__FILE__) Dir.chdir dir rgen_generator=generator_files.map{ |f| "$(rgen_dir)/#{f}" } + cmake_rgen_generator=generator_files.map{ |f| "${rgen_dir}/#{f}" } rgen_srcs=GenFiles.get.map{ |f| "#{$outdir}/#{f}" } rgen_subdirs={} rgen_srcs.each { |src| @@ -95,31 +99,61 @@ if makefile rgen_subdirs[subdir] << src end } - File.open(makefile, 'w') { |out| - out << <<EOS + if (makefile) + File.open(makefile, 'w') { |out| + out << <<EOS # Generated makefile fragment. # Including makefile defines $(rgen_dir) $(rgen_cmd) and $(specs). rgen_generator=#{make_continue rgen_generator} EOS - rgen_subdirs.each_key { |subdir| - out << "\nrgen_#{subdir}_srcs = #{make_continue(rgen_subdirs[subdir])}\n" - } - out << <<EOS + rgen_subdirs.each_key { |subdir| + out << "\nrgen_#{subdir}_srcs = #{make_continue(rgen_subdirs[subdir])}\n" + } + out << <<EOS rgen_srcs=#{make_continue rgen_srcs} # Header file install rules. EOS - ["amqp_0_10", "framing", "client/no_keyword","client", "broker"].each { |ns| - dir="qpid/#{ns}" - dir_ = dir.tr("/", "_") - regex=%r|#{dir}/[^/]+\.h$| - out << <<EOS + ["amqp_0_10", "framing", "client/no_keyword","client", "broker"].each { |ns| + dir="qpid/#{ns}" + dir_ = dir.tr("/", "_") + regex=%r|#{dir}/[^/]+\.h$| + out << <<EOS #{dir_}dir = $(includedir)/#{dir} dist_#{dir_}_HEADERS = #{make_continue rgen_srcs.grep(regex)} EOS - } - } -end + } # each + } # File makefile + end # if (makefile) + + if (cmakefile) + File.open(cmakefile, 'w') { |out| + out << <<EOS +# Generated makefile fragment. +# Including makefile defines ${rgen_dir} ${rgen_cmd} and ${specs}. +set(rgen_generator #{cmake_continue cmake_rgen_generator}) +EOS + rgen_subdirs.each_key { |subdir| + out << "\nset(rgen_#{subdir}_srcs #{cmake_continue(rgen_subdirs[subdir])})\n" + } + out << <<EOS +set(rgen_srcs #{cmake_continue rgen_srcs}) + +# Header file install rules. +EOS + ["amqp_0_10", "framing", "client/no_keyword","client", "broker"].each { |ns| + dir="qpid/#{ns}" + dir_ = dir.tr("/", "_") + regex=%r|#{dir}/[^/]+\.h$| + out << <<EOS +set(#{dir_}dir \${includedir}/#{dir}) +set(dist_#{dir_}_HEADERS #{cmake_continue rgen_srcs.grep(regex)}) + +EOS + } # each + } # File makefile + end # if (makefile) +end |