|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79874 - in trunk/tools/build/v2: . build test
From: jurko.gospodnetic_at_[hidden]
Date: 2012-08-05 11:12:59
Author: jurko
Date: 2012-08-05 11:12:58 EDT (Sun, 05 Aug 2012)
New Revision: 79874
URL: http://svn.boost.org/trac/boost/changeset/79874
Log:
Made Boost Build clear its 'current project' reference after it is done with loading project modules. Any request for the 'current project' reference when there is no project module currently being loaded will now be treated as an error. Updated the related indirect_conditional.py internal Boost Build test case accordingly.
Additional implementation notes:
- internal worker project.load-jamfile() rule now resets the current project when done
- project.use() no longer needs to reset the current project since project.load-jamfile() does that now
Text files modified:
trunk/tools/build/v2/build-system.jam | 2 ++
trunk/tools/build/v2/build/project.jam | 37 +++++++++++++++++++++++++++++++++++--
trunk/tools/build/v2/test/indirect_conditional.py | 12 ++++++++----
3 files changed, 45 insertions(+), 6 deletions(-)
Modified: trunk/tools/build/v2/build-system.jam
==============================================================================
--- trunk/tools/build/v2/build-system.jam (original)
+++ trunk/tools/build/v2/build-system.jam 2012-08-05 11:12:58 EDT (Sun, 05 Aug 2012)
@@ -414,6 +414,8 @@
initialize-config-module project-config : $(file:D) ;
load-config project-config : project-config.jam : $(file:D) ;
}
+
+ project.end-load ;
}
Modified: trunk/tools/build/v2/build/project.jam
==============================================================================
--- trunk/tools/build/v2/build/project.jam (original)
+++ trunk/tools/build/v2/build/project.jam 2012-08-05 11:12:58 EDT (Sun, 05 Aug 2012)
@@ -280,6 +280,8 @@
# second attempt from messing things up.
if ! $(jamfile-module) in $(.jamfile-modules)
{
+ local previous-project = $(.current-project) ;
+
# Initialize the Jamfile module before loading.
initialize $(jamfile-module) : [ path.parent $(jamfile-to-load) ] :
$(jamfile-to-load:BS) ;
@@ -315,6 +317,8 @@
: actual value $(.current-project) ;
}
+ end-load $(previous-project) ;
+
if $(.global-build-dir)
{
if [ attribute $(jamfile-module) location ] && ! [ attribute
@@ -336,6 +340,31 @@
}
+# Called when done loading a project module. Restores the current project to its
+# previous value and does some additional checking to make sure our 'currently
+# loaded project' identifier does not get left with an invalid value.
+#
+rule end-load ( previous-project ? )
+{
+ if ! $(.current-project)
+ {
+ import errors ;
+ errors.error Ending project loading requested when there was no project
+ currently being loaded. ;
+ }
+
+ if ! $(previous-project) && $(.saved-current-project)
+ {
+ import errors ;
+ errors.error Ending project loading requested with no 'previous project'
+ when there were other projects still marked as being loaded
+ recursively. ;
+ }
+
+ .current-project = $(previous-project) ;
+}
+
+
rule mark-as-user ( module-name )
{
if USER_MODULE in [ RULENAMES ]
@@ -702,6 +731,12 @@
#
rule current ( )
{
+ if ! $(.current-project)
+ {
+ import errors ;
+ errors.error Reference to the project currently being loaded requested
+ when there was no project module being loaded. ;
+ }
return $(.current-project) ;
}
@@ -757,7 +792,6 @@
#
rule use ( id : location )
{
- local saved-project = $(.current-project) ;
local project-module = [ project.load $(location) ] ;
local declared-id = [ project.attribute $(project-module) id ] ;
@@ -774,7 +808,6 @@
}
$(id).jamfile-module = $(project-module) ;
}
- .current-project = $(saved-project) ;
}
Modified: trunk/tools/build/v2/test/indirect_conditional.py
==============================================================================
--- trunk/tools/build/v2/test/indirect_conditional.py (original)
+++ trunk/tools/build/v2/test/indirect_conditional.py 2012-08-05 11:12:58 EDT (Sun, 05 Aug 2012)
@@ -64,8 +64,10 @@
def test_glob_in_indirect_conditional():
"""
- Regression test: glob run inside an indirect conditional should work in
- the correct project context, i.e. in the correct folder.
+ Regression test: project-rules.glob rule run from inside an indirect
+ conditional should report an error as it depends on the 'currently loaded
+ project' concept and indirect conditional rules get called only after all
+ the project modules have already finished loading.
"""
t = BoostBuild.Tester()
@@ -91,8 +93,10 @@
lib bar : bar.cpp : <conditional>@print-my-sources ;
""")
- t.run_build_system()
- t.expect_output_lines("My sources:\nbar.cpp")
+ t.run_build_system(status=1)
+ t.expect_output_lines(["My sources:", "bar.cpp"], False)
+ t.expect_output_lines("error: Reference to the project currently being "
+ "loaded requested when there was no project module being loaded.")
t.cleanup()
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk