Process environments created during task execution phase
This commit is contained in:
parent
29ca9b3f13
commit
bb4657e465
5
build_tests/simple/env_in_task.rb
Normal file
5
build_tests/simple/env_in_task.rb
Normal file
@ -0,0 +1,5 @@
|
||||
default do
|
||||
env do |env|
|
||||
env.Program('simple.exe', Dir['*.c'])
|
||||
end
|
||||
end
|
@ -42,6 +42,16 @@ module Rscons
|
||||
@variant_groups = []
|
||||
end
|
||||
|
||||
# Return if Rscons is in the task execution phase.
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
# @return [Boolean]
|
||||
# If Rscons is in the task execution phase.
|
||||
def task_execution_phase?
|
||||
@task_execution_phase
|
||||
end
|
||||
|
||||
# Run the application.
|
||||
#
|
||||
# Execute user-specified tasks.
|
||||
@ -77,6 +87,7 @@ module Rscons
|
||||
return 0
|
||||
end
|
||||
apply_task_params(tasks_and_params)
|
||||
@task_execution_phase = true
|
||||
if tasks_and_params.empty?
|
||||
check_process_environments
|
||||
if Task.tasks["default"]
|
||||
|
@ -130,13 +130,21 @@ module Rscons
|
||||
#
|
||||
# If a block is given it is immediately executed and passed the newly
|
||||
# created Environment object as an argument.
|
||||
# If the Environment is created in task context, the +process+ method is
|
||||
# immediately called.
|
||||
# Otherwise, the Environment is not processed until the task execution
|
||||
# phase.
|
||||
#
|
||||
# @yield [env]
|
||||
# @yieldparam env [Environment]
|
||||
# The created environment.
|
||||
def env(*args, &block)
|
||||
Rscons.application.check_configure
|
||||
Environment.new(*args, &block)
|
||||
e = Environment.new(*args, &block)
|
||||
if Rscons.application.task_execution_phase?
|
||||
e.process
|
||||
end
|
||||
e
|
||||
end
|
||||
|
||||
# Construct a task parameter.
|
||||
|
@ -195,6 +195,14 @@ EOF
|
||||
expect(nr(`./simple.exe`)).to eq "This is a simple C program\n"
|
||||
end
|
||||
|
||||
it "processes the environment when created within a task" do
|
||||
test_dir("simple")
|
||||
result = run_rscons(args: %w[-f env_in_task.rb])
|
||||
expect(result.stderr).to eq ""
|
||||
expect(File.exists?("build/e.1/simple.c.o")).to be_truthy
|
||||
expect(nr(`./simple.exe`)).to eq "This is a simple C program\n"
|
||||
end
|
||||
|
||||
it "uses the build directory specified with -b" do
|
||||
test_dir("simple")
|
||||
result = run_rscons(args: %w[-b b])
|
||||
|
Loading…
x
Reference in New Issue
Block a user