Add Depfile builder mixin - #94
This commit is contained in:
parent
5534878f68
commit
a655d04541
@ -166,6 +166,7 @@ module Rscons
|
||||
end
|
||||
|
||||
# builder mixins
|
||||
require_relative "rscons/builders/mixins/depfile"
|
||||
require_relative "rscons/builders/mixins/object"
|
||||
require_relative "rscons/builders/mixins/object_deps"
|
||||
|
||||
|
21
lib/rscons/builders/mixins/depfile.rb
Normal file
21
lib/rscons/builders/mixins/depfile.rb
Normal file
@ -0,0 +1,21 @@
|
||||
module Rscons
|
||||
module Builders
|
||||
module Mixins
|
||||
# Mixin for builders that make use of generated dependency files.
|
||||
module Depfile
|
||||
|
||||
# Finalize a build operation including dependencies from a generated
|
||||
# dependency file.
|
||||
def finalize_command_with_depfile
|
||||
deps = @sources
|
||||
if File.exists?(@vars["_DEPFILE"])
|
||||
deps += Util.parse_makefile_deps(@vars["_DEPFILE"])
|
||||
end
|
||||
@cache.register_build(@target, @command, deps.uniq, @env)
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -3,6 +3,8 @@ module Rscons
|
||||
module Mixins
|
||||
module Object
|
||||
|
||||
include Depfile
|
||||
|
||||
class << self
|
||||
# Hook called by Ruby when this module is included by a class (klass).
|
||||
def included(klass)
|
||||
@ -50,12 +52,7 @@ module Rscons
|
||||
# Run the builder to produce a build target.
|
||||
def run(params)
|
||||
if @command
|
||||
deps = @sources
|
||||
if File.exists?(@vars["_DEPFILE"])
|
||||
deps += Util.parse_makefile_deps(@vars["_DEPFILE"])
|
||||
end
|
||||
@cache.register_build(@target, @command, deps.uniq, @env)
|
||||
true
|
||||
finalize_command_with_depfile
|
||||
else
|
||||
@vars["_TARGET"] = @target
|
||||
@vars["_SOURCES"] = @sources
|
||||
|
@ -5,15 +5,12 @@ module Rscons
|
||||
# The Preprocess builder invokes the C preprocessor
|
||||
class Preprocess < Builder
|
||||
|
||||
include Mixins::Depfile
|
||||
|
||||
# Run the builder to produce a build target.
|
||||
def run(options)
|
||||
if @command
|
||||
deps = @sources
|
||||
if File.exists?(@vars["_DEPFILE"])
|
||||
deps += Util.parse_makefile_deps(@vars["_DEPFILE"])
|
||||
end
|
||||
@cache.register_build(@target, @command, deps.uniq, @env)
|
||||
true
|
||||
finalize_command_with_depfile
|
||||
else
|
||||
if @sources.find {|s| s.end_with?(*@env.expand_varref("${CXXSUFFIX}", @vars))}
|
||||
pp_cc = "${CXX}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user