-
Notifications
You must be signed in to change notification settings - Fork 139
xcframeworkにmacOS向けのライブラリも同梱する #1056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3a72139
adedab5
cc01a12
f555364
a5e2a89
63fc3a2
c08ea29
a9e5f11
e194c4d
8df9ecd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,14 @@ if [ ! -v IOS_AARCH64_PATH ]; then # AARCH64用のモジュールのディレク | |
| echo "IOS_AARCH64_PATHが未定義です" | ||
| exit 1 | ||
| fi | ||
| if [ ! -v MACOS_ARM64_PATH ]; then # MACOS_ARM64用のモジュールのディレクトリ | ||
| echo "MACOS_ARM64_PATHが未定義です" | ||
| exit 1 | ||
| fi | ||
| if [ ! -v MACOS_X64_PATH ]; then # MACOS_X64用のモジュールのディレクトリ | ||
| echo "MACOS_X64_PATHが未定義です" | ||
| exit 1 | ||
| fi | ||
| if [ ! -v OUTPUT_ASSET_PATH ]; then # 出力するASSETのディレクトリ | ||
| echo "OUTPUT_ASSET_PATHが未定義です" | ||
| exit 1 | ||
|
|
@@ -37,43 +45,63 @@ fi | |
| echo "Original onnx dylib file name: $dylib_string" | ||
|
|
||
| echo "* Copy Framework template" | ||
| arches=("aarch64" "sim") | ||
| artifacts=("${IOS_AARCH64_PATH}" "${IOS_AARCH64_SIM_PATH}") | ||
| for i in "${!arches[@]}"; do | ||
| arch="${arches[$i]}" | ||
| platforms=("ios" "sim" "macos") | ||
| artifacts=("${IOS_AARCH64_PATH}" "${IOS_AARCH64_SIM_PATH}" "${MACOS_ARM64_PATH}") | ||
|
|
||
| declare -a link_onnxruntime_platform=() | ||
| # ONNXRUNTIMEのリンクが必要なプラットフォームを確認 | ||
| for i in "${!platforms[@]}"; do | ||
| platform="${platforms[$i]}" | ||
| artifact="${artifacts[$i]}" | ||
| echo "* Copy Framework-${arch} template" | ||
| mkdir -p "Framework-${arch}/voicevox_core.framework/Headers" | ||
| cp -vr "crates/voicevox_core_c_api/xcframework/Frameworks/${arch}/" "Framework-${arch}/" | ||
| if grep -q -e '^#define VOICEVOX_LINK_ONNXRUNTIME$' -e '^//#define VOICEVOX_LOAD_ONNXRUNTIME$' "${artifact}/include/voicevox_core.h"; then | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (ただのコメントです) ここヘッダーとビルド段階で空中配線されてるの忘れそうな気もするんですよね〜…。
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これはおっしゃる通りですね… この辺りにlink_onnxruntime_platformは必ず長さ1以上であるみたいなassertionを挟む…ぐらいしかパッと思いつかなかったです |
||
| link_onnxruntime_platform+=("${platform}") | ||
| fi | ||
| done | ||
|
|
||
| for i in "${!platforms[@]}"; do | ||
| platform="${platforms[$i]}" | ||
| artifact="${artifacts[$i]}" | ||
| echo "* Copy Framework-${platform} template" | ||
| mkdir -p "Framework-${platform}/voicevox_core.framework/Headers" | ||
| cp -vr "crates/voicevox_core_c_api/xcframework/Frameworks/${platform}/" "Framework-${platform}/" | ||
| cp -v "${artifact}/include/voicevox_core.h" \ | ||
| "Framework-${arch}/voicevox_core.framework/Headers/voicevox_core.h" | ||
| "Framework-${platform}/voicevox_core.framework/Headers/voicevox_core.h" | ||
| done | ||
|
|
||
| echo "* Create dylib" | ||
| # aarch64はdylibをコピー | ||
| # iosはdylibをコピー | ||
| cp -v "${IOS_AARCH64_PATH}/lib/libvoicevox_core.dylib" \ | ||
| "Framework-aarch64/voicevox_core.framework/voicevox_core" | ||
| "Framework-ios/voicevox_core.framework/voicevox_core" | ||
|
|
||
| # simはx86_64とarrch64を合わせてdylib作成 | ||
| lipo -create "${IOS_X86_64_PATH}/lib/libvoicevox_core.dylib" \ | ||
| "${IOS_AARCH64_SIM_PATH}/lib/libvoicevox_core.dylib" \ | ||
| -output "Framework-sim/voicevox_core.framework/voicevox_core" | ||
|
|
||
| for arch in "${arches[@]}"; do | ||
| echo "* Change ${arch} @rpath" | ||
| # macosはx64とarrch64を合わせてdylib作成 | ||
| lipo -create "${MACOS_X64_PATH}/lib/libvoicevox_core.dylib" \ | ||
| "${MACOS_ARM64_PATH}/lib/libvoicevox_core.dylib" \ | ||
| -output "Framework-macos/voicevox_core.framework/voicevox_core" | ||
|
|
||
| for platform in "${platforms[@]}"; do | ||
| echo "* Change ${platform} @rpath" | ||
| # 自身への@rpathを変更 | ||
| install_name_tool -id "@rpath/voicevox_core.framework/voicevox_core" \ | ||
| "Framework-${arch}/voicevox_core.framework/voicevox_core" | ||
| "Framework-${platform}/voicevox_core.framework/voicevox_core" | ||
| done | ||
|
|
||
| for platform in "${link_onnxruntime_platform[@]}"; do | ||
| echo "* Change ${platform} onnxruntime @rpath" | ||
| # onnxruntimeへの@rpathを、voicevox_onnxruntimeのXCFrameworkに変更 | ||
| install_name_tool -change "@rpath/$dylib_string" \ | ||
| "@rpath/voicevox_onnxruntime.framework/voicevox_onnxruntime" \ | ||
| "Framework-${arch}/voicevox_core.framework/voicevox_core" | ||
| "Framework-${platform}/voicevox_core.framework/voicevox_core" | ||
| done | ||
|
|
||
| echo "* Create XCFramework" | ||
| mkdir -p "${OUTPUT_ASSET_PATH}" | ||
| xcodebuild -create-xcframework \ | ||
| -framework "Framework-sim/voicevox_core.framework" \ | ||
| -framework "Framework-aarch64/voicevox_core.framework" \ | ||
| -framework "Framework-ios/voicevox_core.framework" \ | ||
| -framework "Framework-macos/voicevox_core.framework" \ | ||
| -output "${OUTPUT_ASSET_PATH}/voicevox_core.xcframework" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>BuildMachineOSBuild</key> | ||
| <string>23B81</string> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>en</string> | ||
| <key>CFBundleExecutable</key> | ||
| <string>voicevox_core</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>jp.hiroshiba.voicevox.voicevox-core</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundleName</key> | ||
| <string>voicevox_core</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>FMWK</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>1.0</string> | ||
| <key>CFBundleSupportedPlatforms</key> | ||
| <array> | ||
| <string>MacOSX</string> | ||
| </array> | ||
| <key>CFBundleVersion</key> | ||
| <string>1</string> | ||
| <key>DTCompiler</key> | ||
| <string>com.apple.compilers.llvm.clang.1_0</string> | ||
| <key>DTPlatformBuild</key> | ||
| <string>21C52</string> | ||
| <key>DTPlatformName</key> | ||
| <string>macosx</string> | ||
| <key>DTPlatformVersion</key> | ||
| <string>13.0</string> | ||
| <key>DTSDKBuild</key> | ||
| <string>21C52</string> | ||
| <key>DTSDKName</key> | ||
| <string>macosx13.0</string> | ||
| <key>DTXcode</key> | ||
| <string>1510</string> | ||
| <key>DTXcodeBuild</key> | ||
| <string>15C65</string> | ||
| <key>MinimumOSVersion</key> | ||
| <string>13.0</string> | ||
| </dict> | ||
| </plist> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| framework module voicevox_core { | ||
| umbrella header "voicevox_core.h" | ||
| export * | ||
|
|
||
| module * { export * } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # xcframeworkフォルダの内容について | ||
| ## Frameworks | ||
|
|
||
| iOS向けの配布ライブラリXCFramework内のFrameworkを作るための雛形です。 | ||
| 雛形は端末用とシミュレータ用の2種類です。 | ||
| iOSとmacOS向けの配布ライブラリXCFramework内のFrameworkを作るための雛形です。 | ||
| 雛形はiOS端末用(ios)とシミュレータ用(sim)、およびmacOS端末用(macos)の3種類です。 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iosのみではなくなったため、ファイル名からiosを削除している