diff --git a/build_tests/configure/configure_with_top_level_env.rb b/build_tests/configure/configure_with_top_level_env.rb new file mode 100644 index 0000000..3afe4bd --- /dev/null +++ b/build_tests/configure/configure_with_top_level_env.rb @@ -0,0 +1,5 @@ +configure do + check_c_compiler +end +env do |env| +end diff --git a/lib/rscons/application.rb b/lib/rscons/application.rb index f6d0450..7de5c6a 100644 --- a/lib/rscons/application.rb +++ b/lib/rscons/application.rb @@ -207,15 +207,18 @@ module Rscons # # @return [void] def configure - co = ConfigureOp.new(@script) - begin - @script.configure(co) - rescue RsconsError => e - co.close(false) - raise e + unless @_configured + @_configured = true + co = ConfigureOp.new(@script) + begin + @script.configure(co) + rescue RsconsError => e + co.close(false) + raise e + end + Cache.instance["configuration_data"]["enabled_variants"] = @enabled_variants + co.close(true) end - Cache.instance["configuration_data"]["enabled_variants"] = @enabled_variants - co.close(true) end # Remove installed files. diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index df2c15a..2f40f96 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -1836,6 +1836,15 @@ EOF expect(result.status).to_not eq 0 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 "automatically runs the configure task if the project is not yet configured in the given build directory" do test_dir "configure"