lib/autobuild/packages/genom.rb in autobuild-0.1 vs lib/autobuild/packages/genom.rb in autobuild-0.2
- old
+ new
@@ -7,20 +7,25 @@
get_provides
end
def genomstamp; "#{srcdir}/.genom/genom-stamp" end
+ def cpp_options
+ @options[:genomflags].to_a.find_all { |opt| opt =~ /^-D/ }
+ end
+
def get_requires
- File.open("#{srcdir}/#{target}.gen") do |f|
- f.each_line { |line|
- if line =~ /^require\s*:\s*([\w\-]+(?:\s*,\s*[\w\-]+)*);/
+ cpp = ($PROGRAMS['cpp'] || 'cpp')
+ Open3.popen3("#{cpp} #{cpp_options.join(" ")} #{srcdir}/#{target}.gen") do |in, out, err|
+ out.each_line { |line|
+ if line =~ /^\s*requires\s*:\s*([\w\-]+(?:\s*,\s*[\w\-]+)*);/
$1.split(/, /).each { |name|
depends_on name
file genomstamp => Package.name2target(name)
}
- elsif line =~ /^require/
- puts "failed to math #{line}"
+ elsif line =~ /^\s*requires/
+ puts "failed to match #{line}"
end
}
end
end
@@ -36,16 +41,17 @@
end
end
def regen_targets
+ cmdline = [ 'genom', target ] | @options[:genomflags].to_a
+
file buildstamp => genomstamp
file genomstamp => [ :genom, "#{srcdir}/#{target}.gen" ] do
Dir.chdir(srcdir) {
- cmdline = "genom " + @options[:genomflags].to_a.join(" ") + " #{target}"
begin
- subcommand(target, 'genom', cmdline)
+ subcommand(target, 'genom', *cmdline)
rescue SubcommandFailed => e
raise BuildException.new(e), "failed to generate module #{target}"
end
}
end
@@ -55,10 +61,10 @@
file "#{srcdir}/configure" => acuser do
# configure does not depend on the .gen file
# since the generation takes care of rebuilding configure
# if .gen has changed
begin
- subcommand(target, 'genom', cmdline)
+ subcommand(target, 'genom', *cmdline)
rescue SubcommandFailed => e
raise BuildException.new(e), "failed to generate module #{target}"
end
end
end