add build test using a build directory
This commit is contained in:
parent
741f5cfe5e
commit
2cb584312e
5
build_tests/build_dir/build.rb
Normal file
5
build_tests/build_dir/build.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Rscons::Environment.new do |env|
|
||||||
|
env.append('CPPPATH' => Dir['src/**/*/'])
|
||||||
|
env.build_dir('src', 'build')
|
||||||
|
env.Program('build_dir', Dir['src/**/*.c'])
|
||||||
|
end
|
6
build_tests/build_dir/src/one/one.c
Normal file
6
build_tests/build_dir/src/one/one.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "two.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
two();
|
||||||
|
}
|
7
build_tests/build_dir/src/two/two.c
Normal file
7
build_tests/build_dir/src/two/two.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "two.h"
|
||||||
|
|
||||||
|
void two(void)
|
||||||
|
{
|
||||||
|
printf("Hello from two()\n");
|
||||||
|
}
|
6
build_tests/build_dir/src/two/two.h
Normal file
6
build_tests/build_dir/src/two/two.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef TWO_H
|
||||||
|
#define TWO_H
|
||||||
|
|
||||||
|
void two(void);
|
||||||
|
|
||||||
|
#endif
|
@ -18,12 +18,13 @@ module Rscons
|
|||||||
if source.has_suffix?([@env['OBJSUFFIX'], @env['LIBSUFFIX']])
|
if source.has_suffix?([@env['OBJSUFFIX'], @env['LIBSUFFIX']])
|
||||||
source
|
source
|
||||||
else
|
else
|
||||||
o_file = source.set_suffix(@env['OBJSUFFIX', :string])
|
o_file = @env.get_build_fname(source, @env['OBJSUFFIX', :string])
|
||||||
builder = @env.builders.values.find { |b| b.produces?(o_file, source) }
|
builder = @env.builders.values.find { |b| b.produces?(o_file, source) }
|
||||||
builder or raise "No builder found to convert input source #{source.inspect} to an object file."
|
builder or raise "No builder found to convert input source #{source.inspect} to an object file."
|
||||||
builder.run(o_file, [source], cache)
|
builder.run(o_file, [source], cache) or break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if sources
|
||||||
vars = {
|
vars = {
|
||||||
'TARGET' => target,
|
'TARGET' => target,
|
||||||
'SOURCES' => sources,
|
'SOURCES' => sources,
|
||||||
@ -37,4 +38,5 @@ module Rscons
|
|||||||
target
|
target
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -112,4 +112,11 @@ describe Rscons do
|
|||||||
lines = build_testdir
|
lines = build_testdir
|
||||||
lines.should == ['gcc -o simple simple.o -lc']
|
lines.should == ['gcc -o simple simple.o -lc']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'builds object files in a different build directory' do
|
||||||
|
lines = test_dir('build_dir')
|
||||||
|
`./build_dir`.should == "Hello from two()\n"
|
||||||
|
File.exists?('build/one/one.o').should be_true
|
||||||
|
File.exists?('build/two/two.o').should be_true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user