2022-03-06 20:53:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# ARM Toolchain File
|
2022-07-07 04:37:53 +00:00
|
|
|
ARM_TOOLCHAIN_FILE="$(pwd)/cmake/toolchain/armhf-toolchain.cmake"
|
2022-03-06 20:53:27 +00:00
|
|
|
|
|
|
|
# Setup
|
|
|
|
setup() {
|
|
|
|
# Find Toolchain
|
2023-11-24 23:37:08 +00:00
|
|
|
toolchain_file="$(pwd)/cmake/toolchain/${ARCH}-toolchain.cmake"
|
2022-03-06 20:53:27 +00:00
|
|
|
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}"
|
|
|
|
|
2022-07-02 22:14:23 +00:00
|
|
|
# Server Build
|
2023-11-24 23:37:08 +00:00
|
|
|
server_mode='OFF'
|
2022-03-06 20:53:27 +00:00
|
|
|
if [ "${MODE}" = "server" ]; then
|
2022-05-05 00:47:15 +00:00
|
|
|
server_mode='ON'
|
2022-03-06 20:53:27 +00:00
|
|
|
fi
|
2022-07-02 22:14:23 +00:00
|
|
|
# Mixed Build
|
2023-11-24 23:37:08 +00:00
|
|
|
mixed_build='ON'
|
2022-07-02 22:14:23 +00:00
|
|
|
if [ "${ARCH}" = "armhf" ]; then
|
|
|
|
mixed_build='OFF'
|
|
|
|
fi
|
2023-11-24 23:37:08 +00:00
|
|
|
# Extra Flags
|
|
|
|
extra_flags="-DMCPI_IS_MIXED_BUILD=${mixed_build} -DMCPI_SERVER_MODE=${server_mode}"
|
2022-07-02 22:14:23 +00:00
|
|
|
|
2022-03-06 20:53:27 +00:00
|
|
|
# Build ARM Components
|
|
|
|
mkdir arm
|
|
|
|
cd arm
|
2023-11-24 23:37:08 +00:00
|
|
|
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="${ARM_TOOLCHAIN_FILE}" -DMCPI_BUILD_MODE=arm ${extra_flags} "$@" ../../..
|
2022-03-06 20:53:27 +00:00
|
|
|
cd ../
|
|
|
|
|
|
|
|
# Build Native Components
|
|
|
|
mkdir native
|
|
|
|
cd native
|
2023-11-24 23:37:08 +00:00
|
|
|
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DMCPI_BUILD_MODE=native ${extra_flags} "$@" ../../..
|
2022-03-06 20:53:27 +00:00
|
|
|
cd ../
|
|
|
|
|
|
|
|
# Exit
|
|
|
|
cd ../../
|
|
|
|
}
|
|
|
|
|
|
|
|
# Variables
|
2023-11-24 23:37:08 +00:00
|
|
|
MODE="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
|
|
|
|
ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')"
|
2022-03-06 20:53:27 +00:00
|
|
|
shift 2
|
|
|
|
|
|
|
|
# Verify Mode
|
|
|
|
if [ "${MODE}" != "client" ] && [ "${MODE}" != "server" ]; then
|
|
|
|
echo "Invalid Mode: ${MODE}" > /dev/stderr
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup
|
2022-07-02 22:14:23 +00:00
|
|
|
setup "$@"
|