add build test for custom builders
This commit is contained in:
1 parent
2cb584312e
commit
5dee51b21c
4 files changed
+34
-1
No files matched your search
@@ -0,0 +1,16 @@
|
||||
class MySource < Rscons::Builder
|
||||
def run(target, sources, cache)
|
||||
File.open(target, 'w') do |fh|
|
||||
fh.puts <<EOF
|
||||
#define THE_VALUE 5678
|
||||
EOF
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new(echo: :short) do |env|
|
||||
env.add_builder(MySource.new(env))
|
||||
env.MySource('inc.h', [])
|
||||
env.Program('program', Dir['*.c'])
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "inc.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("The value is %d\n", THE_VALUE);
|
||||
}
|
||||
@@ -88,7 +88,10 @@ module Rscons
|
||||
end
|
||||
@targets.each do |target, info|
|
||||
next if targets_processed.include?(target)
|
||||
break unless process_target.call(target)
|
||||
unless process_target.call(target)
|
||||
$stderr.puts "Error: failed to build #{target}"
|
||||
break
|
||||
end
|
||||
end
|
||||
cache.write
|
||||
end
|
||||
|
||||
@@ -119,4 +119,11 @@ describe Rscons do
|
||||
File.exists?('build/one/one.o').should be_true
|
||||
File.exists?('build/two/two.o').should be_true
|
||||
end
|
||||
|
||||
it 'allows Ruby classes as custom builders to be used to construct files' do
|
||||
lines = test_dir('custom_builder')
|
||||
lines.should == ['CC program.o', 'LD program']
|
||||
File.exists?('inc.h').should be_true
|
||||
`./program`.should == "The value is 5678\n"
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user