csukuangfj commited on
Commit
5cda25d
·
1 Parent(s): bbe9a01

add scripts

Browse files
README.md CHANGED
@@ -1,3 +1,26 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+
5
+ This repo contains pre-built static onnxruntime libs for iOS.
6
+
7
+ Please see
8
+ https://github.com/k2-fsa/sherpa-onnx
9
+ for its usage.
10
+
11
+ # How to build xcframework
12
+
13
+ ```
14
+ git clone https://github.com/microsoft/onnxruntime
15
+ cd onnxruntime
16
+ cp ../create-xcframework.sh .
17
+ cp ../run-ios-arm64.sh .
18
+ cp ../run-ios-simulator-arm64.sh .
19
+ cp ../run-ios-simulator-os64.sh .
20
+
21
+ ./run-ios-arm64.sh
22
+ ./run-ios-simulator-arm64.sh
23
+ ./run-ios-simulator-os64.sh
24
+
25
+ ./create-xcframework.sh
26
+ ```
create-xcframework.sh ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
3
+
4
+
5
+ for arch in simulator/os64 simulator/arm64 arm64; do
6
+ libtool -static -o build-ios/$arch/onnxruntime.a \
7
+ build-ios/$arch/Release/static_libraries/libabsl_base.a \
8
+ build-ios/$arch/Release/static_libraries/libabsl_city.a \
9
+ build-ios/$arch/Release/static_libraries/libabsl_hash.a \
10
+ build-ios/$arch/Release/static_libraries/libabsl_low_level_hash.a \
11
+ build-ios/$arch/Release/static_libraries/libabsl_raw_hash_set.a \
12
+ build-ios/$arch/Release/static_libraries/libabsl_raw_logging_internal.a \
13
+ build-ios/$arch/Release/static_libraries/libabsl_throw_delegate.a \
14
+ build-ios/$arch/Release/static_libraries/libclog.a \
15
+ build-ios/$arch/Release/static_libraries/libcpuinfo.a \
16
+ build-ios/$arch/Release/static_libraries/libflatbuffers.a \
17
+ build-ios/$arch/Release/static_libraries/libnsync_cpp.a \
18
+ build-ios/$arch/Release/static_libraries/libonnx.a \
19
+ build-ios/$arch/Release/static_libraries/libonnx_proto.a \
20
+ build-ios/$arch/Release/static_libraries/libonnxruntime_common.a \
21
+ build-ios/$arch/Release/static_libraries/libonnxruntime_flatbuffers.a \
22
+ build-ios/$arch/Release/static_libraries/libonnxruntime_framework.a \
23
+ build-ios/$arch/Release/static_libraries/libonnxruntime_graph.a \
24
+ build-ios/$arch/Release/static_libraries/libonnxruntime_mlas.a \
25
+ build-ios/$arch/Release/static_libraries/libonnxruntime_optimizer.a \
26
+ build-ios/$arch/Release/static_libraries/libonnxruntime_providers.a \
27
+ build-ios/$arch/Release/static_libraries/libonnxruntime_session.a \
28
+ build-ios/$arch/Release/static_libraries/libonnxruntime_util.a \
29
+ build-ios/$arch/Release/static_libraries/libprotobuf-lite.a \
30
+ build-ios/$arch/Release/static_libraries/libre2.a
31
+ done
32
+
33
+ lipo -create build-ios/simulator/os64/onnxruntime.a \
34
+ build-ios/simulator/arm64/onnxruntime.a \
35
+ -output build-ios/simulator/onnxruntime.a
36
+
37
+ rm -rf onnxruntime.xcframework
38
+ xcodebuild -create-xcframework \
39
+ -library build-ios/arm64/onnxruntime.a \
40
+ -library build-ios/simulator/onnxruntime.a \
41
+ -output onnxruntime.xcframework
42
+
43
+ mkdir -p onnxruntime.xcframework/Headers
44
+ cp -v ./build-ios/simulator/os64/install/bin/onnxruntime.framework/Headers/*.h onnxruntime.xcframework/Headers
run-ios-arm64.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
3
+
4
+ # https://onnxruntime.ai/docs/build/ios.html
5
+
6
+ num_jobs=3
7
+
8
+ # Get directory this script is in
9
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10
+
11
+
12
+ build_dir=$DIR/build-ios/arm64
13
+
14
+ #requires python3.6 or higher
15
+ python3 \
16
+ $DIR/tools/ci_build/build.py \
17
+ --build_dir $build_dir \
18
+ --config Release \
19
+ --use_xcode \
20
+ --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF \
21
+ --cmake_extra_defines onnxruntime_BUILD_SHARED_LIB=OFF \
22
+ --cmake_extra_defines CMAKE_INSTALL_PREFIX=$build_dir/install/ \
23
+ --ios \
24
+ --ios_sysroot iphoneos \
25
+ --osx_arch arm64 \
26
+ --target install \
27
+ --parallel $num_jobs \
28
+ --skip_tests \
29
+ --build_apple_framework \
30
+ --apple_deploy_target 13.0
31
+
32
+
run-ios-simulator-arm64.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ # https://onnxruntime.ai/docs/build/ios.html
4
+
5
+ num_jobs=3
6
+
7
+ # Get directory this script is in
8
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
9
+
10
+
11
+ build_dir=$DIR/build-ios/simulator/arm64
12
+
13
+ #requires python3.6 or higher
14
+ python3 \
15
+ $DIR/tools/ci_build/build.py \
16
+ --build_dir $build_dir \
17
+ --config Release \
18
+ --use_xcode \
19
+ --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF \
20
+ --cmake_extra_defines onnxruntime_BUILD_SHARED_LIB=OFF \
21
+ --cmake_extra_defines CMAKE_INSTALL_PREFIX=$build_dir/install/ \
22
+ --ios \
23
+ --ios_sysroot iphonesimulator \
24
+ --osx_arch arm64 \
25
+ --target install \
26
+ --parallel $num_jobs \
27
+ --skip_tests \
28
+ --build_apple_framework \
29
+ --apple_deploy_target 13.0
run-ios-simulator-os64.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
3
+
4
+ # https://onnxruntime.ai/docs/build/ios.html
5
+
6
+ num_jobs=3
7
+
8
+ # Get directory this script is in
9
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10
+
11
+
12
+ build_dir=$DIR/build-ios/simulator/os64
13
+
14
+ #requires python3.6 or higher
15
+ python3 \
16
+ $DIR/tools/ci_build/build.py \
17
+ --build_dir $build_dir \
18
+ --config Release \
19
+ --use_xcode \
20
+ --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF \
21
+ --cmake_extra_defines onnxruntime_BUILD_SHARED_LIB=OFF \
22
+ --cmake_extra_defines CMAKE_INSTALL_PREFIX=$build_dir/install/ \
23
+ --ios \
24
+ --ios_sysroot iphonesimulator \
25
+ --osx_arch x86_64 \
26
+ --target install \
27
+ --parallel $num_jobs \
28
+ --skip_tests \
29
+ --build_apple_framework \
30
+ --apple_deploy_target 13.0
31
+
32
+