You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

78 lines
2.6 KiB

# Builds fat lib for macOS (ARM64 & x86_64).
# Pass PREFIX as argument. If not passed, "local/" is used as deafult. Config can also be passed.
# Sample:
# `sh build-pEpEngine-macOS.sh $MyPREFIX [RELEASE|DEBUG]
# Exit on errors
set -e
SCRIPT_DIR=$(dirname "$0")
PREFIX=$1
CONFIG=$2
if [ "${CONFIG}" = "" ]; then
CONFIG="RELEASE"
fi
VERSION=$(sh "${SCRIPT_DIR}/get-pEp-version.sh" "PEP_ENGINE_VERSION")
# Get Absolute Paths & Setup
pushd "${SCRIPT_DIR}"
SCRIPT_DIR=$(pwd)
popd
if [ "${PREFIX}" = "" ]; then
PREFIX="${SCRIPT_DIR}/local"
fi
mkdir -p "${PREFIX}"
pushd "${PREFIX}"
PREFIX=$(pwd)
popd
PARENT_DIR="${SCRIPT_DIR}/.."
if [ -f "${PREFIX}/lib/libpEpEngine.a" ]; then
echo "lib exists already in ${PREFIX}/lib. If you want to rebuild it, delete the existing one."
exit 0
fi
# libpEpEngine
pushd "${PARENT_DIR}"
PEP_ENGINE_DIR="${PARENT_DIR}/pEpEngine"
if [ ! -d "${PEP_ENGINE_DIR}" ]; then
git clone -b "${VERSION}" https://gitea.pep.foundation/buff/pEpEngine
fi
SQLITE3_DIR="${PARENT_DIR}/sqlite"
if [ ! -d "${SQLITE3_DIR}" ]; then
git clone -b "master" https://pep-security.lu/gitlab/misc/sqlite.git
# build with Engine Xcode project
fi
PEP_TRANSPORT_DIR="${PARENT_DIR}/libpEpTransport"
if [ ! -d "${PEP_TRANSPORT_DIR}" ]; then
git clone -b "master" https://gitea.pep.foundation/pEp.foundation/libpEpTransport.git
# build with Engine Xcode project
fi
LIBETPAN_DIR="${PARENT_DIR}/libetpan"
if [ ! -d "${LIBETPAN_DIR}" ]; then
# git clone -b "master" https://gitea.pep.foundation/pep.foundation/libetpan.git
git clone -b "master" https://gitea.pep.foundation/buff/libetpan.git
# build with Engine Xcode project
fi
XCODE_PROJECT_DIR="${PEP_ENGINE_DIR}/build-mac"
pushd ${XCODE_PROJECT_DIR}
xcodebuild -project "pEpEngine.xcodeproj" -scheme "pEpEngine_macOS" -configuration ${CONFIG}
popd
# Copy Artefacts
cp "${XCODE_PROJECT_DIR}/build/libpEpEngine.a" "${PREFIX}/lib/libpEpEngine.a"
cp "${XCODE_PROJECT_DIR}/Subprojects/pEpASN1/build/libpEpASN1_macOS.a" "${PREFIX}/lib/libasn1.a"
cp "${XCODE_PROJECT_DIR}/Subprojects/PEPSQLITE3/build/libPEPSQLITE3_macOS.a" "${PREFIX}/lib/libsqlite3.a"
cp "${PARENT_DIR}/libetpan/build-mac/build/libetpan.a" "${PREFIX}/lib"
# Copy Headers
cp -r "${XCODE_PROJECT_DIR}/build/include"/* "${PREFIX}/include"
cp -r "${XCODE_PROJECT_DIR}/Subprojects/pEpASN1/build/include"/* "${PREFIX}/include"
cp -r "${XCODE_PROJECT_DIR}/Subprojects/PEPSQLITE3/build/include"/* "${PREFIX}/include"
popd
# Cleanup
export MACOSX_DEPLOYMENT_TARGET=10.10