Add ^^/ shortcut to top-level build directory - close #146
This commit is contained in:
parent
b0f2bbb7d5
commit
f5ab51c477
@ -1,9 +1,10 @@
|
|||||||
build do
|
build do
|
||||||
Environment.new(echo: :command) do |env|
|
Environment.new(echo: :command) do |env|
|
||||||
env.append('CPPPATH' => glob('src/**').sort)
|
env.append("CPPPATH" => glob("src/**"))
|
||||||
FileUtils.mkdir_p(env.build_root)
|
FileUtils.mkdir_p(env.build_root)
|
||||||
FileUtils.mv("src/one/one.c", env.build_root)
|
FileUtils.mv("src/one/one.c", env.build_root)
|
||||||
|
FileUtils.mv("src/two/two.c", Rscons.application.build_dir)
|
||||||
env.Object("^/one.o", "^/one.c")
|
env.Object("^/one.o", "^/one.c")
|
||||||
env.Program("program.exe", glob('src/**/*.c') + ["^/one.o"])
|
env.Program("^^/program.exe", ["^/one.o", "^^/two.c"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -475,10 +475,12 @@ module Rscons
|
|||||||
output_fname
|
output_fname
|
||||||
end
|
end
|
||||||
|
|
||||||
# Expand a path to be relative to the Environment's build root.
|
# Expand paths.
|
||||||
#
|
#
|
||||||
# Paths beginning with "^/" are expanded by replacing "^" with the
|
# Paths beginning with "^/" are expanded by replacing "^" with the
|
||||||
# Environment's build root.
|
# Environment's build root (e.g. "build/envname").
|
||||||
|
# Paths beginning with "^^/" are expanded by replacing "^^" with the
|
||||||
|
# top-level build directory (e.g. "build").
|
||||||
#
|
#
|
||||||
# @param path [String, Array<String>]
|
# @param path [String, Array<String>]
|
||||||
# The path(s) to expand.
|
# The path(s) to expand.
|
||||||
@ -493,7 +495,7 @@ module Rscons
|
|||||||
expand_path(path)
|
expand_path(path)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
path.sub(%r{^\^(?=[\\/])}, @build_root).gsub("\\", "/")
|
path.sub(%r{^\^\^(?=[\\/])}, Rscons.application.build_dir).sub(%r{^\^(?=[\\/])}, @build_root).gsub("\\", "/")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -338,14 +338,14 @@ EOF
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "expands target and source paths starting with ^/ to be relative to the build root" do
|
it "expands target and source paths starting with ^/ and ^^/" do
|
||||||
test_dir("typical")
|
test_dir("typical")
|
||||||
result = run_rscons(rsconscript: "carat.rb")
|
result = run_rscons(rsconscript: "carat.rb", rscons_args: %w[-b bld])
|
||||||
expect(result.stderr).to eq ""
|
expect(result.stderr).to eq ""
|
||||||
verify_lines(lines(result.stdout), [
|
verify_lines(lines(result.stdout), [
|
||||||
%r{gcc -c -o build/e.1/one.o -MMD -MF build/e.1/one.o.mf -Isrc -Isrc/one -Isrc/two build/e.1/one.c},
|
%r{gcc -c -o bld/e.1/one.o -MMD -MF bld/e.1/one.o.mf -Isrc -Isrc/one -Isrc/two bld/e.1/one.c},
|
||||||
%r{gcc -c -o build/e.1/src/two/two.c.o -MMD -MF build/e.1/src/two/two.c.o.mf -Isrc -Isrc/one -Isrc/two src/two/two.c},
|
%r{gcc -c -o bld/e.1/bld/two.c.o -MMD -MF bld/e.1/bld/two.c.o.mf -Isrc -Isrc/one -Isrc/two bld/two.c},
|
||||||
%r{gcc -o program.exe build/e.1/src/two/two.c.o build/e.1/one.o},
|
%r{gcc -o bld/program.exe bld/e.1/one.o bld/e.1/bld/two.c.o},
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user