Sha256: dd5e72d90216f4ae55e69e50c98a310c30951151f2ca425cf6df4536c4c8c3e0

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 KB

Contents

require "fileutils"

module Rscons
  # Namespace module in which to store builders for convenient grouping
  module Builders; end

  # Class to hold an object that knows how to build a certain type of file.
  class Builder
    # Return the name of the builder.
    # If not overridden this defaults to the last component of the class name.
    def name
      self.class.name.split(":").last
    end

    # Return a set of default variable values for the Environment to use
    # unless the user overrides any.
    # @param env [Environment] The Environment.
    def default_variables(env)
      {}
    end

    # Return whether this builder object is capable of producing a given target
    # file name from a given source file name.
    # @param target [String] The target file name.
    # @param source [String, Array] The source file name(s).
    # @param env [Environment] The Environment.
    def produces?(target, source, env)
      false
    end

    # Check if the cache is up to date for the target and if not execute the
    # build command.
    # Return the name of the target or false on failure.
    def standard_build(short_cmd_string, target, command, sources, env, cache)
      unless cache.up_to_date?(target, command, sources, env)
        cache.mkdir_p(File.dirname(target))
        FileUtils.rm_f(target)
        return false unless env.execute(short_cmd_string, command)
        cache.register_build(target, command, sources, env)
      end
      target
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rscons-1.4.3 lib/rscons/builder.rb
rscons-1.4.2 lib/rscons/builder.rb
rscons-1.4.1 lib/rscons/builder.rb
rscons-1.4.0 lib/rscons/builder.rb
rscons-1.3.0 lib/rscons/builder.rb
rscons-1.2.0 lib/rscons/builder.rb
rscons-1.1.0 lib/rscons/builder.rb
rscons-1.0.0 lib/rscons/builder.rb
rscons-0.3.1 lib/rscons/builder.rb
rscons-0.3.0 lib/rscons/builder.rb