Skip to content

Commit d4834d2

Browse files
committed
Insert provided-aliases in module search result
If provided-alias are requested, include them in the module search result. Aliases defined with "provide" and "family" modulefile commands are considered provided-aliases. This change requires to perform the modulefile scan evaluation during step #1 of getModules (gathering of entries) instead of step #4. Provided-aliases are then inserted right after to be part of step #2 and step #3 checks. Signed-off-by: Xavier Delaruelle <[email protected]>
1 parent 9c3cff7 commit d4834d2

File tree

5 files changed

+40
-15
lines changed

5 files changed

+40
-15
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,7 @@ tcl/syntaxdb.tcl: modulecmd.tcl $(NAGELFAR)
11131113
set ::syntax(lprepend) {n x*};\
11141114
set ::syntax(execute-modulefile) {x x n x x x? x? x?};\
11151115
set ::syntax(scanExtraMatchSearch) {x x n};\
1116+
set ::syntax(insertProvidedAliases) {x n};\
11161117
set ::syntax(filterExtraMatchSearch) {x x n n};\
11171118
set ::syntax(findModulesFromDirsAndFiles) {x x x x n n? n? n? n?};\
11181119
set ::syntax(getArrayKey) {n x x};\

tcl/interp.tcl.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ complete {complete complete-un reportCmd nop nop
110110
conflict {conflict nop reportCmd nop nop nop nop conflict-sc }
111111
depends-on {prereqAllModfileCmd nop reportCmd nop nop nop nop prereq-all-sc}
112112
depends-on-any {prereqAnyModfileCmd nop reportCmd nop nop nop nop prereq-sc }
113-
extensions {provide nop reportCmd nop nop nop nop nop }
113+
extensions {provide nop reportCmd nop nop nop nop provide-sc }
114114
family {family family-un reportCmd nop nop nop nop family-sc }
115115
haveDynamicMPATH {nop nop nop nop nop nop nop nop }
116116
hide-modulefile {hide-modulefile hide-modulefile hide-modulefile hide-modulefile hide-modulefile hide-modulefile nop nop }
@@ -133,7 +133,7 @@ prepend-path {prepend-path prepend-path-un prepend-path prepend-path prep
133133
prereq-all {prereqAllModfileCmd nop reportCmd nop nop nop nop prereq-all-sc}
134134
prereq-any {prereqAnyModfileCmd nop reportCmd nop nop nop nop prereq-sc }
135135
prereq {prereqAnyModfileCmd nop reportCmd nop nop nop nop prereq-sc }
136-
provide {provide nop reportCmd nop nop nop nop nop }
136+
provide {provide nop reportCmd nop nop nop nop provide-sc }
137137
pushenv {pushenv pushenv-un pushenv pushenv pushenv pushenv-wh nop pushenv-sc }
138138
remove-path {remove-path remove-path-un remove-path remove-path remove-path edit-path-wh nop edit-path-sc}
139139
remove-property {nop nop nop nop nop nop nop nop }

tcl/modfind.tcl.in

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,7 +3181,16 @@ proc getModules {dir {mod {}} {fetch_mtime 0} {search {}} {filter {}}} {
31813181
}
31823182
}
31833183

3184-
# Phase #3: filter-out dynamically hidden or expired elements
3184+
# Phase #3: scan modulefiles if extra match search is needed
3185+
3186+
if {$ems_required} {
3187+
scanExtraMatchSearch $dir $mod found_list
3188+
if {[isEltInReport provided-alias 0]} {
3189+
insertProvidedAliases $dir found_list
3190+
}
3191+
}
3192+
3193+
# Phase #4: filter-out dynamically hidden or expired elements
31853194

31863195
# define module name and version comparison procs
31873196
defineModStartNbProc $icase
@@ -3237,7 +3246,7 @@ proc getModules {dir {mod {}} {fetch_mtime 0} {search {}} {filter {}}} {
32373246
}
32383247
}
32393248

3240-
# Phase #4: elaborate directory content with default element selection
3249+
# Phase #5: elaborate directory content with default element selection
32413250

32423251
array set dir_list {}
32433252
array set autosym_list {}
@@ -3305,18 +3314,13 @@ proc getModules {dir {mod {}} {fetch_mtime 0} {search {}} {filter {}}} {
33053314
}
33063315
}
33073316

3308-
# Phase #5: perform extra match search
3317+
# Phase #6: perform extra match search filtering
33093318

33103319
if {$ems_required} {
3311-
scanExtraMatchSearch $dir $mod found_list
33123320
filterExtraMatchSearch $dir $mod found_list versmod_list
33133321
}
33143322

3315-
# ensure modEqStatic is defined as expected (could have been redefined
3316-
# during scan evaluation)
3317-
defineModEqStaticProc $icase [getConf extended_default] $mod
3318-
3319-
# Phase #6: filter results to keep those matching search query
3323+
# Phase #7: filter results to keep those matching search query
33203324

33213325
# define module name and version comparison procs
33223326
defineDoesModMatchAtDepthProc $contains $querydepth $mtest

tcl/modscan.tcl

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,16 @@ proc family-sc {name} {
124124
if {![string length $name] || ![regexp {^[A-Za-z0-9_]*$} $name]} {
125125
knerror "Invalid family name '$name'"
126126
}
127-
recordScanModuleElt $name family
127+
recordScanModuleElt $name family provided-alias
128+
}
129+
130+
proc provide-sc {args} {
131+
if {![llength $args]} {
132+
knerror {No module specified in argument}
133+
}
134+
foreach alias $args {
135+
recordScanModuleElt $alias provide provided-alias
136+
}
128137
}
129138

130139
proc prereq-sc {args} {
@@ -367,6 +376,16 @@ proc isExtraMatchSearchRequired {mod} {
367376
{avail paths whatis spider}))}]
368377
}
369378

379+
proc insertProvidedAliases {modpath res_arrname} {
380+
upvar $res_arrname found_list
381+
foreach {alias target_mod} [getScanModuleElt $modpath provided-alias] {
382+
if {![info exists found_list($alias)]} {
383+
##nagelfar ignore Found constant
384+
set found_list($alias) [list alias $target_mod]
385+
}
386+
}
387+
}
388+
370389
# scan modulefiles from currently being built module search result if extra
371390
# match search is needed
372391
proc scanExtraMatchSearch {modpath mod res_arrname} {

tcl/modspec.tcl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,9 +1312,10 @@ proc parseModuleSpecificationProcAdvVersSpec {mlspec nonamespec xtspec\
13121312
# match
13131313
set xtelt_valid_list [list always-load append-path chdir complete conflict\
13141314
depends-on depends-on-any envvar family incompat load load-any\
1315-
prepend-path prereq prereq-all prereq-any pushenv remove-path require\
1316-
set-alias set-function setenv switch switch-on switch-off tag try-load\
1317-
uncomplete unload unset-alias unset-function unsetenv use variant]
1315+
prepend-path prereq prereq-all prereq-any provide provided-alias\
1316+
pushenv remove-path require set-alias set-function setenv switch\
1317+
switch-on switch-off tag try-load uncomplete unload unset-alias\
1318+
unset-function unsetenv use variant]
13181319
set xtelt_modspec_list [list always-load conflict depends-on\
13191320
depends-on-any incompat load load-any prereq prereq-all prereq-any\
13201321
require switch switch-on switch-off try-load unload]

0 commit comments

Comments
 (0)