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

# 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).
# Exit on errors
set -e
SCRIPT_DIR=$(dirname "$0")
ARCH1_DIR=$1
ARCH2_DIR=$2
OUTPUT_DIR=$3
# Get absolute paths
pushd "${SCRIPT_DIR}"
SCRIPT_DIR=$(pwd)
popd
pushd "${ARCH1_DIR}"
ARCH1_DIR=$(pwd)
popd
pushd "${ARCH2_DIR}"
ARCH2_DIR=$(pwd)
popd
pushd "${OUTPUT_DIR}"
OUTPUT_DIR=$(pwd)
popd
exitAndPrintHelp()
{
echo "Must be called with ARCH1_DIR ARCH2_DIR OUTPUT_DIR, all absolute paths."
exit 1
}
if [ "${ARCH1_DIR}" = "" ]; then
exitAndPrintHelp
elif [ "${ARCH2_DIR}" = "" ]; then
exitAndPrintHelp
elif [ "${OUTPUT_DIR}" = "" ]; then
exitAndPrintHelp
fi
echo "##############################################"
echo "# building fat libs from ${ARCH1_DIR}"
echo "##############################################"
pushd "${ARCH1_DIR}"
if [ "$(ls 2>/dev/null || :)" = "" ]; then
exit 0
fi
OBJECT_FILE_NAMES=$(ls *.a 2>/dev/null)
popd
for OBJECT_FILE_NAME in ${OBJECT_FILE_NAMES}; do
IN1="${ARCH1_DIR}/${OBJECT_FILE_NAME}"
IN2="${ARCH2_DIR}/${OBJECT_FILE_NAME}"
OUT="${OUTPUT_DIR}/${OBJECT_FILE_NAME}"
mkdir -p "${OUTPUT_DIR}"
lipo -create -output "${OUT}" "${IN1}" "${IN2}"
done