Sha256: 31cdc9a59c9cde67bc41f1ed736f6134ecc1f2f944cf8f51c81f13b150572960

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 KB

Contents

module Rscons
  module Builders
    # The Preprocess builder invokes the C preprocessor
    class Preprocess < Builder
      # Return default construction variables for the builder.
      #
      # @param env [Environment] The Environment using the builder.
      #
      # @return [Hash] Default construction variables for the builder.
      def default_variables(env)
        {
          "CPP_CMD" => ["${_PREPROCESS_CC}", "-E", "-o", "${_TARGET}", "-I${CPPPATH}", "${CPPFLAGS}", "${CFLAGS}", "${_SOURCES}"],
        }
      end

      # 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)
        pp_cc = if sources.find {|s| s.end_with?(*env.expand_varref("${CXXSUFFIX}", vars))}
                  "${CXX}"
                else
                  "${CC}"
                end
        vars = vars.merge("_PREPROCESS_CC" => pp_cc,
                          "_TARGET" => target,
                          "_SOURCES" => sources)
        command = env.build_command("${CPP_CMD}", vars)
        standard_build("Preprocess #{target}", target, command, sources, env, cache)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rscons-1.8.1 lib/rscons/builders/preprocess.rb
rscons-1.8.0 lib/rscons/builders/preprocess.rb
rscons-1.7.0 lib/rscons/builders/preprocess.rb
rscons-1.6.1 lib/rscons/builders/preprocess.rb
rscons-1.6.0 lib/rscons/builders/preprocess.rb
rscons-1.5.0 lib/rscons/builders/preprocess.rb