Compare commits

..
8 Commits
10 changed files with 125 additions and 22 deletions

No files matched your search

+8
View File
@@ -1,3 +1,11 @@
## v3.0.1
### Fixes
- #156 - Avoid running configure operation twice
- #157 - Load configure task arguments before early configure operations
- #158 - Do not configure for clean tasks when not yet configured
## v3.0.0 ## v3.0.0
- #136 - Move rsconscache into build directory - #136 - Move rsconscache into build directory
+1 -1
View File
@@ -35,7 +35,7 @@ task :dspec, [:example_string] => :build_dist do |task, args|
FileUtils.mkdir_p("test") FileUtils.mkdir_p("test")
FileUtils.cp("dist/rscons", "test/rscons.rb") FileUtils.cp("dist/rscons", "test/rscons.rb")
ENV["dist_specs"] = "1" ENV["dist_specs"] = "1"
Rake::Task["spec"].execute(args.example_string) Rake::Task["spec"].execute(args)
ENV.delete("dist_specs") ENV.delete("dist_specs")
FileUtils.rm_f(Dir.glob(".rscons-*")) FileUtils.rm_f(Dir.glob(".rscons-*"))
end end
@@ -0,0 +1,6 @@
configure do
check_c_compiler
end
env do |env|
puts "Prefix is #{Task["configure"]["prefix"]}"
end
+7
View File
@@ -0,0 +1,7 @@
env do |env|
env.Program('simple.exe', Dir['*.c'])
end
clean do
puts "custom clean action"
end
+3
View File
@@ -446,6 +446,9 @@ end
See ${#Configuring the Project} for more details on how to make use of the See ${#Configuring the Project} for more details on how to make use of the
configuration functionality that Rscons provides. configuration functionality that Rscons provides.
Configure blocks must be defined in the Rsconscript file before any
environments are created.
####> Default Task ####> Default Task
The `default` task is special in that Rscons will execute it if no other task The `default` task is special in that Rscons will execute it if no other task
+35 -19
View File
@@ -73,6 +73,7 @@ module Rscons
# Process exit code (0 on success). # Process exit code (0 on success).
def run(rsconscript, tasks_and_params, show_tasks, all_tasks, enabled_variants) def run(rsconscript, tasks_and_params, show_tasks, all_tasks, enabled_variants)
Cache.instance["failed_commands"] = [] Cache.instance["failed_commands"] = []
@tasks_and_params = tasks_and_params
@enabled_variants = enabled_variants @enabled_variants = enabled_variants
if enabled_variants == "" && !tasks_and_params.include?("configure") if enabled_variants == "" && !tasks_and_params.include?("configure")
if cache_enabled_variants = Cache.instance["configuration_data"]["enabled_variants"] if cache_enabled_variants = Cache.instance["configuration_data"]["enabled_variants"]
@@ -80,13 +81,15 @@ module Rscons
end end
end end
@script = Script.new @script = Script.new
@script.load(rsconscript) if should_load_script
enable_variants @script.load(rsconscript)
enable_variants
end
if show_tasks if show_tasks
show_script_tasks(all_tasks) show_script_tasks(all_tasks)
return 0 return 0
end end
apply_task_params(tasks_and_params) apply_task_params(false)
@task_execution_phase = true @task_execution_phase = true
if tasks_and_params.empty? if tasks_and_params.empty?
check_process_environments check_process_environments
@@ -169,8 +172,8 @@ module Rscons
def distclean def distclean
cache = Cache.instance cache = Cache.instance
clean clean
FileUtils.rm_rf(@build_dir)
cache.clear cache.clear
FileUtils.rm_rf(@build_dir)
end end
# Check if the project needs to be configured. # Check if the project needs to be configured.
@@ -179,6 +182,7 @@ module Rscons
# #
# @return [void] # @return [void]
def check_configure def check_configure
apply_task_params(true)
enable_variants enable_variants
unless Cache.instance["configuration_data"]["configured"] unless Cache.instance["configuration_data"]["configured"]
if @script.autoconf if @script.autoconf
@@ -207,15 +211,18 @@ module Rscons
# #
# @return [void] # @return [void]
def configure def configure
co = ConfigureOp.new(@script) unless @_configured
begin @_configured = true
@script.configure(co) co = ConfigureOp.new(@script)
rescue RsconsError => e begin
co.close(false) @script.configure(co)
raise e rescue RsconsError => e
co.close(false)
raise e
end
Cache.instance["configuration_data"]["enabled_variants"] = @enabled_variants
co.close(true)
end end
Cache.instance["configuration_data"]["enabled_variants"] = @enabled_variants
co.close(true)
end end
# Remove installed files. # Remove installed files.
@@ -375,18 +382,27 @@ module Rscons
end end
end end
def apply_task_params(tasks_and_params) def apply_task_params(only_configure)
tasks_and_params.each do |task_name, task_params| @tasks_and_params.each do |task_name, task_params|
task_params.each do |param_name, param_value| unless only_configure && task_name != "configure"
if param = Task[task_name].params[param_name] task_params.each do |param_name, param_value|
Task[task_name].set_param_value(param_name, param_value) if param = Task[task_name].params[param_name]
else Task[task_name].set_param_value(param_name, param_value)
raise RsconsError.new("Unknown parameter #{param_name.inspect} for task #{task_name}") else
raise RsconsError.new("Unknown parameter #{param_name.inspect} for task #{task_name}")
end
end end
end end
end end
end end
def should_load_script
return true if @tasks_and_params.empty?
return true if Cache.instance["configuration_data"]["configured"]
return false if (@tasks_and_params.keys - %w[distclean clean uninstall]).empty?
true
end
end end
end end
+1
View File
@@ -101,6 +101,7 @@ module Rscons
# #
# @return [void] # @return [void]
def write def write
return unless Dir.exist?(File.dirname(cache_file))
@cache["version"] = VERSION @cache["version"] = VERSION
File.open(cache_file, "w") do |fh| File.open(cache_file, "w") do |fh|
fh.puts(JSON.dump(@cache)) fh.puts(JSON.dump(@cache))
+1 -1
View File
@@ -1,4 +1,4 @@
module Rscons module Rscons
# Project version. # Project version.
VERSION = "3.0.0" VERSION = "3.0.1"
end end
+7 -1
View File
@@ -60,7 +60,13 @@ combined_file.each do |line|
end end
end end
license = File.read("LICENSE.txt").gsub(/^/, "# ") license = File.read("LICENSE.txt").gsub(/^(.*?)$/) do |line|
if line.size > 0
"# #{line}"
else
"#"
end
end
require "zlib" require "zlib"
require "base64" require "base64"
+56
View File
@@ -372,6 +372,17 @@ EOF
expect(File.exists?('simple.c')).to be_truthy expect(File.exists?('simple.c')).to be_truthy
end end
it "executes custom clean action blocks" do
test_dir("simple")
result = run_rscons(args: %w[-f clean.rb])
expect(result.stderr).to eq ""
expect(File.exists?("build/e.1/simple.c.o")).to be_truthy
result = run_rscons(args: %w[-f clean.rb clean])
expect(result.stderr).to eq ""
expect(result.stdout).to match %r{custom clean action}
expect(File.exists?("build/e.1/simple.c.o")).to be_falsey
end
it "does not process environments" do it "does not process environments" do
test_dir("simple") test_dir("simple")
result = run_rscons(args: %w[clean]) result = run_rscons(args: %w[clean])
@@ -1825,6 +1836,51 @@ EOF
expect(result.status).to_not eq 0 expect(result.status).to_not eq 0
end end
it "only runs the configure operation once" do
test_dir "configure"
result = run_rscons(args: %w[-f configure_with_top_level_env.rb configure])
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to_not match %r{Configuring project.*Configuring project}m
end
it "loads configure parameters before invoking configure" do
test_dir "configure"
result = run_rscons(args: %w[-f configure_with_top_level_env.rb configure --prefix=/yodabob])
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to match "Prefix is /yodabob"
end
it "does not configure for distclean operation" do
test_dir "configure"
result = run_rscons(args: %w[-f configure_with_top_level_env.rb distclean])
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to_not match %r{Configuring project}
end
it "does not configure for clean operation" do
test_dir "configure"
result = run_rscons(args: %w[-f configure_with_top_level_env.rb clean])
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to_not match %r{Configuring project}
end
it "does not configure for uninstall operation" do
test_dir "configure"
result = run_rscons(args: %w[-f configure_with_top_level_env.rb uninstall])
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(result.stdout).to_not match %r{Configuring project}
end
it "automatically runs the configure task if the project is not yet configured in the given build directory" do it "automatically runs the configure task if the project is not yet configured in the given build directory" do
test_dir "configure" test_dir "configure"