Environment#parse_flags should put -std=XXX flags in CCFLAGS, not CFLAGS

This commit is contained in:
Josh Holtrop 2016-09-30 14:02:30 -04:00
parent 3065dc48ec
commit c4c2d5c128
2 changed files with 4 additions and 7 deletions

View File

@ -618,8 +618,6 @@ module Rscons
elsif word == "-pthread" elsif word == "-pthread"
append["CCFLAGS", [word]] append["CCFLAGS", [word]]
append["LDFLAGS", [word]] append["LDFLAGS", [word]]
elsif word =~ /^-std=/
append["CFLAGS", [word]]
elsif word =~ /^-Wa,(.*)$/ elsif word =~ /^-Wa,(.*)$/
append["ASFLAGS", $1.split(",")] append["ASFLAGS", $1.split(",")]
elsif word =~ /^-Wl,(.*)$/ elsif word =~ /^-Wl,(.*)$/

View File

@ -396,24 +396,23 @@ module Rscons
describe "#parse_flags" do describe "#parse_flags" do
it "executes the shell command and parses the returned flags when the input argument begins with !" do it "executes the shell command and parses the returned flags when the input argument begins with !" do
env = Environment.new env = Environment.new
env["CFLAGS"] = ["-g"] env["CCFLAGS"] = ["-g"]
expect(env).to receive(:shell).with("my_command").and_return(%[-arch my_arch -Done=two -include ii -isysroot sr -Iincdir -Llibdir -lmy_lib -mno-cygwin -mwindows -pthread -std=c99 -Wa,'asm,args 1 2' -Wl,linker,"args 1 2" -Wp,cpp,args,1,2 -arbitrary +other_arbitrary some_lib /a/b/c/lib]) expect(env).to receive(:shell).with("my_command").and_return(%[-arch my_arch -Done=two -include ii -isysroot sr -Iincdir -Llibdir -lmy_lib -mno-cygwin -mwindows -pthread -std=c99 -Wa,'asm,args 1 2' -Wl,linker,"args 1 2" -Wp,cpp,args,1,2 -arbitrary +other_arbitrary some_lib /a/b/c/lib])
rv = env.parse_flags("!my_command") rv = env.parse_flags("!my_command")
expect(rv).to eq({ expect(rv).to eq({
"CCFLAGS" => %w[-arch my_arch -include ii -isysroot sr -mno-cygwin -pthread -arbitrary +other_arbitrary], "CCFLAGS" => %w[-arch my_arch -include ii -isysroot sr -mno-cygwin -pthread -std=c99 -arbitrary +other_arbitrary],
"LDFLAGS" => %w[-arch my_arch -isysroot sr -mno-cygwin -mwindows -pthread] + ["linker", "args 1 2"] + %w[+other_arbitrary], "LDFLAGS" => %w[-arch my_arch -isysroot sr -mno-cygwin -mwindows -pthread] + ["linker", "args 1 2"] + %w[+other_arbitrary],
"CPPPATH" => %w[incdir], "CPPPATH" => %w[incdir],
"LIBS" => %w[my_lib some_lib /a/b/c/lib], "LIBS" => %w[my_lib some_lib /a/b/c/lib],
"LIBPATH" => %w[libdir], "LIBPATH" => %w[libdir],
"CPPDEFINES" => %w[one=two], "CPPDEFINES" => %w[one=two],
"CFLAGS" => %w[-std=c99],
"ASFLAGS" => ["asm", "args 1 2"], "ASFLAGS" => ["asm", "args 1 2"],
"CPPFLAGS" => %w[cpp args 1 2], "CPPFLAGS" => %w[cpp args 1 2],
}) })
expect(env["CFLAGS"]).to eq(["-g"]) expect(env["CCFLAGS"]).to eq(["-g"])
expect(env["ASFLAGS"]).to eq([]) expect(env["ASFLAGS"]).to eq([])
env.merge_flags(rv) env.merge_flags(rv)
expect(env["CFLAGS"]).to eq(["-g", "-std=c99"]) expect(env["CCFLAGS"]).to eq(%w[-g -arch my_arch -include ii -isysroot sr -mno-cygwin -pthread -std=c99 -arbitrary +other_arbitrary])
expect(env["ASFLAGS"]).to eq(["asm", "args 1 2"]) expect(env["ASFLAGS"]).to eq(["asm", "args 1 2"])
end end
end end