fix #12 - allow overriding dependency file suffix with DEPFILESUFFIX construction variable
This commit is contained in:
parent
851adae66f
commit
df1e3be829
@ -19,6 +19,7 @@ module Rscons
|
|||||||
def default_variables(env)
|
def default_variables(env)
|
||||||
{
|
{
|
||||||
'OBJSUFFIX' => '.o',
|
'OBJSUFFIX' => '.o',
|
||||||
|
'DEPFILESUFFIX' => '.mf',
|
||||||
|
|
||||||
'CPPDEFPREFIX' => '-D',
|
'CPPDEFPREFIX' => '-D',
|
||||||
'INCPREFIX' => '-I',
|
'INCPREFIX' => '-I',
|
||||||
@ -87,7 +88,7 @@ module Rscons
|
|||||||
vars = vars.merge({
|
vars = vars.merge({
|
||||||
'_TARGET' => target,
|
'_TARGET' => target,
|
||||||
'_SOURCES' => sources,
|
'_SOURCES' => sources,
|
||||||
'_DEPFILE' => Rscons.set_suffix(target, '.mf'),
|
'_DEPFILE' => Rscons.set_suffix(target, env.expand_varref("${DEPFILESUFFIX}", vars)),
|
||||||
})
|
})
|
||||||
com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
com_prefix = KNOWN_SUFFIXES.find do |compiler, suffix_var|
|
||||||
sources.first.end_with?(*env.expand_varref("${#{suffix_var}}"))
|
sources.first.end_with?(*env.expand_varref("${#{suffix_var}}"))
|
||||||
|
@ -2,19 +2,31 @@ module Rscons
|
|||||||
module Builders
|
module Builders
|
||||||
describe Object do
|
describe Object do
|
||||||
let(:env) {Environment.new}
|
let(:env) {Environment.new}
|
||||||
|
let(:cache) {double(Cache)}
|
||||||
subject {Object.new}
|
subject {Object.new}
|
||||||
|
|
||||||
it "supports overriding CCCMD construction variable" do
|
it "supports overriding CCCMD construction variable" do
|
||||||
cache = "cache"
|
expect(cache).to receive(:up_to_date?).and_return(false)
|
||||||
allow(cache).to receive(:up_to_date?) { false }
|
expect(cache).to receive(:mkdir_p)
|
||||||
allow(cache).to receive(:mkdir_p) { }
|
expect(FileUtils).to receive(:rm_f)
|
||||||
allow(cache).to receive(:register_build) { }
|
|
||||||
allow(FileUtils).to receive(:rm_f) { }
|
|
||||||
allow(File).to receive(:exists?) { false }
|
|
||||||
expect(env).to receive(:execute).with("CC mod.o", ["llc", "mod.c"]).and_return(true)
|
expect(env).to receive(:execute).with("CC mod.o", ["llc", "mod.c"]).and_return(true)
|
||||||
|
expect(File).to receive(:exists?).and_return(false)
|
||||||
|
expect(cache).to receive(:register_build)
|
||||||
|
|
||||||
subject.run("mod.o", ["mod.c"], cache, env, "CCCMD" => ["llc", "${_SOURCES}"])
|
subject.run("mod.o", ["mod.c"], cache, env, "CCCMD" => ["llc", "${_SOURCES}"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "supports overriding DEPFILESUFFIX construction variable" do
|
||||||
|
expect(cache).to receive(:up_to_date?).and_return(false)
|
||||||
|
expect(cache).to receive(:mkdir_p)
|
||||||
|
expect(FileUtils).to receive(:rm_f)
|
||||||
|
expect(env).to receive(:execute).with(anything, %w[gcc -c -o f.o -MMD -MF f.d in.c]).and_return(true)
|
||||||
|
expect(File).to receive(:exists?).with("f.d").and_return(false)
|
||||||
|
expect(cache).to receive(:register_build)
|
||||||
|
|
||||||
|
subject.run("f.o", ["in.c"], cache, env, "DEPFILESUFFIX" => ".d")
|
||||||
|
end
|
||||||
|
|
||||||
it "raises an error when given a source file with an unknown suffix" do
|
it "raises an error when given a source file with an unknown suffix" do
|
||||||
expect { subject.run("mod.o", ["mod.xyz"], :cache, env, {}) }.to raise_error /unknown input file type: "mod.xyz"/
|
expect { subject.run("mod.o", ["mod.xyz"], :cache, env, {}) }.to raise_error /unknown input file type: "mod.xyz"/
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user