├── .github └── workflows │ ├── android.yml │ ├── macos.yml │ ├── musl-gcc.yml │ ├── ubuntu.yml │ └── windows.yml ├── .gitignore ├── LICENSE ├── Launch-VsDevShell.ps1 ├── README.md ├── build-onnxruntime-android.sh ├── build-onnxruntime-linux.sh ├── build-onnxruntime-mac.sh ├── build-onnxruntime-musl.sh ├── build-onnxruntime-win.ps1 ├── build-onnxruntime.bat ├── justfile ├── onnxruntime_cmake_options.txt ├── patches └── onnxruntime-1.18.0-musl.patch └── release.md /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: android 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | android: 8 | runs-on: ubuntu-22.04 9 | 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | ver: 14 | - { onnx: v1.22.0, ndk: 26.1.10909125, python: 3.10.11, jdk: 17, gradle: 8.6 } 15 | list: 16 | - { arch: armeabi-v7a, min: 19 } 17 | - { arch: arm64-v8a, min: 21 } 18 | - { arch: x86, min: 19 } 19 | - { arch: x86_64 , min: 21 } 20 | 21 | env: 22 | BUILD_SCRIPT: build-onnxruntime-android.sh 23 | SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-${{ matrix.list.arch }}-shared 24 | STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-${{ matrix.list.arch }}-static 25 | JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-${{ matrix.list.arch }}-java 26 | 27 | steps: 28 | # install ndk 29 | - name: install ndk 30 | run: | 31 | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;${{ matrix.ver.ndk }}" 32 | echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/${{ matrix.ver.ndk }}" >> $GITHUB_ENV 33 | 34 | # 删除ndk -g参数 35 | - name: ndk del -g 36 | run: | 37 | echo $ANDROID_NDK_HOME 38 | sed -i -e '/^ -g$/d' $ANDROID_NDK_HOME/build/cmake/android-legacy.toolchain.cmake 39 | 40 | - name: Set up Python 41 | uses: actions/setup-python@v5 42 | with: 43 | python-version: '${{ matrix.ver.python }}' 44 | 45 | - uses: gradle/actions/setup-gradle@v3 46 | with: 47 | gradle-version: ${{ matrix.ver.gradle }} 48 | 49 | # Setup JDK 50 | - name: Set up JDK 51 | uses: actions/setup-java@v4 52 | with: 53 | java-version: '${{ matrix.ver.jdk }}' 54 | distribution: 'adopt' 55 | 56 | - name: test gradle 57 | run: gradle --version 58 | 59 | # 检出代码 60 | - uses: actions/checkout@v4 61 | 62 | # 检出onnxruntime 63 | - name: checkout onnxruntime 64 | uses: actions/checkout@v4 65 | with: 66 | repository: microsoft/onnxruntime 67 | path: onnxruntime-${{ matrix.ver.onnx }} 68 | ref: ${{ matrix.ver.onnx }} 69 | submodules: recursive 70 | 71 | # 复制 72 | - name: copy build script 73 | run: | 74 | cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }} 75 | 76 | # 编译 77 | - name: build 78 | run: | 79 | cd onnxruntime-${{ matrix.ver.onnx }} 80 | chmod a+x ${{ env.BUILD_SCRIPT }} 81 | ./${{ env.BUILD_SCRIPT }} ${{ matrix.list.arch }} ${{ matrix.list.min }} 82 | 83 | # 7z压缩 84 | - name: 7zip 85 | run: | 86 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-android-${{ matrix.list.arch }}/Release/install ${{ matrix.list.arch }} 87 | 7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ matrix.list.arch }} 88 | rm -r -f ${{ matrix.list.arch }} 89 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-android-${{ matrix.list.arch }}/Release/install-static ${{ matrix.list.arch }} 90 | 7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ matrix.list.arch }} 91 | rm -r -f ${{ matrix.list.arch }} 92 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-android-${{ matrix.list.arch }}/Release/java/build/libs ${{ matrix.list.arch }} 93 | 7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ matrix.list.arch }} 94 | 95 | # 上传artifact 96 | - name: upload shared lib 97 | uses: actions/upload-artifact@v4 98 | with: 99 | name: ${{ env.SHARED_PKG_NAME }} 100 | path: ${{ env.SHARED_PKG_NAME }}.7z 101 | 102 | - name: upload static lib 103 | uses: actions/upload-artifact@v4 104 | with: 105 | name: ${{ env.STATIC_PKG_NAME }} 106 | path: ${{ env.STATIC_PKG_NAME }}.7z 107 | 108 | - name: upload java lib 109 | uses: actions/upload-artifact@v4 110 | with: 111 | name: ${{ env.JAVA_PKG_NAME }} 112 | path: ${{ env.JAVA_PKG_NAME }}.7z 113 | 114 | release: 115 | needs: [ android ] 116 | 117 | runs-on: ubuntu-latest 118 | 119 | strategy: 120 | fail-fast: false 121 | matrix: 122 | ver: 123 | - { onnx: v1.22.0 } 124 | 125 | env: 126 | SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-android-shared 127 | STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-android-static 128 | JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-android-java 129 | 130 | steps: 131 | # 检出代码 132 | - uses: actions/checkout@v4 133 | 134 | # 获取所有的git log和tag 135 | # - name: Unshallow 136 | # run: git fetch --prune --unshallow 137 | 138 | # 获取git log 从 previousTag 到 lastTag 139 | # - name: Get git log 140 | # id: git-log 141 | # run: | 142 | # previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) 143 | # lastTag=$(git describe --abbrev=0 --tags) 144 | # echo "previousTag:$previousTag ~ lastTag:$lastTag" 145 | # log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S') 146 | # echo "$log" 147 | # echo "log_state="$log"" >> $GITHUB_ENV 148 | 149 | # 创建Changelog文件 triggered by git tag push 150 | # - name: Generate Changelog 151 | # if: startsWith(github.ref, 'refs/tags/') 152 | # run: | 153 | # echo -e '${{ env.log_state }}' > release.md 154 | 155 | # 下载artifact 156 | - name: download 157 | uses: actions/download-artifact@v4 158 | with: 159 | path: artifacts 160 | 161 | # 查看artifact 162 | - name: list artifact 163 | run: | 164 | tree artifacts 165 | 166 | # 合并 167 | - name: merge shared 168 | run: | 169 | mkdir onnxruntime-android-shared 170 | mv artifacts/*/*-shared.7z artifacts/ 171 | find artifacts/*-shared.7z -exec 7z x {} -aoa -oonnxruntime-android-shared \; 172 | find artifacts/*-shared.7z -exec rm {} \; 173 | pushd onnxruntime-android-shared 174 | echo "message(\"OnnxRuntime Path: \${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" > OnnxRuntimeWrapper.cmake 175 | echo "set(OnnxRuntime_DIR \"\${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" >> OnnxRuntimeWrapper.cmake 176 | popd 177 | 7z a ${{ env.SHARED_PKG_NAME }}.7z onnxruntime-android-shared 178 | rm -r -f onnxruntime-android-shared 179 | 180 | - name: merge static 181 | run: | 182 | mkdir onnxruntime-android-static 183 | mv artifacts/*/*-static.7z artifacts/ 184 | find artifacts/*-static.7z -exec 7z x {} -aoa -oonnxruntime-android-static \; 185 | find artifacts/*-static.7z -exec rm {} \; 186 | pushd onnxruntime-android-static 187 | echo "message(\"OnnxRuntime Path: \${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" > OnnxRuntimeWrapper.cmake 188 | echo "set(OnnxRuntime_DIR \"\${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" >> OnnxRuntimeWrapper.cmake 189 | popd 190 | 7z a ${{ env.STATIC_PKG_NAME }}.7z onnxruntime-android-static 191 | rm -r -f onnxruntime-android-static 192 | 193 | - name: merge java 194 | run: | 195 | mkdir onnxruntime-android-java 196 | mv artifacts/*/*-java.7z artifacts/ 197 | find artifacts/*-java.7z -exec 7z x {} -aoa -oonnxruntime-android-java \; 198 | find artifacts/*-java.7z -exec rm {} \; 199 | 7z a ${{ env.JAVA_PKG_NAME }}.7z onnxruntime-android-java 200 | rm -r -f onnxruntime-android-java 201 | 202 | # 创建release 上传release 203 | # https://github.com/marketplace/actions/create-release 204 | - name: Create release and upload-archive 205 | uses: ncipollo/release-action@v1 206 | with: 207 | prerelease: true 208 | bodyFile: release.md 209 | artifacts: 'onnxruntime-*.7z' 210 | allowUpdates: true 211 | artifactContentType: application/x-7z-compressed 212 | token: ${{ secrets.GITHUB_TOKEN }} 213 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: macos 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | macos: 8 | 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | ver: 13 | - { onnx: v1.22.0, python: 3.10.11, jdk: 11, gradle: 8.6 } 14 | list: 15 | - { os_ver: 12 } 16 | - { os_ver: 13 } 17 | - { os_ver: 14 } 18 | arch: 19 | [ 20 | x86_64, 21 | arm64, 22 | arm64e, 23 | ] 24 | exclude: 25 | - list: { os_ver: 12 } 26 | 27 | runs-on: macos-${{ matrix.list.os_ver }} 28 | name: macos-${{ matrix.list.os_ver }}-${{ matrix.arch }} 29 | 30 | env: 31 | BUILD_SCRIPT: build-onnxruntime-mac.sh 32 | SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-macos-${{ matrix.list.os_ver }}-${{ matrix.arch }}-shared 33 | STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-macos-${{ matrix.list.os_ver }}-${{ matrix.arch }}-static 34 | JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-macos-${{ matrix.list.os_ver }}-${{ matrix.arch }}-java 35 | 36 | steps: 37 | - name: Set up Python 38 | uses: actions/setup-python@v5 39 | with: 40 | python-version: '${{ matrix.ver.python }}' 41 | 42 | # Setup JDK 43 | - name: Set up JDK 44 | uses: actions/setup-java@v4 45 | with: 46 | java-version: '${{ matrix.ver.jdk }}' 47 | distribution: 'adopt' 48 | 49 | - uses: gradle/actions/setup-gradle@v3 50 | with: 51 | gradle-version: ${{ matrix.ver.gradle }} 52 | 53 | - name: test gradle 54 | run: gradle --version 55 | 56 | # 检出代码 57 | - uses: actions/checkout@v4 58 | 59 | # 检出onnxruntime 60 | - name: checkout onnxruntime 61 | uses: actions/checkout@v4 62 | with: 63 | repository: microsoft/onnxruntime 64 | path: onnxruntime-${{ matrix.ver.onnx }} 65 | ref: ${{ matrix.ver.onnx }} 66 | submodules: recursive 67 | 68 | # 复制 69 | - name: copy build script 70 | run: | 71 | cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }} 72 | 73 | # 编译 74 | - name: build lib 75 | run: | 76 | cd onnxruntime-${{ matrix.ver.onnx }} 77 | chmod a+x ${{ env.BUILD_SCRIPT }} 78 | ./${{ env.BUILD_SCRIPT }} -n ${{ matrix.arch }} 79 | 80 | # install文件夹改名macos,并使用7z压缩 81 | - name: 7z shared lib 82 | run: | 83 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Darwin-${{ matrix.arch }}/Release/install ${{ env.SHARED_PKG_NAME }} 84 | 7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ env.SHARED_PKG_NAME }} 85 | rm -r -f ${{ env.SHARED_PKG_NAME }} 86 | 87 | - name: 7z static lib 88 | run: | 89 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Darwin-${{ matrix.arch }}/Release/install-static ${{ env.STATIC_PKG_NAME }} 90 | 7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ env.STATIC_PKG_NAME }} 91 | rm -r -f ${{ env.STATIC_PKG_NAME }} 92 | 93 | - name: build java 94 | run: | 95 | cd onnxruntime-${{ matrix.ver.onnx }} 96 | chmod a+x ${{ env.BUILD_SCRIPT }} 97 | ./${{ env.BUILD_SCRIPT }} -n ${{ matrix.arch }} -j 98 | 99 | - name: 7z java lib 100 | run: | 101 | if [ -d "onnxruntime-${{ matrix.ver.onnx }}/build-Darwin-${{ matrix.arch }}/Release/java/build/libs" ]; then 102 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Darwin-${{ matrix.arch }}/Release/java/build/libs ${{ env.JAVA_PKG_NAME }} 103 | 7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ env.JAVA_PKG_NAME }} 104 | rm -r -f ${{ env.JAVA_PKG_NAME }} 105 | fi 106 | 107 | # 上传artifact 108 | # - name: upload shared lib 109 | # uses: actions/upload-artifact@v4 110 | # with: 111 | # name: ${{ env.SHARED_PKG_NAME }} 112 | # path: ${{ env.SHARED_PKG_NAME }}.7z 113 | 114 | # - name: upload static lib 115 | # uses: actions/upload-artifact@v4 116 | # with: 117 | # name: ${{ env.STATIC_PKG_NAME }} 118 | # path: ${{ env.STATIC_PKG_NAME }}.7z 119 | 120 | # - name: Check file existence 121 | # id: check_java_7z 122 | # uses: andstor/file-existence-action@v3 123 | # with: 124 | # files: "${{ env.JAVA_PKG_NAME }}.7z" 125 | 126 | # - name: upload java lib 127 | # if: steps.check_java_7z.outputs.files_exists == 'true' 128 | # uses: actions/upload-artifact@v4 129 | # with: 130 | # name: ${{ env.JAVA_PKG_NAME }} 131 | # path: ${{ env.JAVA_PKG_NAME }}.7z 132 | 133 | # 获取所有的git log和tag 134 | # - name: Unshallow 135 | # run: git fetch --prune --unshallow 136 | 137 | # 获取git log 从 previousTag 到 lastTag 138 | # - name: Get git log 139 | # id: git-log 140 | # run: | 141 | # previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) 142 | # lastTag=$(git describe --abbrev=0 --tags) 143 | # echo "previousTag:$previousTag ~ lastTag:$lastTag" 144 | # log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S') 145 | # echo "$log" 146 | # echo "log_state="$log"" >> $GITHUB_ENV 147 | 148 | # 创建Changelog文件 triggered by git tag push 149 | # - name: Generate Changelog 150 | # if: startsWith(github.ref, 'refs/tags/') 151 | # run: | 152 | # echo -e '${{ env.log_state }}' > release.md 153 | 154 | # 创建release 上传release 155 | # https://github.com/marketplace/actions/create-release 156 | - name: Create release and upload-archive 157 | uses: ncipollo/release-action@v1 158 | with: 159 | prerelease: true 160 | bodyFile: release.md 161 | artifacts: 'onnxruntime-*.7z' 162 | allowUpdates: true 163 | artifactContentType: application/x-7z-compressed 164 | token: ${{ secrets.GITHUB_TOKEN }} 165 | -------------------------------------------------------------------------------- /.github/workflows/musl-gcc.yml: -------------------------------------------------------------------------------- 1 | name: musl-gcc 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | musl-cross-build: 8 | runs-on: ubuntu-22.04 9 | 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | ver: 14 | - { onnx: v1.22.0, musl: 14.2.0 } 15 | arch: 16 | [ 17 | aarch64-linux-musl, #OK 18 | aarch64_be-linux-musl, 19 | arm-linux-musleabi, 20 | arm-linux-musleabihf, 21 | armeb-linux-musleabi, 22 | armeb-linux-musleabihf, 23 | armel-linux-musleabi, 24 | armel-linux-musleabihf, 25 | armv5l-linux-musleabi, 26 | armv5l-linux-musleabihf, 27 | armv5te-linux-musleabi, 28 | armv6-linux-musleabi, 29 | armv6-linux-musleabihf, 30 | armv7-linux-musleabi, 31 | armv7-linux-musleabihf, 32 | armv7l-linux-musleabihf, 33 | armv7m-linux-musleabi, 34 | armv7r-linux-musleabihf, 35 | i486-linux-musl, 36 | i586-linux-musl, 37 | i686-linux-musl, 38 | m68k-linux-musl, 39 | microblaze-linux-musl, 40 | microblazeel-linux-musl, 41 | mips-linux-musl, 42 | mips-linux-muslsf, 43 | mips-linux-musln32sf, 44 | mips64-linux-musl, 45 | mips64-linux-musln32, 46 | mips64-linux-musln32sf, 47 | mips64el-linux-musl, #OK 48 | mips64el-linux-musln32, 49 | mips64el-linux-musln32sf, 50 | mipsel-linux-musl, #OK 51 | mipsel-linux-musln32, #OK 52 | mipsel-linux-musln32sf, #OK 53 | mipsel-linux-muslsf, #OK 54 | or1k-linux-musl, 55 | powerpc-linux-musl, 56 | powerpc-linux-muslsf, 57 | powerpc64-linux-musl, 58 | powerpc64le-linux-musl, 59 | powerpcle-linux-musl, 60 | powerpcle-linux-muslsf, 61 | riscv32-linux-musl, #OK 62 | riscv64-linux-musl, #OK 63 | s390x-linux-musl, 64 | sh2-linux-musl, #OK 65 | sh2eb-linux-musl, 66 | sh4-linux-musl, 67 | sh4eb-linux-musl, 68 | x86_64-linux-musl, #OK 69 | x86_64-linux-muslx32, #OK 70 | loongarch64-linux-musl, 71 | ] 72 | exclude: 73 | - arch: aarch64_be-linux-musl #error: static assertion failed: ORT format only supports little-endian machines 74 | - arch: armeb-linux-musleabi #error: ‘MLAS_FLOAT32X4’ does not name a type 75 | - arch: armeb-linux-musleabihf #error: static assertion failed: ORT format only supports little-endian machines 76 | - arch: armel-linux-musleabi #error: ‘MLAS_FLOAT32X4’ does not name a type 77 | - arch: armel-linux-musleabihf #error: static assertion failed 78 | - arch: arm-linux-musleabi #error: ‘MLAS_FLOAT32X4’ does not name a type 79 | - arch: arm-linux-musleabihf #error: static assertion failed 80 | - arch: armv5l-linux-musleabi #error: ‘MLAS_FLOAT32X4’ does not name a type 81 | - arch: armv5l-linux-musleabihf #error: static assertion failed 82 | - arch: armv5te-linux-musleabi #error: ‘MLAS_FLOAT32X4’ does not name a type 83 | - arch: armv6-linux-musleabi #error: ‘MLAS_FLOAT32X4’ does not name a type 84 | - arch: armv6-linux-musleabihf #error: static assertion failed 85 | - arch: armv7-linux-musleabi #error: ‘MLAS_FLOAT32X4’ does not name a type 86 | - arch: armv7-linux-musleabihf #error: static assertion failed 87 | - arch: armv7l-linux-musleabihf #error: static assertion failed 88 | - arch: armv7m-linux-musleabi #error: ‘MLAS_FLOAT32X4’ was not declared in this scope 89 | - arch: armv7r-linux-musleabihf #error: static assertion failed 90 | - arch: i486-linux-musl #error: SSE vector return without SSE enabled changes the ABI 91 | - arch: i586-linux-musl #error: SSE vector return without SSE enabled changes the ABI 92 | - arch: i686-linux-musl #error: SSE vector return without SSE enabled changes the ABI 93 | - arch: m68k-linux-musl #error: static assertion failed 94 | - arch: microblazeel-linux-musl #error: static assertion failed: Platform is not 64-bit 95 | - arch: microblaze-linux-musl #error: static assertion failed: ORT format only supports little-endian machines 96 | - arch: mips64el-linux-musln32 #error: static assertion failed: Platform is not 64-bit 97 | - arch: mips64el-linux-musln32sf #error: static assertion failed: Platform is not 64-bit 98 | - arch: mips64-linux-musl #error: static assertion failed: ORT format only supports little-endian machines 99 | - arch: mips64-linux-musln32 #error: static assertion failed: ORT format only supports little-endian machines 100 | - arch: mips64-linux-musln32sf #error: static assertion failed: ORT format only supports little-endian machines 101 | - arch: powerpc64le-linux-musl #error: there are no arguments to ‘vec_splat’ that depend on a template parameter, so a declaration of ‘vec_splat’ must be available 102 | - arch: powerpc64-linux-musl #error: there are no arguments to ‘vec_splat’ that depend on a template parameter, so a declaration of ‘vec_splat’ must be available 103 | - arch: powerpcle-linux-musl #error: GCC vector returned by reference: non-standard ABI extension with no compatibility guarantee 104 | - arch: powerpcle-linux-muslsf #error: GCC vector returned by reference: non-standard ABI extension with no compatibility guarantee 105 | - arch: powerpc-linux-musl #error: GCC vector returned by reference: non-standard ABI extension with no compatibility guarantee 106 | - arch: powerpc-linux-muslsf #error: GCC vector returned by reference: non-standard ABI extension with no compatibility guarantee 107 | - arch: mips-linux-musl #error: static assertion failed: ORT format only supports little-endian machines 108 | - arch: mips-linux-muslsf #error: static assertion failed: ORT format only supports little-endian machines 109 | - arch: mips-linux-musln32sf #error: static assertion failed: ORT format only supports little-endian machines 110 | - arch: or1k-linux-musl #error: static assertion failed: Platform is not 64-bit 111 | - arch: s390x-linux-musl #error: static assertion failed: ORT format only supports little-endian machines 112 | - arch: sh2eb-linux-musl #error: static assertion failed: ORT format only supports little-endian machines 113 | - arch: sh4-linux-musl #error: unable to find a register to spill in class ‘R0_REGS’ 114 | - arch: sh4eb-linux-musl #error: static assertion failed: ORT format only supports little-endian machines 115 | - arch: loongarch64-linux-musl #error: unrecognized command-line option ‘-mlsx’ 116 | - arch: mips64el-linux-musl #error: ld returned 1 exit status 117 | - arch: mipsel-linux-musl #error: ld returned 1 exit status 118 | - arch: mipsel-linux-musln32 #error: ld returned 1 exit status 119 | - arch: mipsel-linux-musln32sf #error: ld returned 1 exit status 120 | - arch: mipsel-linux-muslsf #error: ld returned 1 exit status 121 | - arch: sh2-linux-musl #error: ld returned 1 exit status 122 | 123 | name: ${{ matrix.arch }} 124 | 125 | env: 126 | BUILD_SCRIPT: build-onnxruntime-musl.sh 127 | BUILD_OPTIONS: onnxruntime_cmake_options.txt 128 | SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-${{ matrix.arch }}-shared 129 | STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-${{ matrix.arch }}-static 130 | MUSL_NAME: ${{ matrix.arch }}-${{ matrix.ver.musl }} 131 | 132 | steps: 133 | # 检出代码 134 | - uses: actions/checkout@v4 135 | 136 | # 部署musl 137 | - name: deploy musl gcc 138 | run: | 139 | wget https://github.com/benjaminwan/musl-cross-builder/releases/download/${{ matrix.ver.musl }}/${{ env.MUSL_NAME }}.7z -O ${{ matrix.arch }}.7z 140 | 7z x ${{ matrix.arch }}.7z -aoa 141 | mv ${{ matrix.arch }}/ /opt/ 142 | echo "/opt/${{ matrix.arch }}" >> $GITHUB_PATH 143 | 144 | # 检出onnxruntime 145 | - name: checkout onnxruntime 146 | uses: actions/checkout@v4 147 | with: 148 | repository: microsoft/onnxruntime 149 | path: onnxruntime-${{ matrix.ver.onnx }} 150 | ref: ${{ matrix.ver.onnx }} 151 | submodules: recursive 152 | 153 | - name: git submodule sync 154 | run: | 155 | cd onnxruntime-${{ matrix.ver.onnx }} 156 | git submodule sync --recursive 157 | git submodule update --init --recursive 158 | 159 | # 复制 160 | - name: copy 161 | run: | 162 | cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }} 163 | cp ${{ env.BUILD_OPTIONS }} onnxruntime-${{ matrix.ver.onnx }} 164 | cp -r patches onnxruntime-${{ matrix.ver.onnx }}/ 165 | wget https://github.com/benjaminwan/musl-cross-builder/raw/main/musl-cross.toolchain.cmake -O musl-cross.toolchain.cmake 166 | cp musl-cross.toolchain.cmake onnxruntime-${{ matrix.ver.onnx }} 167 | 168 | - name: build 169 | run: | 170 | cd onnxruntime-${{ matrix.ver.onnx }} 171 | chmod a+x ${{ env.BUILD_SCRIPT }} 172 | ./${{ env.BUILD_SCRIPT }} -n '${{ matrix.arch }}' -p '/opt/${{ matrix.arch }}' 173 | 174 | # install文件夹改名linux,并使用7z压缩 175 | - name: 7zip shared lib 176 | run: | 177 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Release-${{ matrix.arch }}/install ${{ env.SHARED_PKG_NAME }} 178 | 7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ env.SHARED_PKG_NAME }} 179 | rm -r -f ${{ env.SHARED_PKG_NAME }} 180 | 181 | - name: 7zip static lib 182 | run: | 183 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Release-${{ matrix.arch }}/install-static ${{ env.STATIC_PKG_NAME }} 184 | 7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ env.STATIC_PKG_NAME }} 185 | rm -r -f ${{ env.STATIC_PKG_NAME }} 186 | 187 | # 上传artifact 188 | # - name: upload shared lib 189 | # uses: actions/upload-artifact@v4 190 | # with: 191 | # name: ${{ env.SHARED_PKG_NAME }} 192 | # path: ${{ env.SHARED_PKG_NAME }}.7z 193 | 194 | # - name: upload static lib 195 | # uses: actions/upload-artifact@v4 196 | # with: 197 | # name: ${{ env.STATIC_PKG_NAME }} 198 | # path: ${{ env.STATIC_PKG_NAME }}.7z 199 | 200 | # 获取所有的git log和tag 201 | # - name: Unshallow 202 | # run: git fetch --prune --unshallow 203 | 204 | # 获取git log 从 previousTag 到 lastTag 205 | # - name: Get git log 206 | # id: git-log 207 | # run: | 208 | # previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) 209 | # lastTag=$(git describe --abbrev=0 --tags) 210 | # echo "previousTag:$previousTag ~ lastTag:$lastTag" 211 | # log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S') 212 | # echo "$log" 213 | # echo "log_state="$log"" >> $GITHUB_ENV 214 | 215 | # 创建Changelog文件 triggered by git tag push 216 | # - name: Generate Changelog 217 | # if: startsWith(github.ref, 'refs/tags/') 218 | # run: | 219 | # echo -e '${{ env.log_state }}' > release.md 220 | 221 | # 创建release 上传release 222 | # https://github.com/marketplace/actions/create-release 223 | - name: Create release and upload-archive 224 | uses: ncipollo/release-action@v1 225 | with: 226 | prerelease: true 227 | bodyFile: release.md 228 | artifacts: 'onnxruntime-*.7z' 229 | allowUpdates: true 230 | artifactContentType: application/x-7z-compressed 231 | token: ${{ secrets.GITHUB_TOKEN }} 232 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: ubuntu 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | ubuntu: 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | os_name: [ ubuntu ] 14 | ver: 15 | - { onnx: v1.22.0, cmake: 3.28.6, python: 3.10.11, gradle: 8.6, jdk: openjdk-11-jdk } 16 | list: 17 | - { os_ver: 22.04, os_id: jammy } 18 | arch: 19 | [ 20 | amd64, 21 | arm, 22 | arm64, 23 | ] 24 | # exclude: 25 | # - list: { os_ver: 20.04, os_id: focal } 26 | # arch: arm64 27 | 28 | name: ${{ matrix.os_name }}-${{ matrix.list.os_ver }}-${{ matrix.arch }} 29 | 30 | env: 31 | BUILD_SCRIPT: build-onnxruntime-linux.sh 32 | SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}-shared 33 | STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}-static 34 | JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-ubuntu-${{ matrix.list.os_ver }}-${{ matrix.arch }}-java 35 | CMAKE_NAME: cmake-${{ matrix.ver.cmake }}-${{ matrix.os_name }}-${{ matrix.list.os_ver }}-${{ matrix.arch }} 36 | PYTHON_NAME: python-${{ matrix.ver.python }}-${{ matrix.os_name }}-${{ matrix.list.os_ver }}-${{ matrix.arch }} 37 | GRADLE_NAME: gradle-${{ matrix.ver.gradle }}-bin 38 | 39 | steps: 40 | # 检出代码 41 | - uses: actions/checkout@v4 42 | 43 | # 检出onnxruntime 44 | - name: checkout onnxruntime 45 | uses: actions/checkout@v4 46 | with: 47 | repository: microsoft/onnxruntime 48 | path: onnxruntime-${{ matrix.ver.onnx }} 49 | ref: ${{ matrix.ver.onnx }} 50 | submodules: recursive 51 | 52 | # 复制 53 | - name: copy 54 | run: | 55 | cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }} 56 | chmod a+x ${{ env.BUILD_SCRIPT }} 57 | 58 | - name: Host - update 59 | run: sudo apt-get update 60 | 61 | - name: Host - Install host qemu-static 62 | run: sudo apt-get install -y qemu-system binfmt-support qemu-user-static 63 | 64 | - name: Host - Docker multiarch bootstrap 65 | run: sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes 66 | 67 | - name: deploy cmake 68 | run: | 69 | wget https://github.com/benjaminwan/CmakeBuilder/releases/download/${{ matrix.ver.cmake }}/${{ env.CMAKE_NAME }}.7z -O ${{ env.CMAKE_NAME }}.7z 70 | 7z x ${{ env.CMAKE_NAME }}.7z -aoa 71 | rm ${{ env.CMAKE_NAME }}.7z 72 | 73 | - name: deploy python 74 | run: | 75 | wget https://github.com/benjaminwan/PythonBuilder/releases/download/${{ matrix.ver.python }}/${{ env.PYTHON_NAME }}.7z -O ${{ env.PYTHON_NAME }}.7z 76 | 7z x ${{ env.PYTHON_NAME }}.7z -aoa 77 | rm ${{ env.PYTHON_NAME }}.7z 78 | 79 | - name: deploy gradle 80 | run: | 81 | wget https://services.gradle.org/distributions/${{ env.GRADLE_NAME }}.zip -O ${{ env.GRADLE_NAME }}.zip 82 | 7z x ${{ env.GRADLE_NAME }}.zip -aoa 83 | rm ${{ env.GRADLE_NAME }}.zip 84 | 85 | - name: Host - Create Docker template env file 86 | run: | 87 | echo "PATH=/root/cmake-${{ matrix.ver.cmake }}/bin:/root/python-${{ matrix.ver.python }}/bin:/root/gradle-${{ matrix.ver.gradle }}/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" > env.custom 88 | echo "DEBIAN_FRONTEND=noninteractive" >> env.custom 89 | echo "TZ=Etc/UTC" >> env.custom 90 | 91 | - name: Host - Create docker container 92 | run: docker run --name ${{ matrix.os_name }} --env-file env.custom --platform linux/${{ matrix.arch }} -it -d -w /root -v ${{ github.workspace }}:/root ${{ matrix.os_name }}:${{ matrix.list.os_id }} 93 | 94 | - name: Docker - apt-get update 95 | run: docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get update 96 | 97 | - name: Docker - install build deps 98 | run: docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get install -y build-essential git software-properties-common 99 | 100 | - name: Docker - install jdk 101 | run: | 102 | docker exec --env-file env.custom -w /root ${{ matrix.os_name }} add-apt-repository -y ppa:openjdk-r/ppa 103 | docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get update 104 | docker exec --env-file env.custom -w /root ${{ matrix.os_name }} apt-get -y install ${{ matrix.ver.jdk }} 105 | docker exec --env-file env.custom -w /root ${{ matrix.os_name }} java -version 106 | JAVA_DIR=$(docker exec ${{ matrix.os_name }} readlink -f /usr/bin/javac | sed "s:/bin/javac::") 107 | echo "$JAVA_DIR" 108 | echo "JAVA_HOME=$JAVA_DIR" >> env.custom 109 | echo "JAVA_INCLUDE_PATH=$JAVA_DIR/include" >> env.custom 110 | 111 | - name: Docker - build lib 112 | run: | 113 | docker exec --env-file env.custom -w /root ${{ matrix.os_name }} git config --global --add safe.directory "*" 114 | docker exec --env-file env.custom -w /root/onnxruntime-${{ matrix.ver.onnx }} ${{ matrix.os_name }} chmod a+x ${{ env.BUILD_SCRIPT }} 115 | docker exec --env-file env.custom -w /root/onnxruntime-${{ matrix.ver.onnx }} ${{ matrix.os_name }} ./${{ env.BUILD_SCRIPT }} 116 | 117 | # install文件夹改名linux,并使用7z压缩 118 | - name: 7zip shared lib 119 | run: | 120 | sudo chown -R $(id -u):$(id -g) onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/install 121 | sudo chmod -R 755 onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/install 122 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/install ${{ env.SHARED_PKG_NAME }} 123 | 7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ env.SHARED_PKG_NAME }} 124 | rm -r -f ${{ env.SHARED_PKG_NAME }} 125 | 126 | - name: 7zip static lib 127 | run: | 128 | sudo chown -R $(id -u):$(id -g) onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/install-static 129 | sudo chmod -R 755 onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/install-static 130 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/install-static ${{ env.STATIC_PKG_NAME }} 131 | 7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ env.STATIC_PKG_NAME }} 132 | rm -r -f ${{ env.STATIC_PKG_NAME }} 133 | 134 | - name: Docker - build java 135 | run: | 136 | docker exec --env-file env.custom -w /root/onnxruntime-${{ matrix.ver.onnx }} ${{ matrix.os_name }} ./${{ env.BUILD_SCRIPT }} -j 137 | 138 | - name: 7zip java lib 139 | run: | 140 | if [ -d "onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/java/build/libs" ]; then 141 | sudo chown -R $(id -u):$(id -g) onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/java/build/libs 142 | sudo chmod -R 755 onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/java/build/libs 143 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Linux/Release/java/build/libs ${{ env.JAVA_PKG_NAME }} 144 | 7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ env.JAVA_PKG_NAME }} 145 | rm -r -f ${{ env.JAVA_PKG_NAME }} 146 | fi 147 | 148 | # 上传artifact 149 | # - name: upload shared lib 150 | # uses: actions/upload-artifact@v4 151 | # with: 152 | # name: ${{ env.SHARED_PKG_NAME }} 153 | # path: ${{ env.SHARED_PKG_NAME }}.7z 154 | 155 | # - name: upload static lib 156 | # uses: actions/upload-artifact@v4 157 | # with: 158 | # name: ${{ env.STATIC_PKG_NAME }} 159 | # path: ${{ env.STATIC_PKG_NAME }}.7z 160 | 161 | # - name: Check file existence 162 | # id: check_java_7z 163 | # uses: andstor/file-existence-action@v3 164 | # with: 165 | # files: "${{ env.JAVA_PKG_NAME }}.7z" 166 | 167 | # - name: upload java lib 168 | # if: steps.check_java_7z.outputs.files_exists == 'true' 169 | # uses: actions/upload-artifact@v4 170 | # with: 171 | # name: ${{ env.JAVA_PKG_NAME }} 172 | # path: ${{ env.JAVA_PKG_NAME }}.7z 173 | 174 | # 获取所有的git log和tag 175 | # - name: Unshallow 176 | # run: git fetch --prune --unshallow 177 | 178 | # 获取git log 从 previousTag 到 lastTag 179 | # - name: Get git log 180 | # id: git-log 181 | # run: | 182 | # previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) 183 | # lastTag=$(git describe --abbrev=0 --tags) 184 | # echo "previousTag:$previousTag ~ lastTag:$lastTag" 185 | # log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S') 186 | # echo "$log" 187 | # echo "log_state="$log"" >> $GITHUB_ENV 188 | 189 | # 创建Changelog文件 triggered by git tag push 190 | # - name: Generate Changelog 191 | # if: startsWith(github.ref, 'refs/tags/') 192 | # run: | 193 | # echo -e '${{ env.log_state }}' > release.md 194 | 195 | # 创建release 上传release 196 | # https://github.com/marketplace/actions/create-release 197 | - name: Create release and upload-archive 198 | uses: ncipollo/release-action@v1 199 | with: 200 | prerelease: true 201 | bodyFile: release.md 202 | artifacts: 'onnxruntime-*.7z' 203 | allowUpdates: true 204 | artifactContentType: application/x-7z-compressed 205 | token: ${{ secrets.GITHUB_TOKEN }} 206 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: windows 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | windows: 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | ver: 12 | - { onnx: v1.22.0, python: 3.10.11, jdk: 11, gradle: 8.6 } 13 | list: 14 | - { win_ver: 2022, vs_name: vs2022, vs_ver: v143, vs_path: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' } 15 | arch: 16 | [ 17 | x64, 18 | x86, 19 | arm64, 20 | ] 21 | crt: 22 | [ 23 | md, 24 | mt, 25 | ] 26 | 27 | runs-on: windows-${{ matrix.list.win_ver }} 28 | 29 | name: windows-${{ matrix.list.vs_name }}-${{ matrix.arch }}-${{ matrix.crt }} 30 | 31 | env: 32 | BUILD_SCRIPT: build-onnxruntime-win.ps1 33 | SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-windows-${{ matrix.list.vs_name }}-${{ matrix.arch }}-shared-${{ matrix.crt }} 34 | STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-windows-${{ matrix.list.vs_name }}-${{ matrix.arch }}-static-${{ matrix.crt }} 35 | JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-windows-${{ matrix.list.vs_name }}-java-${{ matrix.arch }}-${{ matrix.crt }} 36 | 37 | steps: 38 | # https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json 39 | - name: Set up Python 40 | uses: actions/setup-python@v5 41 | with: 42 | python-version: '${{ matrix.ver.python }}' 43 | 44 | # Setup JDK 45 | - name: Set up JDK 46 | uses: actions/setup-java@v4 47 | with: 48 | java-version: '${{ matrix.ver.jdk }}' 49 | distribution: 'adopt' 50 | 51 | - uses: gradle/actions/setup-gradle@v3 52 | with: 53 | gradle-version: ${{ matrix.ver.gradle }} 54 | 55 | - name: test gradle 56 | run: gradle --version 57 | 58 | # 检出代码 59 | - uses: actions/checkout@v4 60 | 61 | # 检出onnxruntime 62 | - name: checkout onnxruntime 63 | uses: actions/checkout@v4 64 | with: 65 | repository: microsoft/onnxruntime 66 | path: onnxruntime-${{ matrix.ver.onnx }} 67 | ref: ${{ matrix.ver.onnx }} 68 | submodules: recursive 69 | 70 | # 复制 71 | - name: copy 72 | run: | 73 | cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }} 74 | cp Launch-VsDevShell.ps1 onnxruntime-${{ matrix.ver.onnx }} 75 | 76 | - name: build 77 | shell: powershell 78 | run: | 79 | cd onnxruntime-${{ matrix.ver.onnx }} 80 | if ("${{ matrix.arch }}" -eq "x64" ) 81 | { 82 | & '.\Launch-VsDevShell.ps1' -VsInstallationPath '${{ matrix.list.vs_path }}' -SkipAutomaticLocation -HostArch amd64 -Arch amd64 83 | } 84 | else 85 | { 86 | & '.\Launch-VsDevShell.ps1' -VsInstallationPath '${{ matrix.list.vs_path }}' -SkipAutomaticLocation -HostArch amd64 -Arch ${{ matrix.arch }} 87 | } 88 | .\${{ env.BUILD_SCRIPT }} -VsArch ${{ matrix.arch }} -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }} 89 | 90 | # install文件夹改名,并使用7z压缩 91 | - name: 7zip pack shared libs 92 | run: | 93 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-${{ matrix.arch }}-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/Release/install ${{ env.SHARED_PKG_NAME }} 94 | 7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ env.SHARED_PKG_NAME }} 95 | rm ${{ env.SHARED_PKG_NAME }} -r -fo 96 | 97 | - name: 7zip pack static libs 98 | run: | 99 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-${{ matrix.arch }}-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/Release/install-static ${{ env.STATIC_PKG_NAME }} 100 | 7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ env.STATIC_PKG_NAME }} 101 | rm ${{ env.STATIC_PKG_NAME }} -r -fo 102 | 103 | - name: build x64 java 104 | shell: powershell 105 | if: ${{ (matrix.arch == 'x64') }} 106 | run: | 107 | cd onnxruntime-${{ matrix.ver.onnx }} 108 | & '.\Launch-VsDevShell.ps1' -VsInstallationPath '${{ matrix.list.vs_path }}' -SkipAutomaticLocation -HostArch amd64 -Arch amd64 109 | .\${{ env.BUILD_SCRIPT }} -VsArch x64 -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }} -BuildJava 110 | 111 | - name: 7zip pack java libs 112 | if: ${{ (matrix.arch == 'x64') }} 113 | run: | 114 | cp -r onnxruntime-${{ matrix.ver.onnx }}/build-x64-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/Release/java/build/libs ${{ env.JAVA_PKG_NAME }} 115 | 7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ env.JAVA_PKG_NAME }} 116 | 117 | # 上传artifact 118 | - name: upload shared lib 119 | uses: actions/upload-artifact@v4 120 | with: 121 | name: ${{ env.SHARED_PKG_NAME }} 122 | path: ${{ env.SHARED_PKG_NAME }}.7z 123 | 124 | - name: upload static lib 125 | uses: actions/upload-artifact@v4 126 | with: 127 | name: ${{ env.STATIC_PKG_NAME }} 128 | path: ${{ env.STATIC_PKG_NAME }}.7z 129 | 130 | - name: upload java lib 131 | if: ${{ (matrix.arch == 'x64') }} 132 | uses: actions/upload-artifact@v4 133 | with: 134 | name: ${{ env.JAVA_PKG_NAME }} 135 | path: ${{ env.JAVA_PKG_NAME }}.7z 136 | 137 | release: 138 | needs: [ windows ] 139 | 140 | runs-on: ubuntu-latest 141 | 142 | steps: 143 | # 检出代码 144 | - uses: actions/checkout@v4 145 | 146 | # 获取所有的git log和tag 147 | # - name: Unshallow 148 | # run: git fetch --prune --unshallow 149 | 150 | # 获取git log 从 previousTag 到 lastTag 151 | # - name: Get git log 152 | # id: git-log 153 | # run: | 154 | # previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`) 155 | # lastTag=$(git describe --abbrev=0 --tags) 156 | # echo "previousTag:$previousTag ~ lastTag:$lastTag" 157 | # log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S') 158 | # echo "$log" 159 | # echo "log_state="$log"" >> $GITHUB_ENV 160 | 161 | # 创建Changelog文件 triggered by git tag push 162 | # - name: Generate Changelog 163 | # if: startsWith(github.ref, 'refs/tags/') 164 | # run: | 165 | # echo -e '${{ env.log_state }}' > release.md 166 | 167 | # 下载artifact 168 | - name: download 169 | uses: actions/download-artifact@v4 170 | with: 171 | path: artifacts 172 | 173 | # 查看artifact 174 | - name: list artifact 175 | run: | 176 | tree artifacts 177 | 178 | # 创建release 上传release 179 | # https://github.com/marketplace/actions/create-release 180 | - name: upload-windows 181 | uses: ncipollo/release-action@v1 182 | with: 183 | prerelease: true 184 | bodyFile: release.md 185 | artifacts: artifacts/*/*.7z 186 | allowUpdates: true 187 | artifactContentType: application/x-7z-compressed 188 | token: ${{ secrets.GITHUB_TOKEN }} 189 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Python template 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | pip-wheel-metadata/ 26 | share/python-wheels/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | MANIFEST 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .nox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | *.py,cover 53 | .hypothesis/ 54 | .pytest_cache/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | db.sqlite3 64 | db.sqlite3-journal 65 | 66 | # Flask stuff: 67 | instance/ 68 | .webassets-cache 69 | 70 | # Scrapy stuff: 71 | .scrapy 72 | 73 | # Sphinx documentation 74 | docs/_build/ 75 | 76 | # PyBuilder 77 | target/ 78 | 79 | # Jupyter Notebook 80 | .ipynb_checkpoints 81 | 82 | # IPython 83 | profile_default/ 84 | ipython_config.py 85 | 86 | # pyenv 87 | .python-version 88 | 89 | # pipenv 90 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 91 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 92 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 93 | # install all needed dependencies. 94 | #Pipfile.lock 95 | 96 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 97 | __pypackages__/ 98 | 99 | # Celery stuff 100 | celerybeat-schedule 101 | celerybeat.pid 102 | 103 | # SageMath parsed files 104 | *.sage.py 105 | 106 | # Environments 107 | .env 108 | .venv 109 | env/ 110 | venv/ 111 | ENV/ 112 | env.bak/ 113 | venv.bak/ 114 | 115 | # Spyder project settings 116 | .spyderproject 117 | .spyproject 118 | 119 | # Rope project settings 120 | .ropeproject 121 | 122 | # mkdocs documentation 123 | /site 124 | 125 | # mypy 126 | .mypy_cache/ 127 | .dmypy.json 128 | dmypy.json 129 | 130 | # Pyre type checker 131 | .pyre/ 132 | 133 | #idea 134 | .idea -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Launch-VsDevShell.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS Launch Developer PowerShell 3 | .DESCRIPTION 4 | Locates and imports a Developer PowerShell module and calls the Enter-VsDevShell cmdlet. The Developer PowerShell module 5 | is located in one of several ways: 6 | 1) From a path in a Visual Studio installation 7 | 2) From the latest installation of Visual Studio (higher versions first) 8 | 3) From the instance ID of a Visual Studio installation 9 | 4) By selecting a Visual Studio installation from a list 10 | 11 | By default, with no parameters, the path to this script is used to locate the Developer PowerShell module. If that fails, 12 | then the latest Visual Studio installation is used. If both methods fail, then the user can select a Visual Studio installation 13 | from a list. 14 | .PARAMETER VsInstallationPath 15 | A path in a Visual Studio installation. The path is used to locate the Developer PowerShell module. 16 | By default, this is the path to this script. 17 | .PARAMETER Latest 18 | Use the latest Visual Studio installation to locate the Developer PowerShell module. 19 | .PARAMETER List 20 | Display a list of Visual Studio installations to choose from. The choosen installation is used to locate the Developer PowerShell module. 21 | .PARAMETER VsInstanceId 22 | A Visual Studio installation instance ID. The matching installation is used to locate the Developer PowerShell module. 23 | .PARAMETER ExcludePrerelease 24 | Excludes Prerelease versions of Visual Studio from consideration. Applies only to Latest and List. 25 | .PARAMETER VsWherePath 26 | Path to the vswhere utility used to located and identify Visual Studio installations. 27 | By default, the path is the well-known location shared by Visual Studio installations. 28 | #> 29 | [CmdletBinding(DefaultParameterSetName = "Default")] 30 | param ( 31 | [ValidateScript({Test-Path $_})] 32 | [Parameter(ParameterSetName = "VsInstallationPath")] 33 | [string] 34 | $VsInstallationPath = "$($MyInvocation.MyCommand.Definition)", 35 | 36 | [Parameter(ParameterSetName = "Latest")] 37 | [switch] 38 | $Latest, 39 | 40 | [Parameter(ParameterSetName = "List")] 41 | [switch] 42 | $List, 43 | 44 | [Parameter(ParameterSetName = "List")] 45 | [object[]] 46 | $DisplayProperties = @("displayName", "instanceId", "installationVersion", "isPrerelease", "installationName", "installDate"), 47 | 48 | [Parameter(ParameterSetName = "VsInstanceId", Mandatory = $true)] 49 | [string] 50 | $VsInstanceId, 51 | 52 | [Parameter(ParameterSetName = "Latest")] 53 | [Parameter(ParameterSetName = "List")] 54 | [switch] 55 | $ExcludePrerelease, 56 | 57 | [Parameter(ParameterSetName = "Default")] 58 | [Parameter(ParameterSetName = "VsInstallationPath")] 59 | [Parameter(ParameterSetName = "Latest")] 60 | [Parameter(ParameterSetName = "List")] 61 | [Parameter(ParameterSetName = "VsInstanceId")] 62 | [ValidateSet('x86','amd64','arm','arm64')] 63 | [string] 64 | $Arch, 65 | 66 | [Parameter(ParameterSetName = "Default")] 67 | [Parameter(ParameterSetName = "VsInstallationPath")] 68 | [Parameter(ParameterSetName = "Latest")] 69 | [Parameter(ParameterSetName = "List")] 70 | [Parameter(ParameterSetName = "VsInstanceId")] 71 | [ValidateSet('x86','amd64')] 72 | [string] 73 | $HostArch, 74 | 75 | [Parameter(ParameterSetName = "Default")] 76 | [Parameter(ParameterSetName = "VsInstallationPath")] 77 | [Parameter(ParameterSetName = "Latest")] 78 | [Parameter(ParameterSetName = "List")] 79 | [Parameter(ParameterSetName = "VsInstanceId")] 80 | [switch] 81 | $SkipAutomaticLocation, 82 | 83 | [ValidateScript({Test-Path $_ -PathType 'Leaf'})] 84 | [Parameter(ParameterSetName = "Default")] 85 | [Parameter(ParameterSetName = "VsInstallationPath")] 86 | [Parameter(ParameterSetName = "Latest")] 87 | [Parameter(ParameterSetName = "List")] 88 | [Parameter(ParameterSetName = "VsInstanceId")] 89 | [string] 90 | $VsWherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" 91 | ) 92 | 93 | function GetSetupConfigurations { 94 | param ( 95 | $whereArgs 96 | ) 97 | 98 | $expression = "& `"$VsWherePath`" $whereArgs -format json" 99 | Invoke-Expression $expression | ConvertFrom-Json 100 | } 101 | 102 | function LaunchDevShell { 103 | param ( 104 | $config 105 | ) 106 | 107 | $basePath = $config.installationPath 108 | $instanceId = $config.instanceId 109 | 110 | $currModulePath = "$basePath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" 111 | # Prior to 16.3 the DevShell module was in a different location 112 | $prevModulePath = "$basePath\Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll" 113 | 114 | $modulePath = if (Test-Path $prevModulePath) { $prevModulePath } else { $currModulePath } 115 | 116 | if (Test-Path $modulePath) { 117 | Write-Verbose "Found at $modulePath." 118 | 119 | try { 120 | Import-Module $modulePath 121 | } 122 | catch [System.IO.FileLoadException] { 123 | Write-Verbose "The module has already been imported from a different installation of Visual Studio:" 124 | (Get-Module Microsoft.VisualStudio.DevShell).Path | Write-Verbose 125 | } 126 | 127 | $params = @{ 128 | VsInstanceId = $instanceId 129 | } 130 | 131 | $command = Get-Command Enter-VsDevShell 132 | 133 | if ($SkipAutomaticLocation) 134 | { 135 | $params.SkipAutomaticLocation = $true 136 | } 137 | 138 | # -Arch is only available from 17.1 139 | if ($Arch -and $command.Parameters.ContainsKey("Arch")) 140 | { 141 | $params.Arch = $Arch 142 | } 143 | 144 | # -HostArch is only available from 17.1 145 | if ($HostArch -and $command.Parameters.ContainsKey("HostArch")) 146 | { 147 | $params.HostArch = $HostArch 148 | } 149 | 150 | # -ReportNewInstanceType is only available from 16.5 151 | if ($command.Parameters.ContainsKey("ReportNewInstanceType")) { 152 | $params.ReportNewInstanceType = "LaunchScript" 153 | } 154 | 155 | $boundParams = $PSCmdlet.MyInvocation.BoundParameters 156 | 157 | if ($boundParams.ContainsKey("Verbose") -and 158 | $boundParams["Verbose"].IsPresent) 159 | { 160 | Write-Verbose "Enter-VsDevShell Parameters:" 161 | $params.GetEnumerator() | ForEach-Object{ 162 | $message = '{0} = {1}' -f $_.key, $_.value 163 | Write-Verbose $message 164 | } 165 | } 166 | 167 | Enter-VsDevShell @params 168 | exit 169 | } 170 | 171 | throw [System.Management.Automation.ErrorRecord]::new( 172 | [System.Exception]::new("Required assembly could not be located. This most likely indicates an installation error. Try repairing your Visual Studio installation. Expected location: $modulePath"), 173 | "DevShellModuleLoad", 174 | [System.Management.Automation.ErrorCategory]::NotInstalled, 175 | $config) 176 | } 177 | 178 | function VsInstallationPath { 179 | $setupargs = "-path `"$VsInstallationPath`"" 180 | 181 | Write-Verbose "Using path: $VsInstallationPath" 182 | $config = GetSetupConfigurations($setupargs) 183 | LaunchDevShell($config) 184 | } 185 | 186 | function Latest { 187 | $setupargs = "-latest" 188 | 189 | if (-not $ExcludePrerelease) { 190 | $setupargs += " -prerelease" 191 | } 192 | 193 | $config = GetSetupConfigurations($setupargs) 194 | LaunchDevShell($config) 195 | } 196 | 197 | function VsInstanceId { 198 | $configs = GetSetupConfigurations("-prerelease -all") 199 | $config = $configs | Where-Object { $_.instanceId -eq $VsInstanceId } 200 | if ($config) { 201 | Write-Verbose "Found Visual Studio installation with InstanceId of '$($config.instanceId)' and InstallationPath '$($config.installationPath)'" 202 | LaunchDevShell($config) 203 | exit 204 | } 205 | 206 | throw [System.Management.Automation.ErrorRecord]::new( 207 | [System.Exception]::new("Could not find an installation of Visual Studio with InstanceId '$VsInstanceId'."), 208 | "VsSetupInstance", 209 | [System.Management.Automation.ErrorCategory]::InvalidArgument, 210 | $config) 211 | } 212 | 213 | function List { 214 | $setupargs = "-sort" 215 | 216 | if (-not $ExcludePrerelease) { 217 | $setupargs = " -prerelease" 218 | } 219 | 220 | $configs = GetSetupConfigurations($setupargs) 221 | 222 | $DisplayProperties = @("#") + $DisplayProperties 223 | 224 | # Add an incrementing select column 225 | $configs = $configs | 226 | Sort-Object displayName, installationDate | 227 | ForEach-Object {$i = 0}{ $i++; $_ | Add-Member -NotePropertyName "#" -NotePropertyValue $i -PassThru } 228 | 229 | Write-Host "The following Visual Studio installations were found:" 230 | $configs | Format-Table -Property $DisplayProperties 231 | 232 | $selected = Read-Host "Enter '#' of the Visual Studio installation to launch DevShell. to quit: " 233 | if (-not $selected) { exit } 234 | 235 | $config = $configs | Where-Object { $_."#" -eq $selected } 236 | 237 | if ($config) { 238 | LaunchDevShell($config) 239 | } 240 | else { 241 | "Invalid selection: $selected" 242 | } 243 | } 244 | 245 | function Default{ 246 | Write-Verbose "No parameters passed to script. Trying VsInstallationPath." 247 | 248 | try { 249 | VsInstallationPath 250 | exit 251 | } 252 | catch { 253 | Write-Verbose "VsInstallationPath failed. Trying Latest." 254 | } 255 | 256 | Write-Host "Could not start Developer PowerShell using the script path." 257 | Write-Host "Attempting to launch from the latest Visual Studio installation." 258 | 259 | try { 260 | Latest 261 | exit 262 | } 263 | catch { 264 | Write-Verbose "Latest failed. Defaulting to List." 265 | } 266 | 267 | Write-Host "Could not start Developer PowerShell from the latest Visual Studio installation." 268 | Write-Host 269 | 270 | List 271 | } 272 | 273 | if ($PSCmdlet.ParameterSetName) { 274 | & (Get-ChildItem "Function:$($PSCmdlet.ParameterSetName)") 275 | exit 276 | } 277 | # SIG # Begin signature block 278 | # MIIoKgYJKoZIhvcNAQcCoIIoGzCCKBcCAQExDzANBglghkgBZQMEAgEFADB5Bgor 279 | # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG 280 | # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCB7cpavZzVzbDmR 281 | # tFRSbdabKCMPm0+YAH01FA8nFbex/KCCDXYwggX0MIID3KADAgECAhMzAAADrzBA 282 | # DkyjTQVBAAAAAAOvMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD 283 | # VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy 284 | # b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p 285 | # bmcgUENBIDIwMTEwHhcNMjMxMTE2MTkwOTAwWhcNMjQxMTE0MTkwOTAwWjB0MQsw 286 | # CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGlu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EtMDctMDguY3J0 302 | # MAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQELBQADggIBAISxFt/zR2frTFPB45Yd 303 | # mhZpB2nNJoOoi+qlgcTlnO4QwlYN1w/vYwbDy/oFJolD5r6FMJd0RGcgEM8q9TgQ 304 | # 2OC7gQEmhweVJ7yuKJlQBH7P7Pg5RiqgV3cSonJ+OM4kFHbP3gPLiyzssSQdRuPY 305 | # 1mIWoGg9i7Y4ZC8ST7WhpSyc0pns2XsUe1XsIjaUcGu7zd7gg97eCUiLRdVklPmp 306 | # XobH9CEAWakRUGNICYN2AgjhRTC4j3KJfqMkU04R6Toyh4/Toswm1uoDcGr5laYn 307 | # TfcX3u5WnJqJLhuPe8Uj9kGAOcyo0O1mNwDa+LhFEzB6CB32+wfJMumfr6degvLT 308 | # e8x55urQLeTjimBQgS49BSUkhFN7ois3cZyNpnrMca5AZaC7pLI72vuqSsSlLalG 309 | # OcZmPHZGYJqZ0BacN274OZ80Q8B11iNokns9Od348bMb5Z4fihxaBWebl8kWEi2O 310 | # PvQImOAeq3nt7UWJBzJYLAGEpfasaA3ZQgIcEXdD+uwo6ymMzDY6UamFOfYqYWXk 311 | # ntxDGu7ngD2ugKUuccYKJJRiiz+LAUcj90BVcSHRLQop9N8zoALr/1sJuwPrVAtx 312 | # HNEgSW+AKBqIxYWM4Ev32l6agSUAezLMbq5f3d8x9qzT031jMDT+sUAoCw0M5wVt 313 | # CUQcqINPuYjbS1WgJyZIiEkBMIIHejCCBWKgAwIBAgIKYQ6Q0gAAAAAAAzANBgkq 314 | # hkiG9w0BAQsFADCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24x 315 | # EDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlv 316 | # bjEyMDAGA1UEAxMpTWljcm9zb2Z0IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5 317 | # IDIwMTEwHhcNMTE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IbmTlUAXTgqoXNzcitW2o 333 | # ynUClTAZBgkrBgEEAYI3FAIEDB4KAFMAdQBiAEMAQTALBgNVHQ8EBAMCAYYwDwYD 334 | # VR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBRyLToCMZBDuRQFTuHqp8cx0SOJNDBa 335 | # BgNVHR8EUzBRME+gTaBLhklodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2Ny 336 | # bC9wcm9kdWN0cy9NaWNSb29DZXJBdXQyMDExXzIwMTFfMDNfMjIuY3JsMF4GCCsG 337 | # AQUFBwEBBFIwUDBOBggrBgEFBQcwAoZCaHR0cDovL3d3dy5taWNyb3NvZnQuY29t 338 | # L3BraS9jZXJ0cy9NaWNSb29DZXJBdXQyMDExXzIwMTFfMDNfMjIuY3J0MIGfBgNV 339 | # HSAEgZcwgZQwgZEGCSsGAQQBgjcuAzCBgzA/BggrBgEFBQcCARYzaHR0cDovL3d3 340 | # dy5taWNyb3NvZnQuY29tL3BraW9wcy9kb2NzL3ByaW1hcnljcHMuaHRtMEAGCCsG 341 | # AQUFBwICMDQeMiAdAEwAZQBnAGEAbABfAHAAbwBsAGkAYwB5AF8AcwB0AGEAdABl 342 | # AG0AZQBuAHQALiAdMA0GCSqGSIb3DQEBCwUAA4ICAQBn8oalmOBUeRou09h0ZyKb 343 | # C5YR4WOSmUKWfdJ5DJDBZV8uLD74w3LRbYP+vj/oCso7v0epo/Np22O/IjWll11l 344 | # hJB9i0ZQVdgMknzSGksc8zxCi1LQsP1r4z4HLimb5j0bpdS1HXeUOeLpZMlEPXh6 345 | # I/MTfaaQdION9MsmAkYqwooQu6SpBQyb7Wj6aC6VoCo/KmtYSWMfCWluWpiW5IP0 346 | # wI/zRive/DvQvTXvbiWu5a8n7dDd8w6vmSiXmE0OPQvyCInWH8MyGOLwxS3OW560 347 | # STkKxgrCxq2u5bLZ2xWIUUVYODJxJxp/sfQn+N4sOiBpmLJZiWhub6e3dMNABQam 348 | # ASooPoI/E01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nou8A3rUZrdgKIa 410 | # utsH7SHOiOebZGqNu+622vJta3eAYsCAaxAcB9BiJPla7Xad9qrTYdT45VlCYTtB 411 | # SY4oVRsedSADv99jv/iYIAGy1bCytua0o/Qqv9erKmzQCTVMXaDc25DTLcMGJrRu 412 | # a3K0xivdtnoBexzVJr6yXqM+Ba2whIVRvGcriBkKX0FJFeW7r29XX+k0e4DnG6iB 413 | # HKQjec6VNzCCB3EwggVZoAMCAQICEzMAAAAVxedrngKbSZkAAAAAABUwDQYJKoZI 414 | # hvcNAQELBQAwgYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAw 415 | # DgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24x 416 | # MjAwBgNVBAMTKU1pY3Jvc29mdCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAy 417 | # MDEwMB4XDTIxMDkzMDE4MjIyNVoXDTMwMDkzMDE4MzIyNVowfDELMAkGA1UEBhMC 418 | # VVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNV 419 | # BAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEmMCQGA1UEAxMdTWljcm9zb2Z0IFRp 420 | # bWUtU3RhbXAgUENBIDIwMTAwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC 421 | # AQDk4aZM57RyIQt5osvXJHm9DtWC0/3unAcH0qlsTnXIyjVX9gF/bErg4r25Phdg 422 | # M/9cT8dm95VTcVrifkpa/rg2Z4VGIwy1jRPPdzLAEBjoYH1qUoNEt6aORmsHFPPF 423 | # dvWGUNzBRMhxXFExN6AKOG6N7dcP2CZTfDlhAnrEqv1yaa8dq6z2Nr41JmTamDu6 424 | # GnszrYBbfowQHJ1S/rboYiXcag/PXfT+jlPP1uyFVk3v3byNpOORj7I5LFGc6XBp 425 | # Dco2LXCOMcg1KL3jtIckw+DJ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lm1pY3Jvc29mdC5j 441 | # b20vcGtpL2NlcnRzL01pY1Jvb0NlckF1dF8yMDEwLTA2LTIzLmNydDANBgkqhkiG 442 | # 9w0BAQsFAAOCAgEAnVV9/Cqt4SwfZwExJFvhnnJL/Klv6lwUtj5OR2R4sQaTlz0x 443 | # M7U518JxNj/aZGx80HU5bbsPMeTCj/ts0aGUGCLu6WZnOlNN3Zi6th542DYunKmC 444 | # VgADsAW+iehp4LoJ7nvfam++Kctu2D9IdQHZGN5tggz1bSNU5HhTdSRXud2f8449 445 | # xvNo32X2pFaq95W2KFUn0CS9QKC/GbYSEhFdPSfgQJY4rPf5KYnDvBewVIVCs/wM 446 | # nosZiefwC2qBwoEZQhlSdYo2wh3DYXMuLGt7bj8sCXgU6ZGyqVvfSaN0DLzskYDS 447 | # PeZKPmY7T7uG+jIa2Zb0j/aRAfbOxnT99kxybxCrdTDFNLB62FD+CljdQDzHVG2d 448 | # Y3RILLFORy3BFARxv2T5JL5zbcqOCb2zAVdJVGTZc9d/HltEAY5aGZFrDZ+kKNxn 449 | # GSgkujhLmm77IVRrakURR6nxt67I6IleT53S0Ex2tVdUCbFpAUR+fKFhbHP+Crvs 450 | # QWY9af3LwUFJfn6Tvsv4O+S3Fb+0zj6lMVGEvL8CwYKiexcdFYmNcP7ntdAoGokL 451 | # jzbaukz5m/8K6TT4JDVnK+ANuOaMmdbhIurwJ0I9JZTmdHRbatGePu1+oDEzfbzL 452 | # 6Xu/OHBE0ZDxyKs6ijoIYn/ZcGNTTY3ugm2lBRDBcQZqELQdVTNYs6FwZvKhggNN 453 | # MIICNQIBATCB+aGB0aSBzjCByzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hp 454 | # bmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jw 455 | # b3JhdGlvbjElMCMGA1UECxMcTWljcm9zb2Z0IEFtZXJpY2EgT3BlcmF0aW9uczEn 456 | # MCUGA1UECxMe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jEQMA4GA1UEBxMHUmVkbW9u 472 | # ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMSYwJAYDVQQDEx1NaWNy 473 | # b3NvZnQgVGltZS1TdGFtcCBQQ0EgMjAxMAITMwAAAezgK6SC0JFSgAABAAAB7DAN 474 | # BglghkgBZQMEAgEFAKCCAUowGgYJKoZIhvcNAQkDMQ0GCyqGSIb3DQEJEAEEMC8G 475 | # CSqGSIb3DQEJBDEiBCByWnMA9v1nfS9tVSRpVvcwKVoMu5fUUvg73Fbg+HNApzCB 476 | # +gYLKoZIhvcNAQkQAi8xgeowgecwgeQwgb0EICcJ5vVqfTfIhx21QBBbKyo/xciQ 477 | # IXaoMWULejAE1QqDMIGYMIGApH4wfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldh 478 | # c2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBD 479 | # b3Jwb3JhdGlvbjEmMCQGA1UEAxMdTWljcm9zb2Z0IFRpbWUtU3RhbXAgUENBIDIw 480 | # MTACEzMAAAHs4CukgtCRUoAAAQAAAewwIgQgEmFw/DPRNjPvgOuKYf4wnhsPE0J5 481 | # MBkt5oH1ehjHCBMwDQYJKoZIhvcNAQELBQAEggIAkBL7PzI5aH6sRMMpj78lP+/+ 482 | # 0qM9h7xYpHmVT+E3JZiewkuYZfkrh3342Op9MNoXYXqDcL8qzmDGj9ad4sRJ2m+C 483 | # Sj2t3qRSjdwjhE+HPPjqhDeeXNyI1Ih8wk0bK3OIlRizyXx1OlBecy0IVJtOLlh8 484 | # ylZ7fy2U8DvekCLroquN5y6BvnbeMOFonwji9Rf+76AQhsrvlHjQClRRDuTsd+bN 485 | # ylunlpT70NFY+xgptaed6FI4Dkig67VNFvZRPhbDJKJoXinPrF6Zt4pRrMuubcMD 486 | # AqIlFGSRuFL67+6J2ko910a0momC3l+mhnzhY6XEz3g7PC4gwqGI2HgkWyCzEKFz 487 | # gBt3/J59ofGcw6CiuOgsaXfbe+pwf0wUqkwlBXQBeK9v/9pbA2TAOpVhgVy9T8ji 488 | # YkEBLtYpscRA751Vg3F5Ok34TEv3Ixw+dWhyDVMIx6EErpYKsPaMYfeGAHlEsXXh 489 | # Z8mj+f45bAyNWjmm0yhuQcxM5ytAR/kOZGsafX+CY6baSdaPmeATUJ7y9Hzlc1Fg 490 | # 0qJlpH+tV3VlvUno0bsrjeXCsrLs84kixTzo1S7fWtAkm5wVy2LNp+nF5Ownwi8x 491 | # xr83cQNWOlvgU6SS2ekzHo2p2OdDaVo9tiBSaAu0eKx6LINGbQQeJlYNqTylurBc 492 | # 654J+EHdJx92VUjBOXg= 493 | # SIG # End signature block 494 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OnnxruntimeBuilder 2 | 3 | ### 简介 4 | 5 | 编译onnxruntime 动态库和静态库。 6 | 7 | - 仓库的Release的包不支持GPU,仅使用CPU; 8 | - 文件名包含shared代表动态库(windows是.dll,linux是.so,macos是.dylib); 9 | - 文件名包含static代表静态库(***.a); 10 | - 文件名包含windows,linux,macos,android,代表这4种操作系统平台使用的库; 11 | - 文件名包含musl,使用musl工具链交叉编译; 12 | 13 | ### windows版本说明 14 | 15 | - windows版文件名含md代表动态链接crt,文件名含mt代表静态链接crt,静态链接时不需要依赖标准c库,部署时更方便,但文件体积增大; 16 | - 最好选择与你的vs版本一致的库; 17 | 18 | ### 关于老版本Linux系统 19 | - 随着onnxruntime不断更新和升级,对gcc版本要求越来越高,对应的glibc版本要求也越来越高。 20 | - 如果想在老系统如centos7或ubuntu14上使用,请下载v1.6.0版本的库。 21 | - 需要注意的是gcc4不支持avx512指令集,性能可能受到一些影响。 22 | 23 | ### ubuntu CPU架构支持信息 24 | 25 | | CPU架构 | 备注 | 26 | |---------|------------------| 27 | | amd64 | x86_64 一般家用PC | 28 | | arm | arm/v7 armhf | 29 | | arm64 | arm64/v8 aarch64 | 30 | | ppc64le | Power PC 64 LE | 31 | 32 | ### ubuntu版本说明 33 | 34 | | 操作系统 | gcc版本 | libc版本 | binutils版本 | 35 | |--------------|--------|--------|------------| 36 | | ubuntu 14.04 | 4.8.4 | 2.19 | 2.24 | 37 | | ubuntu 16.04 | 5.4.0 | 2.23 | 2.26.1 | 38 | | ubuntu 18.04 | 7.5.0 | 2.27 | 2.30 | 39 | | ubuntu 20.04 | 9.4.0 | 2.31 | 2.34 | 40 | | ubuntu 22.04 | 11.4.0 | 2.35 | 2.38 | 41 | 42 | - 最好选择与你的gcc一致的版本; 43 | - 低版本gcc使用高版本工具编译出来的库会出错; 44 | - onnxruntime 1.17.0以上 在ubuntu 20.04 arm64无法支持,编译出错信息:The compiler doesn't support BFLOAT16 45 | - 1.22.0开始要求gcc版本>11.1,故ubuntu 20.04已弃用 46 | 47 | ### musl版本说明 48 | 49 | - 必须选择一致的工具链版本来编译bin文件; 50 | - 工具链可以从此处获得https://github.com/benjaminwan/musl-cross-builder 51 | 52 | ### 如果7z包解压出错 53 | - 需要安装最新版的7zip工具,https://www.7-zip.org/download.html 54 | 55 | ### 关于OpenMP 56 | 57 | - [官方v1.7.0版本说明](https://github.com/microsoft/onnxruntime/releases/tag/v1.7.0) 58 | Starting from this release, all ONNX Runtime CPU packages are now built without OpenMP. 59 | - 官方仓库Release的从1.7.0开始,所有CPU版的包编译时没有启用OpenMP选项; 60 | - 本仓库重新编译的v1.6.0没有启用OpenMP选项; 61 | - 本仓库的初始版~1.8.0仍然启用了OpenMP选项,即使用本仓库的这些包时,编译环境要求安装OpenMP; -------------------------------------------------------------------------------- /build-onnxruntime-android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # build onnxruntime by benjaminwan 3 | # CMakeFiles/onnxruntime.dir/link.txt/link/lib*.a 4 | # ANDROID_NDK_HOME=/path/android-sdk/ndk/22.1.7171670 5 | 6 | function collectLibs() { 7 | # shared lib 8 | cmake --build . --config Release --target install 9 | # rm -r -f install/bin 10 | mv install/include/onnxruntime/* install/include 11 | rm -rf install/include/onnxruntime 12 | echo "set(OnnxRuntime_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/include\")" >install/OnnxRuntimeConfig.cmake 13 | echo "include_directories(\${OnnxRuntime_INCLUDE_DIRS})" >>install/OnnxRuntimeConfig.cmake 14 | echo "link_directories(\${CMAKE_CURRENT_LIST_DIR}/lib)" >>install/OnnxRuntimeConfig.cmake 15 | echo "set(OnnxRuntime_LIBS onnxruntime)" >>install/OnnxRuntimeConfig.cmake 16 | 17 | # static lib 18 | mkdir -p install-static/lib 19 | cp -r install/include install-static 20 | all_link=$(cat CMakeFiles/onnxruntime.dir/link.txt) 21 | link=${all_link#*onnxruntime.dir} 22 | regex="lib.*.a$" 23 | libs="" 24 | for var in $link; do 25 | if [[ ${var} =~ ${regex} ]]; then 26 | echo cp ${var} install-static/lib 27 | cp ${var} install-static/lib 28 | name=$(echo $var | grep -E ${regex} -o) 29 | name=${name#lib} 30 | name=${name%.a} 31 | libs="${libs} ${name}" 32 | fi 33 | done 34 | echo "set(OnnxRuntime_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/include\")" >install-static/OnnxRuntimeConfig.cmake 35 | echo "include_directories(\${OnnxRuntime_INCLUDE_DIRS})" >>install-static/OnnxRuntimeConfig.cmake 36 | echo "link_directories(\${CMAKE_CURRENT_LIST_DIR}/lib)" >>install-static/OnnxRuntimeConfig.cmake 37 | echo "set(OnnxRuntime_LIBS $libs)" >>install-static/OnnxRuntimeConfig.cmake 38 | cp CMakeFiles/onnxruntime.dir/link.txt install-static/link.log 39 | } 40 | 41 | function pyBuild() { 42 | echo ANDROID_HOME=$ANDROID_HOME 43 | echo ANDROID_NDK_HOME=$ANDROID_NDK_HOME 44 | python3 $DIR/tools/ci_build/build.py --build_dir $DIR/build-android-$1 \ 45 | --config Release \ 46 | --parallel \ 47 | --skip_tests \ 48 | --build_shared_lib \ 49 | --build_java \ 50 | --android \ 51 | --android_abi $1 \ 52 | --android_api $2 \ 53 | --android_sdk_path $ANDROID_HOME \ 54 | --android_ndk_path $ANDROID_NDK_HOME \ 55 | --cmake_extra_defines CMAKE_INSTALL_PREFIX=./install onnxruntime_BUILD_UNIT_TESTS=OFF 56 | 57 | pushd build-android-$1/Release 58 | cmake --build . --config Release -j $NUM_THREADS 59 | collectLibs 60 | popd 61 | } 62 | 63 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 64 | sysOS=$(uname -s) 65 | NUM_THREADS=1 66 | 67 | if [ $sysOS == "Darwin" ]; then 68 | NUM_THREADS=$(sysctl -n hw.ncpu) 69 | elif [ $sysOS == "Linux" ]; then 70 | NUM_THREADS=$(nproc) 71 | else 72 | echo "Other OS: $sysOS" 73 | exit 0 74 | fi 75 | 76 | if [ "$1" ]; then 77 | echo "set ARCH_TYPE=$1" 78 | ARCH_TYPE="$1" 79 | else 80 | echo "#1 ARCH_TYPE is empty("armeabi-v7a","arm64-v8a","x86","x86_64"), use arm64-v8a" 81 | ARCH_TYPE="arm64-v8a" 82 | fi 83 | 84 | if [ "$2" ]; then 85 | echo "set MIN_SDK=$2" 86 | MIN_SDK="$2" 87 | else 88 | echo "#2 MIN_SDK is empty, use 21" 89 | fi 90 | 91 | pyBuild $1 $2 92 | 93 | #echo "message(\"OnnxRuntime Path: \${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" > OnnxRuntimeWrapper.cmake 94 | #echo "set(OnnxRuntime_DIR \"\${CMAKE_CURRENT_LIST_DIR}/\${ANDROID_ABI}\")" >> OnnxRuntimeWrapper.cmake 95 | -------------------------------------------------------------------------------- /build-onnxruntime-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # build onnxruntime by benjaminwan 3 | # CMakeFiles/onnxruntime.dir/link.txt/link/lib*.a 4 | 5 | function is_cmd_exist() { 6 | retval="" 7 | if ! command -v $1 >/dev/null 2>&1; then 8 | retval="false" 9 | else 10 | retval="true" 11 | fi 12 | echo "$retval" 13 | } 14 | 15 | function collect_shared_lib() { 16 | if [ -d "install/bin" ]; then 17 | rm -r -f install/bin 18 | fi 19 | 20 | if [ -d "install/include/onnxruntime" ]; then 21 | mv install/include/onnxruntime/* install/include 22 | rm -rf install/include/onnxruntime 23 | fi 24 | 25 | echo "set(OnnxRuntime_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/include\")" >install/OnnxRuntimeConfig.cmake 26 | echo "include_directories(\${OnnxRuntime_INCLUDE_DIRS})" >>install/OnnxRuntimeConfig.cmake 27 | echo "link_directories(\${CMAKE_CURRENT_LIST_DIR}/lib)" >>install/OnnxRuntimeConfig.cmake 28 | echo "set(OnnxRuntime_LIBS onnxruntime)" >>install/OnnxRuntimeConfig.cmake 29 | } 30 | 31 | function copy_libs() { 32 | all_link=$(cat CMakeFiles/onnxruntime.dir/link.txt) 33 | link=${all_link#*onnxruntime.dir} 34 | regex="lib.*.a$" 35 | libs="" 36 | for var in $link; do 37 | if [[ ${var} =~ ${regex} ]]; then 38 | #echo cp ${var} install-static/lib 39 | cp ${var} install-static/lib 40 | name=$(echo $var | grep -E ${regex} -o) 41 | name=${name#lib} 42 | name=${name%.a} 43 | libs="${libs} ${name}" 44 | fi 45 | done 46 | echo "$libs" 47 | } 48 | 49 | function combine_libs_linux() { 50 | all_link=$(cat CMakeFiles/onnxruntime.dir/link.txt) 51 | link=${all_link#*onnxruntime.dir} 52 | regex="lib.*.a$" 53 | root_path="${PWD}" 54 | static_path="${PWD}/install-static" 55 | lib_path="${PWD}/install-static/lib" 56 | mkdir -p $lib_path 57 | echo "create ${lib_path}/libonnxruntime.a" >${static_path}/libonnxruntime.mri 58 | for var in $link; do 59 | if [[ ${var} =~ ${regex} ]]; then 60 | echo "addlib ${root_path}/${var}" >>${static_path}/libonnxruntime.mri 61 | fi 62 | done 63 | echo "save" >>${static_path}/libonnxruntime.mri 64 | echo "end" >>${static_path}/libonnxruntime.mri 65 | ar -M <${static_path}/libonnxruntime.mri 66 | # ranlib ${lib_path}/libonnxruntime.a 67 | } 68 | 69 | function collect_static_libs() { 70 | if [ -d "install-static" ]; then 71 | rm -r -f install-static 72 | fi 73 | mkdir -p install-static/lib 74 | 75 | if [ -d "install/include" ]; then 76 | cp -r install/include install-static 77 | fi 78 | 79 | if [ ! -f "CMakeFiles/onnxruntime.dir/link.txt" ]; then 80 | echo "link.txt is not exist, collect static libs error." 81 | exit 0 82 | fi 83 | 84 | ar_exist=$(is_cmd_exist ar) 85 | ranlib_exist=$(is_cmd_exist ranlib) 86 | if [ "$ar_exist" == "true" ] && [ "$ranlib_exist" == "true" ]; then 87 | echo "combine_libs_linux" 88 | combine_libs_linux 89 | libs="onnxruntime" 90 | else 91 | echo "copy_libs" 92 | libs=$(copy_libs) 93 | fi 94 | 95 | echo "set(OnnxRuntime_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/include\")" >install-static/OnnxRuntimeConfig.cmake 96 | echo "include_directories(\${OnnxRuntime_INCLUDE_DIRS})" >>install-static/OnnxRuntimeConfig.cmake 97 | echo "link_directories(\${CMAKE_CURRENT_LIST_DIR}/lib)" >>install-static/OnnxRuntimeConfig.cmake 98 | echo "set(OnnxRuntime_LIBS $libs)" >>install-static/OnnxRuntimeConfig.cmake 99 | 100 | cp CMakeFiles/onnxruntime.dir/link.txt install-static/link.log 101 | } 102 | 103 | HOST_OS=$(uname -s) 104 | NUM_THREADS=1 105 | BUILD_TYPE=Release 106 | 107 | if [ $HOST_OS == "Linux" ]; then 108 | NUM_THREADS=$(nproc) 109 | else 110 | echo "Unsupport OS: $HOST_OS" 111 | exit 0 112 | fi 113 | 114 | JAVA_FLAG="" 115 | 116 | while getopts "j" arg; do 117 | case $arg in 118 | j) 119 | echo "j's arg:$OPTARG" 120 | JAVA_FLAG="--build_java" 121 | ;; 122 | ?) 123 | echo -e "unkonw argument. \nuseage1: ./build-onnxruntim-mac.bat -a x86_64 \nuseage2: ./build-onnxruntim-mac.bat -a arm64" 124 | exit 1 125 | ;; 126 | esac 127 | done 128 | 129 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 130 | python3 $DIR/tools/ci_build/build.py --build_dir $DIR/build-$HOST_OS \ 131 | --allow_running_as_root \ 132 | --config $BUILD_TYPE \ 133 | --parallel "$NUM_THREADS" \ 134 | --skip_tests \ 135 | --build_shared_lib \ 136 | --compile_no_warning_as_error \ 137 | $JAVA_FLAG \ 138 | --cmake_extra_defines CMAKE_INSTALL_PREFIX=./install \ 139 | onnxruntime_BUILD_UNIT_TESTS=OFF 140 | 141 | if [ ! -d "build-$HOST_OS/$BUILD_TYPE" ]; then 142 | echo "Build error!" 143 | exit 0 144 | fi 145 | 146 | pushd build-$HOST_OS/$BUILD_TYPE 147 | cmake --install . 148 | if [ ! -d "install" ]; then 149 | echo "Cmake install error!" 150 | exit 0 151 | fi 152 | collect_shared_lib 153 | collect_static_libs 154 | popd 155 | -------------------------------------------------------------------------------- /build-onnxruntime-mac.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # build onnxruntime by benjaminwan 3 | # CMakeFiles/onnxruntime.dir/link.txt/link/lib*.a 4 | 5 | function is_cmd_exist() { 6 | retval="" 7 | if ! command -v $1 >/dev/null 2>&1; then 8 | retval="false" 9 | else 10 | retval="true" 11 | fi 12 | echo "$retval" 13 | } 14 | 15 | function collect_shared_lib() { 16 | if [ -d "install/bin" ]; then 17 | rm -r -f install/bin 18 | fi 19 | 20 | if [ -d "install/include/onnxruntime" ]; then 21 | mv install/include/onnxruntime/* install/include 22 | rm -rf install/include/onnxruntime 23 | fi 24 | 25 | echo "set(OnnxRuntime_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/include\")" >install/OnnxRuntimeConfig.cmake 26 | echo "include_directories(\${OnnxRuntime_INCLUDE_DIRS})" >>install/OnnxRuntimeConfig.cmake 27 | echo "link_directories(\${CMAKE_CURRENT_LIST_DIR}/lib)" >>install/OnnxRuntimeConfig.cmake 28 | echo "set(OnnxRuntime_LIBS onnxruntime)" >>install/OnnxRuntimeConfig.cmake 29 | } 30 | 31 | function copy_libs() { 32 | all_link=$(cat CMakeFiles/onnxruntime.dir/link.txt) 33 | link=${all_link#*onnxruntime.dir} 34 | regex="lib.*.a$" 35 | libs="" 36 | for var in $link; do 37 | if [[ ${var} =~ ${regex} ]]; then 38 | #echo cp ${var} install-static/lib 39 | cp ${var} install-static/lib 40 | name=$(echo $var | grep -E ${regex} -o) 41 | name=${name#lib} 42 | name=${name%.a} 43 | libs="${libs} ${name}" 44 | fi 45 | done 46 | echo "$libs" 47 | } 48 | 49 | function combine_libs_darwin() { 50 | all_link=$(cat CMakeFiles/onnxruntime.dir/link.txt) 51 | link=${all_link#*onnxruntime.dir} 52 | regex="lib.*.a$" 53 | root_path="${PWD}" 54 | lib_path="${PWD}/install-static/lib" 55 | mkdir -p $lib_path 56 | libs="" 57 | for var in $link; do 58 | if [[ ${var} =~ ${regex} ]]; then 59 | libs="${libs} ${root_path}/${var}" 60 | fi 61 | done 62 | libtool -static -o ${lib_path}/libonnxruntime.a ${libs} 63 | } 64 | 65 | function collect_static_libs() { 66 | if [ -d "install-static" ]; then 67 | rm -r -f install-static 68 | fi 69 | mkdir -p install-static/lib 70 | 71 | if [ -d "install/include" ]; then 72 | cp -r install/include install-static 73 | fi 74 | 75 | if [ ! -f "CMakeFiles/onnxruntime.dir/link.txt" ]; then 76 | echo "link.txt is not exist, collect static libs error." 77 | exit 0 78 | fi 79 | 80 | libtool_exist=$(is_cmd_exist libtool) 81 | if [ "$libtool_exist" == "true" ]; then 82 | echo "combine_libs_darwin" 83 | combine_libs_darwin 84 | libs="onnxruntime" 85 | else 86 | echo "copy_libs" 87 | libs=$(copy_libs) 88 | fi 89 | 90 | echo "set(OnnxRuntime_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/include\")" >install-static/OnnxRuntimeConfig.cmake 91 | echo "include_directories(\${OnnxRuntime_INCLUDE_DIRS})" >>install-static/OnnxRuntimeConfig.cmake 92 | echo "link_directories(\${CMAKE_CURRENT_LIST_DIR}/lib)" >>install-static/OnnxRuntimeConfig.cmake 93 | echo "set(OnnxRuntime_LIBS $libs)" >>install-static/OnnxRuntimeConfig.cmake 94 | 95 | cp CMakeFiles/onnxruntime.dir/link.txt install-static/link.log 96 | } 97 | 98 | HOST_OS=$(uname -s) 99 | NUM_THREADS=1 100 | BUILD_TYPE=Release 101 | 102 | if [ $HOST_OS == "Darwin" ]; then 103 | NUM_THREADS=$(sysctl -n hw.ncpu) 104 | else 105 | echo "Unsupported OS: $HOST_OS" 106 | exit 0 107 | fi 108 | 109 | JAVA_FLAG="" 110 | 111 | while getopts "n:j" arg; do 112 | case $arg in 113 | n) 114 | echo "n's arg:$OPTARG" 115 | TARGET_ARCH=$OPTARG 116 | ;; 117 | j) 118 | echo "j's arg:$OPTARG" 119 | JAVA_FLAG="--build_java" 120 | ;; 121 | ?) 122 | echo -e "unknown argument." 123 | echo -e "usage 1: ./build-onnxruntim-mac.bat -n x86_64" 124 | echo -e "usage 2: ./build-onnxruntim-mac.bat -n arm64" 125 | exit 1 126 | ;; 127 | esac 128 | done 129 | 130 | if [ "$TARGET_ARCH" != "x86_64" ] && [ "$TARGET_ARCH" != "arm64" ] && [ "$TARGET_ARCH" != "arm64e" ]; then 131 | echo "Unsupported TARGET_ARCH:$TARGET_ARCH" 132 | exit 0 133 | fi 134 | 135 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 136 | python3 $DIR/tools/ci_build/build.py --build_dir $DIR/build-$HOST_OS-$TARGET_ARCH \ 137 | --config $BUILD_TYPE \ 138 | --parallel "$NUM_THREADS" \ 139 | --skip_tests \ 140 | --build_shared_lib \ 141 | --compile_no_warning_as_error \ 142 | --osx_arch $TARGET_ARCH \ 143 | --apple_deploy_target "10.15" \ 144 | $JAVA_FLAG \ 145 | --cmake_extra_defines CMAKE_INSTALL_PREFIX=./install \ 146 | onnxruntime_BUILD_UNIT_TESTS=OFF \ 147 | CMAKE_OSX_DEPLOYMENT_TARGET="10.15" 148 | 149 | if [ ! -d "build-$HOST_OS-$TARGET_ARCH/$BUILD_TYPE" ]; then 150 | echo "Build error!" 151 | exit 0 152 | fi 153 | 154 | pushd build-$HOST_OS-$TARGET_ARCH/$BUILD_TYPE 155 | cmake --install . 156 | if [ ! -d "install" ]; then 157 | echo "Cmake install error!" 158 | exit 0 159 | fi 160 | collect_shared_lib 161 | collect_static_libs 162 | popd 163 | -------------------------------------------------------------------------------- /build-onnxruntime-musl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # build onnxruntime by benjaminwan 3 | 4 | function is_cmd_exist() { 5 | retval="" 6 | if ! command -v $1 >/dev/null 2>&1; then 7 | retval="false" 8 | else 9 | retval="true" 10 | fi 11 | echo "$retval" 12 | } 13 | 14 | function collect_shared_lib() { 15 | if [ -d "install/bin" ]; then 16 | rm -r -f install/bin 17 | fi 18 | 19 | if [ -d "install/include/onnxruntime" ]; then 20 | mv install/include/onnxruntime/* install/include 21 | rm -rf install/include/onnxruntime 22 | fi 23 | 24 | echo "set(OnnxRuntime_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/include\")" >install/OnnxRuntimeConfig.cmake 25 | echo "include_directories(\${OnnxRuntime_INCLUDE_DIRS})" >>install/OnnxRuntimeConfig.cmake 26 | echo "link_directories(\${CMAKE_CURRENT_LIST_DIR}/lib)" >>install/OnnxRuntimeConfig.cmake 27 | echo "set(OnnxRuntime_LIBS onnxruntime)" >>install/OnnxRuntimeConfig.cmake 28 | } 29 | 30 | function copy_libs() { 31 | all_link=$(cat CMakeFiles/onnxruntime.dir/link.txt) 32 | link=${all_link#*onnxruntime.dir} 33 | regex="lib.*.a$" 34 | libs="" 35 | for var in $link; do 36 | if [[ ${var} =~ ${regex} ]]; then 37 | #echo cp ${var} install-static/lib 38 | cp ${var} install-static/lib 39 | name=$(echo $var | grep -E ${regex} -o) 40 | name=${name#lib} 41 | name=${name%.a} 42 | libs="${libs} ${name}" 43 | fi 44 | done 45 | echo "$libs" 46 | } 47 | 48 | function combine_libs_linux() { 49 | all_link=$(cat CMakeFiles/onnxruntime.dir/link.txt) 50 | link=${all_link#*onnxruntime.dir} 51 | regex="lib.*.a$" 52 | root_path="${PWD}" 53 | static_path="${PWD}/install-static" 54 | lib_path="${PWD}/install-static/lib" 55 | mkdir -p $lib_path 56 | echo "create ${lib_path}/libonnxruntime.a" >${static_path}/libonnxruntime.mri 57 | for var in $link; do 58 | if [[ ${var} =~ ${regex} ]]; then 59 | echo "addlib ${root_path}/${var}" >>${static_path}/libonnxruntime.mri 60 | fi 61 | done 62 | echo "save" >>${static_path}/libonnxruntime.mri 63 | echo "end" >>${static_path}/libonnxruntime.mri 64 | $TOOLCHAIN_NAME-ar -M <${static_path}/libonnxruntime.mri 65 | } 66 | 67 | function collect_static_libs() { 68 | if [ -d "install-static" ]; then 69 | rm -r -f install-static 70 | fi 71 | mkdir -p install-static/lib 72 | 73 | if [ -d "install/include" ]; then 74 | cp -r install/include install-static 75 | fi 76 | 77 | if [ ! -f "CMakeFiles/onnxruntime.dir/link.txt" ]; then 78 | echo "link.txt is not exist, collect static libs error." 79 | exit 0 80 | fi 81 | 82 | ar_exist=$(is_cmd_exist $TOOLCHAIN_NAME-ar) 83 | if [ "$ar_exist" == "true" ]; then 84 | echo "combine_libs_linux" 85 | combine_libs_linux 86 | libs="onnxruntime" 87 | else 88 | echo "copy_libs" 89 | libs=$(copy_libs) 90 | fi 91 | 92 | echo "set(OnnxRuntime_INCLUDE_DIRS \"\${CMAKE_CURRENT_LIST_DIR}/include\")" >install-static/OnnxRuntimeConfig.cmake 93 | echo "include_directories(\${OnnxRuntime_INCLUDE_DIRS})" >>install-static/OnnxRuntimeConfig.cmake 94 | echo "link_directories(\${CMAKE_CURRENT_LIST_DIR}/lib)" >>install-static/OnnxRuntimeConfig.cmake 95 | echo "set(OnnxRuntime_LIBS $libs)" >>install-static/OnnxRuntimeConfig.cmake 96 | 97 | cp CMakeFiles/onnxruntime.dir/link.txt install-static/link.log 98 | } 99 | 100 | HOST_OS=$(uname -s) 101 | NUM_THREADS=1 102 | BUILD_TYPE=Release 103 | 104 | if [ $HOST_OS == "Linux" ]; then 105 | NUM_THREADS=$(nproc) 106 | else 107 | echo "Unsupport OS: $HOST_OS" 108 | exit 0 109 | fi 110 | 111 | while getopts "n:p:" arg; do 112 | case $arg in 113 | n) 114 | echo "n's arg:$OPTARG" 115 | export TOOLCHAIN_NAME="$OPTARG" 116 | ;; 117 | p) 118 | echo "p's arg:$OPTARG" 119 | export TOOLCHAIN_PATH="$OPTARG" 120 | ;; 121 | ?) 122 | echo -e "unkonw argument." 123 | exit 1 124 | ;; 125 | esac 126 | done 127 | echo "TOOLCHAIN_NAME=$TOOLCHAIN_NAME, TOOLCHAIN_PATH=$TOOLCHAIN_PATH" 128 | 129 | if [ -z "$TOOLCHAIN_NAME" ] || [ -z "$TOOLCHAIN_PATH" ]; then 130 | echo -e "empty TOOLCHAIN_NAME or TOOLCHAIN_PATH." 131 | echo -e "usage: ./build-onnxruntime-musl.sh -n 'aarch64-linux-musl' -p '/opt/aarch64-linux-musl'" 132 | exit 1 133 | fi 134 | 135 | export PATH=$TOOLCHAIN_PATH/bin:$PATH 136 | 137 | mkdir -p "build-$BUILD_TYPE-$TOOLCHAIN_NAME" 138 | pushd "build-$BUILD_TYPE-$TOOLCHAIN_NAME" || exit 139 | cmake ../cmake \ 140 | $(cat ../onnxruntime_cmake_options.txt) \ 141 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ 142 | -DCMAKE_INSTALL_PREFIX=install \ 143 | -DCMAKE_TOOLCHAIN_FILE=../musl-cross.toolchain.cmake 144 | patch -p0 -i ../patches/onnxruntime-1.18.0-musl.patch 145 | cmake --build . --config $BUILD_TYPE -j $NUM_THREADS 146 | cmake --build . --config $BUILD_TYPE --target install 147 | 148 | if [ ! -d "install" ]; then 149 | echo "Cmake install error!" 150 | exit 0 151 | fi 152 | collect_shared_lib 153 | collect_static_libs 154 | popd 155 | -------------------------------------------------------------------------------- /build-onnxruntime-win.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS build onnxruntime for windows by benjaminwan 3 | .DESCRIPTION 4 | This is a powershell script for builid onnxruntime in windows. 5 | Put this script to onnxruntime root path, and then run .\build-onnxruntime.ps1 6 | attentions: 7 | 1) Set ExecutionPolicy before run this script: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass 8 | 2) Setup Developer PowerShell: & 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1' -SkipAutomaticLocation -HostArch amd64 -Arch amd64 9 | 3) x86 Java is currently not supported on 32-bit x86 architecture 10 | 4) onnxruntime v1.18 is only support VS2022(v143) 11 | 12 | .PARAMETER VsArch 13 | By default, we run this script on 64 bits Windows, this param is always x64. 14 | Other options are for cross-compiling. 15 | a) .\build-onnxruntime.ps1 -VsArch x64 16 | b) .\build-onnxruntime.ps1 -VsArch x86 17 | c) .\build-onnxruntime.ps1 -VsArch arm64 18 | d) .\build-onnxruntime.ps1 -VsArch arm64ec 19 | .PARAMETER VsVer 20 | By default, this param of onnxruntime v1.18 is always v143 21 | a) .\build-onnxruntime.ps1 -VsVer v140 = VS2015 22 | b) .\build-onnxruntime.ps1 -VsVer v141 = VS2017 23 | c) .\build-onnxruntime.ps1 -VsVer v142 = VS2019 24 | d) .\build-onnxruntime.ps1 -VsVer v143 = VS2022 25 | .PARAMETER VsCRT 26 | a) .\build-onnxruntime.ps1 -VsCRT md 27 | b) .\build-onnxruntime.ps1 -VsCRT mt 28 | .PARAMETER BuildJava 29 | By default, this param is set to False. 30 | .\build-onnxruntime.ps1 -BuildJava 31 | .PARAMETER BuildType 32 | a) .\build-onnxruntime.ps1 -BuildType Release 33 | b) .\build-onnxruntime.ps1 -BuildType Debug 34 | c) .\build-onnxruntime.ps1 -BuildType MinSizeRel 35 | d) .\build-onnxruntime.ps1 -BuildType RelWithDebInfo 36 | #> 37 | 38 | param ( 39 | [Parameter(Mandatory = $false)] 40 | [ValidateSet('x64', 'x86', 'arm64', 'arm64ec')] 41 | [string] $VsArch = "x64", 42 | 43 | [Parameter(Mandatory = $false)] 44 | [ValidateSet('v140', 'v141', 'v142', 'v143')] 45 | [string] $VsVer = 'v143', 46 | 47 | [Parameter(Mandatory = $false)] 48 | [ValidateSet('mt', 'md')] 49 | [string] $VsCRT = 'md', 50 | 51 | [Parameter(Mandatory = $false)] 52 | [switch] $BuildJava = $false, 53 | 54 | [Parameter(Mandatory = $false)] 55 | [ValidateSet('Release', 'Debug', 'MinSizeRel', 'RelWithDebInfo')] 56 | [string] $BuildType = 'Release' 57 | ) 58 | 59 | 60 | # 返回文件的名称 61 | function GetFileName 62 | { 63 | param ([string]$filePath) 64 | return [System.IO.Path]::GetFileName($filePath) 65 | } 66 | 67 | #调用这个函数来检查 lib.exe 是否存在 68 | function CheckLibexeExists 69 | { 70 | if (Get-Command lib.exe -errorAction SilentlyContinue) 71 | { 72 | return $True 73 | } 74 | else 75 | { 76 | return $False 77 | } 78 | } 79 | 80 | function GetLibsList 81 | { 82 | $InFile = "onnxruntime.dir\Release\onnxruntime.tlog\link.read.1.tlog" 83 | $OutFile = "install-static\libs_list.txt" 84 | $LikeLine = "RELEASE\*.LIB" 85 | 86 | $data = Get-Content $InFile | ForEach-Object { $_.split(" ") } 87 | $data | Out-File $OutFile 88 | 89 | $data = Get-Content $OutFile | Where-Object { $_ -like "*$LikeLine*" } 90 | $data | Out-File -Encoding ascii $OutFile 91 | } 92 | 93 | function CollectLibs 94 | { 95 | # 删除 install 目录下所有以 *test*.exe 结尾的文件 96 | Remove-Item -Path "install\*test*.exe" -Force -Recurse 97 | 98 | # 复制 install\include\onnxruntime 目录下的所有文件到 install\include 99 | Copy-Item -Path "install\include\onnxruntime\*" -Destination "install\include" -Force -Recurse 100 | 101 | # 删除 install\include\onnxruntime 目录 102 | Remove-Item -Path "install\include\onnxruntime" -Force -Recurse 103 | 104 | # 创建 install/OnnxRuntimeConfig.cmake 文件,并写入相关内容 105 | Set-Content -Path "install/OnnxRuntimeConfig.cmake" -Value "set(OnnxRuntime_INCLUDE_DIRS `${CMAKE_CURRENT_LIST_DIR}/include`)" 106 | Add-Content -Path "install/OnnxRuntimeConfig.cmake" -Value "include_directories(${OnnxRuntime_INCLUDE_DIRS})" 107 | Add-Content -Path "install/OnnxRuntimeConfig.cmake" -Value "link_directories(`${CMAKE_CURRENT_LIST_DIR}/lib`)" 108 | Add-Content -Path "install/OnnxRuntimeConfig.cmake" -Value "set(OnnxRuntime_LIBS onnxruntime)" 109 | 110 | # 创建 install-static\lib 目录 111 | if (Test-Path -Path "install-static\lib") 112 | { 113 | Remove-Item -Path "install-static\lib" -Force -Recurse 114 | } 115 | New-Item -Path "install-static\lib" -ItemType Directory 116 | 117 | # 复制 install\include 目录下的所有文件到 install-static\include 118 | if (Test-Path -Path "install-static\include") 119 | { 120 | Remove-Item -Path "install-static\include" -Force -Recurse 121 | } 122 | Copy-Item -Path "install\include" -Destination "install-static\include" -Recurse 123 | 124 | # 调用 GetLibsList 函数 125 | GetLibsList 126 | 127 | # 调用 CheckLibexeExists 函数 128 | $LibexeExists = CheckLibexeExists 129 | 130 | # 根据 lib exe 是否存在执行不同的操作 131 | if ($LibexeExists) 132 | { 133 | $libs = @() 134 | Get-Content -Path "install-static\libs_list.txt" | ForEach-Object { 135 | $libs += $_ 136 | } 137 | } 138 | else 139 | { 140 | $libs = @() 141 | Get-Content -Path "install-static\libs_list.txt" | ForEach-Object { 142 | Copy-Item $_ "install-static\lib" 143 | $fileName = GetFileName $_ 144 | $libs += "$fileName" 145 | } 146 | } 147 | 148 | # 复制 onnxruntime.dir\Release\onnxruntime.tlog\link.read.1.tlog 文件到 install-static\link.log 149 | Copy-Item -Path "onnxruntime.dir\Release\onnxruntime.tlog\link.read.1.tlog" -Destination "install-static\link.log" 150 | 151 | # 创建 install-static\OnnxRuntimeConfig.cmake 文件,并写入相关内容 152 | Set-Content -Path "install-static\OnnxRuntimeConfig.cmake" -Value "set(OnnxRuntime_INCLUDE_DIRS `${CMAKE_CURRENT_LIST_DIR}/include`)" 153 | Add-Content -Path "install-static\OnnxRuntimeConfig.cmake" -Value "include_directories(${OnnxRuntime_INCLUDE_DIRS})" 154 | Add-Content -Path "install-static\OnnxRuntimeConfig.cmake" -Value "link_directories(`${CMAKE_CURRENT_LIST_DIR}/lib`)" 155 | 156 | # 根据 lib exe 是否存在写入不同的 OnnxRuntime_LIBS 值, 如果 lib exe 存在,使用 lib.exe 工具生成 onnxruntime.lib 文件 157 | if ($LibexeExists) 158 | { 159 | Add-Content -Path "install-static\OnnxRuntimeConfig.cmake" -Value "set(OnnxRuntime_LIBS onnxruntime.lib)" 160 | lib.exe /OUT:"install-static\lib\onnxruntime.lib" $libs 161 | } 162 | else 163 | { 164 | Add-Content -Path "install-static\OnnxRuntimeConfig.cmake" -Value "set(OnnxRuntime_LIBS $libs)" 165 | } 166 | } 167 | 168 | 169 | #Set-PSDebug -Trace 1 170 | Set-PSDebug -Trace 0 171 | 172 | # 清屏 173 | Clear-Host 174 | 175 | Write-Host "Params: VsArch=$VsArch VsVer=$VsVer VsCRT=$VsCRT BuildJava=$BuildJava BuildType=$BuildType" 176 | 177 | switch ($VsArch) 178 | { 179 | x64 { 180 | $VsArchFlag = '' 181 | $ArmFlag = '' 182 | } 183 | x86 { 184 | $VsArchFlag = '--x86' 185 | $ArmFlag = '' 186 | } 187 | arm64 { 188 | $VsArchFlag = '--arm64' 189 | $ArmFlag = '--buildasx' 190 | } 191 | arm64ec { 192 | $VsArchFlag = '--arm64ec' 193 | $ArmFlag = '--buildasx' 194 | } 195 | default { 196 | exit 197 | } 198 | } 199 | 200 | if ($VsVer -eq "v143") 201 | { 202 | $VsFlag = 'Visual Studio 17 2022' 203 | } 204 | else 205 | { 206 | $VsFlag = 'Visual Studio 16 2019' 207 | } 208 | 209 | if ($VsCRT -eq "mt") 210 | { 211 | $StaticCrtFlag = "--enable_msvc_static_runtime" 212 | } 213 | else 214 | { 215 | $StaticCrtFlag = "" 216 | } 217 | 218 | if ($BuildJava) 219 | { 220 | $JavaFlag = "--build_java" 221 | } 222 | else 223 | { 224 | $JavaFlag = "" 225 | } 226 | 227 | $OutPutPath = "build-$VsArch-$VsVer-$VsCRT" 228 | 229 | if (!(Test-Path -Path $OutPutPath\$BuildType)) 230 | { 231 | Write-Host "创建文件夹:$OutPutPath\$BuildType" 232 | New-Item -Path "$OutPutPath\$BuildType" -ItemType Directory 233 | } 234 | 235 | python $PSScriptRoot\tools\ci_build\build.py ` 236 | $VsArchFlag ` 237 | $ArmFlag ` 238 | $JavaFlag ` 239 | --build_shared_lib ` 240 | --build_dir $PSScriptRoot\$OutPutPath ` 241 | --config $BuildType ` 242 | --parallel ` 243 | --skip_tests ` 244 | --compile_no_warning_as_error ` 245 | --cmake_generator $VsFlag ` 246 | $StaticCrtFlag ` 247 | --cmake_extra_defines CMAKE_INSTALL_PREFIX=./install onnxruntime_BUILD_UNIT_TESTS=OFF 248 | 249 | if (!(Test-Path -Path $OutPutPath\$BuildType\$BuildType)) 250 | { 251 | Write-Host "Build error!" 252 | exit 253 | } 254 | 255 | Push-Location "build-$VsArch-$VsVer-$VsCRT\$BuildType" 256 | 257 | #$LogicalProcessorsNum=(Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors 258 | #cmake --build . --config $BuildType --parallel $LogicalProcessorsNum 259 | 260 | cmake --install . 261 | if (!(Test-Path -Path install)) 262 | { 263 | Write-Host "Cmake install error!" 264 | exit 265 | } 266 | CollectLibs 267 | 268 | Pop-Location 269 | 270 | 271 | -------------------------------------------------------------------------------- /build-onnxruntime.bat: -------------------------------------------------------------------------------- 1 | :: build onnxruntime for windows by benjaminwan 2 | :: x64 build_java, x86 Java is currently not supported on 32-bit x86 architecture 3 | :: use in powershell 4 | :: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass 5 | :: & 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1' -SkipAutomaticLocation -HostArch amd64 -Arch amd64 6 | @ECHO OFF 7 | chcp 65001 8 | cls 9 | SETLOCAL EnableDelayedExpansion 10 | 11 | IF "%1"=="" ( 12 | ECHO input VS_VER none, use v143 13 | set VS_VER="v143" 14 | ) ^ 15 | ELSE ( 16 | ECHO input VS_VER:%1 17 | set VS_VER="%1" 18 | ) 19 | 20 | IF "%2"=="" ( 21 | ECHO input CRT none, use mt 22 | set CRT="mt" 23 | ) ^ 24 | ELSE ( 25 | ECHO input CRT:%2 26 | set CRT="%2" 27 | ) 28 | 29 | call :cmakeParams "x64" %VS_VER% %CRT% 30 | ::call :cmakeParams "Win32" %VS_VER% %CRT% 31 | GOTO:EOF 32 | 33 | :getFileName 34 | call set "libs=%%libs%% %~n1" 35 | GOTO:EOF 36 | 37 | :getFullPathAndName 38 | call set "libs=%%libs%% %~1" 39 | GOTO:EOF 40 | 41 | :check_libexe_exists 42 | ::powershell -Command "if(Get-Command lib.exe -errorAction SilentlyContinue) {'true'} else {'false'}" 43 | set pscmdline='powershell -Command "if(Get-Command lib.exe -errorAction SilentlyContinue) {'true'} else {'false'}"' 44 | for /f %%a in (%pscmdline%) do ( 45 | set libexe_exists=%%a 46 | ) 47 | GOTO:EOF 48 | 49 | :getLibsList 50 | set "InFile=onnxruntime.dir\Release\onnxruntime.tlog\link.read.1.tlog" 51 | set "OutFile=libs_list.txt" 52 | set "LikeLine=RELEASE\*.LIB" 53 | powershell -Command "$data = foreach($line in gc %InFile%){ $line.split(" ")} $data | Out-File %OutFile%" 54 | powershell -Command "$data = foreach($line in gc %OutFile%){ if($line -like '*%LikeLine%*') {$line}} $data | Out-File -Encoding ascii %OutFile%" 55 | GOTO:EOF 56 | 57 | :collectLibs 58 | cmake --build . --config Release --target install 59 | ::del /s/q install\*test*.exe 60 | copy install\include\onnxruntime\* install\include 61 | rd /S /Q install\include\onnxruntime 62 | ECHO set(OnnxRuntime_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include") > install/OnnxRuntimeConfig.cmake 63 | ECHO include_directories(${OnnxRuntime_INCLUDE_DIRS}) >> install/OnnxRuntimeConfig.cmake 64 | ECHO link_directories(${CMAKE_CURRENT_LIST_DIR}/lib) >> install/OnnxRuntimeConfig.cmake 65 | ECHO set(OnnxRuntime_LIBS onnxruntime) >> install/OnnxRuntimeConfig.cmake 66 | 67 | mkdir install-static\lib 68 | xcopy install\include install-static\include /s /y /i 69 | call :getLibsList 70 | 71 | call :check_libexe_exists 72 | 73 | IF "%libexe_exists%" == "true" ( 74 | ECHO "libexe_exists=%libexe_exists%" 75 | set libs= 76 | for /f "Delims=" %%a in (libs_list.txt) do ( 77 | call :getFullPathAndName %%a 78 | ) 79 | ) ELSE ( 80 | ECHO "libexe_exists=%libexe_exists%" 81 | set libs= 82 | for /f "Delims=" %%a in (libs_list.txt) do ( 83 | copy %%a install-static\lib 84 | call :getFileName %%a 85 | ) 86 | ) 87 | 88 | copy onnxruntime.dir\Release\onnxruntime.tlog\link.read.1.tlog install-static\link.log 89 | ECHO set(OnnxRuntime_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include")>install-static\OnnxRuntimeConfig.cmake 90 | ECHO include_directories(${OnnxRuntime_INCLUDE_DIRS})>>install-static\OnnxRuntimeConfig.cmake 91 | ECHO link_directories(${CMAKE_CURRENT_LIST_DIR}/lib)>>install-static\OnnxRuntimeConfig.cmake 92 | 93 | IF "%libexe_exists%" == "true" ( 94 | ECHO set(OnnxRuntime_LIBS onnxruntime.lib)>>install-static\OnnxRuntimeConfig.cmake 95 | ) ELSE ( 96 | ECHO set(OnnxRuntime_LIBS %libs%)>>install-static\OnnxRuntimeConfig.cmake 97 | ) 98 | 99 | ::IF "%libexe_exists%" == "true" ( 100 | :: lib.exe /OUT:install-static\lib\onnxruntime.lib %libs% 101 | ::) 102 | 103 | GOTO:EOF 104 | 105 | :cmakeParams 106 | if "%~1" == "Win32" ( 107 | set MACHINE_FLAG="--x86" 108 | )^ 109 | else ( 110 | set MACHINE_FLAG="--build_java" 111 | ) 112 | IF "%~2" == "v142" ( 113 | set VS_FLAG=--cmake_generator "Visual Studio 16 2019" 114 | ) ^ 115 | ELSE ( 116 | set VS_FLAG=--cmake_generator "Visual Studio 17 2022" 117 | ) 118 | IF "%~3" == "mt" ( 119 | set STATIC_CRT_FLAG="--enable_msvc_static_runtime" 120 | ) ^ 121 | ELSE ( 122 | set STATIC_CRT_FLAG= 123 | ) 124 | python %~dp0\tools\ci_build\build.py --build_dir %~dp0\build-%~1-%~2-%~3 ^ 125 | --config Release ^ 126 | --parallel ^ 127 | --skip_tests ^ 128 | --build_shared_lib ^ 129 | %MACHINE_FLAG% ^ 130 | %VS_FLAG% ^ 131 | %STATIC_CRT_FLAG% ^ 132 | --cmake_extra_defines CMAKE_INSTALL_PREFIX=./install onnxruntime_BUILD_UNIT_TESTS=OFF 133 | pushd "build-%~1-%~2-%~3"\Release 134 | cmake --build . --config Release -j %NUMBER_OF_PROCESSORS% 135 | call :collectLibs 136 | popd 137 | GOTO:EOF -------------------------------------------------------------------------------- /justfile: -------------------------------------------------------------------------------- 1 | shebang := if os() == 'windows' { 2 | 'powershell.exe' 3 | } else { 4 | '/usr/bin/env pwsh' 5 | } 6 | 7 | # Set shell for non-Windows OSs: 8 | set shell := ["powershell", "-c"] 9 | 10 | # Set shell for Windows OSs: 11 | set windows-shell := ["powershell.exe", "-NoLogo", "-Command"] 12 | 13 | onnx := "v1.22.0" 14 | vs := "vs2022" 15 | 16 | default: 17 | @just --list 18 | 19 | # 编译opencv静态库 20 | build_lib: 21 | just _build "x64" "v143" "mt" 22 | just _build "x64" "v143" "md" 23 | just _build "x86" "v143" "mt" 24 | just _build "x86" "v143" "md" 25 | just _build "arm64" "v143" "mt" 26 | just _build "arm64" "v143" "md" 27 | 28 | _build arch ver crt: 29 | #!{{shebang}} 30 | if ("{{arch}}" -eq "x64") { 31 | .\Launch-VsDevShell.ps1 -VsInstallationPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' -SkipAutomaticLocation -HostArch amd64 -Arch amd64 32 | } else { 33 | .\Launch-VsDevShell.ps1 -VsInstallationPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' -SkipAutomaticLocation -HostArch amd64 -Arch "{{arch}}" 34 | } 35 | .\build-onnxruntime-win.ps1 -VsArch {{arch}} -VsVer {{ver}} -VsCRT {{crt}} 36 | cp -r build-{{arch}}-{{ver}}-{{crt}}/Release/install onnxruntime-{{onnx}}-windows-{{vs}}-{{arch}}-shared-{{crt}} 37 | 7z a onnxruntime-{{onnx}}-windows-{{vs}}-{{arch}}-shared-{{crt}}.7z onnxruntime-{{onnx}}-windows-{{vs}}-{{arch}}-shared-{{crt}} 38 | rm onnxruntime-{{onnx}}-windows-{{vs}}-{{arch}}-shared-{{crt}} -r -fo 39 | cp -r build-{{arch}}-{{ver}}-{{crt}}/Release/install-static onnxruntime-{{onnx}}-windows-{{vs}}-{{arch}}-static-{{crt}} 40 | 7z a onnxruntime-{{onnx}}-windows-{{vs}}-{{arch}}-static-{{crt}}.7z onnxruntime-{{onnx}}-windows-{{vs}}-{{arch}}-static-{{crt}} 41 | rm onnxruntime-{{onnx}}-windows-{{vs}}-{{arch}}-static-{{crt}} -r -fo 42 | 43 | # 编译opencv java包 44 | build_java: 45 | just _java "x64" "v143" "mt" 46 | just _java "x64" "v143" "md" 47 | just _java "arm64" "v143" "mt" 48 | just _java "arm64" "v143" "md" 49 | 50 | _java arch ver crt: 51 | #!{{shebang}} 52 | if ("{{arch}}" -eq "x64") { 53 | .\Launch-VsDevShell.ps1 -VsInstallationPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' -SkipAutomaticLocation -HostArch amd64 -Arch amd64 54 | } else { 55 | .\Launch-VsDevShell.ps1 -VsInstallationPath 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' -SkipAutomaticLocation -HostArch amd64 -Arch "{{arch}}" 56 | } 57 | .\build-onnxruntime-win.ps1 -VsArch {{arch}} -VsVer {{ver}} -VsCRT {{crt}} -BuildJava 58 | cp -r build-{{arch}}-{{ver}}-{{crt}}/Release/java/build/libs onnxruntime-{{onnx}}-windows-{{vs}}-java-{{arch}}-{{crt}} 59 | 7z a onnxruntime-{{onnx}}-windows-{{vs}}-java-{{arch}}-{{crt}}.7z onnxruntime-{{onnx}}-windows-{{vs}}-java-{{arch}}-{{crt}} 60 | rm onnxruntime-{{onnx}}-windows-{{vs}}-java-{{arch}}-{{crt}} -r -fo 61 | -------------------------------------------------------------------------------- /onnxruntime_cmake_options.txt: -------------------------------------------------------------------------------- 1 | --compile-no-warning-as-error 2 | -Donnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS=OFF 3 | -Donnxruntime_RUN_ONNX_TESTS=OFF 4 | -Donnxruntime_GENERATE_TEST_REPORTS=ON 5 | -Donnxruntime_USE_VCPKG=OFF 6 | -Donnxruntime_USE_MIMALLOC=OFF 7 | -Donnxruntime_ENABLE_PYTHON=OFF 8 | -Donnxruntime_BUILD_CSHARP=OFF 9 | -Donnxruntime_BUILD_JAVA=OFF 10 | -Donnxruntime_BUILD_NODEJS=OFF 11 | -Donnxruntime_BUILD_OBJC=OFF 12 | -Donnxruntime_BUILD_SHARED_LIB=ON 13 | -Donnxruntime_BUILD_APPLE_FRAMEWORK=OFF 14 | -Donnxruntime_USE_DNNL=OFF 15 | -Donnxruntime_USE_NNAPI_BUILTIN=OFF 16 | -Donnxruntime_USE_VSINPU=OFF 17 | -Donnxruntime_USE_RKNPU=OFF 18 | -Donnxruntime_ENABLE_MICROSOFT_INTERNAL=OFF 19 | -Donnxruntime_USE_VITISAI=OFF 20 | -Donnxruntime_USE_TENSORRT=OFF 21 | -Donnxruntime_USE_NV=OFF 22 | -Donnxruntime_USE_TENSORRT_BUILTIN_PARSER=ON 23 | -Donnxruntime_USE_TENSORRT_INTERFACE=OFF 24 | -Donnxruntime_USE_CUDA_INTERFACE=OFF 25 | -Donnxruntime_USE_NV_INTERFACE=OFF 26 | -Donnxruntime_USE_OPENVINO_INTERFACE=OFF 27 | -Donnxruntime_USE_VITISAI_INTERFACE=OFF 28 | -Donnxruntime_USE_QNN_INTERFACE=OFF 29 | -Donnxruntime_USE_MIGRAPHX=OFF 30 | -Donnxruntime_DISABLE_CONTRIB_OPS=OFF 31 | -Donnxruntime_DISABLE_ML_OPS=OFF 32 | -Donnxruntime_DISABLE_RTTI=OFF 33 | -Donnxruntime_DISABLE_EXCEPTIONS=OFF 34 | -Donnxruntime_MINIMAL_BUILD=OFF 35 | -Donnxruntime_EXTENDED_MINIMAL_BUILD=OFF 36 | -Donnxruntime_MINIMAL_BUILD_CUSTOM_OPS=OFF 37 | -Donnxruntime_REDUCED_OPS_BUILD=OFF 38 | -Donnxruntime_BUILD_MS_EXPERIMENTAL_OPS=OFF 39 | -Donnxruntime_ENABLE_LTO=OFF 40 | -Donnxruntime_USE_ACL=OFF 41 | -Donnxruntime_USE_ARMNN=OFF 42 | -Donnxruntime_ARMNN_RELU_USE_CPU=ON 43 | -Donnxruntime_ARMNN_BN_USE_CPU=ON 44 | -Donnxruntime_USE_JSEP=OFF 45 | -Donnxruntime_USE_WEBGPU=OFF 46 | -Donnxruntime_USE_EXTERNAL_DAWN=OFF 47 | -Donnxruntime_ENABLE_NVTX_PROFILE=OFF 48 | -Donnxruntime_ENABLE_TRAINING=OFF 49 | -Donnxruntime_ENABLE_TRAINING_OPS=OFF 50 | -Donnxruntime_ENABLE_TRAINING_APIS=OFF 51 | -Donnxruntime_ENABLE_CPU_FP16_OPS=OFF 52 | -Donnxruntime_USE_NCCL=OFF 53 | -Donnxruntime_BUILD_BENCHMARKS=OFF 54 | -Donnxruntime_USE_ROCM=OFF 55 | -Donnxruntime_GCOV_COVERAGE=OFF 56 | -Donnxruntime_ENABLE_MEMORY_PROFILE=OFF 57 | -Donnxruntime_ENABLE_CUDA_LINE_NUMBER_INFO=OFF 58 | -Donnxruntime_USE_CUDA_NHWC_OPS=OFF 59 | -Donnxruntime_BUILD_WEBASSEMBLY_STATIC_LIB=OFF 60 | -Donnxruntime_ENABLE_WEBASSEMBLY_EXCEPTION_CATCHING=ON 61 | -Donnxruntime_ENABLE_WEBASSEMBLY_API_EXCEPTION_CATCHING=OFF 62 | -Donnxruntime_ENABLE_WEBASSEMBLY_EXCEPTION_THROWING=ON 63 | -Donnxruntime_WEBASSEMBLY_RUN_TESTS_IN_BROWSER=OFF 64 | -Donnxruntime_ENABLE_WEBASSEMBLY_THREADS=OFF 65 | -Donnxruntime_ENABLE_WEBASSEMBLY_MEMORY64=OFF 66 | -Donnxruntime_ENABLE_WEBASSEMBLY_DEBUG_INFO=OFF 67 | -Donnxruntime_ENABLE_WEBASSEMBLY_PROFILING=OFF 68 | -Donnxruntime_ENABLE_LAZY_TENSOR=OFF 69 | -Donnxruntime_ENABLE_CUDA_PROFILING=OFF 70 | -Donnxruntime_ENABLE_ROCM_PROFILING=OFF 71 | -Donnxruntime_USE_XNNPACK=OFF 72 | -Donnxruntime_USE_WEBNN=OFF 73 | -Donnxruntime_USE_CANN=OFF 74 | -Donnxruntime_USE_TRITON_KERNEL=OFF 75 | -Donnxruntime_DISABLE_FLOAT8_TYPES=OFF 76 | -Donnxruntime_DISABLE_SPARSE_TENSORS=OFF 77 | -Donnxruntime_DISABLE_OPTIONAL_TYPE=OFF 78 | -Donnxruntime_CUDA_MINIMAL=OFF 79 | -Donnxruntime_BUILD_UNIT_TESTS=OFF 80 | -Donnxruntime_CROSS_COMPILING=ON 81 | -DCMAKE_TLS_VERIFY=ON 82 | -DFETCHCONTENT_QUIET=OFF 83 | -------------------------------------------------------------------------------- /patches/onnxruntime-1.18.0-musl.patch: -------------------------------------------------------------------------------- 1 | diff -Nuarp origin/_deps/flatbuffers-src/include/flatbuffers/base.h fixed/_deps/flatbuffers-src/include/flatbuffers/base.h 2 | --- _deps/flatbuffers-src/include/flatbuffers/base.h 2024-07-15 18:46:49.285744238 +0800 3 | +++ _deps/flatbuffers-src/include/flatbuffers/base.h 2024-07-16 09:13:24.000000000 +0800 4 | @@ -270,7 +270,7 @@ namespace flatbuffers { 5 | // strtoull_l}. 6 | #if (defined(_MSC_VER) && _MSC_VER >= 1800) || \ 7 | (defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \ 8 | - (defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \ 9 | + (defined(GLIBC) && defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \ 10 | (!defined(__Fuchsia__) && !defined(__ANDROID_API__)) 11 | #define FLATBUFFERS_LOCALE_INDEPENDENT 1 12 | #else 13 | -------------------------------------------------------------------------------- /release.md: -------------------------------------------------------------------------------- 1 | ## 编译环境 2 | 3 | ### Android 4 | 5 | | 操作系统 | ndk | JDK | gradle | 6 | |--------------|---------------|-----|--------| 7 | | ubuntu 22.04 | 26.1.10909125 | 17 | 8.6 | 8 | 9 | ### Windows 10 | 11 | | 操作系统 | vs版本 | JDK | gradle | MSVC | 12 | |------|--------|-----|--------|-------------| 13 | | 2022 | vs2022 | 11 | 8.6 | 19.42.34440 | 14 | 15 | ### Ubuntu 16 | 17 | | 操作系统 | gcc | libc | binutils | JDK | gradle | 18 | |--------------|--------|------|----------|-----|--------| 19 | | ubuntu 22.04 | 11.4.0 | 2.35 | 2.38 | 11 | 8.6 | 20 | 21 | ### Musl 22 | 23 | | 操作系统 | musl-gcc | 24 | |--------------|----------| 25 | | ubuntu 22.04 | 14.2.0 | 26 | 27 | ### Macos 28 | 29 | | 操作系统 | JDK | gradle | 30 | |------|-----|--------| 31 | | 13 | 11 | 8.6 | 32 | | 14 | 11 | 8.6 | --------------------------------------------------------------------------------