Class: Rscons::Builders::Preprocess

Inherits:
Rscons::Builder show all
Includes:
Mixins::Depfile
Defined in:
lib/rscons/builders/preprocess.rb

Overview

The Preprocess builder invokes the C preprocessor

Instance Attribute Summary

Attributes inherited from Rscons::Builder

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

Instance Method Summary collapse

Methods included from Mixins::Depfile

#finalize_command_with_depfile

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.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rscons/builders/preprocess.rb', line 11

def run(options)
  if @command
    finalize_command_with_depfile
  else
    if @sources.find {|s| s.end_with?(*@env.expand_varref("${CXXSUFFIX}", @vars))}
      pp_cc = "${CXX}"
      depgen = "${CXXDEPGEN}"
    else
      pp_cc = "${CC}"
      depgen = "${CCDEPGEN}"
    end
    @vars["_PREPROCESS_CC"] = pp_cc
    @vars["_PREPROCESS_DEPGEN"] = depgen
    @vars["_TARGET"] = @target
    @vars["_SOURCES"] = @sources
    @vars["_DEPFILE"] = "#{target}#{env.expand_varref("${DEPFILESUFFIX}", vars)}"
    command = @env.build_command("${CPP_CMD}", @vars)
    self.produces(@vars["_DEPFILE"])
    standard_command("Preprocessing <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>", command)
  end
end