| @@ -1,4 +1,5 @@ | |||
| name: windows | |||
| on: | |||
| push: | |||
| branches: [master] | |||
| @@ -28,41 +29,63 @@ on: | |||
| - 'tools/**' | |||
| - '!tools/pnnx/**' | |||
| - 'examples/**' | |||
| concurrency: | |||
| group: windows-${{ github.ref }} | |||
| cancel-in-progress: true | |||
| permissions: | |||
| contents: read | |||
| jobs: | |||
| windows-gpu: | |||
| name: ${{ matrix.vs-version }} | |||
| runs-on: ${{ matrix.os }} | |||
| runs-on: windows-2022 | |||
| strategy: | |||
| fail-fast: false | |||
| matrix: | |||
| include: | |||
| - vs-version: vs2015 | |||
| toolset-version: v140 | |||
| os: windows-2019 | |||
| - vs-version: vs2017 | |||
| toolset-version: v141 | |||
| os: windows-2019 | |||
| - vs-version: vs2019 | |||
| toolset-version: v142 | |||
| os: windows-2022 | |||
| - vs-version: vs2022 | |||
| toolset-version: v143 | |||
| os: windows-2022 | |||
| env: | |||
| UseMultiToolTask: true | |||
| steps: | |||
| - uses: actions/checkout@v4 | |||
| with: | |||
| submodules: true | |||
| - name: Install VS 2017 (v141) Build Tools | |||
| if: matrix.vs-version == 'vs2017' | |||
| shell: pwsh | |||
| run: | | |||
| $vsInstallPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath | |||
| Start-Process -FilePath "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList "modify --installPath `"$vsInstallPath`" --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --quiet --norestart --nocache" -Wait | |||
| - name: Install and Setup VS 2015 (v140) Build Tools | |||
| if: matrix.vs-version == 'vs2015' | |||
| shell: pwsh | |||
| run: | | |||
| $vs140Path = "C:/vs140_build_tools" | |||
| Invoke-WebRequest -Uri "https://aka.ms/vs/15/release/vs_buildtools.exe" -OutFile vs_buildtools.exe | |||
| Start-Process -FilePath "vs_buildtools.exe" -ArgumentList "--installPath `"$vs140Path`" --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.140 --quiet --wait --norestart --nocache" -Wait | |||
| $vcvarsPath = (Get-ChildItem -Path $vs140Path -Filter "vcvars64.bat" -Recurse | Select-Object -First 1).FullName | |||
| $cmd = "`"$vcvarsPath`" && powershell -Command `"`$env:PATH;`$env:INCLUDE;`$env:LIB`"" | |||
| $output = cmd.exe /c $cmd | |||
| $lines = $output -split "`r`n" | |||
| echo "PATH=$($lines[0]);$($env:PATH)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |||
| echo "INCLUDE=$($lines[1])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |||
| echo "LIB=$($lines[2])" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |||
| - name: cache-protobuf | |||
| id: cache-protobuf | |||
| uses: actions/cache@v4 | |||
| @@ -71,13 +94,16 @@ jobs: | |||
| key: protobuf-${{ matrix.vs-version }}-x64-install-2 | |||
| - name: protobuf | |||
| if: steps.cache-protobuf.outputs.cache-hit != 'true' | |||
| shell: pwsh | |||
| run: | | |||
| Invoke-WebRequest -Uri https://github.com/protocolbuffers/protobuf/archive/v3.11.2.zip -OutFile protobuf-3.11.2.zip | |||
| 7z x ./protobuf-3.11.2.zip | |||
| cd protobuf-3.11.2 | |||
| mkdir build-${{ matrix.vs-version }}; cd build-${{ matrix.vs-version }}; cmake -T ${{ matrix.toolset-version }},host=x64 -A x64 -DCMAKE_INSTALL_PREFIX="$env:GITHUB_WORKSPACE\protobuf-install" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DNCNN_BUILD_TESTS=ON ../cmake | |||
| mkdir build-${{ matrix.vs-version }}; cd build-${{ matrix.vs-version }} | |||
| cmake -T ${{ matrix.toolset-version }},host=x64 -A x64 -DCMAKE_INSTALL_PREFIX="$env:GITHUB_WORKSPACE\protobuf-install" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -DNCNN_BUILD_TESTS=ON ../cmake | |||
| cmake --build . --config Release -j 4 | |||
| cmake --build . --config Release --target install | |||
| - name: cache-swiftshader | |||
| if: matrix.vs-version != 'vs2015' && matrix.vs-version != 'vs2017' | |||
| id: cache-swiftshader | |||
| @@ -85,6 +111,7 @@ jobs: | |||
| with: | |||
| path: swiftshader-install | |||
| key: swiftshader-${{ matrix.vs-version }}-x64-install-20240622 | |||
| - name: checkout-swiftshader | |||
| if: matrix.vs-version != 'vs2015' && matrix.vs-version != 'vs2017' && steps.cache-swiftshader.outputs.cache-hit != 'true' | |||
| uses: actions/checkout@v4 | |||
| @@ -92,13 +119,17 @@ jobs: | |||
| repository: google/swiftshader | |||
| path: swiftshader | |||
| ref: de870ac7518fe2b6bb651ecc22fc36647cf7b986 | |||
| - name: checkout-swiftshader-submodules | |||
| if: matrix.vs-version != 'vs2015' && matrix.vs-version != 'vs2017' && steps.cache-swiftshader.outputs.cache-hit != 'true' | |||
| shell: pwsh | |||
| run: | | |||
| cd swiftshader | |||
| git -c submodule."third_party/git-hooks".update=none submodule update --init --recursive | |||
| - name: swiftshader | |||
| if: matrix.vs-version != 'vs2015' && matrix.vs-version != 'vs2017' && steps.cache-swiftshader.outputs.cache-hit != 'true' | |||
| shell: pwsh | |||
| run: | | |||
| cd swiftshader | |||
| mkdir build-${{ matrix.vs-version }}; cd build-${{ matrix.vs-version }} | |||
| @@ -108,39 +139,48 @@ jobs: | |||
| Copy-Item -Path "Windows\*" -Destination "$env:GITHUB_WORKSPACE\swiftshader-install" | |||
| - name: x64 | |||
| shell: pwsh | |||
| run: | | |||
| mkdir build-x64; cd build-x64 | |||
| cmake -T ${{ matrix.toolset-version }},host=x64 -A x64 -Dprotobuf_DIR="$env:GITHUB_WORKSPACE\protobuf-install\cmake" -DNCNN_VULKAN=ON -DNCNN_BUILD_TESTS=ON .. | |||
| cmake --build . --config Release -j 4 | |||
| - name: x64-test | |||
| if: matrix.vs-version != 'vs2015' && matrix.vs-version != 'vs2017' | |||
| shell: pwsh | |||
| run: | | |||
| echo "[Processor]`nThreadCount=1`n" > build-x64/tests/Release/SwiftShader.ini | |||
| Copy-Item -Path "$env:GITHUB_WORKSPACE\swiftshader-install\vulkan-1.dll" -Destination 'build-x64\tests' | |||
| cd build-x64; ctest -C Release --output-on-failure -j 4 | |||
| - name: x64-sse2 | |||
| shell: pwsh | |||
| run: | | |||
| mkdir build-x64-sse2; cd build-x64-sse2 | |||
| cmake -T ${{ matrix.toolset-version }},host=x64 -A x64 -DNCNN_RUNTIME_CPU=OFF -DNCNN_XOP=OFF -DNCNN_AVX=OFF -DNCNN_AVX2=OFF -DNCNN_AVX512=OFF -DNCNN_BUILD_TESTS=ON -DNCNN_DISABLE_RTTI=ON -DNCNN_DISABLE_EXCEPTION=ON -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| cmake --build . --config Release -j 4 | |||
| - name: x64-sse2-test | |||
| shell: pwsh | |||
| run: cd build-x64-sse2; ctest -C Release --output-on-failure -j 4 | |||
| - name: x64-avx | |||
| shell: pwsh | |||
| run: | | |||
| mkdir build-x64-avx; cd build-x64-avx | |||
| cmake -T ${{ matrix.toolset-version }},host=x64 -A x64 -DNCNN_RUNTIME_CPU=OFF -DNCNN_XOP=OFF -DNCNN_AVX=ON -DNCNN_AVX2=OFF -DNCNN_AVX512=OFF -DNCNN_BUILD_TESTS=ON -DNCNN_DISABLE_RTTI=ON -DNCNN_DISABLE_EXCEPTION=ON -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| cmake --build . --config Release -j 4 | |||
| - name: x64-avx-test | |||
| shell: pwsh | |||
| run: cd build-x64-avx; ctest -C Release --output-on-failure -j 4 | |||
| - name: x86 | |||
| shell: pwsh | |||
| run: | | |||
| mkdir build-x86; cd build-x86 | |||
| cmake -T ${{ matrix.toolset-version }},host=x64 -A Win32 -DNCNN_SHARED_LIB=ON -DNCNN_BUILD_TESTS=ON -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| cmake --build . --config Release -j 4 | |||
| - name: x86-test | |||
| shell: pwsh | |||
| run: | | |||
| Copy-Item -Path "build-x86\src\Release\ncnn.dll" -Destination 'build-x86\tests' | |||
| cd build-x86; ctest -C Release --output-on-failure -j 4 | |||