File: modulerc.select_compiler_family

package info (click to toggle)
modules 5.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,996 kB
  • sloc: exp: 79,667; sh: 6,142; tcl: 5,895; makefile: 1,478; ansic: 474; python: 272; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (58 lines) | stat: -rw-r--r-- 2,303 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#%Module
# Choose compiler family
#
# This check if any compiler was previously "module loaded", or if no compiler
# previously loaded, will use the default compiler.  Either way, it will check
# if there is a subdirectory matching the compiler family name, and if so
# will default to that.
#
# If no subdirectory matching compiler family name is found, we just return
# without defaulting.  The modulecmd will default based on its internal rules,
# and it is up to the resulting module file to either load an appropriate
# compiler if no compiler is loaded or to abort with appropriate error
# messages if it wants an incompatible compiler.
#
# Usage:
# In most cases, can simply symlink .modulerc to this file
#
# In more complicated cases, .modulerc can source this file, and can
# then test the variable _did_default, which will be true if we set
# a default for modules for the next level, or false otherwise (in which
# case your .modulerc can set one)

# Source some required Tcl procedures here.  Hack for cookbook
# making use of environment variable for location.
# In production, this should ideally be in a site config file.
# At minimum, hardcode the path
set rootdir $::env(MOD_GIT_ROOTDIR)
set tcllibdir $rootdir/doc/example/compiler-etc-dependencies/tcllib
source $tcllibdir/common_utilities.tcl

set moduledir [file dirname $ModulesCurrentModulefile]
set baseComponent [ file tail $moduledir ]

# Get the currently loaded compiler, or default comp.  Don't module load/prereq it
set fullCompilerTag [ GetLoadedCompiler 1 1 ]
set tmpCompTag [ GetPackageFamilyVersion $fullCompilerTag ]
set compilerFamily [ lindex $tmpCompTag 0 ]
set compFamList "$compilerFamily"

# Allow either gnu or gcc for GCC compilers
if { $compilerFamily eq {gcc} || $compilerFamily  eq {gnu} } {
   set compFamList "gnu gcc"
}

# _did_default will be true if we actually default something
# Useful in case a .modulerc sources us, and wants to set a default if we
# did not
set _did_default false

if { $compilerFamily ne {} } {
   # Default to the family of currently loaded compiler
   set firstChild [ FirstChildModuleInList $compFamList ]
   if { $firstChild ne {} } {
      # Compiler family found, so default to it
      module-version $baseComponent/$firstChild default
      set _did_default true
   }
}