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)
|
||||
{
|
||||
'OBJSUFFIX' => '.o',
|
||||
'DEPFILESUFFIX' => '.mf',
|
||||
|
||||
'CPPDEFPREFIX' => '-D',
|
||||
'INCPREFIX' => '-I',
|
||||
@ -87,7 +88,7 @@ module Rscons
|
||||
vars = vars.merge({
|
||||
'_TARGET' => target,
|
||||
'_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|
|
||||
sources.first.end_with?(*env.expand_varref("${#{suffix_var}}"))
|
||||
|
@ -2,19 +2,31 @@ module Rscons
|
||||
module Builders
|
||||
describe Object do
|
||||
let(:env) {Environment.new}
|
||||
let(:cache) {double(Cache)}
|
||||
subject {Object.new}
|
||||
|
||||
it "supports overriding CCCMD construction variable" do
|
||||
cache = "cache"
|
||||
allow(cache).to receive(:up_to_date?) { false }
|
||||
allow(cache).to receive(:mkdir_p) { }
|
||||
allow(cache).to receive(:register_build) { }
|
||||
allow(FileUtils).to receive(:rm_f) { }
|
||||
allow(File).to receive(:exists?) { false }
|
||||
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("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}"])
|
||||
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
|
||||
expect { subject.run("mod.o", ["mod.xyz"], :cache, env, {}) }.to raise_error /unknown input file type: "mod.xyz"/
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user