From 094b2aa6566fa8d4dda8f2ea0992e385ec0a246a Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 22 Nov 2004 09:02:52 +0000 Subject: [PATCH] Fix some problems with project loading * build/targets.jam (project-target.find): Better error reporting. * build/project.jam (load-jamfile): Use 'path.native' when loading Jamfile, otherwise, target id with absolute directory name won't work for Windows. [SVN r26271] --- v2/build/project.jam | 2 +- v2/build/targets.jam | 17 +++++++++++------ v2/test/absolute_sources.py | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/v2/build/project.jam b/v2/build/project.jam index 4f27379be..7e8fc446b 100644 --- a/v2/build/project.jam +++ b/v2/build/project.jam @@ -306,7 +306,7 @@ local rule load-jamfile ( .current-project = [ target $(module-name) ] $(.current-project) ; if $(jamfile) { - load-aux $(jamfile-module) : $(jamfile) ; + load-aux $(jamfile-module) : [ path.native $(jamfile) ] ; } } } diff --git a/v2/build/targets.jam b/v2/build/targets.jam index bd1cae0d7..97ceb2d79 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -298,7 +298,7 @@ class project-target : abstract-target # Find and return the target with the specified id, treated # relative to self. - rule find ( id ) + rule find ( id : no-error ? ) { local result ; local project = $(self.project) ; @@ -307,7 +307,8 @@ class project-target : abstract-target local split = [ MATCH (.*)//(.*) : $(id) ] ; local project-part = $(split[1]) ; local target-part = $(split[2]) ; - + + local extra-error-message ; if $(project-part) { # There's explicit project part in id. Looks up the @@ -316,8 +317,12 @@ class project-target : abstract-target if $(pm) { project-target = [ project.target $(pm) ] ; - result = [ $(project-target).find $(target-part) ] ; - } + result = [ $(project-target).find $(target-part) : no-error ] ; + } + else + { + extra-error-message = "error: could not find project '$(project-part)'" ; + } } else { @@ -348,12 +353,13 @@ class project-target : abstract-target } } - if ! $(result) + if ! $(result) && ! $(no-error) { ECHO "error: Unable to find file or target named" ; ECHO "error: '$(id)'" ; ECHO "error: referred from project at" ; ECHO "error: '$(current-location)'" ; + ECHO $(extra-error-message) ; EXIT ; } return $(result) ; @@ -433,7 +439,6 @@ class project-target : abstract-target target-module # The module to intern into. ) { - ECHO "Injecting constants to " $(target-module) ; for local c in $(self.constants) { modules.poke $(target-module) : $(c) : $(self.constant.$(c)) ; diff --git a/v2/test/absolute_sources.py b/v2/test/absolute_sources.py index 522e6d7e7..a7664be0e 100644 --- a/v2/test/absolute_sources.py +++ b/v2/test/absolute_sources.py @@ -52,4 +52,22 @@ alias a : $(pwd)/a.cpp ; t.run_build_system() t.expect_addition("bin/$toolset/debug/a.exe") +# Test absolute path in target ids +t.rm(".") +t.write("d1/project-root.jam", "") +t.write("d1/Jamfile", """ +exe a : a.cpp ; +""") +t.write("d1/a.cpp", """ +int main() { return 0; } +""") +t.write("d2/project-root.jam", "") +t.write("d2/Jamfile", """ +local pwd = [ PWD ] ; +alias x : $(pwd)/../d1//a ; +""") + +t.run_build_system(subdir="d2") +t.expect_addition("d1/bin/$toolset/debug/a.exe") + t.cleanup()