From 9d14cc7eb0ffbf085e42535ee0f90d588d37cedc Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 26 Jan 2022 19:30:47 -0500 Subject: [PATCH] Cleaning up more test failures --- build_tests/typical/install.rb | 12 +++++++++--- lib/rscons/application.rb | 23 +++++++++++++++++++---- lib/rscons/cli.rb | 9 ++------- lib/rscons/environment.rb | 1 + lib/rscons/task.rb | 4 +--- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/build_tests/typical/install.rb b/build_tests/typical/install.rb index 628baee..67fd0f1 100644 --- a/build_tests/typical/install.rb +++ b/build_tests/typical/install.rb @@ -1,9 +1,13 @@ project_name "install_test" -default do - Environment.new do |env| - env["CPPPATH"] += glob("src/**") +Environment.new do |env| + env["CPPPATH"] += glob("src/**") + + task "build" do env.Program("^/program.exe", glob("src/**/*.c")) + end + + task "install", deps: "build" do env.InstallDirectory("${prefix}/bin") env.Install("${prefix}/bin", "^/program.exe") env.InstallDirectory("${prefix}/share") @@ -12,3 +16,5 @@ default do env.Install("${prefix}/src", "src") end end + +default(deps: "build") diff --git a/lib/rscons/application.rb b/lib/rscons/application.rb index 46f5483..5f13658 100644 --- a/lib/rscons/application.rb +++ b/lib/rscons/application.rb @@ -17,12 +17,17 @@ module Rscons # The number of threads to use when scheduling subprocesses. attr_accessor :n_threads + # @return [Script] + # Build script. + attr_reader :script + # @return [Boolean] # Whether to run verbosely. attr_accessor :verbose # Create Application instance. def initialize + @script = Script.new @build_dir = ENV["RSCONS_BUILD_DIR"] || "build" ENV.delete("RSCONS_BUILD_DIR") @n_threads = Util.determine_n_threads @@ -35,8 +40,6 @@ module Rscons # # @api private # - # @param script [Script] - # The script. # @param tasks [Array] # List of task(s) to execute. # @param options [Hash] @@ -44,8 +47,7 @@ module Rscons # # @return [Integer] # Process exit code (0 on success). - def run(script, tasks, options = {}) - @script = script + def run(tasks, options = {}) Cache.instance["failed_commands"] = [] begin tasks.each do |task| @@ -123,6 +125,19 @@ module Rscons cache.clear end + # Check if the project needs to be configured. + # + # @api private + # + # @return [void] + def check_configure + unless Cache.instance["configuration_data"]["configured"] + if @script.autoconf + configure + end + end + end + # Configure the project. # # @api private diff --git a/lib/rscons/cli.rb b/lib/rscons/cli.rb index 8604d29..00198a6 100644 --- a/lib/rscons/cli.rb +++ b/lib/rscons/cli.rb @@ -8,11 +8,6 @@ module Rscons # Default files to look for to execute if none specified. DEFAULT_RSCONSCRIPTS = %w[Rsconscript Rsconscript.rb] - # Create an instance of the rscons command-line interpreter. - def initialize - @script = Script.new - end - # Run the Rscons CLI. # # @param argv [Array] @@ -125,7 +120,7 @@ module Rscons # Load the build script. if rsconscript - @script.load(rsconscript) + Rscons.application.script.load(rsconscript) end # Do help after loading the build script (if found) so that any @@ -155,7 +150,7 @@ module Rscons # Finally, with the script fully loaded and command-line parsed, run # the application to execute all required tasks. - Rscons.application.run(@script, tasks) + Rscons.application.run(tasks) end def usage diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 560a2e4..3c1dcb4 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -76,6 +76,7 @@ module Rscons # If a block is given, the Environment object is yielded to the block and # when the block returns, the {#process} method is automatically called. def initialize(options = {}) + Rscons.application.check_configure unless Cache.instance["configuration_data"]["configured"] raise "Project must be configured before creating an Environment" end diff --git a/lib/rscons/task.rb b/lib/rscons/task.rb index 09f33ec..aa70f0a 100644 --- a/lib/rscons/task.rb +++ b/lib/rscons/task.rb @@ -137,9 +137,7 @@ module Rscons def execute @executed = true if @autoconf - unless Cache.instance["configuration_data"]["configured"] - Task["configure"].check_execute - end + Rscons.application.check_configure end @deps.each do |dep| Task[dep].check_execute