Only configure if necessary - close #131
This commit is contained in:
parent
5c28e557bd
commit
44f61da571
3
build_tests/configure/no_configure_output.rb
Normal file
3
build_tests/configure/no_configure_output.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
default do
|
||||||
|
puts "default"
|
||||||
|
end
|
@ -1,5 +1,8 @@
|
|||||||
project_name "install_test"
|
project_name "install_test"
|
||||||
|
|
||||||
|
configure do
|
||||||
|
end
|
||||||
|
|
||||||
env do |env|
|
env do |env|
|
||||||
env["CPPPATH"] += glob("src/**")
|
env["CPPPATH"] += glob("src/**")
|
||||||
|
|
||||||
|
@ -49,7 +49,11 @@ module Rscons
|
|||||||
# @return [Application]
|
# @return [Application]
|
||||||
# The Application singleton.
|
# The Application singleton.
|
||||||
def application
|
def application
|
||||||
@application ||= Application.new
|
unless @application
|
||||||
|
@application = Application.new
|
||||||
|
@application._initialize
|
||||||
|
end
|
||||||
|
@application
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return whether the given target is a phony target.
|
# Return whether the given target is a phony target.
|
||||||
|
@ -21,13 +21,18 @@ module Rscons
|
|||||||
# Build script.
|
# Build script.
|
||||||
attr_reader :script
|
attr_reader :script
|
||||||
|
|
||||||
|
# @return [Boolean]
|
||||||
|
# Whether to configure silently.
|
||||||
|
attr_accessor :silent_configure
|
||||||
|
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
# Whether to run verbosely.
|
# Whether to run verbosely.
|
||||||
attr_accessor :verbose
|
attr_accessor :verbose
|
||||||
|
|
||||||
# Create Application instance.
|
# Create Application instance.
|
||||||
def initialize
|
def _initialize
|
||||||
@script = Script.new
|
@script = Script.new
|
||||||
|
@silent_configure = true
|
||||||
@build_dir = ENV["RSCONS_BUILD_DIR"] || "build"
|
@build_dir = ENV["RSCONS_BUILD_DIR"] || "build"
|
||||||
ENV.delete("RSCONS_BUILD_DIR")
|
ENV.delete("RSCONS_BUILD_DIR")
|
||||||
@n_threads = Util.determine_n_threads
|
@n_threads = Util.determine_n_threads
|
||||||
|
@ -16,14 +16,18 @@ module Rscons
|
|||||||
cache = Cache.instance
|
cache = Cache.instance
|
||||||
cache["failed_commands"] = []
|
cache["failed_commands"] = []
|
||||||
cache["configuration_data"] = {}
|
cache["configuration_data"] = {}
|
||||||
|
unless Rscons.application.silent_configure
|
||||||
if project_name = script.project_name
|
if project_name = script.project_name
|
||||||
Ansi.write($stdout, "Configuring ", :cyan, project_name, :reset, "...\n")
|
Ansi.write($stdout, "Configuring ", :cyan, project_name, :reset, "...\n")
|
||||||
else
|
else
|
||||||
$stdout.puts "Configuring project..."
|
$stdout.puts "Configuring project..."
|
||||||
end
|
end
|
||||||
|
end
|
||||||
vars = {}
|
vars = {}
|
||||||
Task["configure"].params.each do |name, param|
|
Task["configure"].params.each do |name, param|
|
||||||
|
unless Rscons.application.silent_configure
|
||||||
Ansi.write($stdout, "Setting #{name}... ", :green, param.value, :reset, "\n")
|
Ansi.write($stdout, "Setting #{name}... ", :green, param.value, :reset, "\n")
|
||||||
|
end
|
||||||
vars[name] = param.value
|
vars[name] = param.value
|
||||||
end
|
end
|
||||||
store_merge(vars)
|
store_merge(vars)
|
||||||
|
@ -389,6 +389,7 @@ module Rscons
|
|||||||
#
|
#
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def load(path)
|
def load(path)
|
||||||
|
Rscons.application.silent_configure = true
|
||||||
script_contents = File.read(path, mode: "rb")
|
script_contents = File.read(path, mode: "rb")
|
||||||
TopLevelDsl.new(self).instance_eval(script_contents, path, 1)
|
TopLevelDsl.new(self).instance_eval(script_contents, path, 1)
|
||||||
end
|
end
|
||||||
|
@ -155,6 +155,7 @@ module Rscons
|
|||||||
Task[dependency].check_execute
|
Task[dependency].check_execute
|
||||||
end
|
end
|
||||||
if @name == "configure"
|
if @name == "configure"
|
||||||
|
Rscons.application.silent_configure = false
|
||||||
Rscons.application.configure
|
Rscons.application.configure
|
||||||
else
|
else
|
||||||
@actions.each do |action|
|
@actions.each do |action|
|
||||||
|
@ -192,7 +192,15 @@ module Rscons
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Create or modify a task.
|
# Create or modify a task.
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
# @return [Task]
|
||||||
|
# Created task.
|
||||||
def task(name, options = {}, &block)
|
def task(name, options = {}, &block)
|
||||||
|
if name == "configure"
|
||||||
|
Rscons.application.silent_configure = false
|
||||||
|
end
|
||||||
if task = Task.tasks[name]
|
if task = Task.tasks[name]
|
||||||
task.modify(options, &block)
|
task.modify(options, &block)
|
||||||
else
|
else
|
||||||
|
@ -1789,6 +1789,14 @@ EOF
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "configure operation" do
|
context "configure operation" do
|
||||||
|
it "does not print configuring messages when no configure block and configure task not called" do
|
||||||
|
test_dir "configure"
|
||||||
|
result = run_rscons(args: %w[-f no_configure_output.rb])
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.status).to eq 0
|
||||||
|
expect(result.stdout.chomp).to eq "default"
|
||||||
|
end
|
||||||
|
|
||||||
it "raises a method not found error for configure methods called outside a configure block" do
|
it "raises a method not found error for configure methods called outside a configure block" do
|
||||||
test_dir "configure"
|
test_dir "configure"
|
||||||
result = run_rscons(args: %w[-f scope.rb])
|
result = run_rscons(args: %w[-f scope.rb])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user