Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eff9a10d0c | ||
|
|
6ad3fb0785 | ||
|
|
32e8a55b4e | ||
|
|
3733cb6114 |
No files matched your search
@@ -1,5 +1,18 @@
|
||||
## ChangeLog
|
||||
|
||||
### v1.18.0
|
||||
|
||||
#### Performance Improvements
|
||||
|
||||
- Backport 2.x VarSet performance improvements to 1.x branch.
|
||||
- Remove Cache dirty-tracking
|
||||
- Reduce recursion of VarSet#expand_varref by expanding vars earlier.
|
||||
|
||||
#### Fixes
|
||||
|
||||
- #73 - fix inconsistent type handling in VarSet#expand_varref
|
||||
- #75 - avoid mkdir() race conditions
|
||||
|
||||
### v1.17.0
|
||||
|
||||
#### New Features
|
||||
|
||||
+16
-16
@@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
rscons (1.17.0)
|
||||
rscons (1.18.0)
|
||||
json (>= 1.8, < 3.0)
|
||||
|
||||
GEM
|
||||
@@ -10,23 +10,23 @@ GEM
|
||||
diff-lcs (1.3)
|
||||
docile (1.3.2)
|
||||
json (2.2.0)
|
||||
rake (12.3.2)
|
||||
rdoc (6.1.1)
|
||||
rspec (3.8.0)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-core (3.8.2)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-expectations (3.8.4)
|
||||
rake (13.0.0)
|
||||
rdoc (6.2.0)
|
||||
rspec (3.9.0)
|
||||
rspec-core (~> 3.9.0)
|
||||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-core (3.9.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-expectations (3.9.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-mocks (3.8.1)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-mocks (3.9.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-support (3.8.2)
|
||||
simplecov (0.15.0)
|
||||
docile (~> 1.1.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-support (3.9.0)
|
||||
simplecov (0.17.1)
|
||||
docile (~> 1.1)
|
||||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.2)
|
||||
|
||||
@@ -280,6 +280,24 @@ module Rscons
|
||||
@varset.send(:[], *args)
|
||||
end
|
||||
|
||||
# Access the value of a construction variable.
|
||||
#
|
||||
# @since 1.18.0
|
||||
#
|
||||
# This method is similar to #[] but does not make a copy-on-access copy of
|
||||
# the variable accessed. This means that the returned value is NOT safe to
|
||||
# be modified by the caller. Thus the caller must guarantee that it does
|
||||
# not modify the returned value.
|
||||
#
|
||||
# @param key [String, Symbol]
|
||||
# The construction variable name.
|
||||
#
|
||||
# @return [Object]
|
||||
# The construction variable's value.
|
||||
def get_var(key)
|
||||
@varset.get_var(key)
|
||||
end
|
||||
|
||||
# Set a construction variable's value.
|
||||
#
|
||||
# @see VarSet#[]=
|
||||
@@ -782,7 +800,7 @@ module Rscons
|
||||
append["LDFLAGS", ["-arch", val]]
|
||||
end
|
||||
skip = true
|
||||
elsif word =~ /^#{self["CPPDEFPREFIX"]}(.*)$/
|
||||
elsif word =~ /^#{get_var("CPPDEFPREFIX")}(.*)$/
|
||||
handle["CPPDEFINES", $1]
|
||||
elsif word == "-include"
|
||||
if val = words[i + 1]
|
||||
@@ -795,11 +813,11 @@ module Rscons
|
||||
append["LDFLAGS", ["-isysroot", val]]
|
||||
end
|
||||
skip = true
|
||||
elsif word =~ /^#{self["INCPREFIX"]}(.*)$/
|
||||
elsif word =~ /^#{get_var("INCPREFIX")}(.*)$/
|
||||
handle["CPPPATH", $1]
|
||||
elsif word =~ /^#{self["LIBLINKPREFIX"]}(.*)$/
|
||||
elsif word =~ /^#{get_var("LIBLINKPREFIX")}(.*)$/
|
||||
handle["LIBS", $1]
|
||||
elsif word =~ /^#{self["LIBDIRPREFIX"]}(.*)$/
|
||||
elsif word =~ /^#{get_var("LIBDIRPREFIX")}(.*)$/
|
||||
handle["LIBPATH", $1]
|
||||
elsif word == "-mno-cygwin"
|
||||
append["CCFLAGS", [word]]
|
||||
@@ -848,7 +866,7 @@ module Rscons
|
||||
# @return [void]
|
||||
def merge_flags(flags)
|
||||
flags.each_pair do |key, val|
|
||||
if self[key].is_a?(Array) and val.is_a?(Array)
|
||||
if self.get_var(key).is_a?(Array) and val.is_a?(Array)
|
||||
self[key] += val
|
||||
else
|
||||
self[key] = val
|
||||
|
||||
+50
-21
@@ -11,11 +11,13 @@ module Rscons
|
||||
append(vars)
|
||||
end
|
||||
|
||||
# Access the value of variable.
|
||||
# Access the value of a variable.
|
||||
#
|
||||
# @param key [String, Symbol] The variable name.
|
||||
# @param key [String, Symbol]
|
||||
# The variable name.
|
||||
#
|
||||
# @return [Object] The variable's value.
|
||||
# @return [Object]
|
||||
# The variable's value.
|
||||
def [](key)
|
||||
if @my_vars.include?(key)
|
||||
@my_vars[key]
|
||||
@@ -30,11 +32,38 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
# Access the value of a variable.
|
||||
#
|
||||
# This method is similar to #[] but does not make a copy-on-access copy of
|
||||
# the variable accessed. This means that the returned value is NOT safe to
|
||||
# be modified by the caller. Thus the caller must guarantee that it does
|
||||
# not modify the returned value.
|
||||
#
|
||||
# @param key [String, Symbol]
|
||||
# The variable name.
|
||||
#
|
||||
# @return [Object]
|
||||
# The variable's value.
|
||||
def get_var(key)
|
||||
if @my_vars.include?(key)
|
||||
@my_vars[key]
|
||||
else
|
||||
@coa_vars.each do |coa_vars|
|
||||
if coa_vars.include?(key)
|
||||
return coa_vars[key]
|
||||
end
|
||||
end
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# Assign a value to a variable.
|
||||
#
|
||||
# @param key [String, Symbol] The variable name.
|
||||
# @param key [String, Symbol]
|
||||
# The variable name.
|
||||
#
|
||||
# @param val [Object] The value to set.
|
||||
# @param val [Object]
|
||||
# The value to set.
|
||||
def []=(key, val)
|
||||
@my_vars[key] = val
|
||||
end
|
||||
@@ -95,29 +124,27 @@ module Rscons
|
||||
# Expanded value with "$!{var}" variable references replaced.
|
||||
def expand_varref(varref, lambda_args)
|
||||
case varref
|
||||
when Symbol, true, false, nil
|
||||
varref
|
||||
when String
|
||||
if varref =~ /^(.*)\$\{([^}]+)\}(.*)$/
|
||||
prefix, varname, suffix = $1, $2, $3
|
||||
prefix = expand_varref(prefix, lambda_args) unless prefix.empty?
|
||||
varval = expand_varref(self[varname], lambda_args)
|
||||
varval = expand_varref(get_var(varname), lambda_args)
|
||||
# suffix needs no expansion since the regex matches the last occurence
|
||||
case varval
|
||||
when Symbol, true, false, nil, String
|
||||
if prefix.is_a?(Array)
|
||||
prefix.map {|p| "#{p}#{varval}#{suffix}"}
|
||||
else
|
||||
"#{prefix}#{varval}#{suffix}"
|
||||
end
|
||||
when Array
|
||||
if prefix.is_a?(Array)
|
||||
varval.map {|vv| prefix.map {|p| "#{p}#{vv}#{suffix}"}}.flatten
|
||||
else
|
||||
varval.map {|vv| "#{prefix}#{vv}#{suffix}"}
|
||||
end
|
||||
when String, Symbol, true, false, nil
|
||||
if prefix.is_a?(Array)
|
||||
prefix.map {|p| "#{p}#{varval}#{suffix}"}
|
||||
else
|
||||
"#{prefix}#{varval}#{suffix}"
|
||||
end
|
||||
else
|
||||
raise "Unknown construction variable type: #{varval.class} (from #{varname.inspect} => #{self[varname].inspect})"
|
||||
raise "Unknown construction variable type: #{varval.class} (from #{varname.inspect} => #{get_var(varname).inspect})"
|
||||
end
|
||||
else
|
||||
varref
|
||||
@@ -126,6 +153,8 @@ module Rscons
|
||||
varref.map do |ent|
|
||||
expand_varref(ent, lambda_args)
|
||||
end.flatten
|
||||
when Symbol, true, false, nil
|
||||
varref
|
||||
when Proc
|
||||
expand_varref(varref[*lambda_args], lambda_args)
|
||||
else
|
||||
@@ -194,16 +223,16 @@ module Rscons
|
||||
#
|
||||
# @return [Object] Deep copied value.
|
||||
def deep_dup(obj)
|
||||
obj_class = obj.class
|
||||
if obj_class == Hash
|
||||
case obj
|
||||
when String
|
||||
obj.dup
|
||||
when Array
|
||||
obj.map { |v| deep_dup(v) }
|
||||
when Hash
|
||||
obj.reduce({}) do |result, (k, v)|
|
||||
result[k] = deep_dup(v)
|
||||
result
|
||||
end
|
||||
elsif obj_class == Array
|
||||
obj.map { |v| deep_dup(v) }
|
||||
elsif obj_class == String
|
||||
obj.dup
|
||||
else
|
||||
obj
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Rscons
|
||||
# gem version
|
||||
VERSION = "1.17.0"
|
||||
VERSION = "1.18.0"
|
||||
end
|
||||
@@ -169,7 +169,7 @@ module Rscons
|
||||
expect { v.expand_varref({a: :b}, :lambda_args) }.to raise_error /Unknown construction variable type: Hash/
|
||||
end
|
||||
it "raises an error when an expanded variable is an unexpected type" do
|
||||
expect(v).to receive(:[]).at_least(1).times.with("bad").and_return("bad_val")
|
||||
expect(v).to receive(:get_var).at_least(1).times.with("bad").and_return("bad_val")
|
||||
expect(v).to receive(:expand_varref).with("bad_val", :lambda_args).and_return({a: :b})
|
||||
expect(v).to receive(:expand_varref).and_call_original
|
||||
expect { v.expand_varref("${bad}", :lambda_args) }.to raise_error /Unknown construction variable type: Hash/
|
||||
|
||||
Reference in new issue
Block a user