2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 00:52:16 +00:00

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

[SVN r79874]
This commit is contained in:
Jurko Gospodnetić
2012-08-05 15:12:58 +00:00
parent 893b641db6
commit 74468b59ac
3 changed files with 45 additions and 6 deletions

View File

@@ -414,6 +414,8 @@ local rule load-configuration-files
initialize-config-module project-config : $(file:D) ;
load-config project-config : project-config.jam : $(file:D) ;
}
project.end-load ;
}

View File

@@ -280,6 +280,8 @@ local rule load-jamfile ( dir : jamfile-module )
# 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 @@ local rule load-jamfile ( dir : jamfile-module )
: actual value $(.current-project) ;
}
end-load $(previous-project) ;
if $(.global-build-dir)
{
if [ attribute $(jamfile-module) location ] && ! [ attribute
@@ -336,6 +340,31 @@ local rule load-jamfile ( dir : jamfile-module )
}
# 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 @@ class project-attributes
#
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 target ( project-module )
#
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 @@ rule use ( id : location )
}
$(id).jamfile-module = $(project-module) ;
}
.current-project = $(saved-project) ;
}

View File

@@ -64,8 +64,10 @@ rule a3-rule-2 ( properties * )
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 @@ rule print-my-sources ( properties * )
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()