fill in ConfigureOp#test_c_compiler
This commit is contained in:
parent
c9de4f37e6
commit
af033ee4e0
@ -88,7 +88,7 @@ module Rscons
|
|||||||
if ccc = @script.check_c_compiler
|
if ccc = @script.check_c_compiler
|
||||||
co.check_c_compiler(ccc)
|
co.check_c_compiler(ccc)
|
||||||
end
|
end
|
||||||
rescue ConfigureOp::ConfigFailure
|
rescue ConfigureOp::ConfigureFailure
|
||||||
rv = 1
|
rv = 1
|
||||||
end
|
end
|
||||||
co.close
|
co.close
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
require "fileutils"
|
require "fileutils"
|
||||||
|
require "open3"
|
||||||
|
|
||||||
module Rscons
|
module Rscons
|
||||||
# Class to manage a configure operation.
|
# Class to manage a configure operation.
|
||||||
class ConfigureOp
|
class ConfigureOp
|
||||||
|
|
||||||
# Exception raised when a configuration error occurs.
|
# Exception raised when a configuration error occurs.
|
||||||
class ConfigFailure < Exception; end
|
class ConfigureFailure < Exception; end
|
||||||
|
|
||||||
# Create a ConfigureOp.
|
# Create a ConfigureOp.
|
||||||
#
|
#
|
||||||
@ -51,6 +52,28 @@ module Rscons
|
|||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Whether the C compiler tested successfully.
|
# Whether the C compiler tested successfully.
|
||||||
def test_c_compiler(cc)
|
def test_c_compiler(cc)
|
||||||
|
File.open("#{@work_dir}/cfgtest.c", "wb") do |fh|
|
||||||
|
fh.puts <<-EOF
|
||||||
|
#include <stdio.h>
|
||||||
|
int main(int argc, char * argv[]) {
|
||||||
|
printf("Hello.\\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
case cc
|
||||||
|
when "gcc"
|
||||||
|
command = %W[gcc -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.c]
|
||||||
|
when "clang"
|
||||||
|
command = %W[clang -o #{@work_dir}/cfgtest.exe #{@work_dir}/cfgtest.c]
|
||||||
|
else
|
||||||
|
raise ConfigureFailure.new("Unknown C compiler (#{cc})")
|
||||||
|
end
|
||||||
|
@log_fh.puts("Command: #{command.join(" ")}")
|
||||||
|
stdout, stderr, status = Open3.capture3(*command)
|
||||||
|
@log_fh.write(stdout)
|
||||||
|
@log_fh.write(stderr)
|
||||||
|
status != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user