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