From 19dbab3426a02a5add2c4a9dd82856fe3457b079 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 28 Nov 2021 22:36:24 -0500 Subject: [PATCH] Run subsidiary rscons binary from rscons() method if found - close #129 --- lib/rscons/script.rb | 10 +++++++--- spec/build_tests_spec.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lib/rscons/script.rb b/lib/rscons/script.rb index 6077b75..a254e68 100644 --- a/lib/rscons/script.rb +++ b/lib/rscons/script.rb @@ -55,15 +55,19 @@ module Rscons # @param args[Array] # Arguments to pass to rscons subprocess. def rscons(path, *args) - me = File.expand_path($0) + rscons_path = File.expand_path($0) path = File.expand_path(path) if File.directory?(path) - command = [me, *args] + command = [*args] dir = path else - command = [me, "-f", path, *args] + command = ["-f", path, *args] dir = File.dirname(path) end + if File.exist?("#{dir}/rscons") + rscons_path = "#{dir}/rscons" + end + command = [rscons_path] + command print_dir = dir != "." && dir != File.expand_path(Dir.pwd) if ENV["specs"] and not ENV["dist_specs"] # specs command = ["ruby", $LOAD_PATH.map {|p| ["-I", p]}, command].flatten # specs diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 650bd94..092e2e7 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -2694,6 +2694,32 @@ EOF end end + context "with a rscons binary in the subsidiary script directory" do + it "executes rscons from the subsidiary script directory" do + test_dir "subsidiary" + + File.binwrite("sub/rscons", <