Skip to content

Commit 1a9bfd2

Browse files
authored
Apothecary XCFramework library merge fix (#388)
1 parent b80bcb6 commit 1a9bfd2

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

apothecary/apothecary

+18-13
Original file line numberDiff line numberDiff line change
@@ -1604,9 +1604,11 @@ function frameworkFormula() {
16041604
# Final merging pass to combine binaries of same / merged architectures into single binary to prevent linking issues
16051605
for dir in "${merged_dirs[@]}"; do
16061606
echo "Processing directory: $dir"
1607-
# rm -f "${dir}/${1}.a"
1607+
1608+
# Find all .a files in the directory
16081609
a_files=($(find "$dir" -name '*.a' -print0 | xargs -0))
1609-
echo "[$dir]"
1610+
echo "[$dir] - Found archives: ${#a_files[@]}"
1611+
16101612
num_files=${#a_files[@]}
16111613
if [ "$num_files" -gt 1 ]; then
16121614
echo "Multiple archives found in $dir. Commencing the merge..."
@@ -1622,12 +1624,12 @@ function frameworkFormula() {
16221624
xcframework_flags+=" -headers $LIBS_DIR_REAL/$1/include"
16231625
fi
16241626
elif [ "$num_files" -gt 0 ]; then
1625-
# Directly use the single archive or skip if none
1626-
echo "Directly use the single archive or skip if none ${a_files[0]}]"
1627+
# Directly use the single archive
1628+
echo "Directly use the single archive ${a_files[0]}"
16271629
xcframework_flags+=" -library ${a_files[0]}"
16281630
xcframework_flags+=" -headers $LIBS_DIR_REAL/$1/include"
16291631
else
1630-
echo " Skip for [$dir]]"
1632+
echo "No archives found. Skip for [$dir]"
16311633
fi
16321634
done
16331635

@@ -1721,7 +1723,7 @@ function xframeworkFormula() {
17211723
mkdir -p "${X_INCLUDE}"
17221724
mkdir -p "${X_LICENSE}"
17231725

1724-
if [[ $1 == "fmod" ]] || [[ $1 == "fmodex" ]] || [[ $1 == "libusb" ]] || [[ $1 == "glm" ]] || [[ $1 == "json" ]] || [[ $1 == "utf8" ]]; then
1726+
if [[ $1 == "fmod" ]] || [[ $1 == "fmodex" ]] || [[ $1 == "glm" ]] || [[ $1 == "json" ]] || [[ $1 == "utf8" ]]; then
17251727
if ! command -v rsync &> /dev/null; then
17261728
if [[ -e "${LIBS_DIR_REAL}/${1}/lib/${TYPE}/" ]]; then
17271729
mkdir -p "${X_LIBS}"
@@ -1878,14 +1880,17 @@ function xframeworkFormula() {
18781880
# Final merging pass to combine binaries of same / merged architectures into single binary to prevent linking issues
18791881
echo "merged_dirs:"
18801882
for dir in "${merged_dirs[@]}"; do
1881-
echo "Processing directory: [$dir]"
1882-
rm -f "${dir}/${1}.a"
1883+
echo "Processing directory: $dir"
1884+
1885+
# Find all .a files in the directory
18831886
a_files=($(find "$dir" -name '*.a' -print0 | xargs -0))
1887+
echo "[$dir] - Found archives: ${#a_files[@]}"
1888+
18841889
num_files=${#a_files[@]}
18851890
if [ "$num_files" -gt 1 ]; then
1886-
echo "Multiple archives found in [$dir]. Commencing the merge..."
1891+
echo "Multiple archives found in $dir. Commencing the merge..."
18871892
libtool -static -o "${dir}/${1}.a" "${a_files[@]}"
1888-
echo "Merged into [${dir}/${1}.a]"
1893+
echo "Merged into ${dir}/${1}.a"
18891894
for a_file in "${a_files[@]}"; do
18901895
rm -f "$a_file"
18911896
done
@@ -1896,12 +1901,12 @@ function xframeworkFormula() {
18961901
xcframework_flags+=" -headers $LIBS_DIR_REAL/$1/include"
18971902
fi
18981903
elif [ "$num_files" -gt 0 ]; then
1899-
# Directly use the single archive or skip if none
1900-
echo "Directly use the single archive or skip if none ${a_files[0]}]"
1904+
# Directly use the single archive
1905+
echo "Directly use the single archive ${a_files[0]}"
19011906
xcframework_flags+=" -library ${a_files[0]}"
19021907
xcframework_flags+=" -headers $LIBS_DIR_REAL/$1/include"
19031908
else
1904-
echo " Skip for [$dir]]"
1909+
echo "No archives found. Skip for [$dir]"
19051910
fi
19061911
done
19071912

0 commit comments

Comments
 (0)