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.

56 lines
1.3 KiB

10 months ago
10 months ago
10 months ago
  1. # Creates fat libs of all .a files in `ARCH1_DIR` (1st param), combining .a with same name in `ARCH2_DIR` (2nd param), saving fat lib in `OUTPUT_DIR` (3rd param).
  2. # Exit on errors
  3. set -e
  4. SCRIPT_DIR=$(dirname "$0")
  5. ARCH1_DIR=$1
  6. ARCH2_DIR=$2
  7. OUTPUT_DIR=$3
  8. # Get absolute paths
  9. pushd "${SCRIPT_DIR}"
  10. SCRIPT_DIR=$(pwd)
  11. popd
  12. pushd "${ARCH1_DIR}"
  13. ARCH1_DIR=$(pwd)
  14. popd
  15. pushd "${ARCH2_DIR}"
  16. ARCH2_DIR=$(pwd)
  17. popd
  18. pushd "${OUTPUT_DIR}"
  19. OUTPUT_DIR=$(pwd)
  20. popd
  21. exitAndPrintHelp()
  22. {
  23. echo "Must be called with ARCH1_DIR ARCH2_DIR OUTPUT_DIR, all absolute paths."
  24. exit 1
  25. }
  26. if [ "${ARCH1_DIR}" = "" ]; then
  27. exitAndPrintHelp
  28. elif [ "${ARCH2_DIR}" = "" ]; then
  29. exitAndPrintHelp
  30. elif [ "${OUTPUT_DIR}" = "" ]; then
  31. exitAndPrintHelp
  32. fi
  33. echo "##############################################"
  34. echo "# building fat libs from ${ARCH1_DIR}"
  35. echo "##############################################"
  36. pushd "${ARCH1_DIR}"
  37. if [ "$(ls 2>/dev/null || :)" = "" ]; then
  38. exit 0
  39. fi
  40. OBJECT_FILE_NAMES=$(ls *.a 2>/dev/null)
  41. popd
  42. for OBJECT_FILE_NAME in ${OBJECT_FILE_NAMES}; do
  43. IN1="${ARCH1_DIR}/${OBJECT_FILE_NAME}"
  44. IN2="${ARCH2_DIR}/${OBJECT_FILE_NAME}"
  45. OUT="${OUTPUT_DIR}/${OBJECT_FILE_NAME}"
  46. mkdir -p "${OUTPUT_DIR}"
  47. lipo -create -output "${OUT}" "${IN1}" "${IN2}"
  48. done