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:
parent
87d2a308c3
commit
d080c04a5d
|
@ -1,7 +1,11 @@
|
||||||
#compdef makelinux.zsh
|
#compdef makelinux.zsh
|
||||||
|
|
||||||
function _makelinux.zsh() {
|
function _makelinux.zsh() {
|
||||||
_arguments '*: :_make'
|
_arguments \
|
||||||
|
--clang'[compile using clang]' \
|
||||||
|
--gcc'[compile using gcc]' \
|
||||||
|
--arm64'[cross-compile for arm64]' \
|
||||||
|
'*: :_make'
|
||||||
}
|
}
|
||||||
|
|
||||||
_makelinux.zsh "$@"
|
_makelinux.zsh "$@"
|
||||||
|
|
|
@ -1,11 +1,30 @@
|
||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
let jobs=$(nproc)-2
|
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
|
if [ -f .git/config ] && [ -f .git/HEAD ]; then
|
||||||
REV=$(git rev-parse --short HEAD)$(git diff --quiet || echo "-dirty")
|
REV=$(git rev-parse --short HEAD)$(git diff --quiet || echo "-dirty")
|
||||||
scripts/config --set-str CONFIG_LOCALVERSION "-g$REV"
|
scripts/config --set-str CONFIG_LOCALVERSION "-g$REV"
|
||||||
fi
|
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
|
||||||
|
|
Loading…
Reference in New Issue