mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Meta: Automatically pick an appropriate GCC binary
This commit is contained in:
parent
1e5c2c6231
commit
9780cdfb33
Notes:
sideshowbarker
2024-07-18 09:23:00 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/9780cdfb339 Pull-request: https://github.com/SerenityOS/serenity/pull/8594 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/nico
@ -107,8 +107,36 @@ create_build_dir() {
|
||||
cmake -GNinja "${CMAKE_ARGS[@]}" -S . -B "$BUILD_DIR"
|
||||
}
|
||||
|
||||
pick_gcc() {
|
||||
local BEST_VERSION=0
|
||||
local BEST_GCC_CANDIDATE=""
|
||||
for GCC_CANDIDATE in gcc gcc-10 gcc-11 gcc-12 /usr/local/bin/gcc-11 /opt/homebrew/bin/gcc-11; do
|
||||
if ! command -v $GCC_CANDIDATE >/dev/null 2>&1; then
|
||||
continue
|
||||
fi
|
||||
if $GCC_CANDIDATE --version 2>&1 | grep "Apple clang" >/dev/null; then
|
||||
continue
|
||||
fi
|
||||
if ! $GCC_CANDIDATE -dumpversion >/dev/null 2>&1; then
|
||||
continue
|
||||
fi
|
||||
local VERSION="$($GCC_CANDIDATE -dumpversion)"
|
||||
local MAJOR_VERSION="${VERSION%%.*}"
|
||||
if [ "$MAJOR_VERSION" -gt "$BEST_VERSION" ]; then
|
||||
BEST_VERSION=$MAJOR_VERSION
|
||||
BEST_GCC_CANDIDATE="$GCC_CANDIDATE"
|
||||
fi
|
||||
done
|
||||
CMAKE_ARGS+=("-DCMAKE_C_COMPILER=$BEST_GCC_CANDIDATE")
|
||||
CMAKE_ARGS+=("-DCMAKE_CXX_COMPILER=${BEST_GCC_CANDIDATE/gcc/g++}")
|
||||
if [ "$BEST_VERSION" -lt 10 ]; then
|
||||
die "Please make sure that GCC version 10.2 or higher is installed."
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_with_target() {
|
||||
is_valid_target || ( >&2 echo "Unknown target: $TARGET"; usage )
|
||||
pick_gcc
|
||||
|
||||
if [ ! -d "$SERENITY_SOURCE_DIR" ]; then
|
||||
SERENITY_SOURCE_DIR="$(get_top_dir)"
|
||||
|
Loading…
Reference in New Issue
Block a user