Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0adb64c5d | ||
|
|
95da14e029 | ||
|
|
58b41df426 | ||
|
|
bd525e2742 | ||
|
|
c08a2243b9 | ||
|
|
0de1e8e970 | ||
|
|
6f20a1da3f |
No files matched your search
@@ -329,6 +329,15 @@ http://rubydoc.info/github/holtrop/rscons/frames.
|
||||
|
||||
## Release Notes
|
||||
|
||||
### v1.4.2
|
||||
|
||||
- add Environment#expand_path
|
||||
- expand construction variable references in builder targets and sources before invoking builder
|
||||
|
||||
### v1.4.1
|
||||
|
||||
- fix invoking a builder with no sources while a build root defined
|
||||
|
||||
### v1.4.0
|
||||
|
||||
- add CFile builder
|
||||
|
||||
+27
-16
@@ -172,7 +172,7 @@ module Rscons
|
||||
# called after the block returns.
|
||||
def process
|
||||
unless @targets.empty?
|
||||
clean_target_paths!
|
||||
expand_paths!
|
||||
cache = Cache.instance
|
||||
cache.clear_checksum_cache!
|
||||
targets_processed = {}
|
||||
@@ -258,7 +258,7 @@ module Rscons
|
||||
unless vars.nil? or vars.is_a?(Hash) or vars.is_a?(VarSet)
|
||||
raise "Unexpected construction variable set: #{vars.inspect}"
|
||||
end
|
||||
sources = [sources] unless sources.is_a?(Array)
|
||||
sources = Array(sources)
|
||||
add_target(target, @builders[method.to_s], sources, vars, rest)
|
||||
else
|
||||
super
|
||||
@@ -337,24 +337,35 @@ module Rscons
|
||||
builder.run(target, sources, cache, self, vars)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Expand all target paths that begin with ^/ to be relative to the
|
||||
# Environment's build root, if present
|
||||
def clean_target_paths!
|
||||
if @build_root
|
||||
expand = lambda do |path|
|
||||
# Expand a path to be relative to the Environment's build root.
|
||||
#
|
||||
# Paths beginning with "^/" are expanded by replacing "^" with the
|
||||
# Environment's build root.
|
||||
#
|
||||
# @param path [String] The path to expand.
|
||||
#
|
||||
# @return [String] The expanded path.
|
||||
def expand_path(path)
|
||||
path.sub(%r{^\^(?=[\\/])}, @build_root)
|
||||
end
|
||||
|
||||
new_targets = {}
|
||||
@targets.each_pair do |target, target_params|
|
||||
target_params[:sources].map! do |source|
|
||||
expand[source]
|
||||
private
|
||||
|
||||
# Expand target and source paths before invoking builders.
|
||||
#
|
||||
# This method expand construction variable references in the target and
|
||||
# source file names before passing them to the builder. It also expands
|
||||
# "^/" prefixes to the Environment's build root if a build root is defined.
|
||||
def expand_paths!
|
||||
@targets = @targets.reduce({}) do |result, (target, target_params)|
|
||||
sources = target_params[:sources].map do |source|
|
||||
source = expand_path(source) if @build_root
|
||||
expand_varref(source)
|
||||
end
|
||||
new_targets[expand[target]] = target_params
|
||||
end
|
||||
@targets = new_targets
|
||||
target = expand_path(target) if @build_root
|
||||
target = expand_varref(target)
|
||||
result[target] = target_params.merge(sources: sources)
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Rscons
|
||||
# gem version
|
||||
VERSION = "1.4.0"
|
||||
VERSION = "1.4.2"
|
||||
end
|
||||
@@ -484,4 +484,44 @@ EOF
|
||||
File.read("simplepp.cc").should =~ /# \d+ "simple.cc"/
|
||||
`./simple`.should == "This is a simple C++ program\n"
|
||||
end
|
||||
|
||||
it "supports invoking builders with no sources and a build_root defined" do
|
||||
class TestBuilder < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
target
|
||||
end
|
||||
end
|
||||
test_dir("simple")
|
||||
Rscons::Environment.new do |env|
|
||||
env.build_root = "build"
|
||||
env.add_builder(TestBuilder.new)
|
||||
env.TestBuilder("file")
|
||||
end
|
||||
end
|
||||
|
||||
it "expands construction variables in builder target and sources before invoking the builder" do
|
||||
test_dir('custom_builder')
|
||||
class MySource < Rscons::Builder
|
||||
def run(target, sources, cache, env, vars)
|
||||
File.open(target, 'w') do |fh|
|
||||
fh.puts <<EOF
|
||||
#define THE_VALUE 678
|
||||
EOF
|
||||
end
|
||||
target
|
||||
end
|
||||
end
|
||||
|
||||
Rscons::Environment.new do |env|
|
||||
env["hdr"] = "inc.h"
|
||||
env["src"] = "program.c"
|
||||
env.add_builder(MySource.new)
|
||||
env.MySource('${hdr}')
|
||||
env.Program('program', "${src}")
|
||||
end
|
||||
|
||||
lines.should == ['CC program.o', 'LD program']
|
||||
File.exists?('inc.h').should be_true
|
||||
`./program`.should == "The value is 678\n"
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user