-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
82 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# This script is used to build the project on the Ubuntu Jammy (22.04) distribution. | ||
# It is not intended to be used on other distributions, and must be run from the project root. | ||
|
||
PARALLELISM_LEVEL=4 | ||
|
||
function check_root() { | ||
# Root access is required to install the dependencies. | ||
if [ "$EUID" -ne 0 ]; then | ||
echo "Please run as root." | ||
abort | ||
fi | ||
} | ||
|
||
function check_dependencies() { | ||
for cmd in wget add-apt-repository; do | ||
if ! command -v $cmd &>/dev/null; then | ||
echo "$cmd could not be found" | ||
exit | ||
fi | ||
done | ||
} | ||
|
||
function install_dependencies() { | ||
# wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc | ||
# add-apt-repository -y "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | ||
# add-apt-repository -y ppa:ubuntu-toolchain-r/ppa | ||
apt update | ||
export NEEDRESTART_SUSPEND=1 | ||
apt install -y unzip gcc-14 g++-14 clang-18 lldb-18 lld-18 libc++-18-dev libc++abi-18-dev libllvmlibc-18-dev clang-tools-18 libgcrypt20-dev openssl libreadline8 libreadline-dev libsodium23 libsodium-dev | ||
|
||
# Install CMake 3.29.3 | ||
if dpkg -s "cmake" >/dev/null 2>&1; then | ||
apt remove -y --purge --auto-remove cmake | ||
fi | ||
|
||
wget -qO- "https://github.com/Kitware/CMake/releases/download/v3.29.3/cmake-3.29.3-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local | ||
|
||
# Install Ninja 1.12 | ||
if dpkg -s "ninja-build" >/dev/null 2>&1; then | ||
apt remove -y --purge --auto-remove ninja-build | ||
fi | ||
|
||
wget -q "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip" | ||
unzip ninja-linux.zip -d /usr/local/bin | ||
} | ||
|
||
function build_blake3() { | ||
./install-blake3.sh clang-18 | ||
} | ||
|
||
function configure_cmake() { | ||
cmake -B build -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_BUILD_TYPE=Debug -G Ninja | ||
} | ||
|
||
function build_project() { | ||
cmake --build build --config Debug -j "$PARALLELISM_LEVEL" | ||
} | ||
|
||
trap "echo 'An unexpected error occurred. Program aborted.'" ERR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,28 @@ | ||
#!/bin/env bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
# Run from this directory | ||
cd "${0%/*}" || abort | ||
|
||
# This script is used to build the project on the Ubuntu Jammy (22.04) distribution. | ||
# It is not intended to be used on other distributions, and must be run from the project root. | ||
# Include the build functions | ||
. ./build-functions.sh | ||
|
||
PARALLELISM_LEVEL=4 | ||
# Root access is required to install the dependencies. | ||
check_root | ||
|
||
function check_root() { | ||
# Root access is required to install the dependencies. | ||
if [ "$EUID" -ne 0 ]; then | ||
echo "Please run as root." | ||
abort | ||
fi | ||
} | ||
# Check for required commands | ||
check_dependencies | ||
|
||
function check_dependencies() { | ||
for cmd in wget add-apt-repository; do | ||
if ! command -v $cmd &>/dev/null; then | ||
echo "$cmd could not be found" | ||
exit | ||
fi | ||
done | ||
} | ||
# Install dependencies | ||
install_dependencies | ||
|
||
function install_dependencies() { | ||
# wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc | ||
# add-apt-repository -y "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | ||
# add-apt-repository -y ppa:ubuntu-toolchain-r/ppa | ||
apt update | ||
export NEEDRESTART_SUSPEND=1 | ||
apt install -y unzip gcc-14 g++-14 clang-18 lldb-18 lld-18 libc++-18-dev libc++abi-18-dev libllvmlibc-18-dev clang-tools-18 libgcrypt20-dev openssl libreadline8 libreadline-dev libsodium23 libsodium-dev | ||
echo "Ninja: $(ninja --version), CMake: $(cmake --version)" | ||
|
||
# Install CMake 3.29.3 | ||
if dpkg -s "cmake" >/dev/null 2>&1; then | ||
apt remove -y --purge --auto-remove cmake | ||
fi | ||
# Build and install BLAKE3 | ||
build_blake3 | ||
|
||
wget -qO- "https://github.com/Kitware/CMake/releases/download/v3.29.3/cmake-3.29.3-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local | ||
# Configure CMake | ||
cd .. || abort | ||
configure_cmake | ||
|
||
# Install Ninja 1.12 | ||
if dpkg -s "ninja-build" >/dev/null 2>&1; then | ||
apt remove -y --purge --auto-remove ninja-build | ||
fi | ||
|
||
wget -q "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip" | ||
unzip ninja-linux.zip -d /usr/local/bin | ||
} | ||
|
||
function build_blake3() { | ||
./install-blake3.sh clang-18 | ||
} | ||
|
||
function configure_cmake() { | ||
cmake -B build -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_BUILD_TYPE=Debug -G Ninja | ||
} | ||
|
||
function build_project() { | ||
cmake --build build --config Debug -j "$PARALLELISM_LEVEL" | ||
} | ||
|
||
main() { | ||
trap "echo 'An unexpected error occurred. Program aborted.'" ERR | ||
check_root | ||
check_dependencies | ||
cd "${0%/*}" || abort | ||
install_dependencies | ||
echo "Ninja: $(ninja --version), CMake: $(cmake --version)" | ||
build_blake3 | ||
cd .. || abort | ||
configure_cmake | ||
build_project | ||
} | ||
|
||
main | ||
# Build the project | ||
build_project |