Class: Rscons::Builders::Command

Inherits:
Rscons::Builder show all
Defined in:
lib/rscons/builders/command.rb

Overview

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

Example:

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

Since:

  • 1.8.0

Instance Method Summary collapse

Methods inherited from Rscons::Builder

#create_build_target, #default_variables, #features, #name, #produces?, #setup, #standard_build, #standard_finalize, #standard_threaded_build

Instance Method Details

#finalize(options) ⇒ String?

Finalize a build.

Parameters:

  • options (Hash)

    Finalize options.

Returns:

  • (String, nil)

    The target name on success or nil on failure.

Since:

  • 1.8.0



42
43
44
# File 'lib/rscons/builders/command.rb', line 42

def finalize(options)
  standard_finalize(options)
end

#run(options) ⇒ String, ThreadedCommand

Run the builder to produce a build target.

Parameters:

  • options (Hash)

    Builder run options.

Returns:

Since:

  • 1.8.0



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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