From 2eb6750dbd62d7ccf92e26f207793e8bc8cc5151 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 21 Oct 2003 09:24:47 +0000 Subject: [PATCH] Fix a problem with 'use-project' which refers to child project. Thanks to Austin Bingham for the bug report. * new/project.jam (load): Don't mark project as loaded here. (load-jamfile): Mark it as loaded here. [SVN r20439] --- new/project.jam | 15 ++++++++++----- test/double_loading.py | 20 +++++++++++++++++++- v2/build/project.jam | 15 ++++++++++----- v2/test/double_loading.py | 20 +++++++++++++++++++- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/new/project.jam b/new/project.jam index 68de8e0ce..b38219676 100644 --- a/new/project.jam +++ b/new/project.jam @@ -64,8 +64,6 @@ rule load ( jamfile-location ) # If Jamfile is already loaded, don't try again. if ! $(module-name) in $(.jamfile-modules) { - .jamfile-modules += $(module-name) ; - load-jamfile $(jamfile-location) ; for local p in [ attribute $(module-name) projects-to-build ] @@ -246,10 +244,17 @@ local rule load-jamfile ( # Initialize the jamfile module before loading. # initialize $(jamfile-module) : [ path.parent $(jamfile-to-load) ] ; - + # Now load the Jamfile in it's own context. - # - modules.load $(jamfile-module) : [ path.native $(jamfile-to-load) ] : . ; + # Initialization might have load parent Jamfiles, which might have + # loaded the current Jamfile with use-project. Do a final check to make + # sure it's not loaded already. + if ! $(jamfile-module) in $(.jamfile-modules) + { + .jamfile-modules += $(jamfile-module) ; + modules.load $(jamfile-module) : [ path.native $(jamfile-to-load) ] : . ; + } + } # Initialize the module for a project. diff --git a/test/double_loading.py b/test/double_loading.py index 3453bf8e2..e1418dccd 100644 --- a/test/double_loading.py +++ b/test/double_loading.py @@ -5,12 +5,12 @@ # all copies. This software is provided "as is" without express or implied # warranty, and with no claim as to its suitability for any purpose. -# Regression test for double loading of the same Jamfile. from BoostBuild import Tester, List import string t = Tester() +# Regression test for double loading of the same Jamfile. t.write("Jamfile", """ build-project subdir ; """) @@ -25,5 +25,23 @@ ECHO "Loaded subdir" ; t.run_build_system(subdir="subdir") t.fail_test(string.count(t.stdout(), "Loaded subdir") != 1) +# Regression test for a more contrived case. The top-level +# jamfile refers to subdir via use-project, while subdir's +# Jamfile is being loaded. The motivation why use-project +# referring to subprojects are usefull can be found at +# http://article.gmane.org/gmane.comp.lib.boost.build/3906/ +t.write("Jamfile", """ +use-project /subdir : subdir ; +""") + +t.write("project-root.jam", """ +""") + +t.write("subdir/Jamfile", """ +project subdir ; +""") + +t.run_build_system(subdir="subdir"); + t.cleanup() diff --git a/v2/build/project.jam b/v2/build/project.jam index 68de8e0ce..b38219676 100644 --- a/v2/build/project.jam +++ b/v2/build/project.jam @@ -64,8 +64,6 @@ rule load ( jamfile-location ) # If Jamfile is already loaded, don't try again. if ! $(module-name) in $(.jamfile-modules) { - .jamfile-modules += $(module-name) ; - load-jamfile $(jamfile-location) ; for local p in [ attribute $(module-name) projects-to-build ] @@ -246,10 +244,17 @@ local rule load-jamfile ( # Initialize the jamfile module before loading. # initialize $(jamfile-module) : [ path.parent $(jamfile-to-load) ] ; - + # Now load the Jamfile in it's own context. - # - modules.load $(jamfile-module) : [ path.native $(jamfile-to-load) ] : . ; + # Initialization might have load parent Jamfiles, which might have + # loaded the current Jamfile with use-project. Do a final check to make + # sure it's not loaded already. + if ! $(jamfile-module) in $(.jamfile-modules) + { + .jamfile-modules += $(jamfile-module) ; + modules.load $(jamfile-module) : [ path.native $(jamfile-to-load) ] : . ; + } + } # Initialize the module for a project. diff --git a/v2/test/double_loading.py b/v2/test/double_loading.py index 3453bf8e2..e1418dccd 100644 --- a/v2/test/double_loading.py +++ b/v2/test/double_loading.py @@ -5,12 +5,12 @@ # all copies. This software is provided "as is" without express or implied # warranty, and with no claim as to its suitability for any purpose. -# Regression test for double loading of the same Jamfile. from BoostBuild import Tester, List import string t = Tester() +# Regression test for double loading of the same Jamfile. t.write("Jamfile", """ build-project subdir ; """) @@ -25,5 +25,23 @@ ECHO "Loaded subdir" ; t.run_build_system(subdir="subdir") t.fail_test(string.count(t.stdout(), "Loaded subdir") != 1) +# Regression test for a more contrived case. The top-level +# jamfile refers to subdir via use-project, while subdir's +# Jamfile is being loaded. The motivation why use-project +# referring to subprojects are usefull can be found at +# http://article.gmane.org/gmane.comp.lib.boost.build/3906/ +t.write("Jamfile", """ +use-project /subdir : subdir ; +""") + +t.write("project-root.jam", """ +""") + +t.write("subdir/Jamfile", """ +project subdir ; +""") + +t.run_build_system(subdir="subdir"); + t.cleanup()