|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +ATFL_VERSION="%ATFL_VERSION%" |
| 4 | +ATFL_BUILD="%ATFL_BUILD%" |
| 5 | +ATFL_INSTALL_PREFIX="%ATFL_INSTALL_PREFIX%" |
| 6 | + |
| 7 | +mkdir -p "moduledeps/atfl/${ATFL_VERSION}/clang-autocomplete" |
| 8 | +( |
| 9 | +cat <<EOT |
| 10 | +---------------------------------------------------------------- |
| 11 | +-- |
| 12 | +-- clang-autocomplete |
| 13 | +-- |
| 14 | +-- |
| 15 | +-- Copyright 2015-2025 Arm Limited. All rights reserved. |
| 16 | +-- |
| 17 | +
|
| 18 | +--------------------------------------------------------------------------- |
| 19 | +-- Variable definitions -- |
| 20 | +--------------------------------------------------------------------------- |
| 21 | +
|
| 22 | +-- Base install directory of ATfL |
| 23 | +local install_prefix = "${ATFL_INSTALL_PREFIX}" |
| 24 | +
|
| 25 | +--------------------------------------------------------------------------- |
| 26 | +-- Main section -- |
| 27 | +--------------------------------------------------------------------------- |
| 28 | +
|
| 29 | +-- Install directory of this package |
| 30 | +local package_prefix = pathJoin(install_prefix, "") |
| 31 | +
|
| 32 | +local autocomplete_file = pathJoin(package_prefix, "/share/clang/bash-autocomplete.sh") |
| 33 | +
|
| 34 | +execute{cmd="source " .. autocomplete_file, modeA={"load"}} |
| 35 | +
|
| 36 | +-- Lmod can't figure out how to unsource files without help, so we undo it here |
| 37 | +execute{cmd="complete -r armclang armflang armclang++", modeA={"unload"}} |
| 38 | +execute{cmd="unset -f _clang", modeA={"unload"}} |
| 39 | +EOT |
| 40 | +) > "moduledeps/atfl/${ATFL_VERSION}/clang-autocomplete/${ATFL_VERSION}.lua" |
| 41 | + |
| 42 | +mkdir -p "modulefiles/atfl" |
| 43 | +( |
| 44 | +cat <<EOT |
| 45 | +#%Module1.0################################################################ |
| 46 | +## |
| 47 | +## ATfL |
| 48 | +## |
| 49 | +## |
| 50 | +## Copyright 2015-2025 Arm Limited. All rights reserved. |
| 51 | +## |
| 52 | +
|
| 53 | +########################################################################### |
| 54 | +# Module description # |
| 55 | +########################################################################### |
| 56 | +
|
| 57 | +proc ModulesHelp { } { |
| 58 | + puts stderr " " |
| 59 | + puts stderr "This module loads the ATfL toolchain." |
| 60 | + puts stderr "\nVersion ${ATFL_VERSION}\n" |
| 61 | +} |
| 62 | +
|
| 63 | +module-whatis "Name: ATfL" |
| 64 | +module-whatis "Version: ${ATFL_VERSION}" |
| 65 | +module-whatis "Category: compiler, runtime support" |
| 66 | +module-whatis "Description: This module loads the ATfL toolchain, providing armclang, armclang++, and armflang." |
| 67 | +
|
| 68 | +########################################################################### |
| 69 | +# Variable definitions # |
| 70 | +########################################################################### |
| 71 | +
|
| 72 | +# Base install directory of ATfL |
| 73 | +set install_prefix ${ATFL_INSTALL_PREFIX} |
| 74 | +
|
| 75 | +# Base module directory of ATfL |
| 76 | +# This is worked out dynamically so that the modulefiles can be moved |
| 77 | +# from the install directory |
| 78 | +set module_prefix [file dirname \$ModulesCurrentModulefile]/../.. |
| 79 | +
|
| 80 | +# Base directory of all dependant modules |
| 81 | +set moduledeps \$module_prefix/moduledeps |
| 82 | +
|
| 83 | +########################################################################### |
| 84 | +# Main section # |
| 85 | +########################################################################### |
| 86 | +# Pull in some utility functions |
| 87 | +source \$module_prefix/moduleglobals/compiler_functions/${ATFL_VERSION} |
| 88 | +
|
| 89 | +# Install directory of this package |
| 90 | +set package_prefix \$install_prefix |
| 91 | +
|
| 92 | +# Arm-specific environment variables |
| 93 | + setenv ARM_LINUX_COMPILER_DIR \$package_prefix |
| 94 | + setenv ARM_LINUX_COMPILER_BUILD ${ATFL_BUILD} |
| 95 | +
|
| 96 | +# Standard environment variables |
| 97 | + prepend-path PATH \$package_prefix/bin |
| 98 | + prepend-path CPATH \$package_prefix/include |
| 99 | + prepend-path LIBRARY_PATH \$package_prefix/lib |
| 100 | + append-path LIBRARY_PATH \$package_prefix/lib/aarch64-unknown-linux-gnu |
| 101 | + prepend-path MANPATH \$package_prefix/share/man |
| 102 | +
|
| 103 | +# Make dependant modules available |
| 104 | +prepend-path MODULEPATH \$moduledeps/atfl/${ATFL_VERSION} |
| 105 | +
|
| 106 | +if { [is-lmod] } { |
| 107 | + # Lmod family |
| 108 | + # When this modulefile is used with lmod, This ensures only one compiler is loaded at once |
| 109 | + family "compiler" |
| 110 | +} |
| 111 | +
|
| 112 | +# Source the bash-autocomplete.sh |
| 113 | +set SHELL [module-info shell] |
| 114 | +switch -- \$SHELL { |
| 115 | + {sh} - {bash} { |
| 116 | + if { [is-lmod] } { |
| 117 | + module load clang-autocomplete/${ATFL_VERSION} |
| 118 | + } else { |
| 119 | + set autocomplete_file \$package_prefix/share/clang/bash-autocomplete.sh |
| 120 | + if { [file exists \$autocomplete_file] } { |
| 121 | + puts "source \$autocomplete_file" |
| 122 | + } |
| 123 | + } |
| 124 | + } |
| 125 | +} |
| 126 | +EOT |
| 127 | +) > "modulefiles/atfl/${ATFL_VERSION}" |
| 128 | + |
| 129 | +mkdir -p "moduleglobals/compiler_functions" |
| 130 | +( |
| 131 | +cat <<EOT |
| 132 | +#%Module1.0################################################################ |
| 133 | +## |
| 134 | +## Utility functions for Arm modulefiles |
| 135 | +## |
| 136 | +## |
| 137 | +## Copyright 2015-2025 Arm Limited. All rights reserved. |
| 138 | +## |
| 139 | +
|
| 140 | +# Helper function, to load/unload a set of prerequisite modules |
| 141 | +proc depends-on {dependencies} { |
| 142 | + foreach dep \$dependencies { |
| 143 | + if { [module-info mode load] } { |
| 144 | + # This will load the module if it has not already been loaded |
| 145 | + # is-loaded only triggers on a mode load, so it would not allow an auto-unload |
| 146 | + if { ! [is-loaded \$dep] } { |
| 147 | + module load \$dep |
| 148 | + } |
| 149 | + } |
| 150 | + } |
| 151 | +} |
| 152 | +
|
| 153 | +proc is-lmod {} { |
| 154 | + global env |
| 155 | + if { [info exists env(LMOD_VERSION_MAJOR)] } { |
| 156 | + return true |
| 157 | + } |
| 158 | + return false |
| 159 | +} |
| 160 | +EOT |
| 161 | +) > "moduleglobals/compiler_functions/${ATFL_VERSION}" |
0 commit comments