Class: Rscons::Builders::CFile
- Inherits:
-
Rscons::Builder
- Object
- Rscons::Builder
- Rscons::Builders::CFile
- Defined in:
- lib/rscons/builders/cfile.rb
Overview
Build a C or C++ source file given a lex (.l, .ll) or yacc (.y, .yy) input file.
- Examples
-
env.CFile(“parser.tab.cc”, “parser.yy”) env.CFile(“lex.yy.cc”, “parser.ll”)
Instance Method Summary collapse
-
#default_variables(env) ⇒ Hash
Return default construction variables for the builder.
-
#finalize(options) ⇒ String?
Finalize a build.
-
#run(target, sources, cache, env, vars) ⇒ String, false
Run the builder to produce a build target.
Methods inherited from Rscons::Builder
#create_build_target, #features, #name, #produces?, #setup, #standard_build, #standard_finalize, #standard_threaded_build
Instance Method Details
#default_variables(env) ⇒ Hash
Return default construction variables for the builder.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rscons/builders/cfile.rb', line 16 def default_variables(env) { "YACC" => "bison", "YACC_FLAGS" => ["-d"], "YACC_CMD" => ["${YACC}", "${YACC_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"], "YACCSUFFIX" => [".y", ".yy"], "LEX" => "flex", "LEX_FLAGS" => [], "LEX_CMD" => ["${LEX}", "${LEX_FLAGS}", "-o", "${_TARGET}", "${_SOURCES}"], "LEXSUFFIX" => [".l", ".ll"], } end |
#finalize(options) ⇒ String?
Finalize a build.
64 65 66 |
# File 'lib/rscons/builders/cfile.rb', line 64 def finalize() standard_finalize() end |
#run(target, sources, cache, env, vars) ⇒ String, false
Run the builder to produce a build target.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rscons/builders/cfile.rb', line 39 def run(target, sources, cache, env, vars) vars = vars.merge({ "_TARGET" => target, "_SOURCES" => sources, }) cmd = case when sources.first.end_with?(*env.("${LEXSUFFIX}")) "LEX" when sources.first.end_with?(*env.("${YACCSUFFIX}")) "YACC" else raise "Unknown source file #{sources.first.inspect} for CFile builder" end command = env.build_command("${#{cmd}_CMD}", vars) standard_threaded_build("#{cmd} #{target}", target, command, sources, env, cache) end |