diff --git a/src/tools/jam/Jambase b/src/tools/jam/Jambase index e11ded1027..42c85638fc 100644 --- a/src/tools/jam/Jambase +++ b/src/tools/jam/Jambase @@ -919,7 +919,7 @@ rule LocalClean # Like Clean, but has only effect in a Jamfile in the # directory or any of its subdirectories where jam has been invoked. - if [ FIsPrefix $(INVOCATION_SUBDIR) : $(SUBDIR_TOKENS) ] { + if [ FIsPrefix $(SUBDIR_UP) : $(SUBDIR_DOWN) ] { Clean $(1) : $(2) ; } } @@ -930,7 +930,7 @@ rule LocalDepends # Like Depends, but has only effect in a Jamfile in the # directory or any of its subdirectories where jam has been invoked. - if [ FIsPrefix $(INVOCATION_SUBDIR) : $(SUBDIR_TOKENS) ] { + if [ FIsPrefix $(SUBDIR_UP) : $(SUBDIR_DOWN) ] { Depends $(1) : $(2) ; } } @@ -1230,6 +1230,17 @@ rule SubDir { $(_top)-SET = true ; + ## LOCAL CHANGE + # + # Needed below to reset $(_top), so that to the SubDir invoked by the + # top jamfile we will include, it will appear, as if the code has + # never been executed. + # + local _originalTop = $($(_top)) ; + # + ## LOCAL CHANGE + + # First time we've seen this TOP. # We'll initialize a number of internal variables: # @@ -1324,6 +1335,33 @@ rule SubDir SUBDIR_DOWN = ; SUBDIR_ROOT = $($(_top)-ROOT) ; + ## LOCAL CHANGE + # + # If we are the first Jamfile, we include the top Jamfile of this + # tree and stop processing. + # + if ! $(INVOCATION_SUBDIR_SET) + { + INVOCATION_SUBDIR_SET = true ; + INVOCATION_SUBDIR_TOP = $($(_top)) ; + INVOCATION_SUBDIR = $(_tokens) ; + if $(INVOCATION_SUBDIR) + { + # Reset $(_top)-SET and $(_top) so that it appears as if the + # code till this point has never been executed (let alone the + # setting of the INVOCATION_SUBDIR_SET and INVOCATION_SUBDIR + # variables). + # + $(_top)-SET = ; + $(_top) = $(_originalTop) ; + + include $(JAMFILE:D=$(INVOCATION_SUBDIR_TOP)) ; + jumptoeof ; + } + } + # + ## LOCAL CHANGE + # Include $(TOPRULES) or $(TOP)/Jamrules. # Include $(TOPRULES) if set. # Otherwise include $(TOP)/Jamrules if present. @@ -1334,23 +1372,6 @@ rule SubDir NoCare $(JAMRULES:R=$($(_top)):G=$(_top)) ; include $(JAMRULES:R=$($(_top)):G=$(_top)) ; } - - ## LOCAL CHANGE - # - # If we are the first Jamfile, we include the top Jamfile of this - # tree and stop processing. - # - if ! $(INVOCATION_SUBDIR_SET) { - INVOCATION_SUBDIR_SET = true ; - INVOCATION_SUBDIR_TOP = $(_top) ; - INVOCATION_SUBDIR = $(_tokens) ; - if $(INVOCATION_SUBDIR) { - SubInclude $(_top) ; - jumptoeof ; - } - } - # - ## LOCAL CHANGE } # Get path from $(TOP) to named directory. diff --git a/src/tools/jam/jambase.c b/src/tools/jam/jambase.c index be7260d016..8e162a4986 100644 --- a/src/tools/jam/jambase.c +++ b/src/tools/jam/jambase.c @@ -583,13 +583,13 @@ const char *jambase[] = { "}\n", "rule LocalClean\n", "{\n", -"if [ FIsPrefix $(INVOCATION_SUBDIR) : $(SUBDIR_TOKENS) ] {\n", +"if [ FIsPrefix $(SUBDIR_UP) : $(SUBDIR_DOWN) ] {\n", "Clean $(1) : $(2) ;\n", "}\n", "}\n", "rule LocalDepends\n", "{\n", -"if [ FIsPrefix $(INVOCATION_SUBDIR) : $(SUBDIR_TOKENS) ] {\n", +"if [ FIsPrefix $(SUBDIR_UP) : $(SUBDIR_DOWN) ] {\n", "Depends $(1) : $(2) ;\n", "}\n", "}\n", @@ -743,6 +743,7 @@ const char *jambase[] = { "if ! $($(_top)-SET)\n", "{\n", "$(_top)-SET = true ;\n", +"local _originalTop = $($(_top)) ;\n", "if $($(_top))\n", "{\n", "$(_top)-UP = ;\n", @@ -768,21 +769,25 @@ const char *jambase[] = { "SUBDIR_UP = $($(_top)-UP) ;\n", "SUBDIR_DOWN = ;\n", "SUBDIR_ROOT = $($(_top)-ROOT) ;\n", +"if ! $(INVOCATION_SUBDIR_SET)\n", +"{\n", +"INVOCATION_SUBDIR_SET = true ;\n", +"INVOCATION_SUBDIR_TOP = $($(_top)) ;\n", +"INVOCATION_SUBDIR = $(_tokens) ;\n", +"if $(INVOCATION_SUBDIR)\n", +"{\n", +"$(_top)-SET = ;\n", +"$(_top) = $(_originalTop) ;\n", +"include $(JAMFILE:D=$(INVOCATION_SUBDIR_TOP)) ;\n", +"jumptoeof ;\n", +"}\n", +"}\n", "if $($(_top)RULES) { \n", "include $($(_top)RULES) ;\n", "} else { \n", "NoCare $(JAMRULES:R=$($(_top)):G=$(_top)) ;\n", "include $(JAMRULES:R=$($(_top)):G=$(_top)) ;\n", "}\n", -"if ! $(INVOCATION_SUBDIR_SET) {\n", -"INVOCATION_SUBDIR_SET = true ;\n", -"INVOCATION_SUBDIR_TOP = $(_top) ;\n", -"INVOCATION_SUBDIR = $(_tokens) ;\n", -"if $(INVOCATION_SUBDIR) {\n", -"SubInclude $(_top) ;\n", -"jumptoeof ;\n", -"}\n", -"}\n", "}\n", "SUBDIR_UP = $($(_top)-UP) ;\n", "SUBDIR_DOWN = $($(_top)-DOWN) $(_tokens) ;\n", @@ -793,7 +798,6 @@ const char *jambase[] = { "LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(SUBDIR) ;\n", "LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(SUBDIR) ;\n", "SOURCE_GRIST = [ FGrist $(SUBDIR_TOKENS) ] ;\n", -"HDRGRIST = $(SOURCE_GRIST) ;\n", "SUBDIR$(SUBDIRRESET) = ;\n", "$(SUBDIRRULES) $(<) ;\n", "}\n",