From 02aff35222ce796bd29fd7014d6d4e37a5bba40b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 24 Jan 2015 09:24:47 -0500 Subject: [PATCH] allow overriding Command builder short description with CMD_DESC variable -- close #22 --- README.md | 4 +++- lib/rscons/builders/command.rb | 3 ++- spec/rscons/builders/command_spec.rb | 8 +++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2f2e2c8..59ece4c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/rscons/builders/command.rb b/lib/rscons/builders/command.rb index 0ee4192..3dc6f09 100644 --- a/lib/rscons/builders/command.rb +++ b/lib/rscons/builders/command.rb @@ -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 diff --git a/spec/rscons/builders/command_spec.rb b/spec/rscons/builders/command_spec.rb index 4c99a5c..96ae96c 100755 --- a/spec/rscons/builders/command_spec.rb +++ b/spec/rscons/builders/command_spec.rb @@ -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