Debian Codegraph @

doc/example/compiler-etc-dependencies/modulerc3/foo/.modulerc

raw
1 #%Module
2 # Choose compiler family
3 #
4 # This check if any compiler was previously "module loaded", or if no compiler
5 # previously loaded, will use the default compiler. Either way, it will check
6 # if there is a subdirectory matching the compiler family name, and if so
7 # will default to that.
8 #
9 # If no subdirectory matching compiler family name is found, we just return
10 # without defaulting. The modulecmd will default based on its internal rules,
11 # and it is up to the resulting module file to either load an appropriate
12 # compiler if no compiler is loaded or to abort with appropriate error
13 # messages if it wants an incompatible compiler.
14 #
15 # Usage:
16 # In most cases, can simply symlink .modulerc to this file
17 #
18 # In more complicated cases, .modulerc can source this file, and can
19 # then test the variable _did_default, which will be true if we set
20 # a default for modules for the next level, or false otherwise (in which
21 # case your .modulerc can set one)
22
23 # Source some required Tcl procedures here. Hack for cookbook
24 # making use of environment variable for location.
25 # In production, this should ideally be in a site config file.
26 # At minimum, hardcode the path
27 set rootdir $::env(MOD_GIT_ROOTDIR)
28 set tcllibdir $rootdir/doc/example/compiler-etc-dependencies/tcllib
29 source $tcllibdir/common_utilities.tcl
30
31 set moduledir [file dirname $ModulesCurrentModulefile]
32 set baseComponent [ file tail $moduledir ]
33
34 # Get the currently loaded compiler, or default comp. Don't module load/prereq it
35 set fullCompilerTag [ GetLoadedCompiler 1 1 ]
36 set tmpCompTag [ GetPackageFamilyVersion $fullCompilerTag ]
37 set compilerFamily [ lindex $tmpCompTag 0 ]
38 set compFamList "$compilerFamily"
39
40 # Allow either gnu or gcc for GCC compilers
41 if { $compilerFamily eq {gcc} || $compilerFamily eq {gnu} } {
42 set compFamList "gnu gcc"
43 }
44
45 # _did_default will be true if we actually default something
46 # Useful in case a .modulerc sources us, and wants to set a default if we
47 # did not
48 set _did_default false
49
50 if { $compilerFamily ne {} } {
51 # Default to the family of currently loaded compiler
52 set firstChild [ FirstChildModuleInList $compFamList ]
53 if { $firstChild ne {} } {
54 # Compiler family found, so default to it
55 module-version $baseComponent/$firstChild default
56 set _did_default true
57 }
58 }