Module: Rscons::Builders::Mixins::Object
- Includes:
- Depfile
- Included in:
- Object, SharedObject
- Defined in:
- lib/rscons/builders/mixins/object.rb
Overview
Mixin for builders needing to build object files.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(klass) ⇒ Object
Hook called by Ruby when this module is included by a class (klass).
Instance Method Summary collapse
-
#initialize(params) ⇒ Object
Construct a builder conforming to the Object interface.
-
#run(params) ⇒ Object
Run the builder to produce a build target.
Methods included from Depfile
#finalize_command_with_depfile
Class Method Details
.included(klass) ⇒ Object
Hook called by Ruby when this module is included by a class (klass).
18 19 20 |
# File 'lib/rscons/builders/mixins/object.rb', line 18 def included(klass) klass.__send__(:extend, ClassMethods) end |
Instance Method Details
#initialize(params) ⇒ Object
Construct a builder conforming to the Object interface.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rscons/builders/mixins/object.rb', line 51 def initialize(params) super build_params = self.class.providers.find do |build_params| @sources.first.end_with?(*@env.(build_params[:suffix], @vars)) end unless build_params raise "Unknown input file type: #{@sources.first.inspect}" end @command_template = if @vars[:direct] build_params[:direct_command] else build_params[:command] end @short_description = build_params[:short_description] || "Compiling" @preferred_ld = build_params[:preferred_ld] end |
#run(params) ⇒ Object
Run the builder to produce a build target.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rscons/builders/mixins/object.rb', line 70 def run(params) if @command finalize_command_with_depfile else @vars["_TARGET"] = @target @vars["_SOURCES"] = @sources depfilesuffix = @env.("${DEPFILESUFFIX}", vars) @vars["_DEPFILE"] = if @vars[:direct] || !@target.start_with?("#{@env.build_root}/") @env.get_build_fname(@target, depfilesuffix, self.class) else "#{@target}#{depfilesuffix}" end @vars["D_IMPORT_PATH"] = @env.("${D_IMPORT_PATH}").map do |import_path| if @env.d_precompile_import_paths.include?(import_path) [@env.d_precompile_import_paths[import_path], import_path] else import_path end end.flatten @cache.mkdir_p(File.dirname(@vars["_DEPFILE"])) command = @env.build_command(@command_template, @vars) self.produces(@vars["_DEPFILE"]) if @vars[:direct] = "#{@short_description}/Linking <source>#{Util.short_format_paths(@sources)}<reset> => <target>#{@target}<reset>" else = "#{@short_description} <source>#{Util.short_format_paths(@sources)}<reset>" end standard_command(, command) end end |