From 464fd28ee9e30df317145d7b819413d1be350798 Mon Sep 17 00:00:00 2001 From: Guoyu Wang <62914304+gwang-msft@users.noreply.github.com> Date: Thu, 29 Jul 2021 17:28:02 -0700 Subject: [PATCH] Update iOS packaging script to default build static framework, disable bitcode (#8533) * default package build to static, disable bitcode * fix pipeline failure * Address CR comments --- tools/ci_build/build.py | 3 --- tools/ci_build/github/apple/build_ios_framework.py | 7 ++++++- .../github/apple/c/onnxruntime-mobile-c.podspec.template | 1 + .../objectivec/onnxruntime-mobile-objc.podspec.template | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index c460c90950..b5178135e8 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -330,8 +330,6 @@ def parse_arguments(): help="Specify the minimum version of the target platform " "(e.g. macOS or iOS)" "This is only supported on MacOS") - parser.add_argument("--apple_disable_bitcode", action='store_true', - help="Disable bitcode for iOS, bitcode is by default enabled for iOS.") # WebAssembly build parser.add_argument("--build_wasm", action='store_true', help="Build for WebAssembly") @@ -909,7 +907,6 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home "-DCMAKE_OSX_DEPLOYMENT_TARGET=" + args.apple_deploy_target, # we do not need protoc binary for ios cross build "-Dprotobuf_BUILD_PROTOC_BINARIES=OFF", - "-Donnxruntime_ENABLE_BITCODE=" + ("OFF" if args.apple_disable_bitcode else "ON"), "-DCMAKE_TOOLCHAIN_FILE=" + ( args.ios_toolchain_file if args.ios_toolchain_file else "../cmake/onnxruntime_ios.toolchain.cmake") diff --git a/tools/ci_build/github/apple/build_ios_framework.py b/tools/ci_build/github/apple/build_ios_framework.py index 433fa1b734..cba3c5bd64 100644 --- a/tools/ci_build/github/apple/build_ios_framework.py +++ b/tools/ci_build/github/apple/build_ios_framework.py @@ -72,7 +72,9 @@ def _build_package(args): # get the compiled lib path framework_dir = os.path.join( - build_dir_current_arch, build_config, build_config + "-" + sysroot, 'onnxruntime.framework') + build_dir_current_arch, build_config, build_config + "-" + sysroot, + 'onnxruntime.framework' if args.build_dynamic_framework + else os.path.join('static_framework', 'onnxruntime.framework')) ort_libs.append(os.path.join(framework_dir, 'onnxruntime')) # We only need to copy Info.plist, framework_info.json, and headers once since they are the same @@ -125,6 +127,9 @@ def parse_args(): parser.add_argument('build_settings_file', type=pathlib.Path, help='Provide the file contains settings for building iOS framework') + parser.add_argument("--build_dynamic_framework", action='store_true', + help="Build Dynamic Framework (default is build static framework).") + args = parser.parse_args() if not args.build_settings_file.resolve().is_file(): diff --git a/tools/ci_build/github/apple/c/onnxruntime-mobile-c.podspec.template b/tools/ci_build/github/apple/c/onnxruntime-mobile-c.podspec.template index 3554f9047e..1d2a736b7e 100644 --- a/tools/ci_build/github/apple/c/onnxruntime-mobile-c.podspec.template +++ b/tools/ci_build/github/apple/c/onnxruntime-mobile-c.podspec.template @@ -8,6 +8,7 @@ Pod::Spec.new do |spec| spec.summary = "ONNX Runtime Mobile C/C++ Pod" spec.platform = :ios, "@IOS_DEPLOYMENT_TARGET@" spec.vendored_frameworks = "onnxruntime.framework" + spec.static_framework = true spec.weak_framework = [ @WEAK_FRAMEWORK@ ] spec.source_files = "onnxruntime.framework/Headers/*.h" spec.preserve_paths = [ @LICENSE_FILE@ ] diff --git a/tools/ci_build/github/apple/objectivec/onnxruntime-mobile-objc.podspec.template b/tools/ci_build/github/apple/objectivec/onnxruntime-mobile-objc.podspec.template index c784662197..8694ca77f6 100644 --- a/tools/ci_build/github/apple/objectivec/onnxruntime-mobile-objc.podspec.template +++ b/tools/ci_build/github/apple/objectivec/onnxruntime-mobile-objc.podspec.template @@ -14,6 +14,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '@IOS_DEPLOYMENT_TARGET@' s.preserve_paths = [ @LICENSE_FILE@ ] s.default_subspec = "Core" + s.static_framework = true s.subspec "Core" do |core| core.dependency "onnxruntime-mobile-c", "#{s.version}"