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.

47 lines
1.5 KiB

  1. # Generates a build script for building fat lib for iOS (ARM64 & x86_64).
  2. # Pass PREFIX as argument. If not passed, "local/" is used as deafult.
  3. # To generate the script the specific `buildcode/$NAME_OF_LIB_TO_BUILD.code` is merged into the commont `build-ios_dependency.template` and saved to `generated.sh`
  4. # Exit on errors
  5. set -e
  6. SCRIPT_DIR=$(dirname "$0")
  7. LIB_NAME=$1
  8. PREFIX=$2
  9. # Get Absolute Paths
  10. pushd "${SCRIPT_DIR}"
  11. SCRIPT_DIR=$(pwd)
  12. popd
  13. mkdir -p "${PREFIX}"
  14. pushd "${PREFIX}"
  15. PREFIX=$(pwd)
  16. popd
  17. GENERATED_SCRIPT="${SCRIPT_DIR}/generated.sh"
  18. exitAndPrintHelp()
  19. {
  20. 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\`"
  21. exit 1
  22. }
  23. if [ "${LIB_NAME}" = "" ]; then
  24. exitAndPrintHelp
  25. fi
  26. # Say Hello
  27. echo "#####################################################"
  28. echo "#Generating buildscript for ${LIB_NAME}"
  29. echo "#####################################################"
  30. # Generate Actual Script
  31. BUILD_CODE_FILE="${SCRIPT_DIR}/buildcode/${LIB_NAME}.code"
  32. BUILD_SCRIPT_TEMPLATE_FILE="${SCRIPT_DIR}/build-ios_dependency.template"
  33. SEARCH_STRING="BUILD_CODE"
  34. #Replaces ${SEARCH_STRING} in file ${BUILD_SCRIPT_TEMPLATE_FILE} with content of ${BUILD_CODE_FILE}
  35. /opt/local/bin/gsed -e "/${SEARCH_STRING}/r ${BUILD_CODE_FILE}" -e "/${SEARCH_STRING}/d" ${BUILD_SCRIPT_TEMPLATE_FILE} > "${GENERATED_SCRIPT}"
  36. sh ${GENERATED_SCRIPT} ${PREFIX}
  37. # Cleanup
  38. rm -rf "${TMP_DIR}"