From 58c2349b48362ab970c6c6d10b4d418b018408e8 Mon Sep 17 00:00:00 2001 From: Peter Soetens Date: Fri, 1 Feb 2013 12:16:02 +0100 Subject: [PATCH] typegen: add -x target option to make -i target aware Otherwise, we had to hard-code - into the -i flags in user code. Now, we can silently pass -x target and for each -i flag, it will look if either version of the .pc file exists. Signed-off-by: Peter Soetens --- bin/typegen | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/bin/typegen b/bin/typegen index 94ae8f7..517448f 100755 --- a/bin/typegen +++ b/bin/typegen @@ -12,6 +12,7 @@ typekit = Orocos::Generation::Typekit.new typekit_loader = Orocos::Generation::Project.new transports = DEFAULT_TRANSPORTS.dup.to_set +target_suf = "" parser = OptionParser.new do |opt| available_transports = Orocos::Generation::Typekit.plugins.keys @@ -22,18 +23,26 @@ usage: typegen [--transports=NAME1,NAME2] [--output=output_dir] [--import=LIBRAR this installation of typegen knows the following transports: #{available_transports} EOF + opt.on('-x OROCOS_TARGET', '--orocos_target=OROCOS_TARGET', String, "Target to use when searching for import libraries (must precede -i !)") do |target| + target_suf = "-" + target + end + opt.on('-i LIBRARY', '--import=LIBRARY', String, "a library or typekit to get headers and/or types from, using its pkg-config name") do |name| begin - pkg = Utilrb::PkgConfig.new(name) - if pkg.typelist && !pkg.typelist.empty? - typekit = typekit_loader.load_typekit(name) - typekit.using_typekit(typekit) - else - typekit.using_library(pkg) - end + pkg = Utilrb::PkgConfig.new("#{name}#{target_suf}") rescue Utilrb::PkgConfig::NotFound - STDERR.puts "#{name} cannot be found by pkg-config" - exit(1) + begin + pkg = Utilrb::PkgConfig.new("#{name}") + rescue Utilrb::PkgConfig::NotFound + STDERR.puts "#{name} cannot be found by pkg-config" + exit(1) + end + end + if pkg.typelist && !pkg.typelist.empty? + typekit = typekit_loader.load_typekit(name) + typekit.using_typekit(typekit) + else + typekit.using_library(pkg) end end -- 1.7.9.5