Tweak specs to all pass cleanly on MacOS

This commit is contained in:
Josh Holtrop 2022-02-27 19:09:54 -05:00
parent 20b5020284
commit 90c3867cae
8 changed files with 30 additions and 12 deletions

View File

@ -1,4 +1,7 @@
env(echo: :command) do |env| env(echo: :command) do |env|
env.Program('library.exe', ['lib.a', 'three.c']) env["LIBS"] << "mylib"
env.Library("lib.a", ['one.c', 'two.c'], 'CPPFLAGS' => ['-Dmake_lib']) env["LIBPATH"] << "."
env.Program("library.exe", "one.c")
env.depends("library.exe", "libmylib.a")
env.Library("libmylib.a", ["two.c", "three.c"], "CPPFLAGS" => ["-Dmake_lib"])
end end

View File

@ -1,8 +1,11 @@
#include <stdio.h> #include <stdio.h>
#ifdef make_lib void two();
void three();
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
two();
printf("Library\n"); printf("Library\n");
three();
} }
#endif

View File

@ -1,4 +1,4 @@
env(echo: :command) do |env| env(echo: :command) do |env|
env["ARCMD"] = %w[ar rcf ${_TARGET} ${_SOURCES}] env["ARCMD"] = %w[ar rcsu ${_TARGET} ${_SOURCES}]
env.Library("lib.a", glob("*.c")) env.Library("lib.a", glob("*.c"))
end end

View File

@ -0,0 +1,3 @@
void three(void)
{
}

View File

@ -0,0 +1,3 @@
void two(void)
{
}

View File

@ -1,5 +1,6 @@
env(echo: :command) do |env| env(echo: :command) do |env|
env["LD"] = "gcc" env["LD"] = "gcc"
mkdir_p("libdir")
env["LIBPATH"] += ["libdir"] env["LIBPATH"] += ["libdir"]
env.Program('simple.exe', Dir['*.c']) env.Program('simple.exe', Dir['*.c'])
end end

View File

@ -1,3 +1,6 @@
#ifdef ONE #ifdef ONE
#error ONE should not be defined #error ONE should not be defined
#endif #endif
void two(void)
{
}

View File

@ -565,14 +565,16 @@ EOF
result = run_rscons result = run_rscons
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [ verify_lines(lines(result.stdout), [
%r{gcc -c -o build/e.1/one.c.o -MMD -MF build/e.1/one.c.o.mf -Dmake_lib one.c},
%r{gcc -c -o build/e.1/two.c.o -MMD -MF build/e.1/two.c.o.mf -Dmake_lib two.c}, %r{gcc -c -o build/e.1/two.c.o -MMD -MF build/e.1/two.c.o.mf -Dmake_lib two.c},
%r{ar rcs lib.a build/e.1/one.c.o build/e.1/two.c.o}, %r{gcc -c -o build/e.1/three.c.o -MMD -MF build/e.1/three.c.o.mf -Dmake_lib three.c},
%r{gcc -c -o build/e.1/three.c.o -MMD -MF build/e.1/three.c.o.mf three.c}, %r{ar rcs libmylib.a build/e.1/two.c.o build/e.1/three.c.o},
%r{gcc -o library.exe lib.a build/e.1/three.c.o}, %r{gcc -c -o build/e.1/one.c.o -MMD -MF build/e.1/one.c.o.mf one.c},
%r{gcc -o library.exe build/e.1/one.c.o -L. -lmylib},
]) ])
expect(File.exists?("library.exe")).to be_truthy expect(File.exists?("library.exe")).to be_truthy
expect(nr(`ar t lib.a`)).to eq "one.c.o\ntwo.c.o\n" ar_t = nr(`ar t libmylib.a`)
expect(ar_t).to match %r{\btwo.c.o\b}
expect(ar_t).to match %r{\bthree.c.o\b}
end end
it 'supports build hooks to override construction variables' do it 'supports build hooks to override construction variables' do
@ -1664,7 +1666,7 @@ EOF
test_dir("library") test_dir("library")
result = run_rscons(args: %w[-f override_arcmd.rb]) result = run_rscons(args: %w[-f override_arcmd.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
verify_lines(lines(result.stdout), [%r{ar rcf lib.a build/e.1/one.c.o build/e.1/three.c.o build/e.1/two.c.o}]) verify_lines(lines(result.stdout), [%r{ar rcsu lib.a build/e.1/one.c.o build/e.1/three.c.o build/e.1/two.c.o}])
end end
it "allows passing object files as sources" do it "allows passing object files as sources" do
@ -1709,7 +1711,7 @@ EOF
]) ])
expect(File.exist?("simple.exe")).to be_truthy expect(File.exist?("simple.exe")).to be_truthy
expect(File.exist?("simple.size")).to be_truthy expect(File.exist?("simple.size")).to be_truthy
expect(File.read("simple.size")).to match /text.*data.*bss/ expect(File.read("simple.size")).to match /text.*data/i
end end
end end