Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0adb64c5d | ||
|
|
95da14e029 | ||
|
|
58b41df426 | ||
|
|
bd525e2742 | ||
|
|
c08a2243b9 |
No files matched your search
@@ -329,6 +329,15 @@ http://rubydoc.info/github/holtrop/rscons/frames.
|
|||||||
|
|
||||||
## Release Notes
|
## 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
|
### v1.4.0
|
||||||
|
|
||||||
- add CFile builder
|
- add CFile builder
|
||||||
|
|||||||
+27
-16
@@ -172,7 +172,7 @@ module Rscons
|
|||||||
# called after the block returns.
|
# called after the block returns.
|
||||||
def process
|
def process
|
||||||
unless @targets.empty?
|
unless @targets.empty?
|
||||||
clean_target_paths!
|
expand_paths!
|
||||||
cache = Cache.instance
|
cache = Cache.instance
|
||||||
cache.clear_checksum_cache!
|
cache.clear_checksum_cache!
|
||||||
targets_processed = {}
|
targets_processed = {}
|
||||||
@@ -337,24 +337,35 @@ module Rscons
|
|||||||
builder.run(target, sources, cache, self, vars)
|
builder.run(target, sources, cache, self, vars)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Expand all target paths that begin with ^/ to be relative to the
|
# Expand target and source paths before invoking builders.
|
||||||
# Environment's build root, if present
|
#
|
||||||
def clean_target_paths!
|
# This method expand construction variable references in the target and
|
||||||
if @build_root
|
# source file names before passing them to the builder. It also expands
|
||||||
expand = lambda do |path|
|
# "^/" prefixes to the Environment's build root if a build root is defined.
|
||||||
path.sub(%r{^\^(?=[\\/])}, @build_root)
|
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
|
end
|
||||||
|
target = expand_path(target) if @build_root
|
||||||
new_targets = {}
|
target = expand_varref(target)
|
||||||
@targets.each_pair do |target, target_params|
|
result[target] = target_params.merge(sources: sources)
|
||||||
target_params[:sources].map! do |source|
|
result
|
||||||
expand[source]
|
|
||||||
end
|
|
||||||
new_targets[expand[target]] = target_params
|
|
||||||
end
|
|
||||||
@targets = new_targets
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module Rscons
|
module Rscons
|
||||||
# gem version
|
# gem version
|
||||||
VERSION = "1.4.1"
|
VERSION = "1.4.2"
|
||||||
end
|
end
|
||||||
@@ -498,4 +498,30 @@ EOF
|
|||||||
env.TestBuilder("file")
|
env.TestBuilder("file")
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
Reference in new issue
Block a user