Class: Rscons::Builders::Command

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

Overview

A builder to execute an arbitrary 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}])

Instance Attribute Summary

Attributes inherited from Rscons::Builder

#build_step, #cache, #env, #preferred_ld, #side_effects, #sources, #target, #vars

Instance Method Summary collapse

Methods inherited from Rscons::Builder

#depends, extra_path, #finalize_command, #initialize, name, #name, #print_run_message, #produces, #register_command, #standard_command, #wait_for

Constructor Details

This class inherits a constructor from Rscons::Builder

Instance Method Details

#run(options) ⇒ Object

Run the builder to produce a build target.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rscons/builders/command.rb', line 12

def run(options)
  if @command
    finalize_command
  else
    @vars["_TARGET"] = @target
    @vars["_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_command("#{cmd_desc} <target>#{@target}<reset>", command, options)
  end
end