Add Depfile builder mixin - #94

This commit is contained in:
josh committed 2019-04-09 18:41:02 -04:00
1 parent 5534878f68
commit a655d04541
4 files changed
+28 -12

No files matched your search

+21
View 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
View File
@@ -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
+3 -6
View File
@@ -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}"