Skip to content

Commit 7f035c3

Browse files
[ATfL] Support bash autocompletion and lmod (arm#200)
It's a cherry-pick from the arm-software branch. Fixes the initial lmod support and extends bash autocompletion to the arm?lang* commands when the mkmodulesdirs.sh script is run. Co-authored-by: Gary Carroll <[email protected]>
1 parent f117e84 commit 7f035c3

File tree

2 files changed

+8
-42
lines changed

2 files changed

+8
-42
lines changed

arm-software/linux/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ package() {
415415
echo "-frtlib-add-rpath @atfl-performance.cfg" > clang++.cfg
416416
echo "-frtlib-add-rpath @atfl-performance.cfg" > flang.cfg
417417
cd -
418+
echo "complete -F _clang armclang" >> ${ATFL_DIR}/share/clang/bash-autocomplete.sh
419+
echo "complete -F _clang armclang++" >> ${ATFL_DIR}/share/clang/bash-autocomplete.sh
420+
echo "complete -F _clang armflang" >> ${ATFL_DIR}/share/clang/bash-autocomplete.sh
418421
run_command tar --owner=root --group=root -czf "$OUTPUT_DIR/$TAR_NAME" -C "$BUILD_DIR" atfl |
419422
tee "${LOGS_DIR}/package.txt"
420423
}

arm-software/linux/mkmoduledirs.sh.var

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,6 @@ ATFL_VERSION="%ATFL_VERSION%"
44
ATFL_BUILD="%ATFL_BUILD%"
55
ATFL_INSTALL_PREFIX="%ATFL_INSTALL_PREFIX%"
66

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-
427
mkdir -p "modulefiles/atfl"
438
(
449
cat <<EOT
@@ -106,18 +71,16 @@ set package_prefix \$install_prefix
10671
append-path LIBRARY_PATH \$package_prefix/lib/aarch64-unknown-linux-gnu
10772
prepend-path MANPATH \$package_prefix/share/man
10873
109-
if { [is-lmod] } {
110-
# Lmod family
111-
# When this modulefile is used with lmod, This ensures only one compiler is loaded at once
112-
family "compiler"
113-
}
114-
11574
# Source the bash-autocomplete.sh
11675
set SHELL [module-info shell]
11776
switch -- \$SHELL {
11877
{sh} - {bash} {
11978
if { [is-lmod] } {
120-
module load clang-autocomplete/${ATFL_VERSION}
79+
local autocomplete_file = pathJoin(package_prefix, "/share/clang/bash-autocomplete.sh")
80+
execute{cmd="source " .. autocomplete_file, modeA={"load"}}
81+
## Lmod can't figure out how to unsource files without help, so we undo it here
82+
execute{cmd="complete -r armclang armflang armclang++", modeA={"unload"}}
83+
execute{cmd="unset -f _clang", modeA={"unload"}}
12184
} else {
12285
set autocomplete_file \$package_prefix/share/clang/bash-autocomplete.sh
12386
if { [file exists \$autocomplete_file] } {

0 commit comments

Comments
 (0)