Improve configuration error messages - close #162
This commit is contained in:
parent
419e6ed313
commit
c48526fd97
@ -12,7 +12,8 @@ module Rscons
|
|||||||
def initialize(script)
|
def initialize(script)
|
||||||
@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_fh = File.open("#{@work_dir}/config.log", "wb")
|
@log_file_name = "#{@work_dir}/config.log"
|
||||||
|
@log_fh = File.open(@log_file_name, "wb")
|
||||||
cache = Cache.instance
|
cache = Cache.instance
|
||||||
cache["failed_commands"] = []
|
cache["failed_commands"] = []
|
||||||
cache["configuration_data"] = {}
|
cache["configuration_data"] = {}
|
||||||
@ -64,7 +65,9 @@ module Rscons
|
|||||||
cc = ccc.find do |cc|
|
cc = ccc.find do |cc|
|
||||||
test_c_compiler(cc, options)
|
test_c_compiler(cc, options)
|
||||||
end
|
end
|
||||||
complete(cc ? 0 : 1, options.merge(success_message: cc))
|
complete(cc ? 0 : 1, options.merge(
|
||||||
|
success_message: cc,
|
||||||
|
fail_message: "not found (checked #{ccc.join(", ")})"))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check for a working C++ compiler.
|
# Check for a working C++ compiler.
|
||||||
@ -86,7 +89,9 @@ module Rscons
|
|||||||
cc = ccc.find do |cc|
|
cc = ccc.find do |cc|
|
||||||
test_cxx_compiler(cc, options)
|
test_cxx_compiler(cc, options)
|
||||||
end
|
end
|
||||||
complete(cc ? 0 : 1, options.merge(success_message: cc))
|
complete(cc ? 0 : 1, options.merge(
|
||||||
|
success_message: cc,
|
||||||
|
fail_message: "not found (checked #{ccc.join(", ")})"))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check for a working D compiler.
|
# Check for a working D compiler.
|
||||||
@ -108,7 +113,9 @@ module Rscons
|
|||||||
dc = cdc.find do |dc|
|
dc = cdc.find do |dc|
|
||||||
test_d_compiler(dc, options)
|
test_d_compiler(dc, options)
|
||||||
end
|
end
|
||||||
complete(dc ? 0 : 1, options.merge(success_message: dc))
|
complete(dc ? 0 : 1, options.merge(
|
||||||
|
success_message: dc,
|
||||||
|
fail_message: "not found (checked #{cdc.join(", ")})"))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check for a package or configure program output.
|
# Check for a package or configure program output.
|
||||||
@ -375,6 +382,8 @@ module Rscons
|
|||||||
# A define to set (in CPPDEFINES) if the requested item is found.
|
# A define to set (in CPPDEFINES) if the requested item is found.
|
||||||
# @option options [String] :success_message
|
# @option options [String] :success_message
|
||||||
# Message to print on success (default "found").
|
# Message to print on success (default "found").
|
||||||
|
# @option options [String] :fail_message
|
||||||
|
# Message to print on failure (default "not found").
|
||||||
def complete(status, options)
|
def complete(status, options)
|
||||||
success_message = options[:success_message] || "found"
|
success_message = options[:success_message] || "found"
|
||||||
fail_message = options[:fail_message] || "not found"
|
fail_message = options[:fail_message] || "not found"
|
||||||
@ -398,7 +407,7 @@ module Rscons
|
|||||||
options[:on_fail].call
|
options[:on_fail].call
|
||||||
end
|
end
|
||||||
if should_fail
|
if should_fail
|
||||||
raise RsconsError.new("Configuration failed")
|
raise RsconsError.new("Configuration failed; log file written to #{@log_file_name}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -43,7 +43,11 @@ describe Rscons do
|
|||||||
Dir.chdir(@owd)
|
Dir.chdir(@owd)
|
||||||
if example.exception
|
if example.exception
|
||||||
@statics[:keep_test_run_dir] = true
|
@statics[:keep_test_run_dir] = true
|
||||||
puts "Leaving #{@build_test_run_dir} for inspection due to test failure"
|
message = "Leaving #{@build_test_run_dir} for inspection due to test failure"
|
||||||
|
if example.exception.backtrace.find {|e| e =~ %r{^(.*/#{File.basename(__FILE__)}:\d+)}}
|
||||||
|
message += " (#{$1})"
|
||||||
|
end
|
||||||
|
puts "\n#{message}"
|
||||||
else
|
else
|
||||||
rm_rf(@build_test_run_dir)
|
rm_rf(@build_test_run_dir)
|
||||||
end
|
end
|
||||||
@ -1933,9 +1937,9 @@ EOF
|
|||||||
create_exe "gcc", "exit 1"
|
create_exe "gcc", "exit 1"
|
||||||
create_exe "clang", "exit 1"
|
create_exe "clang", "exit 1"
|
||||||
result = run_rscons(args: %W[-f #{rsconscript} configure])
|
result = run_rscons(args: %W[-f #{rsconscript} configure])
|
||||||
expect(result.stderr).to match /Configuration failed/
|
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 C compiler\.\.\. not found/
|
expect(result.stdout).to match /Checking for C compiler\.\.\. not found \(checked gcc, clang\)/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1987,9 +1991,9 @@ EOF
|
|||||||
create_exe "g++", "exit 1"
|
create_exe "g++", "exit 1"
|
||||||
create_exe "clang++", "exit 1"
|
create_exe "clang++", "exit 1"
|
||||||
result = run_rscons(args: %W[-f #{rsconscript} configure])
|
result = run_rscons(args: %W[-f #{rsconscript} configure])
|
||||||
expect(result.stderr).to match /Configuration failed/
|
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 C\+\+ compiler\.\.\. not found/
|
expect(result.stdout).to match /Checking for C\+\+ compiler\.\.\. not found \(checked g\+\+, clang\+\+\)/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2043,9 +2047,9 @@ EOF
|
|||||||
create_exe "gdc", "exit 1"
|
create_exe "gdc", "exit 1"
|
||||||
create_exe "ldc2", "exit 1"
|
create_exe "ldc2", "exit 1"
|
||||||
result = run_rscons(args: %W[-f #{rsconscript} configure])
|
result = run_rscons(args: %W[-f #{rsconscript} configure])
|
||||||
expect(result.stderr).to match /Configuration failed/
|
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/
|
expect(result.stdout).to match /Checking for D compiler\.\.\. not found \(checked gdc, ldc2\)/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2514,7 +2518,7 @@ EOF
|
|||||||
expect(result.stdout).to match /Checking for C compiler\.\.\. not found/
|
expect(result.stdout).to match /Checking for C compiler\.\.\. not found/
|
||||||
expect(result.status).to_not eq 0
|
expect(result.status).to_not eq 0
|
||||||
expect(result.stderr).to_not match /from\s/
|
expect(result.stderr).to_not match /from\s/
|
||||||
expect(lines(result.stderr).last).to eq "Configuration failed"
|
expect(lines(result.stderr).last).to match /Configuration failed/
|
||||||
end
|
end
|
||||||
|
|
||||||
it "does not rebuild after building with auto-configuration" do
|
it "does not rebuild after building with auto-configuration" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user