implement ConfigureOp#check_d_compiler
This commit is contained in:
1 parent
d54d363a25
commit
d656df5407
5 files changed
+96
No files matched your search
@@ -91,6 +91,9 @@ module Rscons
|
||||
if ccc = @script.check_cxx_compiler
|
||||
co.check_cxx_compiler(ccc)
|
||||
end
|
||||
if cdc = @script.check_d_compiler
|
||||
co.check_d_compiler(cdc)
|
||||
end
|
||||
rescue ConfigureOp::ConfigureFailure
|
||||
rv = 1
|
||||
end
|
||||
|
||||
@@ -72,6 +72,29 @@ module Rscons
|
||||
end
|
||||
end
|
||||
|
||||
# Check for a working D compiler.
|
||||
#
|
||||
# @param cdc [Array<String>]
|
||||
# D compiler(s) to check for.
|
||||
#
|
||||
# @return [void]
|
||||
def check_d_compiler(cdc)
|
||||
$stdout.write("Checking for D compiler... ")
|
||||
if cdc.empty?
|
||||
# Default D compiler search array.
|
||||
cdc = %w[gdc ldc2]
|
||||
end
|
||||
dc = cdc.find do |dc|
|
||||
test_d_compiler(dc)
|
||||
end
|
||||
if dc
|
||||
Ansi.write($stdout, :green, dc, "\n")
|
||||
else
|
||||
Ansi.write($stdout, :red, "not found\n")
|
||||
raise ConfigureFailure.new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Test a C compiler.
|
||||
@@ -135,6 +158,36 @@ module Rscons
|
||||
status == 0
|
||||
end
|
||||
|
||||
# Test a D compiler.
|
||||
#
|
||||
# @param dc [String]
|
||||
# D compiler to test.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether the D compiler tested successfully.
|
||||
def test_d_compiler(dc)
|
||||
File.open("#{@work_dir}/cfgtest.d", "wb") do |fh|
|
||||
fh.puts <<-EOF
|
||||
import std.stdio;
|
||||
int main() {
|
||||
writeln("Hello.");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
end
|
||||
case dc
|
||||
when "gdc"
|
||||
command = %W[gdc -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.d]
|
||||
when "ldc2"
|
||||
command = %W[ldc2 -of=#{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.d]
|
||||
else
|
||||
$stderr.puts "Unknown D compiler (#{dc})"
|
||||
raise ConfigureFailure.new
|
||||
end
|
||||
_, _, status = log_and_test_command(command)
|
||||
status == 0
|
||||
end
|
||||
|
||||
# Execute a test command and log the result.
|
||||
def log_and_test_command(command)
|
||||
begin
|
||||
|
||||
Reference in new issue
Block a user