Simplify Scripts

This commit is contained in:
TheBrokenRail 2023-12-26 17:45:53 -05:00
parent 5f8c700081
commit 631cbc07d0
2 changed files with 67 additions and 80 deletions

View File

@ -2,42 +2,35 @@
set -e
# Build
build() {
# Use Build Dir
if [ ! -f "build/${MODE}-${ARCH}/arm/build.ninja" ] || [ ! -f "build/${MODE}-${ARCH}/native/build.ninja" ]; then
# Run CMake
./scripts/setup.sh "${MODE}" "${ARCH}"
fi
cd "build/${MODE}-${ARCH}"
# Create Prefix
if [ -z "${DESTDIR+x}" ]; then
export DESTDIR="$(cd ../../; pwd)/out/${MODE}-${ARCH}"
rm -rf "${DESTDIR}"
mkdir -p "${DESTDIR}"
fi
# Build ARM Components
cd arm
cmake --build .
cmake --install .
cd ../
# Build Native Components
cd native
cmake --build .
cmake --install .
cd ../
# Exit
cd ../../
}
# Variables
MODE="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')"
shift 2
# Build
build "${MODE}" "${ARCH}"
# Run CMake If Needed
if [ ! -f "build/${MODE}-${ARCH}/arm/build.ninja" ] || [ ! -f "build/${MODE}-${ARCH}/native/build.ninja" ]; then
./scripts/setup.sh "${MODE}" "${ARCH}"
fi
# Use Build Dir
cd "build/${MODE}-${ARCH}"
# Create Prefix
if [ -z "${DESTDIR+x}" ]; then
export DESTDIR="$(cd ../../; pwd)/out/${MODE}-${ARCH}"
rm -rf "${DESTDIR}"
mkdir -p "${DESTDIR}"
fi
# Build ARM Components
cd arm
cmake --build .
cmake --install .
cd ../
# Build Native Components
cd native
cmake --build .
cmake --install .
cd ../
# Exit
cd ../../

View File

@ -5,49 +5,6 @@ set -e
# ARM Toolchain File
ARM_TOOLCHAIN_FILE="$(pwd)/cmake/toolchain/armhf-toolchain.cmake"
# Setup
setup() {
# Find Toolchain
toolchain_file="$(pwd)/cmake/toolchain/${ARCH}-toolchain.cmake"
if [ ! -f "${toolchain_file}" ]; then
echo "Invalid Architecture: ${ARCH}" > /dev/stderr
exit 1
fi
# Create Build Dir
rm -rf "build/${MODE}-${ARCH}"
mkdir -p "build/${MODE}-${ARCH}"
cd "build/${MODE}-${ARCH}"
# Server Build
server_mode='OFF'
if [ "${MODE}" = "server" ]; then
server_mode='ON'
fi
# Mixed Build
mixed_build='ON'
if [ "${ARCH}" = "armhf" ]; then
mixed_build='OFF'
fi
# Extra Flags
extra_flags="-DMCPI_IS_MIXED_BUILD=${mixed_build} -DMCPI_SERVER_MODE=${server_mode}"
# Build ARM Components
mkdir arm
cd arm
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="${ARM_TOOLCHAIN_FILE}" -DMCPI_BUILD_MODE=arm ${extra_flags} "$@" ../../..
cd ../
# Build Native Components
mkdir native
cd native
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DMCPI_BUILD_MODE=native ${extra_flags} "$@" ../../..
cd ../
# Exit
cd ../../
}
# Variables
MODE="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')"
@ -59,5 +16,42 @@ if [ "${MODE}" != "client" ] && [ "${MODE}" != "server" ]; then
exit 1
fi
# Setup
setup "$@"
# Find Toolchain
toolchain_file="$(pwd)/cmake/toolchain/${ARCH}-toolchain.cmake"
if [ ! -f "${toolchain_file}" ]; then
echo "Invalid Architecture: ${ARCH}" > /dev/stderr
exit 1
fi
# Create Build Dir
rm -rf "build/${MODE}-${ARCH}"
mkdir -p "build/${MODE}-${ARCH}"
cd "build/${MODE}-${ARCH}"
# Server Build
server_mode='OFF'
if [ "${MODE}" = "server" ]; then
server_mode='ON'
fi
# Mixed Build
mixed_build='ON'
if [ "${ARCH}" = "armhf" ]; then
mixed_build='OFF'
fi
# Extra Flags
extra_flags="-DMCPI_IS_MIXED_BUILD=${mixed_build} -DMCPI_SERVER_MODE=${server_mode}"
# Build ARM Components
mkdir arm
cd arm
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE="${ARM_TOOLCHAIN_FILE}" -DMCPI_BUILD_MODE=arm ${extra_flags} "$@" ../../..
cd ../
# Build Native Components
mkdir native
cd native
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DMCPI_BUILD_MODE=native ${extra_flags} "$@" ../../..
cd ../
# Exit
cd ../../