Add build_dir script method - close #155

This commit is contained in:
Josh Holtrop 2022-02-20 18:13:59 -05:00
parent 8269a98d01
commit e9e3c6711f
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,3 @@
default do
touch "#{build_dir}/a.file"
end

View File

@ -10,6 +10,14 @@ module Rscons
@script = script @script = script
end end
# Get the Rscons build directory path.
#
# @return [String]
# Rscons build directory path.
def build_dir
Rscons.application.build_dir
end
# Return a list of paths matching the specified pattern(s). # Return a list of paths matching the specified pattern(s).
# #
# A pattern can contain a "/**" component to recurse through directories. # A pattern can contain a "/**" component to recurse through directories.

View File

@ -3187,4 +3187,22 @@ EOF
end end
end end
context "build_dir method" do
it "returns the top-level build directory path 1" do
test_dir "typical"
result = run_rscons(args: %w[-f build_dir.rb])
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(File.exist?("build/a.file")).to be_truthy
end
it "returns the top-level build directory path 2" do
test_dir "typical"
result = run_rscons(args: %w[-f build_dir.rb -b bb])
expect(result.stderr).to eq ""
expect(result.status).to eq 0
expect(File.exist?("bb/a.file")).to be_truthy
end
end
end end