diff --git a/scripts/build.sh b/scripts/build.sh index e166ddf..2c713f1 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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 ../../ diff --git a/scripts/setup.sh b/scripts/setup.sh index 4d8a011..33f9f24 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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 ../../