Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 targets to build
|
||||||
* a collection of build hooks
|
* a collection of build hooks
|
||||||
|
|
||||||
When cloning an environment, the construction variables, builders, and build
|
When cloning an environment, the construction variables and builders are
|
||||||
directories are cloned, but the new environment does not inherit any of the
|
cloned, but the new environment does not inherit any of the targets, build
|
||||||
targets or build hooks from the source environment.
|
hooks, build directories, or the build root from the source environment.
|
||||||
|
|
||||||
Cloned environments contain "deep copies" of construction variables.
|
Cloned environments contain "deep copies" of construction variables.
|
||||||
For example, in:
|
For example, in:
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ module Rscons
|
|||||||
# Hash of +{"builder_name" => builder_object}+ pairs.
|
# Hash of +{"builder_name" => builder_object}+ pairs.
|
||||||
attr_reader :builders
|
attr_reader :builders
|
||||||
|
|
||||||
|
# String or +nil+
|
||||||
|
attr_accessor :build_root
|
||||||
|
|
||||||
# Create an Environment object.
|
# Create an Environment object.
|
||||||
# @param variables [Hash]
|
# @param variables [Hash]
|
||||||
# The variables hash can contain construction variables, which are
|
# The variables hash can contain construction variables, which are
|
||||||
@@ -42,10 +45,10 @@ module Rscons
|
|||||||
|
|
||||||
# Make a copy of the Environment object.
|
# Make a copy of the Environment object.
|
||||||
# The cloned environment will contain a copy of all environment options,
|
# The cloned environment will contain a copy of all environment options,
|
||||||
# construction variables, builders, and build directories. It will not
|
# construction variables, and builders. It will not contain a copy of the
|
||||||
# contain a copy of the targets or build hooks.
|
# targets, build hooks, build directories, or the build root. If a block
|
||||||
# If a block is given, the Environment object is yielded to the block and
|
# is given, the Environment object is yielded to the block and when the
|
||||||
# when the block returns, the {#process} method is automatically called.
|
# block returns, the {#process} method is automatically called.
|
||||||
def clone(variables = {})
|
def clone(variables = {})
|
||||||
env = Environment.new()
|
env = Environment.new()
|
||||||
@builders.each do |builder_name, builder|
|
@builders.each do |builder_name, builder|
|
||||||
@@ -88,14 +91,19 @@ module Rscons
|
|||||||
# This method takes into account the Environment's build directories.
|
# This method takes into account the Environment's build directories.
|
||||||
def get_build_fname(source_fname, suffix)
|
def get_build_fname(source_fname, suffix)
|
||||||
build_fname = source_fname.set_suffix(suffix).gsub('\\', '/')
|
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)
|
if src_dir.is_a?(Regexp)
|
||||||
build_fname.sub!(src_dir, obj_dir)
|
build_fname.sub!(src_dir, obj_dir)
|
||||||
else
|
else
|
||||||
build_fname.sub!(%r{^#{src_dir}/}, "#{obj_dir}/")
|
build_fname.sub!(%r{^#{src_dir}/}, "#{obj_dir}/")
|
||||||
end
|
end
|
||||||
build_fname.gsub!('\\', '/')
|
|
||||||
end
|
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
|
build_fname
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module Rscons
|
module Rscons
|
||||||
# gem version
|
# gem version
|
||||||
VERSION = "0.1.0"
|
VERSION = "0.2.0"
|
||||||
end
|
end
|
||||||
@@ -158,6 +158,28 @@ describe Rscons do
|
|||||||
File.exists?('build_two/two.o').should be_true
|
File.exists?('build_two/two.o').should be_true
|
||||||
end
|
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
|
it 'cleans built files' do
|
||||||
test_dir('build_dir')
|
test_dir('build_dir')
|
||||||
Rscons::Environment.new do |env|
|
Rscons::Environment.new do |env|
|
||||||
|
|||||||
Reference in new issue
Block a user