Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c89dddbd6 | ||
|
|
c07d9f86a6 | ||
|
|
ff26da8865 | ||
|
|
5ff555cf6a | ||
|
|
e3aadc562f |
No files matched your search
@@ -66,7 +66,7 @@ end
|
||||
|
||||
```ruby
|
||||
class GenerateFoo < Rscons::Builder
|
||||
def run(target, sources, user_deps, cache, env, vars)
|
||||
def run(target, sources, cache, env, vars)
|
||||
cache.mkdir_p(File.dirname(target))
|
||||
File.open(target, "w") do |fh|
|
||||
fh.puts <<EOF
|
||||
@@ -86,12 +86,12 @@ end
|
||||
|
||||
```ruby
|
||||
class CmdBuilder < Rscons::Builder
|
||||
def run(target, sources, user_deps, cache, env, vars)
|
||||
def run(target, sources, cache, env, vars)
|
||||
cmd = ["cmd", "-i", sources.first, "-o", target]
|
||||
unless cache.up_to_date?(target, cmd, sources, user_deps)
|
||||
unless cache.up_to_date?(target, cmd, sources, env)
|
||||
cache.mkdir_p(File.dirname(target))
|
||||
system(cmd)
|
||||
cache.register_build(target, cmd, sources, user_deps)
|
||||
cache.register_build(target, cmd, sources, env)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -105,9 +105,9 @@ end
|
||||
|
||||
```ruby
|
||||
class CmdBuilder < Rscons::Builder
|
||||
def run(target, sources, user_deps, cache, env, vars)
|
||||
def run(target, sources, cache, env, vars)
|
||||
cmd = ["cmd", "-i", sources.first, "-o", target]
|
||||
standard_build("CmdBld #{target}", target, cmd, sources, user_deps, env, cache)
|
||||
standard_build("CmdBld #{target}", target, cmd, sources, env, cache)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+2
-2
@@ -117,7 +117,7 @@ module Rscons
|
||||
# command used to build target must be identical
|
||||
return false unless @cache[:targets][target][:command] == command
|
||||
|
||||
cached_deps = @cache[:targets][target][:deps] or []
|
||||
cached_deps = @cache[:targets][target][:deps] || []
|
||||
cached_deps_fnames = cached_deps.map { |dc| dc[:fname] }
|
||||
if options[:strict_deps]
|
||||
# depedencies passed in must exactly equal those in the cache
|
||||
@@ -129,7 +129,7 @@ module Rscons
|
||||
|
||||
# set of user dependencies must match
|
||||
user_deps = env.get_user_deps(target) || []
|
||||
cached_user_deps = @cache[:targets][target][:user_deps] or []
|
||||
cached_user_deps = @cache[:targets][target][:user_deps] || []
|
||||
cached_user_deps_fnames = cached_user_deps.map { |dc| dc[:fname] }
|
||||
return false unless user_deps == cached_user_deps_fnames
|
||||
|
||||
|
||||
@@ -185,6 +185,11 @@ module Rscons
|
||||
@varset.merge(extra_vars).expand_varref(command_template)
|
||||
end
|
||||
|
||||
# Expand a construction variable reference (String or Array)
|
||||
def expand_varref(varref)
|
||||
@varset.expand_varref(varref)
|
||||
end
|
||||
|
||||
# Execute a builder command
|
||||
# @param short_desc [String] Message to print if the Environment's echo
|
||||
# mode is set to :short
|
||||
|
||||
+2
-14
@@ -17,20 +17,8 @@ module Rscons
|
||||
|
||||
# Access the value of variable as a particular type
|
||||
# @param key [String, Symbol] The variable name.
|
||||
# @param type [Symbol, nil] Optional specification of the type desired.
|
||||
# If the variable is a String and type is :array, a 1-element array with
|
||||
# the variable value will be returned. If the variable is an Array and
|
||||
# type is :string, the first element from the variable value will be
|
||||
# returned.
|
||||
def [](key, type = nil)
|
||||
val = @vars[key]
|
||||
if type == :array and not val.is_a?(Array)
|
||||
[val]
|
||||
elsif type == :scalar and val.is_a?(Array)
|
||||
val.first
|
||||
else
|
||||
val
|
||||
end
|
||||
def [](key)
|
||||
@vars[key]
|
||||
end
|
||||
|
||||
# Assign a value to a variable.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Rscons
|
||||
# gem version
|
||||
VERSION = "0.3.0"
|
||||
VERSION = "0.3.1"
|
||||
end
|
||||
@@ -199,6 +199,20 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
describe "#expand_varref" do
|
||||
it "returns the fully expanded variable reference" do
|
||||
env = Environment.new
|
||||
env["path"] = ["dir1", "dir2"]
|
||||
env["flags"] = ["-x", "-y", "${specialflag}"]
|
||||
env["specialflag"] = "-z"
|
||||
env.expand_varref(["-p${path}", "${flags}"]).should == ["-pdir1", "-pdir2", "-x", "-y", "-z"]
|
||||
env.expand_varref("foo").should == "foo"
|
||||
expect {env.expand_varref("${foo}")}.to raise_error /expand.a.variable.reference/
|
||||
env.expand_varref("${specialflag}").should == "-z"
|
||||
env.expand_varref("${path}").should == ["dir1", "dir2"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "#execute" do
|
||||
context "with echo: :short" do
|
||||
context "with no errors" do
|
||||
|
||||
@@ -30,12 +30,6 @@ module Rscons
|
||||
v["qax"].should == [3, 6]
|
||||
v["qux"].should == {a: :b}
|
||||
end
|
||||
it "allows accessing a non-array converted to an array" do
|
||||
v["fuz", :array].should == ["a string"]
|
||||
end
|
||||
it "allows accessing an array as a single value" do
|
||||
v["qax", :scalar].should == 3
|
||||
end
|
||||
end
|
||||
|
||||
describe :[]= do
|
||||
|
||||
Reference in new issue
Block a user