Class: Rscons::Builders::CFile

Inherits:
Rscons::Builder show all
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 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
27
28
29
30
31
# File 'lib/rscons/builders/cfile.rb', line 12

def run(options)
  if @command
    finalize_command
  else
    @vars["_TARGET"] = @target
    @vars["_SOURCES"] = @sources
    case
    when @sources.first.end_with?(*@env.expand_varref("${LEXSUFFIX}"))
      cmd = "LEX"
      message = "Generating lexer"
    when @sources.first.end_with?(*@env.expand_varref("${YACCSUFFIX}"))
      cmd = "YACC"
      message = "Generating parser"
    else
      raise "Unknown source file #{@sources.first.inspect} for CFile builder"
    end
    command = @env.build_command("${#{cmd}_CMD}", @vars)
    standard_command("#{message} from <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>", command)
  end
end