Cleaning up more test failures

This commit is contained in:
Josh Holtrop 2022-01-26 19:30:47 -05:00
parent d255c7f46e
commit 9d14cc7eb0
5 changed files with 32 additions and 17 deletions

View File

@ -1,9 +1,13 @@
project_name "install_test" project_name "install_test"
default do Environment.new do |env|
Environment.new do |env| env["CPPPATH"] += glob("src/**")
env["CPPPATH"] += glob("src/**")
task "build" do
env.Program("^/program.exe", glob("src/**/*.c")) env.Program("^/program.exe", glob("src/**/*.c"))
end
task "install", deps: "build" do
env.InstallDirectory("${prefix}/bin") env.InstallDirectory("${prefix}/bin")
env.Install("${prefix}/bin", "^/program.exe") env.Install("${prefix}/bin", "^/program.exe")
env.InstallDirectory("${prefix}/share") env.InstallDirectory("${prefix}/share")
@ -12,3 +16,5 @@ default do
env.Install("${prefix}/src", "src") env.Install("${prefix}/src", "src")
end end
end end
default(deps: "build")

View File

@ -17,12 +17,17 @@ module Rscons
# The number of threads to use when scheduling subprocesses. # The number of threads to use when scheduling subprocesses.
attr_accessor :n_threads attr_accessor :n_threads
# @return [Script]
# Build script.
attr_reader :script
# @return [Boolean] # @return [Boolean]
# Whether to run verbosely. # Whether to run verbosely.
attr_accessor :verbose attr_accessor :verbose
# Create Application instance. # Create Application instance.
def initialize def initialize
@script = Script.new
@build_dir = ENV["RSCONS_BUILD_DIR"] || "build" @build_dir = ENV["RSCONS_BUILD_DIR"] || "build"
ENV.delete("RSCONS_BUILD_DIR") ENV.delete("RSCONS_BUILD_DIR")
@n_threads = Util.determine_n_threads @n_threads = Util.determine_n_threads
@ -35,8 +40,6 @@ module Rscons
# #
# @api private # @api private
# #
# @param script [Script]
# The script.
# @param tasks [Array<String>] # @param tasks [Array<String>]
# List of task(s) to execute. # List of task(s) to execute.
# @param options [Hash] # @param options [Hash]
@ -44,8 +47,7 @@ module Rscons
# #
# @return [Integer] # @return [Integer]
# Process exit code (0 on success). # Process exit code (0 on success).
def run(script, tasks, options = {}) def run(tasks, options = {})
@script = script
Cache.instance["failed_commands"] = [] Cache.instance["failed_commands"] = []
begin begin
tasks.each do |task| tasks.each do |task|
@ -123,6 +125,19 @@ module Rscons
cache.clear cache.clear
end 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. # Configure the project.
# #
# @api private # @api private

View File

@ -8,11 +8,6 @@ module Rscons
# Default files to look for to execute if none specified. # Default files to look for to execute if none specified.
DEFAULT_RSCONSCRIPTS = %w[Rsconscript Rsconscript.rb] 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. # Run the Rscons CLI.
# #
# @param argv [Array] # @param argv [Array]
@ -125,7 +120,7 @@ module Rscons
# Load the build script. # Load the build script.
if rsconscript if rsconscript
@script.load(rsconscript) Rscons.application.script.load(rsconscript)
end end
# Do help after loading the build script (if found) so that any # 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 # Finally, with the script fully loaded and command-line parsed, run
# the application to execute all required tasks. # the application to execute all required tasks.
Rscons.application.run(@script, tasks) Rscons.application.run(tasks)
end end
def usage def usage

View File

@ -76,6 +76,7 @@ module Rscons
# If a block is given, the Environment object is yielded to the block and # If a block is given, the Environment object is yielded to the block and
# when the block returns, the {#process} method is automatically called. # when the block returns, the {#process} method is automatically called.
def initialize(options = {}) def initialize(options = {})
Rscons.application.check_configure
unless Cache.instance["configuration_data"]["configured"] unless Cache.instance["configuration_data"]["configured"]
raise "Project must be configured before creating an Environment" raise "Project must be configured before creating an Environment"
end end

View File

@ -137,9 +137,7 @@ module Rscons
def execute def execute
@executed = true @executed = true
if @autoconf if @autoconf
unless Cache.instance["configuration_data"]["configured"] Rscons.application.check_configure
Task["configure"].check_execute
end
end end
@deps.each do |dep| @deps.each do |dep|
Task[dep].check_execute Task[dep].check_execute