env.depends() does not work with build-root-relative "^/" paths - close #121
This commit is contained in:
parent
d1a35501ef
commit
7c8becc3f9
18
build_tests/simple/user_dependencies_carat.rb
Normal file
18
build_tests/simple/user_dependencies_carat.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
class FileBuilder < Builder
|
||||||
|
def self.name
|
||||||
|
"File"
|
||||||
|
end
|
||||||
|
def run(options)
|
||||||
|
FileUtils.mkdir_p(File.dirname(@target))
|
||||||
|
File.binwrite(@target, ENV["file_contents"])
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
build do
|
||||||
|
Environment.new do |env|
|
||||||
|
env.add_builder(FileBuilder)
|
||||||
|
env.File("^/file.txt")
|
||||||
|
program = env.Program("^/simple.exe", Dir["*.c"])
|
||||||
|
env.depends("^/simple.exe", "^/file.txt")
|
||||||
|
end
|
||||||
|
end
|
@ -346,12 +346,12 @@ module Rscons
|
|||||||
if target.is_a?(Builder)
|
if target.is_a?(Builder)
|
||||||
target = target.target
|
target = target.target
|
||||||
end
|
end
|
||||||
target = expand_varref(target.to_s)
|
target = expand_path(expand_varref(target.to_s))
|
||||||
user_deps = user_deps.map do |ud|
|
user_deps = user_deps.map do |ud|
|
||||||
if ud.is_a?(Builder)
|
if ud.is_a?(Builder)
|
||||||
ud = ud.target
|
ud = ud.target
|
||||||
end
|
end
|
||||||
expand_varref(ud)
|
expand_path(expand_varref(ud))
|
||||||
end
|
end
|
||||||
@user_deps[target] ||= []
|
@user_deps[target] ||= []
|
||||||
@user_deps[target] = (@user_deps[target] + user_deps).uniq
|
@user_deps[target] = (@user_deps[target] + user_deps).uniq
|
||||||
|
@ -55,6 +55,8 @@ describe Rscons do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:passenv) {{}}
|
||||||
|
|
||||||
def test_dir(build_test_directory)
|
def test_dir(build_test_directory)
|
||||||
Dir.chdir(@owd)
|
Dir.chdir(@owd)
|
||||||
rm_rf(@build_test_run_dir)
|
rm_rf(@build_test_run_dir)
|
||||||
@ -147,6 +149,7 @@ EOF
|
|||||||
stdout, stderr, status = nil, nil, nil
|
stdout, stderr, status = nil, nil, nil
|
||||||
Bundler.with_unbundled_env do
|
Bundler.with_unbundled_env do
|
||||||
env = ENV.to_h
|
env = ENV.to_h
|
||||||
|
env.merge!(passenv)
|
||||||
path = ["#{@build_test_run_dir}/_bin", "#{env["PATH"]}"]
|
path = ["#{@build_test_run_dir}/_bin", "#{env["PATH"]}"]
|
||||||
if options[:path]
|
if options[:path]
|
||||||
path = Array(options[:path]) + path
|
path = Array(options[:path]) + path
|
||||||
@ -601,6 +604,27 @@ EOF
|
|||||||
expect(result.stdout).to eq ""
|
expect(result.stdout).to eq ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "rebuilds when user-specified dependencies using ^ change" do
|
||||||
|
test_dir("simple")
|
||||||
|
|
||||||
|
passenv["file_contents"] = "1"
|
||||||
|
result = run_rscons(rsconscript: "user_dependencies_carat.rb")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
verify_lines(lines(result.stdout), [
|
||||||
|
%r{Compiling simple.c},
|
||||||
|
%r{Linking .*simple.exe},
|
||||||
|
])
|
||||||
|
|
||||||
|
passenv["file_contents"] = "2"
|
||||||
|
result = run_rscons(rsconscript: "user_dependencies_carat.rb")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
verify_lines(lines(result.stdout), [%r{Linking .*simple.exe}])
|
||||||
|
|
||||||
|
result = run_rscons(rsconscript: "user_dependencies_carat.rb")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.stdout).to eq ""
|
||||||
|
end
|
||||||
|
|
||||||
unless RUBY_PLATFORM =~ /mingw|msys/
|
unless RUBY_PLATFORM =~ /mingw|msys/
|
||||||
it "supports building D sources with gdc" do
|
it "supports building D sources with gdc" do
|
||||||
test_dir("d")
|
test_dir("d")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user