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

  1. # Builds fat lib for macOS (ARM64 & x86_64).
  2. # Pass PREFIX as argument. If not passed, "local/" is used as deafult.
  3. # Exit on errors
  4. set -e
  5. SCRIPT_DIR=$(dirname "$0")
  6. LIB_NAME=$1
  7. PREFIX=$2
  8. # Get Absolute Paths
  9. pushd "${SCRIPT_DIR}"
  10. SCRIPT_DIR=$(pwd)
  11. popd
  12. mkdir -p "${PREFIX}"
  13. pushd "${PREFIX}"
  14. PREFIX=$(pwd)
  15. popd
  16. GENERATED_SCRIPT="${SCRIPT_DIR}/generated.sh"
  17. exitAndPrintHelp()
  18. {
  19. echo "Must be called passing \`LIB_NAME`\` (mandatory). \`PREFIX\` can also be passed (optional).\nSample:\n\`generate_and_run_ios_dependency_build_script \$LIB_NAME\`\n`generate_and_run_ios_dependency_build_script \$LIB_NAME \$PREFIX\`"
  20. exit 1
  21. }
  22. if [ "${LIB_NAME}" = "" ]; then
  23. exitAndPrintHelp
  24. fi
  25. # Say Hello
  26. echo "#####################################################"
  27. echo "#Generating buildscript for ${LIB_NAME}"
  28. echo "#####################################################"
  29. # Generate Actual Script
  30. BUILD_CODE_FILE="${SCRIPT_DIR}/buildcode/${LIB_NAME}.code"
  31. BUILD_SCRIPT_TEMPLATE_FILE="${SCRIPT_DIR}/build-ios_dependency.template"
  32. SEARCH_STRING="BUILD_CODE"
  33. #Replaces ${SEARCH_STRING} in file ${BUILD_SCRIPT_TEMPLATE_FILE} with content of ${BUILD_CODE_FILE}
  34. /opt/local/bin/gsed -e "/${SEARCH_STRING}/r ${BUILD_CODE_FILE}" -e "/${SEARCH_STRING}/d" ${BUILD_SCRIPT_TEMPLATE_FILE} > "${GENERATED_SCRIPT}"
  35. sh ${GENERATED_SCRIPT} ${PREFIX}
  36. # Cleanup
  37. rm -rf "${TMP_DIR}"