Remove Rscons.application.vars

This commit is contained in:
Josh Holtrop 2022-01-25 22:32:26 -05:00
parent b1b94595f6
commit dbd764749b
5 changed files with 16 additions and 31 deletions

View File

@ -4,17 +4,17 @@ class DebugBuilder < Rscons::Builder
finalize_command finalize_command
else else
@command = %W[gcc -c -o #{@target} #{@sources.first}] @command = %W[gcc -c -o #{@target} #{@sources.first}]
if Rscons.vars["command_change"] if ENV["command_change"] == "command_change"
@command += %w[-Wall] @command += %w[-Wall]
end end
if Rscons.vars["new_dep"] if ENV["test"] == "new_dep"
@sources += ["extra"] @sources += ["extra"]
end end
if Rscons.vars["strict_deps1"] if ENV["test"] == "strict_deps1"
@sources += ["extra"] @sources += ["extra"]
strict_deps = true strict_deps = true
end end
if Rscons.vars["strict_deps2"] if ENV["test"] == "strict_deps2"
@sources = ["extra"] + @sources @sources = ["extra"] + @sources
strict_deps = true strict_deps = true
end end
@ -30,7 +30,7 @@ end
default do default do
Environment.new do |env| Environment.new do |env|
env.add_builder(DebugBuilder) env.add_builder(DebugBuilder)
if Rscons.vars["new_user_dep"] if ENV["test"] == "new_user_dep"
env.depends("foo.o", "new_dep") env.depends("foo.o", "new_dep")
end end
env.DebugBuilder("foo.o", "simple.c") env.DebugBuilder("foo.o", "simple.c")

View File

@ -50,13 +50,6 @@ module Rscons
@application ||= Application.new @application ||= Application.new
end end
# Access any variables set on the rscons command-line.
#
# @return [VarSet]
def vars(*args)
application.vars(*args)
end
# Return whether the given target is a phony target. # Return whether the given target is a phony target.
# #
# @param target [Symbol, String] Target name. # @param target [Symbol, String] Target name.

View File

@ -21,16 +21,11 @@ module Rscons
# Whether to run verbosely. # Whether to run verbosely.
attr_accessor :verbose attr_accessor :verbose
# @return [VarSet]
# Access any variables set on the rscons command-line.
attr_reader :vars
# Create Application instance. # Create Application instance.
def initialize def initialize
@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
@vars = VarSet.new
@build_step = 0 @build_step = 0
end end

View File

@ -111,14 +111,6 @@ module Rscons
end.order!(argv) end.order!(argv)
# Set vars before loading the build script so the build script can
# refer to them.
argv.each do |arg|
if arg =~ /^([^=]+)=(.*)$/
Rscons.application.vars[$1] = $2
end
end
# Find the build script. # Find the build script.
if rsconscript if rsconscript
unless File.exists?(rsconscript) unless File.exists?(rsconscript)

View File

@ -1544,16 +1544,19 @@ EOF
test_dir("simple") test_dir("simple")
result = run_rscons(args: %w[-f cache_debugging.rb]) result = run_rscons(args: %w[-f cache_debugging.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
result = run_rscons(args: %w[-f cache_debugging.rb build command_change=yes]) passenv["test"] = "command_change"
result = run_rscons(args: %w[-f cache_debugging.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(result.stdout).to match /Target foo\.o needs rebuilding because the command used to build it has changed/ expect(result.stdout).to match /Target foo\.o needs rebuilding because the command used to build it has changed/
end end
it "prints a message when strict_deps is in use and the set of dependencies does not match" do it "prints a message when strict_deps is in use and the set of dependencies does not match" do
test_dir("simple") test_dir("simple")
result = run_rscons(args: %w[-f cache_debugging.rb build strict_deps1=yes]) passenv["test"] = "strict_deps1"
result = run_rscons(args: %w[-f cache_debugging.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
result = run_rscons(args: %w[-f cache_debugging.rb build strict_deps2=yes]) passenv["test"] = "strict_deps2"
result = run_rscons(args: %w[-f cache_debugging.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(result.stdout).to match /Target foo\.o needs rebuilding because the :strict_deps option is given and the set of dependencies does not match the previous set of dependencies/ expect(result.stdout).to match /Target foo\.o needs rebuilding because the :strict_deps option is given and the set of dependencies does not match the previous set of dependencies/
end end
@ -1562,7 +1565,8 @@ EOF
test_dir("simple") test_dir("simple")
result = run_rscons(args: %w[-f cache_debugging.rb]) result = run_rscons(args: %w[-f cache_debugging.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
result = run_rscons(args: %w[-f cache_debugging.rb build new_dep=yes]) passenv["test"] = "new_dep"
result = run_rscons(args: %w[-f cache_debugging.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(result.stdout).to match /Target foo\.o needs rebuilding because there are new dependencies/ expect(result.stdout).to match /Target foo\.o needs rebuilding because there are new dependencies/
end end
@ -1571,7 +1575,8 @@ EOF
test_dir("simple") test_dir("simple")
result = run_rscons(args: %w[-f cache_debugging.rb]) result = run_rscons(args: %w[-f cache_debugging.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
result = run_rscons(args: %w[-f cache_debugging.rb build new_user_dep=yes]) passenv["test"] = "new_user_dep"
result = run_rscons(args: %w[-f cache_debugging.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(result.stdout).to match /Target foo\.o needs rebuilding because the set of user-specified dependency files has changed/ expect(result.stdout).to match /Target foo\.o needs rebuilding because the set of user-specified dependency files has changed/
end end
@ -2331,7 +2336,7 @@ EOF
it "does everything" do it "does everything" do
test_dir "configure" test_dir "configure"
create_exe "pkg-config", "echo '-DMYPACKAGE'" create_exe "pkg-config", "echo '-DMYPACKAGE'"
result = run_rscons(args: %w[-f everything.rb configure --build=bb --prefix=/my/prefix]) result = run_rscons(args: %w[-f everything.rb --build=bb configure --prefix=/my/prefix])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(result.status).to eq 0 expect(result.status).to eq 0
expect(result.stdout).to match /Configuring configure test\.\.\./ expect(result.stdout).to match /Configuring configure test\.\.\./