class Rscons::Builders::Command

Execute a command that will produce the given target based on the given sources.

@since 1.8.0

Example:

env.Command("docs.html", "docs.md",
            CMD => %w[pandoc -fmarkdown -thtml -o${_TARGET} ${_SOURCES}])

Public Instance Methods

finalize(options) click to toggle source

Finalize a build.

@param options [Hash]

Finalize options.

@return [String, nil]

The target name on success or nil on failure.
# File lib/rscons/builders/command.rb, line 42
def finalize(options)
  standard_finalize(options)
end
run(options) click to toggle source

Run the builder to produce a build target.

@param options [Hash] Builder run options.

@return [String, ThreadedCommand]

Target file name if target is up to date or a {ThreadedCommand}
to execute to build the target.
# File lib/rscons/builders/command.rb, line 20
def run(options)
  target, sources, cache, env, vars = options.values_at(:target, :sources, :cache, :env, :vars)
  vars = vars.merge({
    "_TARGET" => target,
    "_SOURCES" => sources,
  })
  command = env.build_command("${CMD}", vars)
  cmd_desc = vars["CMD_DESC"] || "Command"
  options = {}
  if vars["CMD_STDOUT"]
    options[:stdout] = env.expand_varref("${CMD_STDOUT}", vars)
  end
  standard_threaded_build("#{cmd_desc} #{target}", target, command, sources, env, cache, options)
end