Spaces:
Running
Running
Support static xcframework packaging in build-xcframework.sh (#3322)
Browse files* This commit allows for the building of a static xcframework by adding a
BUILD_STATIC_XCFRAMEWORK option. When enabled, the build-xcframework.sh
script builds a self-contained static whisper.xcframework.
The motivation for this change is so that command line binaries can link
whisper.cpp without forcing users to install the whisper.xcframework
separately.
* Update build-xcframework.sh
Co-authored-by: Daniel Bevenius <[email protected]>
* Address reviewer feedback: remove extra indentation around static xcframework creation.
* squash! Address reviewer feedback: remove extra indentation around static xcframework creation.
Fix whitespaces.
---------
Co-authored-by: Daniel Bevenius <[email protected]>
- build-xcframework.sh +24 -0
build-xcframework.sh
CHANGED
|
@@ -15,6 +15,7 @@ GGML_METAL_EMBED_LIBRARY=ON
|
|
| 15 |
GGML_BLAS_DEFAULT=ON
|
| 16 |
GGML_METAL_USE_BF16=ON
|
| 17 |
GGML_OPENMP=OFF
|
|
|
|
| 18 |
|
| 19 |
COMMON_C_FLAGS="-Wno-macro-redefined -Wno-shorten-64-to-32 -Wno-unused-command-line-argument -g"
|
| 20 |
COMMON_CXX_FLAGS="-Wno-macro-redefined -Wno-shorten-64-to-32 -Wno-unused-command-line-argument -g"
|
|
@@ -327,6 +328,15 @@ combine_static_libraries() {
|
|
| 327 |
arch_flags+=" -arch $arch"
|
| 328 |
done
|
| 329 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
# Create dynamic library
|
| 331 |
echo "Creating dynamic library for ${platform}."
|
| 332 |
xcrun -sdk $sdk clang++ -dynamiclib \
|
|
@@ -529,6 +539,20 @@ combine_static_libraries "build-tvos-device" "Release-appletvos" "tvos" "false"
|
|
| 529 |
|
| 530 |
# Create XCFramework with correct debug symbols paths
|
| 531 |
echo "Creating XCFramework..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
xcodebuild -create-xcframework \
|
| 533 |
-framework $(pwd)/build-ios-sim/framework/whisper.framework \
|
| 534 |
-debug-symbols $(pwd)/build-ios-sim/dSYMs/whisper.dSYM \
|
|
|
|
| 15 |
GGML_BLAS_DEFAULT=ON
|
| 16 |
GGML_METAL_USE_BF16=ON
|
| 17 |
GGML_OPENMP=OFF
|
| 18 |
+
BUILD_STATIC_XCFRAMEWORK=${BUILD_STATIC_XCFRAMEWORK:-OFF}
|
| 19 |
|
| 20 |
COMMON_C_FLAGS="-Wno-macro-redefined -Wno-shorten-64-to-32 -Wno-unused-command-line-argument -g"
|
| 21 |
COMMON_CXX_FLAGS="-Wno-macro-redefined -Wno-shorten-64-to-32 -Wno-unused-command-line-argument -g"
|
|
|
|
| 328 |
arch_flags+=" -arch $arch"
|
| 329 |
done
|
| 330 |
|
| 331 |
+
|
| 332 |
+
if [[ "${BUILD_STATIC_XCFRAMEWORK}" == "ON" ]]; then
|
| 333 |
+
echo "Packaging static framework for ${platform}."
|
| 334 |
+
mkdir -p "$(dirname "${base_dir}/${output_lib}")"
|
| 335 |
+
cp "${temp_dir}/combined.a" "${base_dir}/${output_lib}"
|
| 336 |
+
rm -rf "${temp_dir}"
|
| 337 |
+
return
|
| 338 |
+
fi
|
| 339 |
+
|
| 340 |
# Create dynamic library
|
| 341 |
echo "Creating dynamic library for ${platform}."
|
| 342 |
xcrun -sdk $sdk clang++ -dynamiclib \
|
|
|
|
| 539 |
|
| 540 |
# Create XCFramework with correct debug symbols paths
|
| 541 |
echo "Creating XCFramework..."
|
| 542 |
+
|
| 543 |
+
if [[ "${BUILD_STATIC_XCFRAMEWORK}" == "ON" ]]; then
|
| 544 |
+
xcodebuild -create-xcframework \
|
| 545 |
+
-framework $(pwd)/build-ios-sim/framework/whisper.framework \
|
| 546 |
+
-framework $(pwd)/build-ios-device/framework/whisper.framework \
|
| 547 |
+
-framework $(pwd)/build-macos/framework/whisper.framework \
|
| 548 |
+
-framework $(pwd)/build-visionos/framework/whisper.framework \
|
| 549 |
+
-framework $(pwd)/build-visionos-sim/framework/whisper.framework \
|
| 550 |
+
-framework $(pwd)/build-tvos-device/framework/whisper.framework \
|
| 551 |
+
-framework $(pwd)/build-tvos-sim/framework/whisper.framework \
|
| 552 |
+
-output $(pwd)/build-apple/whisper.xcframework
|
| 553 |
+
exit 0
|
| 554 |
+
fi
|
| 555 |
+
|
| 556 |
xcodebuild -create-xcframework \
|
| 557 |
-framework $(pwd)/build-ios-sim/framework/whisper.framework \
|
| 558 |
-debug-symbols $(pwd)/build-ios-sim/dSYMs/whisper.dSYM \
|