Skip to content

Commit b665387

Browse files
committed
doc: desc. siteconfig hook var in MIGRATING
1 parent 60f528f commit b665387

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

.aspell.en.pws

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 857
1+
personal_ws-1.1 en 862
22
ABBRVLIST
33
ActiveTcl
44
Adrien
@@ -44,6 +44,7 @@ EnvModEscS
4444
EnvironmentModules
4545
Envmodules
4646
ErrorAndExit
47+
FIXME
4748
FOOENV
4849
FOOVERSION
4950
FirstChildModuleInList
@@ -369,6 +370,7 @@ emacs
369370
embeddable
370371
enablement
371372
env
373+
environ
372374
envml
373375
envvar
374376
envvars
@@ -568,6 +570,7 @@ msg
568570
mtreview
569571
multilib
570572
mvapich
573+
myhost
571574
mysoftware
572575
mytag
573576
myversion
@@ -604,6 +607,7 @@ optionname
604607
os
605608
osVersion
606609
othertag
610+
othervalue
607611
oxymoronic
608612
packagename
609613
parsable
@@ -847,6 +851,7 @@ whitespace
847851
wip
848852
xavier
849853
xfz
854+
xg
850855
xrdb
851856
xtrace
852857
zA

MIGRATING.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,86 @@ or all together with :subcmd:`stashclear`.
337337
:ps:`$` module stashlist
338338
No stash collection.
339339
340+
Siteconfig hook variables
341+
-------------------------
342+
343+
Several Tcl variables are introduced for :ref:`Site-specific configuration`
344+
script to define specific commands and variables in the evaluation context of
345+
modulefiles and modulercs. These commands and variables setup in
346+
:file:`siteconfig.tcl` can be used in modulefile or modulerc. Sites can easily
347+
extend modulefile and modulerc syntax with specific elements.
348+
349+
:sitevar:`modulefile_extra_cmds` variable defines a list of commands to expose
350+
in the modulefile evaluation context and the associated procedure to run when
351+
this command is called. This variable has to be defined in
352+
:file:`siteconfig.tcl` located for instance at |file etcdir_siteconfig|.
353+
354+
In the following example :sitevar:`modulefile_extra_cmds` is used to define
355+
the ``sys`` command and bound it to the ``sys`` procedure that is also defined
356+
in :file:`siteconfig.tcl`.
357+
358+
.. code-block:: tcl
359+
360+
proc sys {mode} {
361+
switch -- $mode {
362+
name { return myhost-$::tcl_platform(machine) }
363+
default { error "Unknown mode '$mode'" }
364+
}
365+
}
366+
set modulefile_extra_cmds {sys sys}
367+
368+
Once :file:`siteconfig.tcl` is setup, the ``sys`` command can be called by
369+
modulefiles. In the following example it is used to determine the application
370+
path.
371+
372+
.. parsed-literal::
373+
374+
:ps:`$` cat /path/to/modulefiles/foo/1.2
375+
#%Module
376+
append-path PATH /path/to/apps/foo-1.2/[sys name]/bin
377+
378+
:ps:`$` module show foo/1.2
379+
-------------------------------------------------------------------
380+
:sgrhi:`/path/to/modulefiles/foo/1.2`:
381+
382+
:sgrcm:`append-path` PATH /path/to/apps/foo-1.2/myhost-x86_64/bin
383+
-------------------------------------------------------------------
384+
385+
:sitevar:`modulerc_extra_cmds` follows the same approach than
386+
:sitevar:`modulefile_extra_cmds` and makes specific commands available during
387+
modulerc evaluation.
388+
389+
:sitevar:`modulefile_extra_vars` variable defines a list of variables to
390+
expose in the modulefile evaluation context and their associated value. This
391+
variable has to be defined in :file:`siteconfig.tcl`.
392+
393+
In the following example :sitevar:`modulefile_extra_vars` is used to define
394+
the ``APP_ROOT`` variable with ``/path/to/apps`` as value.
395+
396+
.. code-block:: tcl
397+
398+
set modulefile_extra_vars {APP_ROOT /path/to/apps}
399+
400+
Once :file:`siteconfig.tcl` is setup, the ``APP_ROOT`` variable can be used in
401+
modulefiles.
402+
403+
.. parsed-literal::
404+
405+
:ps:`$` cat /path/to/modulefiles/bar/2.1
406+
#%Module
407+
append-path PATH $APP_ROOT/bar-2.1/[sys name]/bin
408+
409+
:ps:`$` module show bar/2.1
410+
-------------------------------------------------------------------
411+
:sgrhi:`/path/to/modulefiles/bar/2.1`:
412+
413+
:sgrcm:`append-path` PATH /path/to/apps/bar-2.1/myhost-x86_64/bin
414+
-------------------------------------------------------------------
415+
416+
:sitevar:`modulerc_extra_vars` follows the same approach than
417+
:sitevar:`modulefile_extra_vars` and makes specific variables available during
418+
modulerc evaluation.
419+
340420

341421
v5.1
342422
====

0 commit comments

Comments
 (0)