Skip to content

Commit 4900b8f

Browse files
committed
Record requirement modulepath spec in environment
When a requirement is defined with a specific modulepath set, record this spec in the user environment. This information is stored in __MODULES_LMPREREQPATH environment variable.
1 parent e1eda1b commit 4900b8f

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed

.hunspell.en.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,3 +1187,4 @@ B2
11871187
A2
11881188
C2
11891189
stdin
1190+
LMPREREQPATH

tcl/mfcmd.tcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,10 @@ proc prereqAnyModfileCmd {tryload auto args} {
11771177
}
11781178
lappend record_list {*}$args
11791179
setLoadedPrereq $currentModule $record_list
1180+
1181+
if {[llength $modulepath_list]} {
1182+
setLoadedPrereqPath $currentModule $record_list $modulepath_list
1183+
}
11801184
}
11811185

11821186
if {$auto} {

tcl/modeval.tcl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ proc pushSettings {} {
604604
g_moduleNPODepend g_dependNPOHash g_prereqViolation\
605605
g_prereqNPOViolation g_conflictViolation g_moduleUnmetDep\
606606
g_unmetDepHash g_moduleEval g_moduleHiddenEval g_scanModuleVariant\
607-
g_savedLoReqOfReloadMod g_savedLoReqOfUnloadMod} {
607+
g_savedLoReqOfReloadMod g_savedLoReqOfUnloadMod\
608+
g_loadedModulePrereqPath} {
608609
##nagelfar ignore Suspicious variable name
609610
lappend ::g_SAVE_$var [array get ::$var]
610611
}
@@ -633,7 +634,8 @@ proc popSettings {} {
633634
g_moduleNPODepend g_dependNPOHash g_prereqViolation\
634635
g_prereqNPOViolation g_conflictViolation g_moduleUnmetDep\
635636
g_unmetDepHash g_moduleEval g_moduleHiddenEval g_scanModuleVariant\
636-
g_savedLoReqOfReloadMod g_savedLoReqOfUnloadMod g_uReqUnFromDepReList} {
637+
g_savedLoReqOfReloadMod g_savedLoReqOfUnloadMod g_uReqUnFromDepReList\
638+
g_loadedModulePrereqPath} {
637639
##nagelfar ignore Suspicious variable name
638640
set ::g_SAVE_$var [lrange [set ::g_SAVE_$var] 0 end-1]
639641
}
@@ -650,7 +652,8 @@ proc restoreSettings {} {
650652
g_moduleNPODepend g_dependNPOHash g_prereqViolation\
651653
g_prereqNPOViolation g_conflictViolation g_moduleUnmetDep\
652654
g_unmetDepHash g_moduleEval g_moduleHiddenEval g_scanModuleVariant\
653-
g_savedLoReqOfReloadMod g_savedLoReqOfUnloadMod} {
655+
g_savedLoReqOfReloadMod g_savedLoReqOfUnloadMod\
656+
g_loadedModulePrereqPath} {
654657
# clear current $var arrays
655658
##nagelfar ignore #5 Suspicious variable name
656659
if {[info exists ::$var]} {

tcl/modfind.tcl.in

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,29 @@ proc getLoadedPrereq {mod} {
16871687
}
16881688
}
16891689

1690+
proc setLoadedPrereqPath {mod args} {
1691+
appendNoDupToList ::g_loadedModulePrereqPath($mod) {*}$args
1692+
}
1693+
1694+
proc unsetLoadedPrereqPath {mod} {
1695+
if {[info exists ::g_loadedModulePrereqPath($mod)]} {
1696+
unset ::g_loadedModulePrereqPath($mod)
1697+
}
1698+
}
1699+
1700+
proc getLoadedPrereqPath {mod {prereq {}}} {
1701+
if {[info exists ::g_loadedModulePrereqPath($mod)]} {
1702+
if {![string length $prereq]} {
1703+
return $::g_loadedModulePrereqPath($mod)
1704+
}
1705+
# return specific entry for given prereq
1706+
array set prereq_path_arr $::g_loadedModulePrereqPath($mod)
1707+
if {[info exists prereq_path_arr($prereq)]} {
1708+
return $prereq_path_arr($prereq)
1709+
}
1710+
}
1711+
}
1712+
16901713
proc setLoadedAltname {mod args} {
16911714
foreach arg $args {
16921715
switch -- [lindex $arg 0] {
@@ -1846,7 +1869,7 @@ proc getEnvLoadedModulePropertyStructDepth {prop} {
18461869
conflict - extratag - tag {
18471870
return 1Lvl
18481871
}
1849-
altname - prereq - sourcesh - stickyrule - variant {
1872+
altname - prereq - prereqpath - sourcesh - stickyrule - variant {
18501873
return 2Lvl
18511874
}
18521875
}
@@ -2399,6 +2422,10 @@ proc cacheCurrentModules {{exitonerr 1}} {
23992422
}
24002423
setLoadedPrereq {*}$modpre
24012424
}
2425+
foreach modpre_path [getEnvLoadedModulePropertyParsedList\
2426+
prereqpath] {
2427+
setLoadedPrereqPath {*}$modpre_path
2428+
}
24022429

24032430
foreach mod $modlist {
24042431
# get all tags also recorded on mod and vr designation

tcl/subcmd.tcl.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,8 @@ proc cmdModuleLoad {context uasked tryload loadany tag_list modulepath_list\
12991299
# declare the prereq of this module
13001300
setEnvLoadedModuleProperty $modname prereq [getLoadedPrereq\
13011301
$modname]
1302+
setEnvLoadedModuleProperty $modname prereqpath [getLoadedPrereqPath\
1303+
$modname]
13021304

13031305
# declare the alternative names of this module
13041306
setEnvLoadedModuleProperty $modname altname [getLoadedAltname\
@@ -1674,6 +1676,8 @@ proc cmdModuleUnload {context match auto force onlyureq args} {
16741676
# unset prereq declared for this module
16751677
unsetEnvLoadedModuleProperty $modname prereq
16761678
unsetLoadedPrereq $modname
1679+
unsetEnvLoadedModuleProperty $modname prereqpath
1680+
unsetLoadedPrereqPath $modname
16771681

16781682
# unset alternative names declared for this module
16791683
unsetEnvLoadedModuleProperty $modname altname

0 commit comments

Comments
 (0)