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.
 
 

46 lines
1.3 KiB

# Builds fat lib for macOS (ARM64 & x86_64).
# Pass PREFIX as argument. If not passed, "local/" is used as deafult.
# Exit on errors
set -e
SCRIPT_DIR=$(dirname "$0")
LIB_NAME=$1
PREFIX=$2
# Get Absolute Paths
pushd "${SCRIPT_DIR}"
SCRIPT_DIR=$(pwd)
popd
mkdir -p "${PREFIX}"
pushd "${PREFIX}"
PREFIX=$(pwd)
popd
GENERATED_SCRIPT="${SCRIPT_DIR}/generated.sh"
exitAndPrintHelp()
{
echo "Must be called passing \`LIB_NAME`\` (mandatory). \`PREFIX\` can also be passed (optional).\nSample:\n\`generate_and_run_mac_dependency_build_script \$LIB_NAME\`\n`generate_and_run_mac_dependency_build_script \$LIB_NAME \$PREFIX\`"
exit 1
}
if [ "${LIB_NAME}" = "" ]; then
exitAndPrintHelp
fi
# Say Hello
echo "#####################################################"
echo "#Generating buildscript for ${LIB_NAME}"
echo "#####################################################"
# Generate Actual Script
BUILD_CODE_FILE="${SCRIPT_DIR}/buildcode/${LIB_NAME}.code"
BUILD_SCRIPT_TEMPLATE_FILE="${SCRIPT_DIR}/build-macos_dependency.template"
SEARCH_STRING="BUILD_CODE"
#Replaces ${SEARCH_STRING} in file ${BUILD_SCRIPT_TEMPLATE_FILE} with content of ${BUILD_CODE_FILE}
/opt/local/bin/gsed -e "/${SEARCH_STRING}/r ${BUILD_CODE_FILE}" -e "/${SEARCH_STRING}/d" ${BUILD_SCRIPT_TEMPLATE_FILE} > "${GENERATED_SCRIPT}"
sh ${GENERATED_SCRIPT} ${PREFIX}
# Cleanup
rm -rf "${TMP_DIR}"