From 60b2f5d00650b713f250d9d5af7a9775779e4359 Mon Sep 17 00:00:00 2001 From: Vasyl Skorych Date: Tue, 8 Oct 2024 00:31:57 +0200 Subject: [PATCH] ci: Fix Windows build --- .github/workflows/build_windows.yml | 133 ++++++++++++++++++---------- 1 file changed, 86 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index af4ac06..7cab7c4 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -9,19 +9,9 @@ name: Windows on: [push] env: - # Path to the solution/project files relative to the root of the project. - SOLUTION_FILE_PATH: . - SOLUTION_FILE_NAME: musen.sln - INSTALLER_PROJECT_PATH: ./Installers/InstallerProject/ - - # Configuration type to build. - BUILD_CONFIGURATION: Release - BUILD_PLATFORM: x64 - - # Versions - QT_VERSION: 5.15.2 - QT_VS_VERSION: msvc2019_64 - QT_VS_ADDIN_VERSION: 3.2.0 + QT_VS_ADDIN_URL: https://ftp.fau.de/qtproject/archive/vsaddin/3.2.0/qt-vsaddin-msvc2022-x64-3.2.0-rev.47.vsix + PATH_TO_CUDA: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA + PATH_TO_VS_CUDA_TARGETS: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\BuildCustomizations jobs: build: @@ -42,7 +32,7 @@ jobs: # If cached, only install essential build tools and set environmental variables. cache-key-prefix: 'cache-qt' # Version of Qt to install. - version: ${{env.QT_VERSION}} + version: 5.15.2 # Architecture. arch: win64_msvc2019_64 # Directory to install. @@ -64,7 +54,7 @@ jobs: # Also, it installs them to %LOCALAPPDATA%\QtMsBuild, so they can not be used by other Windows users. # Download the extension and extract requited files to the project directory. run: | - Invoke-WebRequest -Uri https://ftp.fau.de/qtproject/archive/vsaddin/${{env.QT_VS_ADDIN_VERSION}}/qt-vsaddin-msvc2022-x64-${{env.QT_VS_ADDIN_VERSION}}-rev.47.vsix -MaximumRetryCount 10 -RetryIntervalSec 30 -OutFile vspackage.vsix + Invoke-WebRequest -Uri ${{env.QT_VS_ADDIN_URL}} -MaximumRetryCount 10 -RetryIntervalSec 30 -OutFile vspackage.vsix Expand-Archive vspackage.vsix -DestinationPath ${{github.workspace}}/ExternalLibraries/qtvsaddin - name: Cache ZLib @@ -99,7 +89,7 @@ jobs: id: cache-cuda uses: actions/cache@v4 with: - path: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA + path: ${{env.PATH_TO_CUDA}} key: ${{runner.os}}-CUDACache - name: Install CUDA @@ -108,24 +98,48 @@ jobs: id: install-cuda with: cuda: '11.8.0' - sub-packages: '["cudart", "curand_dev", "nvcc", "thrust"]' + sub-packages: '["cudart", "curand_dev", "nvcc", "thrust", "visual_studio_integration"]' method: 'network' - - name: Install CUDA VS integration - uses: Jimver/cuda-toolkit@v0.2.17 - id: install-cuda-vs - with: - cuda: '11.8.0' - sub-packages: '["visual_studio_integration"]' - method: 'network' + - name: Get CUDA MsBuild tools + if: steps.cache-cuda.outputs.cache-hit == 'true' + # Get additional project files to build CUDA projects with MSBuild. This work is normally done by CUDA visual_studio_integration. + # But since it installation of visual_studio_integration is very slow, we do it manually if cache was hit. + # Set environment variables and copy build customization files. + run: | + echo ("CUDA_PATH=${{env.PATH_TO_CUDA}}\v11.8") >> $env:GITHUB_ENV + echo ("CUDA_PATH_V11_8=${{env.PATH_TO_CUDA}}\v11.8") >> $env:GITHUB_ENV + New-Item -ItemType Directory -Force -Path "${{env.PATH_TO_VS_CUDA_TARGETS}}" + Copy-Item "${{env.PATH_TO_CUDA}}\v11.8\extras\visual_studio_integration\MSBuildExtensions\*" "${{env.PATH_TO_VS_CUDA_TARGETS}}\" - name: Build working-directory: ${{github.workspace}} env: QtToolsPath: ${{env.QT_ROOT_DIR}}/bin QtMsBuild: ${{github.workspace}}/ExternalLibraries/qtvsaddin/QtMsBuild - # Add additional options to the MSBuild command line here: see https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference. - run: msbuild -maxCpuCount -verbosity:minimal -property:Configuration=${{env.BUILD_CONFIGURATION}} -property:Platform=${{env.BUILD_PLATFORM}} ${{env.SOLUTION_FILE_PATH}}/${{env.SOLUTION_FILE_NAME}} + run: msbuild -maxCpuCount -verbosity:minimal -property:Configuration=Release -property:Platform=x64 ${{github.workspace}}/musen.sln + + # - name: Upload Build Artifact + # # if: github.ref == 'refs/heads/master' + # uses: actions/upload-artifact@v4 + # with: + # name: build-artifact + # if-no-files-found: error + # retention-days: 1 + # compression-level: 1 + # path: | + # ${{github.workspace}}/x64/Release/*.exe + # ${{github.workspace}}/x64/Release/*.dll + + - name: Upload Release Build Artifact + # if: github.ref == 'refs/heads/master' + uses: actions/upload-artifact@v4 + with: + name: build-artifact + if-no-files-found: error + retention-days: 1 + compression-level: 1 + path: ${{github.workspace}}/x64/Release/* installer: runs-on: windows-latest @@ -150,7 +164,7 @@ jobs: # If cached, only install essential build tools and set environmental variables. cache-key-prefix: 'cache-qt' # Version of Qt to install. - version: ${{env.QT_VERSION}} + version: 5.15.2 # Architecture. arch: win64_msvc2019_64 # Directory to install. @@ -172,7 +186,7 @@ jobs: # Also, it installs them to %LOCALAPPDATA%\QtMsBuild, so they can not be used by other Windows users. # Download the extension and extract requited files to the project directory. run: | - Invoke-WebRequest -Uri https://ftp.fau.de/qtproject/archive/vsaddin/${{env.QT_VS_ADDIN_VERSION}}/qt-vsaddin-msvc2022-x64-${{env.QT_VS_ADDIN_VERSION}}-rev.47.vsix -MaximumRetryCount 10 -RetryIntervalSec 30 -OutFile vspackage.vsix + Invoke-WebRequest -Uri ${{env.QT_VS_ADDIN_URL}} -MaximumRetryCount 10 -RetryIntervalSec 30 -OutFile vspackage.vsix Expand-Archive vspackage.vsix -DestinationPath ${{github.workspace}}/ExternalLibraries/qtvsaddin - name: Cache ZLib @@ -207,7 +221,7 @@ jobs: id: cache-cuda uses: actions/cache@v4 with: - path: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA + path: ${{env.PATH_TO_CUDA}} key: ${{runner.os}}-CUDACache - name: Install CUDA @@ -216,32 +230,45 @@ jobs: id: install-cuda with: cuda: '11.8.0' - sub-packages: '["cudart", "curand_dev", "nvcc", "thrust"]' - method: 'network' - - - name: Install CUDA VS integration - uses: Jimver/cuda-toolkit@v0.2.17 - id: install-cuda-vs - with: - cuda: '11.8.0' - sub-packages: '["visual_studio_integration"]' + sub-packages: '["cudart", "curand_dev", "nvcc", "thrust", "visual_studio_integration"]' method: 'network' - - name: Build - working-directory: ${{github.workspace}} - env: - QtToolsPath: ${{env.QT_ROOT_DIR}}/bin - QtMsBuild: ${{github.workspace}}/ExternalLibraries/qtvsaddin/QtMsBuild + - name: Get CUDA MsBuild tools + if: steps.cache-cuda.outputs.cache-hit == 'true' + # Get additional project files to build CUDA projects with MSBuild. This work is normally done by CUDA visual_studio_integration. + # But since it installation of visual_studio_integration is very slow, we do it manually if cache was hit. + # Set environment variables and copy build customization files. run: | - msbuild -maxCpuCount -verbosity:minimal -property:Configuration=Debug -property:Platform=${{env.BUILD_PLATFORM}} ${{env.SOLUTION_FILE_PATH}}/${{env.SOLUTION_FILE_NAME}} - msbuild -maxCpuCount -verbosity:minimal -property:Configuration=Release -property:Platform=${{env.BUILD_PLATFORM}} ${{env.SOLUTION_FILE_PATH}}/${{env.SOLUTION_FILE_NAME}} + echo ("CUDA_PATH=${{env.PATH_TO_CUDA}}\v11.8") >> $env:GITHUB_ENV + echo ("CUDA_PATH_V11_8=${{env.PATH_TO_CUDA}}\v11.8") >> $env:GITHUB_ENV + New-Item -ItemType Directory -Force -Path "${{env.PATH_TO_VS_CUDA_TARGETS}}" + Copy-Item "${{env.PATH_TO_CUDA}}\v11.8\extras\visual_studio_integration\MSBuildExtensions\*" "${{env.PATH_TO_VS_CUDA_TARGETS}}\" + + - name: Download Release Build Artifact + uses: actions/download-artifact@v4 + with: + name: build-artifact + path: ${{github.workspace}}/x64/Release/ + + # - name: Build Debug + # working-directory: ${{github.workspace}} + # env: + # QtToolsPath: ${{env.QT_ROOT_DIR}}/bin + # QtMsBuild: ${{github.workspace}}/ExternalLibraries/qtvsaddin/QtMsBuild + # During compilation in Debug, "fatal error C1060: compiler is out of heap space" happens for some CUDA files. + # To workaround this, we run compilation for the second time to build missed projects. + # run: | + # $devenv = & vswhere.exe '-property' productPath + # Start-Process -FilePath $devenv -ArgumentList '${{github.workspace}}/musen.sln /build "Debug|x64"' -Wait + # msbuild -maxCpuCount -verbosity:minimal -property:Configuration=Debug -property:Platform=x64 ${{github.workspace}}/musen.sln + # msbuild -maxCpuCount -verbosity:minimal -property:Configuration=Debug -property:Platform=x64 ${{github.workspace}}/musen.sln - name: Build Installer working-directory: ${{github.workspace}} env: QtToolsPath: ${{env.QT_ROOT_DIR}}/bin QtMsBuild: ${{github.workspace}}/ExternalLibraries/qtvsaddin/QtMsBuild - run: msbuild -maxCpuCount -verbosity:minimal -property:Configuration=${{env.BUILD_CONFIGURATION}} -property:Platform=${{env.BUILD_PLATFORM}} -property:SolutionDir=${{github.workspace}}/ -property:SolutionPath=${{github.workspace}}/${{env.SOLUTION_FILE_NAME}} -property:QtInstallDir=${{github.workspace}}/ExternalLibraries/qt/Qt/${{env.QT_VERSION}}/${{env.QT_VS_VERSION}}/ ${{env.INSTALLER_PROJECT_PATH}} + run: msbuild -maxCpuCount -verbosity:minimal -property:Configuration=Release -property:Platform=x64 -property:SolutionDir=${{github.workspace}}/ -property:SolutionPath=${{github.workspace}}/musen.sln -property:QtInstallDir=${{github.workspace}}/ExternalLibraries/qt/Qt/5.15.2/msvc2019_64/ ${{github.workspace}}/Installers/InstallerProject/ - name: Run Installer shell: pwsh @@ -271,7 +298,7 @@ jobs: shell: pwsh run: | $UnInstallerFile = Resolve-Path "${{ env.LOCALAPPDATA_DIR }}/Programs/MUSEN/unins000.exe" - Start-Process -FilePath $UnInstallerFile -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /skipaskconfig=yes" -Wait + Start-Process -FilePath $UnInstallerFile -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART" -Wait release: runs-on: windows-latest @@ -323,3 +350,15 @@ jobs: files: | MUSEN.${{steps.get-version.outputs.VERSION}}.open.setup.exe MUSEN.${{steps.get-version.outputs.VERSION}}.open.portable.zip + + # cleanup: + # runs-on: windows-latest + # needs: [build, installer] + # if: ${{always()}} + + # steps: + # - name: Delete Build Artifact + # uses: geekyeggo/delete-artifact@v4 + # with: + # name: build-artifact + # failOnError: false