makelinux.zsh: Add compiler selection options

I add an easy way to select between gcc and clang. Additionally, I add
an option to cross-compile for arm64 architectures.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Anna Schumaker 2023-04-04 10:29:19 -04:00
parent 87d2a308c3
commit d080c04a5d
2 changed files with 26 additions and 3 deletions

View File

@ -1,7 +1,11 @@
#compdef makelinux.zsh
function _makelinux.zsh() {
_arguments '*: :_make'
_arguments \
--clang'[compile using clang]' \
--gcc'[compile using gcc]' \
--arm64'[cross-compile for arm64]' \
'*: :_make'
}
_makelinux.zsh "$@"

View File

@ -1,11 +1,30 @@
#!/bin/zsh
set -eo pipefail
let jobs=$(nproc)-2
ARCH=$(uname -m)
CROSS_COMPILE=
CC=
OPTS=(--clang)
zparseopts -D -K -clang+=OPTS -gcc+=OPTS -arm64+=OPTS
case ${OPTS[-1]} in
--clang) CC=clang ;;
--gcc) CC=gcc ;;
--arm64) ARCH=arm64
CC=gcc
CROSS_COMPILE=aarch64-linux-gnu-
;;
esac
if [ -f .git/config ] && [ -f .git/HEAD ]; then
REV=$(git rev-parse --short HEAD)$(git diff --quiet || echo "-dirty")
scripts/config --set-str CONFIG_LOCALVERSION "-g$REV"
fi
make -j$jobs $* | python /home/anna/bin/colors/make.py
make -j$jobs CC=$CC ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $* | python -u /home/anna/bin/colors/make.py
if [[ "$CC" == "clang" ]]; then
scripts/clang-tools/gen_compile_commands.py &
fi