Do not configure for clean tasks when not yet configured - close #158

This commit is contained in:
Josh Holtrop 2022-03-13 22:15:55 -04:00
parent 1bf1c30242
commit b3df37e9ea
3 changed files with 40 additions and 3 deletions

View File

@ -81,8 +81,10 @@ module Rscons
end
end
@script = Script.new
if should_load_script
@script.load(rsconscript)
enable_variants
end
if show_tasks
show_script_tasks(all_tasks)
return 0
@ -170,8 +172,8 @@ module Rscons
def distclean
cache = Cache.instance
clean
FileUtils.rm_rf(@build_dir)
cache.clear
FileUtils.rm_rf(@build_dir)
end
# Check if the project needs to be configured.
@ -394,6 +396,13 @@ module Rscons
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

View File

@ -101,6 +101,7 @@ module Rscons
#
# @return [void]
def write
return unless Dir.exist?(File.dirname(cache_file))
@cache["version"] = VERSION
File.open(cache_file, "w") do |fh|
fh.puts(JSON.dump(@cache))

View File

@ -1854,6 +1854,33 @@ EOF
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
test_dir "configure"