mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
Meta: Validate explicitly set TOOLCHAIN in serenity.sh
Previously, `serenity.sh rebuild-toolchain x86_64 clang` would simply start building GCC instead and call it a day. With this change, if a toolchain is passed as an argument, it is validated if it is either "GNU" or "Clang" and exits with an error otherwise. The `TOOLCHAIN` value defaults to the `SERENITY_TOOLCHAIN` environment variable if not provided explicitly.
This commit is contained in:
parent
2b764b3594
commit
b7ffb2bde7
1 changed files with 10 additions and 15 deletions
|
@ -8,7 +8,7 @@ print_help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $NAME COMMAND [TARGET] [TOOLCHAIN] [ARGS...]
|
Usage: $NAME COMMAND [TARGET] [TOOLCHAIN] [ARGS...]
|
||||||
Supported TARGETs: aarch64, i686, x86_64, lagom. Defaults to SERENITY_ARCH, or i686 if not set.
|
Supported TARGETs: aarch64, i686, x86_64, lagom. Defaults to SERENITY_ARCH, or i686 if not set.
|
||||||
Supported TOOLCHAINs: GNU, Clang. Defaults to GNU if not set.
|
Supported TOOLCHAINs: GNU, Clang. Defaults to SERENITY_TOOLCHAIN, or GNU if not set.
|
||||||
Supported COMMANDs:
|
Supported COMMANDs:
|
||||||
build: Compiles the target binaries, [ARGS...] are passed through to ninja
|
build: Compiles the target binaries, [ARGS...] are passed through to ninja
|
||||||
install: Installs the target binary
|
install: Installs the target binary
|
||||||
|
@ -92,21 +92,16 @@ CMAKE_ARGS=()
|
||||||
HOST_COMPILER=""
|
HOST_COMPILER=""
|
||||||
|
|
||||||
# Toolchain selection only applies to non-lagom targets.
|
# Toolchain selection only applies to non-lagom targets.
|
||||||
if [ "$TARGET" != "lagom" ]; then
|
if [ "$TARGET" != "lagom" ] && [ -n "$1" ]; then
|
||||||
case "$1" in
|
TOOLCHAIN_TYPE="$1"; shift
|
||||||
GNU|Clang)
|
else
|
||||||
TOOLCHAIN_TYPE="$1"; shift
|
TOOLCHAIN_TYPE="${SERENITY_TOOLCHAIN:-"GNU"}"
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ -n "$1" ]; then
|
|
||||||
echo "WARNING: unknown toolchain '$1'. Defaulting to GNU."
|
|
||||||
echo " Valid values are 'Clang', 'GNU' (default)"
|
|
||||||
fi
|
|
||||||
TOOLCHAIN_TYPE="GNU"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
CMAKE_ARGS+=( "-DSERENITY_TOOLCHAIN=$TOOLCHAIN_TYPE" )
|
|
||||||
fi
|
fi
|
||||||
|
if ! [[ "${TOOLCHAIN_TYPE}" =~ ^(GNU|Clang)$ ]]; then
|
||||||
|
>&2 echo "ERROR: unknown toolchain '${TOOLCHAIN_TYPE}'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
CMAKE_ARGS+=( "-DSERENITY_TOOLCHAIN=$TOOLCHAIN_TYPE" )
|
||||||
|
|
||||||
CMD_ARGS=( "$@" )
|
CMD_ARGS=( "$@" )
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue