Added a command builder to the list of default builders

This commit is contained in:
Michael D. Lowis committed 2014-10-13 12:27:05 -04:00
1 parent 469f575564
commit e279959d79
4 files changed
+61

No files matched your search

+2
View File
@@ -6,6 +6,7 @@ require_relative "rscons/varset"
require_relative "rscons/version"
# default builders
require_relative "rscons/builders/command"
require_relative "rscons/builders/cfile"
require_relative "rscons/builders/disassemble"
require_relative "rscons/builders/library"
@@ -18,6 +19,7 @@ module Rscons
# Names of the default builders which will be added to all newly created
# {Environment} objects.
DEFAULT_BUILDERS = [
:Command,
:CFile,
:Disassemble,
:Library,
+30
View File
@@ -0,0 +1,30 @@
module Rscons
module Builders
# Execute a command that will produce the given target based on the given
# sources.
#
# Example::
# env.Command("docs.html", "docs.md",
# CMD => ['pandoc', '-fmarkdown', '-thtml', '-o${_TARGET}', '${_SOURCES}'])
class Command < Builder
# Run the builder to produce a build target.
#
# @param target [String] Target file name.
# @param sources [Array<String>] Source file name(s).
# @param cache [Cache] The Cache object.
# @param env [Environment] The Environment executing the builder.
# @param vars [Hash,VarSet] Extra construction variables.
#
# @return [String,false]
# Name of the target file on success or false on failure.
def run(target, sources, cache, env, vars)
vars = vars.merge({
"_TARGET" => target,
"_SOURCES" => sources,
})
command = env.build_command("${CMD}", vars)
standard_build("CMD #{target}", target, command, sources, env, cache)
end
end
end
end