Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fcbd39057 | ||
|
|
d0bbc78751 | ||
|
|
7249e57951 | ||
|
|
d01913641f | ||
|
|
d5be569cd5 | ||
|
|
4d7ed373e7 | ||
|
|
72558391a2 | ||
|
|
d01767981c |
No files matched your search
@@ -127,9 +127,9 @@ An Rscons::Environment consists of:
|
||||
* a collection of targets to build
|
||||
* a collection of build hooks
|
||||
|
||||
When cloning an environment, the construction variables, builders, and build
|
||||
directories are cloned, but the new environment does not inherit any of the
|
||||
targets or build hooks from the source environment.
|
||||
When cloning an environment, the construction variables and builders are
|
||||
cloned, but the new environment does not inherit any of the targets, build
|
||||
hooks, build directories, or the build root from the source environment.
|
||||
|
||||
Cloned environments contain "deep copies" of construction variables.
|
||||
For example, in:
|
||||
|
||||
@@ -17,6 +17,7 @@ module Rscons
|
||||
def run(target, sources, cache, env, vars = {})
|
||||
# build sources to linkable objects
|
||||
objects = env.build_sources(sources, [env['OBJSUFFIX'], env['LIBSUFFIX']].flatten, cache, vars)
|
||||
return false unless objects
|
||||
ld = if env["LD"]
|
||||
env["LD"]
|
||||
elsif sources.find {|s| s.has_suffix?(env["DSUFFIX"])}
|
||||
|
||||
@@ -9,6 +9,9 @@ module Rscons
|
||||
# Hash of +{"builder_name" => builder_object}+ pairs.
|
||||
attr_reader :builders
|
||||
|
||||
# String or +nil+
|
||||
attr_accessor :build_root
|
||||
|
||||
# Create an Environment object.
|
||||
# @param variables [Hash]
|
||||
# The variables hash can contain construction variables, which are
|
||||
@@ -42,12 +45,12 @@ module Rscons
|
||||
|
||||
# Make a copy of the Environment object.
|
||||
# The cloned environment will contain a copy of all environment options,
|
||||
# construction variables, builders, and build directories. It will not
|
||||
# contain a copy of the targets or build hooks.
|
||||
# If a block is given, the Environment object is yielded to the block and
|
||||
# when the block returns, the {#process} method is automatically called.
|
||||
# construction variables, and builders. It will not contain a copy of the
|
||||
# targets, build hooks, build directories, or the build root. If a block
|
||||
# is given, the Environment object is yielded to the block and when the
|
||||
# block returns, the {#process} method is automatically called.
|
||||
def clone(variables = {})
|
||||
env = Environment.new()
|
||||
env = self.class.new
|
||||
@builders.each do |builder_name, builder|
|
||||
env.add_builder(builder)
|
||||
end
|
||||
@@ -88,14 +91,19 @@ module Rscons
|
||||
# This method takes into account the Environment's build directories.
|
||||
def get_build_fname(source_fname, suffix)
|
||||
build_fname = source_fname.set_suffix(suffix).gsub('\\', '/')
|
||||
@build_dirs.each do |src_dir, obj_dir|
|
||||
found_match = @build_dirs.find do |src_dir, obj_dir|
|
||||
if src_dir.is_a?(Regexp)
|
||||
build_fname.sub!(src_dir, obj_dir)
|
||||
else
|
||||
build_fname.sub!(%r{^#{src_dir}/}, "#{obj_dir}/")
|
||||
end
|
||||
build_fname.gsub!('\\', '/')
|
||||
end
|
||||
if @build_root and not found_match
|
||||
unless source_fname.start_with?('/') or source_fname =~ %r{^\w:[\\/]}
|
||||
build_fname = "#{@build_root}/#{build_fname}"
|
||||
end
|
||||
end
|
||||
build_fname.gsub!('\\', '/')
|
||||
build_fname
|
||||
end
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ module Rscons
|
||||
elsif varval.is_a?(Array)
|
||||
varval.map {|vv| expand_varref("#{prefix}#{vv}#{suffix}")}.flatten
|
||||
else
|
||||
raise "I do not know how to expand a variable reference to a #{varval.class.name}"
|
||||
raise "I do not know how to expand a variable reference to a #{varval.class.name} (from #{varname.inspect} => #{@vars[varname].inspect})"
|
||||
end
|
||||
else
|
||||
varref
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Rscons
|
||||
# gem version
|
||||
VERSION = "0.1.0"
|
||||
VERSION = "0.2.2"
|
||||
end
|
||||
@@ -158,6 +158,28 @@ describe Rscons do
|
||||
File.exists?('build_two/two.o').should be_true
|
||||
end
|
||||
|
||||
it 'uses build directories before build root' do
|
||||
test_dir('build_dir')
|
||||
Rscons::Environment.new do |env|
|
||||
env.append('CPPPATH' => Dir['src/**/*/'])
|
||||
env.build_dir("src", "build")
|
||||
env.build_root = "build_root"
|
||||
env.Program('build_dir', Dir['src/**/*.c'])
|
||||
end
|
||||
lines.should == ["CC build/one/one.o", "CC build/two/two.o", "LD build_dir"]
|
||||
end
|
||||
|
||||
it 'uses build_root if no build directories match' do
|
||||
test_dir('build_dir')
|
||||
Rscons::Environment.new do |env|
|
||||
env.append('CPPPATH' => Dir['src/**/*/'])
|
||||
env.build_dir("src2", "build")
|
||||
env.build_root = "build_root"
|
||||
env.Program('build_dir', Dir['src/**/*.c'])
|
||||
end
|
||||
lines.should == ["CC build_root/src/one/one.o", "CC build_root/src/two/two.o", "LD build_dir"]
|
||||
end
|
||||
|
||||
it 'cleans built files' do
|
||||
test_dir('build_dir')
|
||||
Rscons::Environment.new do |env|
|
||||
|
||||
Reference in new issue
Block a user