Fix configuration checks performed with ldc2 compiler - close #172
This commit is contained in:
parent
f8c21a9bcc
commit
415fa424d1
@ -1,3 +1,3 @@
|
|||||||
configure do
|
configure do
|
||||||
check_d_compiler "gdc", "ldc2"
|
check_d_compiler "gdc", "ldc2", "ldc"
|
||||||
end
|
end
|
||||||
|
|||||||
8
build_tests/configure/check_lib_with_ldc.rb
Normal file
8
build_tests/configure/check_lib_with_ldc.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
configure do
|
||||||
|
check_d_compiler "ldc2"
|
||||||
|
check_lib "z"
|
||||||
|
end
|
||||||
|
|
||||||
|
env(echo: :command) do |env|
|
||||||
|
env.Program("simple.exe", "simple.d")
|
||||||
|
end
|
||||||
@ -1,5 +1,6 @@
|
|||||||
require "fileutils"
|
require "fileutils"
|
||||||
require "open3"
|
require "open3"
|
||||||
|
require "set"
|
||||||
|
|
||||||
module Rscons
|
module Rscons
|
||||||
# Class to manage a configure operation.
|
# Class to manage a configure operation.
|
||||||
@ -10,6 +11,7 @@ module Rscons
|
|||||||
# @param script [Script]
|
# @param script [Script]
|
||||||
# Build script.
|
# Build script.
|
||||||
def initialize(script)
|
def initialize(script)
|
||||||
|
@tested_compilers = {}
|
||||||
@work_dir = "#{Rscons.application.build_dir}/_configure"
|
@work_dir = "#{Rscons.application.build_dir}/_configure"
|
||||||
FileUtils.mkdir_p(@work_dir)
|
FileUtils.mkdir_p(@work_dir)
|
||||||
@log_file_name = "#{@work_dir}/config.log"
|
@log_file_name = "#{@work_dir}/config.log"
|
||||||
@ -65,6 +67,10 @@ module Rscons
|
|||||||
cc = ccc.find do |cc|
|
cc = ccc.find do |cc|
|
||||||
test_c_compiler(cc, options)
|
test_c_compiler(cc, options)
|
||||||
end
|
end
|
||||||
|
if cc
|
||||||
|
@tested_compilers["c"] ||= Set.new
|
||||||
|
@tested_compilers["c"] << cc
|
||||||
|
end
|
||||||
complete(cc ? 0 : 1, options.merge(
|
complete(cc ? 0 : 1, options.merge(
|
||||||
success_message: cc,
|
success_message: cc,
|
||||||
fail_message: "not found (checked #{ccc.join(", ")})"))
|
fail_message: "not found (checked #{ccc.join(", ")})"))
|
||||||
@ -89,6 +95,10 @@ module Rscons
|
|||||||
cc = ccc.find do |cc|
|
cc = ccc.find do |cc|
|
||||||
test_cxx_compiler(cc, options)
|
test_cxx_compiler(cc, options)
|
||||||
end
|
end
|
||||||
|
if cc
|
||||||
|
@tested_compilers["cxx"] ||= Set.new
|
||||||
|
@tested_compilers["cxx"] << cc
|
||||||
|
end
|
||||||
complete(cc ? 0 : 1, options.merge(
|
complete(cc ? 0 : 1, options.merge(
|
||||||
success_message: cc,
|
success_message: cc,
|
||||||
fail_message: "not found (checked #{ccc.join(", ")})"))
|
fail_message: "not found (checked #{ccc.join(", ")})"))
|
||||||
@ -108,11 +118,15 @@ module Rscons
|
|||||||
end
|
end
|
||||||
if cdc.empty?
|
if cdc.empty?
|
||||||
# Default D compiler search array.
|
# Default D compiler search array.
|
||||||
cdc = %w[gdc ldc2]
|
cdc = %w[gdc ldc2 ldc]
|
||||||
end
|
end
|
||||||
dc = cdc.find do |dc|
|
dc = cdc.find do |dc|
|
||||||
test_d_compiler(dc, options)
|
test_d_compiler(dc, options)
|
||||||
end
|
end
|
||||||
|
if dc
|
||||||
|
@tested_compilers["d"] ||= Set.new
|
||||||
|
@tested_compilers["d"] << dc
|
||||||
|
end
|
||||||
complete(dc ? 0 : 1, options.merge(
|
complete(dc ? 0 : 1, options.merge(
|
||||||
success_message: dc,
|
success_message: dc,
|
||||||
fail_message: "not found (checked #{cdc.join(", ")})"))
|
fail_message: "not found (checked #{cdc.join(", ")})"))
|
||||||
@ -252,17 +266,36 @@ module Rscons
|
|||||||
def check_lib(lib, options = {})
|
def check_lib(lib, options = {})
|
||||||
check_libpath = [nil] + (options[:check_libpath] || [])
|
check_libpath = [nil] + (options[:check_libpath] || [])
|
||||||
Ansi.write($stdout, "Checking for library '", :cyan, lib, :reset, "'... ")
|
Ansi.write($stdout, "Checking for library '", :cyan, lib, :reset, "'... ")
|
||||||
File.open("#{@work_dir}/cfgtest.c", "wb") do |fh|
|
if @tested_compilers["d"]
|
||||||
|
source_file = "#{@work_dir}/cfgtest.d"
|
||||||
|
File.open(source_file, "wb") do |fh|
|
||||||
|
fh.puts <<-EOF
|
||||||
|
int main() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
else
|
||||||
|
source_file = "#{@work_dir}/cfgtest.c"
|
||||||
|
File.open(source_file, "wb") do |fh|
|
||||||
fh.puts <<-EOF
|
fh.puts <<-EOF
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
ld = "${CC}"
|
||||||
|
%w[d cxx c].each do |language|
|
||||||
|
if @tested_compilers[language]
|
||||||
|
ld = @tested_compilers[language].first
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
vars = {
|
vars = {
|
||||||
"LD" => "${CC}",
|
"LD" => ld,
|
||||||
"LIBS" => [lib],
|
"LIBS" => [lib],
|
||||||
"_SOURCES" => "#{@work_dir}/cfgtest.c",
|
"_SOURCES" => source_file,
|
||||||
"_TARGET" => "#{@work_dir}/cfgtest.exe",
|
"_TARGET" => "#{@work_dir}/cfgtest.exe",
|
||||||
}
|
}
|
||||||
status = 1
|
status = 1
|
||||||
@ -496,8 +529,10 @@ module Rscons
|
|||||||
env = BasicEnvironment.new
|
env = BasicEnvironment.new
|
||||||
merge = {
|
merge = {
|
||||||
"DC" => dc,
|
"DC" => dc,
|
||||||
"DCCMD" => env["DCCMD"].map {|e| e.sub(/^-o$/, "-of")},
|
"DC:-o" => "-of",
|
||||||
"LDCMD" => env["LDCMD"].map {|e| e.sub(/^-o$/, "-of")},
|
"LD:-o" => "-of",
|
||||||
|
"LIBDIRPREFIX" => "-L-L",
|
||||||
|
"LIBLINKPREFIX" => "-L-l",
|
||||||
"DDEPGEN" => ["-deps=${_DEPFILE}"],
|
"DDEPGEN" => ["-deps=${_DEPFILE}"],
|
||||||
}
|
}
|
||||||
merge["OBJSUFFIX"] = [ldc_objsuffix]
|
merge["OBJSUFFIX"] = [ldc_objsuffix]
|
||||||
|
|||||||
@ -35,8 +35,9 @@ module Rscons
|
|||||||
"CXXFLAGS" => [],
|
"CXXFLAGS" => [],
|
||||||
"CXXSUFFIX" => %w[.cc .cpp .cxx .C],
|
"CXXSUFFIX" => %w[.cc .cpp .cxx .C],
|
||||||
"DC" => "gdc",
|
"DC" => "gdc",
|
||||||
"DCCMD" => %w[${DC} -c -o ${_TARGET} ${DDEPGEN} ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${_SOURCES}],
|
"DC:-o" => "-o",
|
||||||
"DCCMD:direct" => %w[${DC} -o ${_TARGET} ${DDEPGEN} ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${LDFLAGS} ${_SOURCES} ${LIBDIRPREFIX}${LIBPATH} ${LIBLINKPREFIX}${LIBS}],
|
"DCCMD" => %w[${DC} -c ${DC:-o} ${_TARGET} ${DDEPGEN} ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${_SOURCES}],
|
||||||
|
"DCCMD:direct" => %w[${DC} ${DC:-o} ${_TARGET} ${DDEPGEN} ${INCPREFIX}${D_IMPORT_PATH} ${DFLAGS} ${LDFLAGS} ${_SOURCES} ${LIBDIRPREFIX}${LIBPATH} ${LIBLINKPREFIX}${LIBS}],
|
||||||
"DDEPGEN" => %w[-MMD -MF ${_DEPFILE}],
|
"DDEPGEN" => %w[-MMD -MF ${_DEPFILE}],
|
||||||
"DEPFILESUFFIX" => ".mf",
|
"DEPFILESUFFIX" => ".mf",
|
||||||
"DFLAGS" => [],
|
"DFLAGS" => [],
|
||||||
@ -46,7 +47,8 @@ module Rscons
|
|||||||
"D_IMPORT_PATH" => [],
|
"D_IMPORT_PATH" => [],
|
||||||
"INCPREFIX" => "-I",
|
"INCPREFIX" => "-I",
|
||||||
"LD" => nil,
|
"LD" => nil,
|
||||||
"LDCMD" => %w[${LD} -o ${_TARGET} ${LDFLAGS} ${_SOURCES} ${LIBDIRPREFIX}${LIBPATH} ${LIBLINKPREFIX}${LIBS}],
|
"LD:-o" => "-o",
|
||||||
|
"LDCMD" => %w[${LD} ${LD:-o} ${_TARGET} ${LDFLAGS} ${_SOURCES} ${LIBDIRPREFIX}${LIBPATH} ${LIBLINKPREFIX}${LIBS}],
|
||||||
"LDFLAGS" => [],
|
"LDFLAGS" => [],
|
||||||
"LEX" => "flex",
|
"LEX" => "flex",
|
||||||
"LEX_CMD" => %w[${LEX} ${LEX_FLAGS} -o ${_TARGET} ${_SOURCES}],
|
"LEX_CMD" => %w[${LEX} ${LEX_FLAGS} -o ${_TARGET} ${_SOURCES}],
|
||||||
|
|||||||
@ -2047,10 +2047,11 @@ EOF
|
|||||||
test_dir "configure"
|
test_dir "configure"
|
||||||
create_exe "gdc", "exit 1"
|
create_exe "gdc", "exit 1"
|
||||||
create_exe "ldc2", "exit 1"
|
create_exe "ldc2", "exit 1"
|
||||||
|
create_exe "ldc", "exit 1"
|
||||||
result = run_rscons(args: %W[-f #{rsconscript} configure])
|
result = run_rscons(args: %W[-f #{rsconscript} configure])
|
||||||
expect(result.stderr).to match %r{Configuration failed; log file written to build/_configure/config.log}
|
expect(result.stderr).to match %r{Configuration failed; log file written to build/_configure/config.log}
|
||||||
expect(result.status).to_not eq 0
|
expect(result.status).to_not eq 0
|
||||||
expect(result.stdout).to match /Checking for D compiler\.\.\. not found \(checked gdc, ldc2\)/
|
expect(result.stdout).to match /Checking for D compiler\.\.\. not found \(checked gdc, ldc2, ldc\)/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2287,6 +2288,18 @@ EOF
|
|||||||
expect(result.stdout).to_not match /-lm/
|
expect(result.stdout).to_not match /-lm/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "finds the requested library with only ldc compiler" do
|
||||||
|
test_dir "configure"
|
||||||
|
create_exe "gcc", "exit 1"
|
||||||
|
create_exe "clang", "exit 1"
|
||||||
|
create_exe "gcc++", "exit 1"
|
||||||
|
create_exe "clang++", "exit 1"
|
||||||
|
result = run_rscons(args: %w[-f check_lib_with_ldc.rb])
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.status).to eq 0
|
||||||
|
expect(result.stdout).to match /Checking for library 'z'... found/
|
||||||
|
end
|
||||||
|
|
||||||
it "modifies LIBPATH based on check_libpath" do
|
it "modifies LIBPATH based on check_libpath" do
|
||||||
test_dir "configure"
|
test_dir "configure"
|
||||||
FileUtils.mkdir_p("usr1")
|
FileUtils.mkdir_p("usr1")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user