├── README.md ├── .gitignore ├── LICENSE ├── .github └── workflows │ └── build.yml └── Build-Windows.ps1 /README.md: -------------------------------------------------------------------------------- 1 | # onnxruntime-static-win -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | release 3 | *.zip 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Kaito Udagawa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: "Build" 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | tags: 8 | - "*" 9 | pull_request: 10 | branches: 11 | - "main" 12 | 13 | env: 14 | ONNXRUNTIME_VERSION: "v1.17.3" 15 | 16 | jobs: 17 | BuildWindows: 18 | runs-on: "windows-2022" 19 | 20 | strategy: 21 | matrix: 22 | config: 23 | - "Release" 24 | 25 | steps: 26 | - name: "Get version" 27 | shell: bash 28 | run: | 29 | if [[ $GITHUB_REF =~ ^refs/tags/ ]] 30 | then version="${GITHUB_REF#refs/tags/}" 31 | else version=main 32 | fi 33 | printf "version=%s" "$version" > "$GITHUB_OUTPUT" 34 | id: "get-version" 35 | 36 | - name: "Checkout" 37 | uses: "actions/checkout@v4" 38 | 39 | - name: "Download the ONNX Runtime source code" 40 | run: "git clone -b ${{ env.ONNXRUNTIME_VERSION }} --recurse-submodules --depth 1 https://github.com/microsoft/onnxruntime.git" 41 | 42 | - name: "Run Build-Windows.ps1" 43 | run: "./Build-Windows.ps1 -Configuration ${{ matrix.config }} -Version ${{ steps.get-version.outputs.version }}" 44 | 45 | - uses: "actions/upload-artifact@v3" 46 | with: 47 | name: "onnxruntime-win-${{ matrix.config }}" 48 | path: "release/*.zip" 49 | 50 | Release: 51 | runs-on: "ubuntu-22.04" 52 | 53 | if: "github.event_name == 'push' && contains(github.ref, 'refs/tags/')" 54 | 55 | needs: 56 | - "BuildWindows" 57 | 58 | permissions: 59 | contents: "write" 60 | 61 | defaults: 62 | run: 63 | shell: "bash" 64 | 65 | steps: 66 | - name: "Get version" 67 | run: | 68 | if [[ $GITHUB_REF =~ ^refs/tags/ ]] 69 | then version="${GITHUB_REF#refs/tags/}" 70 | else version=main 71 | fi 72 | printf "version=%s" "$version" > "$GITHUB_OUTPUT" 73 | id: "get-version" 74 | 75 | - name: "Download build artifacts" 76 | uses: "actions/download-artifact@v3" 77 | 78 | - name: "Create Release" 79 | uses: "softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5" 80 | with: 81 | draft: true 82 | tag_name: "${{ steps.get-version.outputs.version }}" 83 | name: "${{ steps.get-version.outputs.version }}" 84 | files: | 85 | ${{ github.workspace }}/**/*.zip 86 | -------------------------------------------------------------------------------- /Build-Windows.ps1: -------------------------------------------------------------------------------- 1 | Param($Configuration, $Version) 2 | 3 | if (Test-Path release) { 4 | Remove-Item release -Recurse -Force 5 | } 6 | New-Item release\$Configuration\bin -ItemType Directory -Force 7 | New-Item release\$Configuration\include -ItemType Directory -Force 8 | New-Item release\$Configuration\lib -ItemType Directory -Force 9 | 10 | python onnxruntime\tools\ci_build\build.py --cmake_generator "Visual Studio 17 2022" --build_dir build --config $Configuration --parallel --skip_tests --skip_submodule_sync --use_dml 11 | 12 | $binArray = 13 | "build\packages\Microsoft.AI.DirectML.1.13.1\bin\x64-win\DirectML.dll", 14 | "build\packages\Microsoft.AI.DirectML.1.13.1\bin\x64-win\DirectML.lib" 15 | 16 | $includeArray = 17 | "onnxruntime\include\onnxruntime\core\framework\provider_options.h", 18 | "onnxruntime\include\onnxruntime\core\providers\cpu\cpu_provider_factory.h", 19 | "onnxruntime\include\onnxruntime\core\providers\dml\dml_provider_factory.h", 20 | "onnxruntime\include\onnxruntime\core\session\onnxruntime_c_api.h", 21 | "onnxruntime\include\onnxruntime\core\session\onnxruntime_cxx_api.h", 22 | "onnxruntime\include\onnxruntime\core\session\onnxruntime_cxx_inline.h", 23 | "onnxruntime\include\onnxruntime\core\session\onnxruntime_float16.h", 24 | "onnxruntime\include\onnxruntime\core\session\onnxruntime_run_options_config_keys.h", 25 | "onnxruntime\include\onnxruntime\core\session\onnxruntime_session_options_config_keys.h" 26 | 27 | $libArray = 28 | "build\$Configuration\_deps\abseil_cpp-build\absl\base\$Configuration\absl_throw_delegate.lib", 29 | "build\$Configuration\_deps\abseil_cpp-build\absl\container\$Configuration\absl_raw_hash_set.lib", 30 | "build\$Configuration\_deps\abseil_cpp-build\absl\hash\$Configuration\absl_city.lib", 31 | "build\$Configuration\_deps\abseil_cpp-build\absl\hash\$Configuration\absl_hash.lib", 32 | "build\$Configuration\_deps\abseil_cpp-build\absl\hash\$Configuration\absl_low_level_hash.lib", 33 | "build\$Configuration\_deps\onnx-build\$Configuration\onnx_proto.lib", 34 | "build\$Configuration\_deps\onnx-build\$Configuration\onnx.lib", 35 | "build\$Configuration\_deps\re2-build\$Configuration\re2.lib", 36 | "build\$Configuration\$Configuration\onnxruntime_common.lib", 37 | "build\$Configuration\$Configuration\onnxruntime_flatbuffers.lib", 38 | "build\$Configuration\$Configuration\onnxruntime_framework.lib", 39 | "build\$Configuration\$Configuration\onnxruntime_graph.lib", 40 | "build\$Configuration\$Configuration\onnxruntime_mlas.lib", 41 | "build\$Configuration\$Configuration\onnxruntime_optimizer.lib", 42 | "build\$Configuration\$Configuration\onnxruntime_providers_dml.lib", 43 | "build\$Configuration\$Configuration\onnxruntime_providers_shared.lib", 44 | "build\$Configuration\$Configuration\onnxruntime_providers.lib", 45 | "build\$Configuration\$Configuration\onnxruntime_session.lib", 46 | "build\$Configuration\$Configuration\onnxruntime_util.lib" 47 | 48 | if ($Configuration -eq "Debug") { 49 | $libArray += "build\Debug\_deps\protobuf-build\Debug\libprotobuf-lited.lib" 50 | } else { 51 | $libArray += "build\Release\_deps\protobuf-build\Release\libprotobuf-lite.lib" 52 | } 53 | 54 | foreach ($bin in $binArray) { 55 | Copy-Item $bin release\$Configuration\bin -Verbose 56 | } 57 | 58 | foreach ($include in $includeArray) { 59 | Copy-Item $include release\$Configuration\include -Verbose 60 | } 61 | 62 | foreach ($lib in $libArray) { 63 | Copy-Item $lib release\$Configuration\lib -Verbose 64 | } 65 | 66 | Compress-Archive release\$Configuration\* release\onnxruntime-windows-$Version-$Configuration.zip -Verbose 67 | --------------------------------------------------------------------------------