mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Toolchain+Meta: Add script to build CMake from source
Since we upstreamed CMake support for Serenity, we can use the Platform files from upstream instead of keeping our local copy. While not added in this commit, we can add patching capabilities for the platform files similar to what we do for gdb, llvm, gcc, and binutils later.
This commit is contained in:
parent
8855334fcc
commit
e4a59f664b
Notes:
sideshowbarker
2024-07-18 04:46:35 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/e4a59f664b Pull-request: https://github.com/SerenityOS/serenity/pull/16421 Reviewed-by: https://github.com/timschumi
2 changed files with 67 additions and 0 deletions
6
Meta/CMake/cmake-version.cmake
Normal file
6
Meta/CMake/cmake-version.cmake
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Note: Update this alongside Toolchain/BuildCMake.sh
|
||||
set(version_ok 0)
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.25.1)
|
||||
set(version_ok 1)
|
||||
endif()
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "${version_ok}")
|
61
Toolchain/BuildCMake.sh
Executable file
61
Toolchain/BuildCMake.sh
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script builds the CMake build system
|
||||
set -e
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
PREFIX_DIR="$DIR/Local/cmake"
|
||||
BUILD_DIR="$DIR/Build/cmake"
|
||||
TARBALLS_DIR="$DIR/Tarballs"
|
||||
|
||||
NPROC="nproc"
|
||||
SYSTEM_NAME="$(uname -s)"
|
||||
|
||||
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
|
||||
NPROC="sysctl -n hw.ncpuonline"
|
||||
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
|
||||
NPROC="sysctl -n hw.ncpu"
|
||||
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
|
||||
NPROC="sysctl -n hw.ncpu"
|
||||
fi
|
||||
|
||||
[ -z "$MAKEJOBS" ] && MAKEJOBS=$($NPROC)
|
||||
|
||||
# Note: Update this alongside Meta/CMake/cmake-version.cmake
|
||||
CMAKE_VERSION=3.25.1
|
||||
CMAKE_ARCHIVE_SHA256=1c511d09516af493694ed9baf13c55947a36389674d657a2d5e0ccedc6b291d8
|
||||
CMAKE_ARCHIVE=cmake-${CMAKE_VERSION}.tar.gz
|
||||
CMAKE_ARCHIVE_URL=https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_ARCHIVE}
|
||||
|
||||
mkdir -p "$DIR"/Tarballs
|
||||
pushd "$DIR"/Tarballs
|
||||
if [ ! -e "${CMAKE_ARCHIVE}" ]; then
|
||||
echo "Downloading CMake from ${CMAKE_ARCHIVE_URL}..."
|
||||
curl "${CMAKE_ARCHIVE_URL}" -L -o "${CMAKE_ARCHIVE}"
|
||||
else
|
||||
echo "${CMAKE_ARCHIVE} already exists, not downloading archive"
|
||||
fi
|
||||
|
||||
if ! sha256sum --status -c <(echo "${CMAKE_ARCHIVE_SHA256}" "${CMAKE_ARCHIVE}"); then
|
||||
echo "CMake archive SHA256 sum mismatch, please run script again"
|
||||
rm -f "${CMAKE_ARCHIVE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "cmake-${CMAKE_VERSION}" ]; then
|
||||
echo "Extracting ${CMAKE_ARCHIVE}..."
|
||||
tar -xf "${CMAKE_ARCHIVE}"
|
||||
else
|
||||
echo "cmake-${CMAKE_VERSION} already exists, not extracting archive"
|
||||
fi
|
||||
popd
|
||||
|
||||
mkdir -p "${PREFIX_DIR}"
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
pushd "${BUILD_DIR}"
|
||||
"${TARBALLS_DIR}"/cmake-"${CMAKE_VERSION}"/bootstrap --prefix="${PREFIX_DIR}" --parallel="${MAKEJOBS}"
|
||||
make -j "${MAKEJOBS}"
|
||||
make install
|
||||
popd
|
Loading…
Reference in a new issue