allow overriding Command builder short description with CMD_DESC variable -- close #22

This commit is contained in:
Josh Holtrop 2015-01-24 09:24:47 -05:00
parent 897d31ebe0
commit 02aff35222
3 changed files with 10 additions and 5 deletions

View File

@ -252,7 +252,8 @@ you can use the `exclude_builders` key to the Environment constructor.
env.Command(target, sources, "CMD" => command)
# Example
env.Command("docs.html", "docs.md",
"CMD" => ["pandoc", "-fmarkdown", "-thtml", "-o${_TARGET}", "${_SOURCES}"])
"CMD" => ["pandoc", "-fmarkdown", "-thtml", "-o${_TARGET}", "${_SOURCES}"],
"CMD_DESC" => "PANDOC")
```
The command builder executes a user-defined command in order to produce the
@ -389,6 +390,7 @@ http://rubydoc.info/github/holtrop/rscons/frames.
- rework Preprocess builder to consider deep dependencies
- remove ${CFLAGS} from default CPP_CMD
- fix variable references that expand to arrays in build target sources
- allow overriding Command builder short description with CMD_DESC variable
### v1.8.1

View File

@ -25,7 +25,8 @@ module Rscons
"_SOURCES" => sources,
})
command = env.build_command("${CMD}", vars)
standard_build("CMD #{target}", target, command, sources, env, cache)
cmd_desc = vars["CMD_DESC"] || "cmd_desc"
standard_build("#{cmd_desc} #{target}", target, command, sources, env, cache)
end
end
end

View File

@ -1,16 +1,18 @@
module Rscons
module Builders
describe Command do
let(:command) { ['pandoc', '-fmarkdown', '-thtml', '-o${_TARGET}', '${_SOURCES}'] }
let(:env) {Environment.new}
subject {Command.new}
it "invokes the command to build the target" do
expected_cmd = ['pandoc', '-fmarkdown', '-thtml', '-ofoo.html', 'foo.md']
expect(subject).to receive(:standard_build).with("CMD foo.html", "foo.html", expected_cmd, ["foo.md"], env, :cache)
subject.run("foo.html", ["foo.md"], :cache, env, {'CMD' => command})
expect(subject).to receive(:standard_build).with("PANDOC foo.html", "foo.html", expected_cmd, ["foo.md"], env, :cache)
subject.run("foo.html", ["foo.md"], :cache, env,
"CMD" => command, "CMD_DESC" => "PANDOC")
end
end
end
end