Environment: add #parse_flags, #parse_flags!, and #merge_flags
This commit is contained in:
1 parent
7c9e7e833a
commit
ef18c9da35
2 files changed
+185
-2
No files matched your search
@@ -379,6 +379,60 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
describe "#parse_flags" do
|
||||
it "executes the shell command and parses the returned flags when the input argument begins with !" do
|
||||
env = Environment.new
|
||||
env["CFLAGS"] = ["-g"]
|
||||
env.should_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")
|
||||
expect(rv).to eq({
|
||||
"CCFLAGS" => %w[-arch my_arch -include ii -isysroot sr -mno-cygwin -pthread -arbitrary +other_arbitrary],
|
||||
"LDFLAGS" => %w[-arch my_arch -isysroot sr -mno-cygwin -mwindows -pthread] + ["linker", "args 1 2"] + %w[+other_arbitrary],
|
||||
"CPPPATH" => %w[incdir],
|
||||
"LIBS" => %w[my_lib some_lib /a/b/c/lib],
|
||||
"LIBPATH" => %w[libdir],
|
||||
"CPPDEFINES" => %w[one=two],
|
||||
"CFLAGS" => %w[-std=c99],
|
||||
"ASFLAGS" => ["asm", "args 1 2"],
|
||||
"CPPFLAGS" => %w[cpp args 1 2],
|
||||
})
|
||||
expect(env["CFLAGS"]).to eq(["-g"])
|
||||
expect(env["ASFLAGS"]).to eq([])
|
||||
env.merge_flags(rv)
|
||||
expect(env["CFLAGS"]).to eq(["-g", "-std=c99"])
|
||||
expect(env["ASFLAGS"]).to eq(["asm", "args 1 2"])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#parse_flags!" do
|
||||
it "parses the given build flags and merges them into the Environment" do
|
||||
env = Environment.new
|
||||
env["CFLAGS"] = ["-g"]
|
||||
rv = env.parse_flags!("-I incdir -D my_define -L /a/libdir -l /some/lib")
|
||||
expect(rv).to eq({
|
||||
"CPPPATH" => %w[incdir],
|
||||
"LIBS" => %w[/some/lib],
|
||||
"LIBPATH" => %w[/a/libdir],
|
||||
"CPPDEFINES" => %w[my_define],
|
||||
})
|
||||
expect(env["CPPPATH"]).to eq(%w[incdir])
|
||||
expect(env["LIBS"]).to eq(%w[/some/lib])
|
||||
expect(env["LIBPATH"]).to eq(%w[/a/libdir])
|
||||
expect(env["CPPDEFINES"]).to eq(%w[my_define])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#merge_flags" do
|
||||
it "appends array contents and replaces other variable values" do
|
||||
env = Environment.new
|
||||
env["CPPPATH"] = ["incdir"]
|
||||
env["CSUFFIX"] = ".x"
|
||||
env.merge_flags("CPPPATH" => ["a"], "CSUFFIX" => ".c")
|
||||
expect(env["CPPPATH"]).to eq(%w[incdir a])
|
||||
expect(env["CSUFFIX"]).to eq(".c")
|
||||
end
|
||||
end
|
||||
|
||||
describe ".parse_makefile_deps" do
|
||||
it 'handles dependencies on one line' do
|
||||
File.should_receive(:read).with('makefile').and_return(<<EOS)
|
||||
|
||||
Reference in new issue
Block a user