Skip to content

build: Fix build with some compilers #42

build: Fix build with some compilers

build: Fix build with some compilers #42

Workflow file for this run

# Copyright (c) 2024, DyssolTEC GmbH.
# All rights reserved. This file is part of MUSEN framework http://msolids.net/musen.
# See LICENSE file for license and warranty information.
# A workflow for compilation on Windows
name: Windows
on: [push]
env:
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:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
# Whether to cache Qt automatically.
cache: 'true'
# If cached, only install essential build tools and set environmental variables.
cache-key-prefix: 'cache-qt'
# Version of Qt to install.
version: 5.15.2
# Architecture.
arch: win64_msvc2019_64
# Directory to install.
dir: ${{github.workspace}}/ExternalLibraries/qt
# Whether or not to automatically run setup-python to find a valid python version.
setup-python: 'false'
- name: Cache QtMsBuild tools
id: cache-qt-ms-build-tools
uses: actions/cache@v4
with:
path: ${{github.workspace}}/ExternalLibraries/qtvsaddin
key: ${{runner.os}}-QtMsBuildCache
- name: Get QtMsBuild tools
if: steps.cache-qt-ms-build-tools.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}
# Get additional project files to build Qt solution with MSBuild. This work is usually done in Visual Studio with Qt VS Tools extension.
# 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 ${{env.QT_VS_ADDIN_URL}} -MaximumRetryCount 10 -RetryIntervalSec 30 -OutFile vspackage.vsix
Expand-Archive vspackage.vsix -DestinationPath ${{github.workspace}}/ExternalLibraries/qtvsaddin
- name: Cache ZLib
id: cache-zlib
uses: actions/cache@v4
with:
path: ${{github.workspace}}/ExternalLibraries/zlib
key: ${{runner.os}}-ZLibCache
- name: Build ZLib
if: steps.cache-zlib.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/ExternalLibraries
shell: pwsh
# Run the script to build zlib.
run: .\CompileZLib.ps1
- name: Cache Protobuf
id: cache-protobuf
uses: actions/cache@v4
with:
path: ${{github.workspace}}/ExternalLibraries/protobuf
key: ${{runner.os}}-ProtobufCache
- name: Build Protobuf
if: steps.cache-protobuf.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/ExternalLibraries
shell: pwsh
# Run the script to build protobuf.
run: .\CompileProtobuf.ps1
- name: Cache CUDA
id: cache-cuda
uses: actions/cache@v4
with:
path: ${{env.PATH_TO_CUDA}}
key: ${{runner.os}}-CUDACache
- name: Install CUDA
if: steps.cache-cuda.outputs.cache-hit != 'true'
uses: Jimver/cuda-toolkit@v0.2.17
id: install-cuda
with:
cuda: '11.8.0'
sub-packages: '["cudart", "curand_dev", "nvcc", "thrust", "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
run: msbuild -maxCpuCount -verbosity:minimal -property:Configuration=Release -property:Platform=x64 ${{github.workspace}}/musen.sln
- name: Upload Release Build Artifact
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
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
needs: [build]
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get LocalAppData Directory
run: echo ("LOCALAPPDATA_DIR=" + $env:LOCALAPPDATA) >> $env:GITHUB_ENV
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
# Whether to cache Qt automatically.
cache: 'true'
# If cached, only install essential build tools and set environmental variables.
cache-key-prefix: 'cache-qt'
# Version of Qt to install.
version: 5.15.2
# Architecture.
arch: win64_msvc2019_64
# Directory to install.
dir: ${{github.workspace}}/ExternalLibraries/qt
# Whether or not to automatically run setup-python to find a valid python version.
setup-python: 'false'
- name: Cache QtMsBuild tools
id: cache-qt-ms-build-tools
uses: actions/cache@v4
with:
path: ${{github.workspace}}/ExternalLibraries/qtvsaddin
key: ${{runner.os}}-QtMsBuildCache
- name: Get QtMsBuild tools
if: steps.cache-qt-ms-build-tools.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}
# Get additional project files to build Qt solution with MSBuild. This work is usually done in Visual Studio with Qt VS Tools extension.
# 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 ${{env.QT_VS_ADDIN_URL}} -MaximumRetryCount 10 -RetryIntervalSec 30 -OutFile vspackage.vsix
Expand-Archive vspackage.vsix -DestinationPath ${{github.workspace}}/ExternalLibraries/qtvsaddin
- name: Cache ZLib
id: cache-zlib
uses: actions/cache@v4
with:
path: ${{github.workspace}}/ExternalLibraries/zlib
key: ${{runner.os}}-ZLibCache
- name: Build ZLib
if: steps.cache-zlib.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/ExternalLibraries
shell: pwsh
# Run the script to build zlib.
run: .\CompileZLib.ps1
- name: Cache Protobuf
id: cache-protobuf
uses: actions/cache@v4
with:
path: ${{github.workspace}}/ExternalLibraries/protobuf
key: ${{runner.os}}-ProtobufCache
- name: Build Protobuf
if: steps.cache-protobuf.outputs.cache-hit != 'true'
working-directory: ${{github.workspace}}/ExternalLibraries
shell: pwsh
# Run the script to build protobuf.
run: .\CompileProtobuf.ps1
- name: Cache CUDA
id: cache-cuda
uses: actions/cache@v4
with:
path: ${{env.PATH_TO_CUDA}}
key: ${{runner.os}}-CUDACache
- name: Install CUDA
if: steps.cache-cuda.outputs.cache-hit != 'true'
uses: Jimver/cuda-toolkit@v0.2.17
id: install-cuda
with:
cuda: '11.8.0'
sub-packages: '["cudart", "curand_dev", "nvcc", "thrust", "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: Download Release Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
path: ${{github.workspace}}/x64/Release/
- 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=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
run: |
$InstallerFile = Resolve-Path "${{github.workspace}}\Installers\Installers\MUSEN*.exe"
Start-Process -FilePath $InstallerFile -ArgumentList "/SP- /SILENT /SUPPRESSMSGBOXES /CURRENTUSER" -Wait
- name: Upload Installer Artifact
uses: actions/upload-artifact@v4
with:
name: installer-artifact
if-no-files-found: error
retention-days: 7
compression-level: 0
path: ${{github.workspace}}/Installers/Installers/*.exe
- name: Upload Portable Installer Artifact
uses: actions/upload-artifact@v4
with:
name: portable-installer-artifact
if-no-files-found: error
retention-days: 7
compression-level: 9
path: ${{ env.LOCALAPPDATA_DIR }}/Programs/MUSEN
- name: Uninstall MUSEN
shell: pwsh
run: |
$UnInstallerFile = Resolve-Path "${{ env.LOCALAPPDATA_DIR }}/Programs/MUSEN/unins000.exe"
Start-Process -FilePath $UnInstallerFile -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART" -Wait
release:
runs-on: windows-latest
needs: [installer]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Installer Artifact
uses: actions/download-artifact@v4
with:
name: installer-artifact
path: ${{github.workspace}}/Installers/Installers/
- name: Download Portable Installer Artifact
uses: actions/download-artifact@v4
with:
name: portable-installer-artifact
path: C:/Program Files/MUSEN
- name: Get Version
id: get-version
shell: pwsh
run: |
$TAG='${{github.ref_name}}'
$VERSION=$TAG.TrimStart('v')
echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT
- name: Rename Installer
working-directory: ${{github.workspace}}/Installers/Installers/
shell: pwsh
run: |
Get-ChildItem -Path "." | Rename-Item -NewName "MUSEN.${{steps.get-version.outputs.VERSION}}.open.setup.exe"
Move-Item -Path "MUSEN.${{steps.get-version.outputs.VERSION}}.open.setup.exe" -Destination "${{github.workspace}}/MUSEN.${{steps.get-version.outputs.VERSION}}.open.setup.exe"
- name: Zip Portable Installer
shell: pwsh
run: |
Compress-Archive -Path 'C:/Program Files/MUSEN' -DestinationPath ${{github.workspace}}/MUSEN.${{steps.get-version.outputs.VERSION}}.open.portable.zip
- name: Release
uses: softprops/action-gh-release@v2
with:
name: 'MUSEN ${{github.ref_name}}'
draft: 'true'
body_path: CHANGELOG
files: |
MUSEN.${{steps.get-version.outputs.VERSION}}.open.setup.exe
MUSEN.${{steps.get-version.outputs.VERSION}}.open.portable.zip