add :check_libpath option to check_lib configuration method - #107
This commit is contained in:
parent
6e590b62a6
commit
51a9dd365f
5
build_tests/configure/check_lib_libpath1.rb
Normal file
5
build_tests/configure/check_lib_libpath1.rb
Normal file
@ -0,0 +1,5 @@
|
||||
build do
|
||||
Environment.new(echo: :command) do |env|
|
||||
env.Library("usr2/libfrobulous.a", "two.c")
|
||||
end
|
||||
end
|
10
build_tests/configure/check_lib_libpath2.rb
Normal file
10
build_tests/configure/check_lib_libpath2.rb
Normal file
@ -0,0 +1,10 @@
|
||||
configure do
|
||||
check_lib "m", check_libpath: ["./usr1"]
|
||||
check_lib "frobulous", check_libpath: ["./usr2"]
|
||||
end
|
||||
|
||||
build do
|
||||
Environment.new(echo: :command) do |env|
|
||||
env.Program("simple.exe", "simple.c")
|
||||
end
|
||||
end
|
4
build_tests/configure/two.c
Normal file
4
build_tests/configure/two.c
Normal file
@ -0,0 +1,4 @@
|
||||
int two(void)
|
||||
{
|
||||
return 42;
|
||||
}
|
@ -235,6 +235,7 @@ module Rscons
|
||||
|
||||
# Check for a library.
|
||||
def check_lib(lib, options = {})
|
||||
check_libpath = [nil] + (options[:check_libpath] || [])
|
||||
Ansi.write($stdout, "Checking for library '", :cyan, lib, :reset, "'... ")
|
||||
File.open("#{@work_dir}/cfgtest.c", "wb") do |fh|
|
||||
fh.puts <<-EOF
|
||||
@ -249,8 +250,21 @@ module Rscons
|
||||
"_SOURCES" => "#{@work_dir}/cfgtest.c",
|
||||
"_TARGET" => "#{@work_dir}/cfgtest.exe",
|
||||
}
|
||||
command = BasicEnvironment.new.build_command("${LDCMD}", vars)
|
||||
_, _, status = log_and_test_command(command)
|
||||
status = 1
|
||||
check_libpath.each do |libpath|
|
||||
env = BasicEnvironment.new
|
||||
if libpath
|
||||
env["LIBPATH"] += Array(libpath)
|
||||
end
|
||||
command = env.build_command("${LDCMD}", vars)
|
||||
_, _, status = log_and_test_command(command)
|
||||
if status == 0
|
||||
if libpath
|
||||
store_append({"LIBPATH" => Array(libpath)}, options)
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
if status == 0
|
||||
store_append({"LIBS" => [lib]}, options)
|
||||
end
|
||||
|
@ -1986,6 +1986,23 @@ EOF
|
||||
expect(result.stdout).to match /Checking for library 'm'... found/
|
||||
expect(result.stdout).to_not match /-lm/
|
||||
end
|
||||
|
||||
it "modifies LIBPATH based on check_libpath" do
|
||||
test_dir "configure"
|
||||
FileUtils.mkdir_p("usr1")
|
||||
FileUtils.mkdir_p("usr2")
|
||||
result = run_rscons(rsconscript: "check_lib_libpath1.rb")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
result = run_rscons(rsconscript: "check_lib_libpath2.rb", op: "configure")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
result = run_rscons(rsconscript: "check_lib_libpath2.rb")
|
||||
expect(result.stderr).to eq ""
|
||||
expect(result.status).to eq 0
|
||||
expect(result.stdout).to match %r{-L\./usr2}
|
||||
expect(result.stdout).to_not match %r{-L\./usr1}
|
||||
end
|
||||
end
|
||||
|
||||
context "check_program" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user