test all known compiler invocation commands - close #66

This commit is contained in:
Josh Holtrop 2018-11-29 17:44:36 -05:00
parent e3e2e46d6e
commit 8d7fd4bda8

View File

@ -216,26 +216,20 @@ module Rscons
fh.puts <<-EOF fh.puts <<-EOF
#include <stdio.h> #include <stdio.h>
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
printf("Hello.\\n"); printf("Success.\\n");
return 0; return 0;
} }
EOF EOF
end end
case cc command = %W[#{cc} -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.c]
when "gcc" merge = {"CC" => cc}
command = %W[gcc -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.c]
merge = {"CC" => "gcc"}
when "clang"
command = %W[clang -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.c]
merge = {"CC" => "clang"}
else
$stderr.puts "Unknown C compiler (#{cc})"
raise ConfigureFailure.new
end
_, _, status = log_and_test_command(command) _, _, status = log_and_test_command(command)
if status == 0 if status == 0
store_merge(merge) stdout, _, status = log_and_test_command(["#{@work_dir}/cfgtest.exe"])
true if status == 0 and stdout =~ /Success/
store_merge(merge)
true
end
end end
end end
@ -252,26 +246,20 @@ module Rscons
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
cout << "Hello." << endl; cout << "Success." << endl;
return 0; return 0;
} }
EOF EOF
end end
case cc command = %W[#{cc} -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.cxx]
when "g++" merge = {"CXX" => cc}
command = %W[g++ -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.cxx]
merge = {"CXX" => "g++"}
when "clang++"
command = %W[clang++ -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.cxx]
merge = {"CXX" => "clang++"}
else
$stderr.puts "Unknown C++ compiler (#{cc})"
raise ConfigureFailure.new
end
_, _, status = log_and_test_command(command) _, _, status = log_and_test_command(command)
if status == 0 if status == 0
store_merge(merge) stdout, _, status = log_and_test_command(["#{@work_dir}/cfgtest.exe"])
true if status == 0 and stdout =~ /Success/
store_merge(merge)
true
end
end end
end end
@ -287,31 +275,33 @@ module Rscons
fh.puts <<-EOF fh.puts <<-EOF
import std.stdio; import std.stdio;
int main() { int main() {
writeln("Hello."); writeln("Success.");
return 0; return 0;
} }
EOF EOF
end end
case dc [:gdc, :ldc2].find do |dc_test|
when "gdc" case dc_test
command = %W[gdc -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.d] when :gdc
merge = {"DC" => "gdc"} command = %W[#{dc} -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.d]
when "ldc2" merge = {"DC" => dc}
command = %W[ldc2 -of #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.d] when :ldc2
env = Environment.new command = %W[#{dc} -of #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.d]
merge = { env = Environment.new
"DC" => "ldc2", merge = {
"DCCMD" => env["DCCMD"].map {|e| if e == "-o"; "-of"; else; e; end}, "DC" => dc,
"LDCMD" => env["LDCMD"].map {|e| if e == "-o"; "-of"; else; e; end}, "DCCMD" => env["DCCMD"].map {|e| if e == "-o"; "-of"; else; e; end},
} "LDCMD" => env["LDCMD"].map {|e| if e == "-o"; "-of"; else; e; end},
else }
$stderr.puts "Unknown D compiler (#{dc})" end
raise ConfigureFailure.new _, _, status = log_and_test_command(command)
end if status == 0
_, _, status = log_and_test_command(command) stdout, _, status = log_and_test_command(["#{@work_dir}/cfgtest.exe"])
if status == 0 if status == 0 and stdout =~ /Success/
store_merge(merge) store_merge(merge)
true true
end
end
end end
end end