Skip to content

Commit

Permalink
toolset.using preserves current project (#407)
Browse files Browse the repository at this point in the history
Using project rule preserves the current project, and toolset.using does not. The problem is that the former is not available in modules that are not projects, and so one has to preserve the current project manually, just in case. I don't think there is ever any point in not preserving the current project when initializing a toolset module, so this change pushes this responsibility on toolset.using.
  • Loading branch information
grisumbras authored Nov 10, 2024
1 parent 5131ab8 commit 937a9f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/build/project.jam
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,6 @@ module project-rules
{
import toolset ;

local saved-project = [ modules.peek project : .current-project ] ;

# Temporarily change the search path so the module referred to by
# 'using' can be placed in the same directory as Jamfile. User will
# expect the module to be found even though the directory is not in
Expand All @@ -1290,13 +1288,6 @@ module project-rules
$(9) : $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : $(16) : $(17)
: $(18) : $(19) ;
modules.poke : BOOST_BUILD_PATH : $(x) ;

# The above might have clobbered .current-project in case it caused a
# new project instance to be created (which would then automatically
# get set as the 'current' project). Restore the correct value so any
# main targets declared after this do not get mapped to the loaded
# module's project.
modules.poke project : .current-project : $(saved-project) ;
}

rule import ( * : * : * )
Expand Down
9 changes: 9 additions & 0 deletions src/build/toolset.jam
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ if --ignore-toolset-requirements in [ modules.peek : ARGV ]
#
rule using ( toolset-module : * )
{
local saved-project = [ modules.peek project : .current-project ] ;

import $(toolset-module) ;
$(toolset-module).init $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9)
;

# The above might have clobbered .current-project in case it caused a
# new project instance to be created (which would then automatically
# get set as the 'current' project). Restore the correct value so any
# main targets declared after this do not get mapped to the loaded
# module's project.
modules.poke project : .current-project : $(saved-project) ;
}


Expand Down

0 comments on commit 937a9f3

Please sign in to comment.