Compare commits

..
3 Commits
Author SHA1 Message Date
josh 4d7ed373e7 v0.2.0 2013-11-08 15:45:35 -05:00
josh 72558391a2 clarify documentation about cloning Environments 2013-11-08 15:45:24 -05:00
josh d01767981c add Environment#build_root to be used if no build directories match 2013-11-08 14:52:39 -05:00
4 changed files with 40 additions and 10 deletions

No files matched your search

+3 -3
View File
@@ -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:
+14 -6
View File
@@ -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,10 +45,10 @@ 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()
@builders.each do |builder_name, builder|
@@ -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
+1 -1
View File
@@ -1,4 +1,4 @@
module Rscons
# gem version
VERSION = "0.1.0"
VERSION = "0.2.0"
end
+22
View File
@@ -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|