Skip to content

Instantly share code, notes, and snippets.

@jakoch
Created July 10, 2021 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakoch/4545d0c4ebb9240d5391cb0f2a2bb5f2 to your computer and use it in GitHub Desktop.
Save jakoch/4545d0c4ebb9240d5391cb0f2a2bb5f2 to your computer and use it in GitHub Desktop.
appveyor build script for an ttauri based application
#-------------------------------------------------------------------
# AppVeyor build configuration
# https://www.appveyor.com/docs/
# https://www.appveyor.com/docs/appveyor-yml/
#-------------------------------------------------------------------
clone_depth: 5
version: '{build}'
#-------------------------------------------------------------------
# Build configuration
#-------------------------------------------------------------------
# defaults
platform: x64
configuration: Release
environment:
# appveyor
APPVEYOR_SAVE_CACHE_ON_ERROR: true
APPVEYOR_CACHE_ENTRY_ZIP_ARGS: -t7z -m0=lzma -mx=5
APPVEYOR_RDP_PASSWORD: somePassword#123
# vcpkg
VCPKG_ROOT: "C:\\Tools\\vcpkg"
# vulkan
VULKAN_VERSION: "1.2.170.0"
VULKAN_SDK: "C:\\VulkanSDK\\%VULKAN_VERSION%"
VULKAN_SDK_URL: "https://sdk.lunarg.com/sdk/download/%VULKAN_VERSION%/windows/VulkanSDK-%VULKAN_VERSION%-Installer.exe?Human=true"
VULKAN_RUNTIME_URL: "https://sdk.lunarg.com/sdk/download/%VULKAN_VERSION%/windows/vulkan-runtime-components.zip?Human=true"
# the build matrix
# Platform | Compiler | Target Triplet | Build Type
matrix:
# Windows | MSVC 2019 | x64-windows-static | ReleaseWithDebugInfo
#
- APPVEYOR_JOB_NAME: Win-MSVC19-x64-Static-RelWithDebInfo
VCPKG_TARGET_TRIPLET: "x64-windows-static"
COMPILER: MSVC19
BUILD_TYPE: RelWithDebInfo
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
# Windows | MSVC 2019 Preview | x64-windows-static | ReleaseWithDebugInfo
#
- APPVEYOR_JOB_NAME: Win-MSVC19-x64-Static-RelWithDebInfo
VCPKG_TARGET_TRIPLET: "x64-windows-static"
COMPILER: MSVC19
BUILD_TYPE: RelWithDebInfo
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 Preview
build:
# MSBuild verbosity level
verbosity: minimal
# scripts that are called at very beginning, before repo cloning
init:
- ps: |
function Invoke-IgnoreStderr {
param($command)
& $command @args
if ($LASTEXITCODE -eq 0) {
$host.SetShouldExit(0)
} else {
throw
}
}
- ps: Get-Date
- ps: cmake --version
- ps: msbuild /version
- ps: vcpkg version
- ps: |
if ($env:COMPILER -eq "CLANG") {
clang++ -v
}
- ps: Write-Host "Number of processors; $env:NUMBER_OF_PROCESSORS"
install:
- ps: |
$vcpkg_json = Get-Content "vcpkg.json" -Raw | ConvertFrom-Json
$env:PROJECT_VERSION = $vcpkg_json."version"
# If appveyor was launched due to a tag push:
# The BUILD_VERSION_NUMBER is the name of the tag, example: "v1.2.3"
# If appveyor was launched due to an commit or pull request:
# The BUILD_VERSION_NUMBER is extracted from `cvpkg.txt`,
# together with the first 7 sha-digits, example: "v1.2.3-89abcde"
#
# The BUILD_VERSION_NUMBER is later also used for naming the release folder, e.g.
# "[APPVEYOR_PROJECT_SLUG]-[BUILD_VERSION_NUMBER]" -> "ttauri-hello-world-v1.2.3-89abcde".
if ($env:APPVEYOR_REPO_TAG -eq "true") {
$env:BUILD_VERSION_NUMBER = "$env:APPVEYOR_REPO_TAG_NAME"
} else {
$env:BUILD_VERSION_NUMBER = "v$env:PROJECT_VERSION-$($env:APPVEYOR_REPO_COMMIT.substring(0,7))"
}
$env:BUILD_VERSION_NUMBER_US = $env:BUILD_VERSION_NUMBER -replace "\.","-"
# CPack will use the name as follows to create a .json file and -file directory
$env:CPACK_NAME = "$env:APPVEYOR_PROJECT_SLUG-$env:PROJECT_VERSION-$env:VCPKG_TARGET_TRIPLET"
# The .zip file we will create that contains the CPack files will use the BUILD_VERSION_NUMBER
$env:PACKAGE_NAME = "$env:APPVEYOR_PROJECT_SLUG-$env:BUILD_VERSION_NUMBER_US-$env:VCPKG_TARGET_TRIPLET"
- ps: Write-Host "build_version_number; $env:BUILD_VERSION_NUMBER"
- ps: Update-AppveyorBuild -Version "$env:BUILD_VERSION_NUMBER"
# Update VCPKG use our custom version to be able to use ttauri
- ps: Push-Location "C:\Tools\vcpkg"
#- ps: Invoke-IgnoreStderr git remote set-url origin https://github.com/ttauri-project/vcpkg.git
#- ps: Invoke-IgnoreStderr git fetch origin
#- ps: Invoke-IgnoreStderr git checkout ttauri-port
- ps: Invoke-IgnoreStderr git pull --quiet
- ps: .\bootstrap-vcpkg.bat -disableMetrics
- ps: vcpkg version
- ps: Pop-Location
- ps: vcpkg integrate install --triplet=$env:VCPKG_TARGET_TRIPLET --feature-flags=manifests
# Download and install the VULKAN_SDK
# You can not install the VulkanSDK using power-shell, due to the install script requiring
# UAC which requires full administration privileges which power-shell does not allow unless
# the script is code-signed.
- ps: |
if (-not (Test-Path -LiteralPath $env:VULKAN_SDK\Bin)) {
Start-FileDownload "$env:VULKAN_SDK_URL" -FileName "Vulkan_SDK_Installer.exe"
}
- cmd: IF EXIST "Vulkan_SDK_Installer.exe" ( .\Vulkan_SDK_Installer.exe /S )
- ps: Get-ChildItem "$env:VULKAN_SDK"
- ps: |
# Install Vulkan Runtime (for vulkan-1.dll)
if (-not (Test-Path -LiteralPath $env:VULKAN_SDK\runtime)) {
Start-FileDownload "$env:VULKAN_RUNTIME_URL" -FileName "vulkan-runtime.zip"
7z e "vulkan-runtime.zip" -o"$env:VULKAN_SDK\runtime\$env:PLATFORM" "*/$env:PLATFORM"
}
- ps: Get-ChildItem "$env:VULKAN_SDK\runtime\$env:PLATFORM"
# Init MSVC environment, see https://www.appveyor.com/docs/lang/cpp/
- cmd: if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019 Preview"
(call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM% )
- cmd: if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019"
(call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM% )
before_build:
# CHECK important folders to see if everything is present
- ps: Write-Host "Current Directory; $(Get-Location)"
- ps: Get-ChildItem
- ps: Get-ChildItem $env:VULKAN_SDK\Bin
build_script:
- ps: New-Item -Path "." -Name "build" -ItemType "Directory" -Force
- ps: Push-Location "build"
- ps: |
#
# generate build files
#
if ("$env:COMPILER" -eq "MSVC19") {
Invoke-IgnoreStderr cmake -G "Visual Studio 16 2019" -A $env:PLATFORM .. `
-DVCPKG_TARGET_TRIPLET="$env:VCPKG_TARGET_TRIPLET" `
-DCMAKE_VERBOSE_MAKEFILE=ON
if ($LASTEXITCODE -eq 0) { $host.SetShouldExit(0) }
} elseif ("$env:COMPILER" -eq "CLANG") {
Invoke-IgnoreStderr cmake -G "Visual Studio 16 2019" -A $env:PLATFORM -T ClangCL .. `
-DVCPKG_TARGET_TRIPLET="$env:VCPKG_TARGET_TRIPLET" `
-DCMAKE_VERBOSE_MAKEFILE=ON `
-DCMAKE_C_COMPILER=C:/PROGRA~1/LLVM/bin/clang.exe `
-DCMAKE_CXX_COMPILER=C:/PROGRA~1/LLVM/bin/clang-cl.exe
if ($LASTEXITCODE -eq 0) { $host.SetShouldExit(0) }
} else {
Write-Host "Unknown compiler requested".
throw
}
- ps: Invoke-IgnoreStderr cmake --build . --config $env:BUILD_TYPE -j $($env:NUMBER_OF_PROCESSORS + 1) "--" `
/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- ps: Invoke-IgnoreStderr cmake --install . --config $env:BUILD_TYPE --prefix ..\install --strip --verbose
# Generate a CPack-external package. Then make a .zip file from the install-components
# and the cpack.json file which where generated by CPack-external.
- ps: Invoke-IgnoreStderr cmake --build . --config $env:BUILD_TYPE --target package
- ps: Push-Location "$env:CPACK_NAME-files"
- ps: Copy-Item "..\$env:CPACK_NAME.json" -Destination "ecpack.json"
- ps: 7z a -r -- "..\$env:PACKAGE_NAME-ecpack.zip" "*"
- ps: Pop-Location
# Go back cloned project directory
- ps: Pop-Location
after_build:
# Check if all build artifacts are present, before packaging.
- ps: Get-ChildItem "build"
- ps: Get-ChildItem "install"
on_failure:
- ps: Push-AppveyorArtifact "$env:APPVEYOR_BUILD_FOLDER\build\CMakeFiles\CMakeOutput.log"
- ps: Push-AppveyorArtifact "$env:APPVEYOR_BUILD_FOLDER\build\CMakeFiles\CMakeError.log"
#-------------------------------------------------------------------
# Build Artifacts
#-------------------------------------------------------------------
artifacts:
- path: build\%PACKAGE_NAME%-ecpack.zip
name: "ECPack file"
#-------------------------------------------------------------------
# Deployment configuration
#-------------------------------------------------------------------
# deploy to Github Releases on tag push (conditional deploy)
#deploy:
# provider: GitHub
# release: 'hello-world $(APPVEYOR_REPO_TAG_NAME)'
# tag: $(APPVEYOR_REPO_TAG_NAME)
# #description: '[**Changelog**](https://github.com/ttauri-project/ttauri_hello_world/blob/main/CHANGELOG.md)'
# artifact: ttauri_hello_world_zip
# draft: false
# prerelease: false
# force_update: true # overwrite files of existing release on GitHub (for re-releasing)
# on:
# branch: main # release from main branch only
# appveyor_repo_tag: true # deploy on tag push only
# auth_token: # encrypted token from GitHub
# secure: *hash*
#-------------------------------------------------------------------
# Cache things until an appveyor.yml file change
#-------------------------------------------------------------------
cache:
- '%APPVEYOR_BUILD_FOLDER%\build\vcpkg_installed -> %APPVEYOR_BUILD_FOLDER%\build\vcpkg_installed\vcpkg\status'
- '%VULKAN_SDK%\Bin -> appveyor.yml'
- '%VULKAN_SDK%\Bin32 -> appveyor.yml'
- '%VULKAN_SDK%\Include -> appveyor.yml'
- '%VULKAN_SDK%\Lib -> appveyor.yml'
- '%VULKAN_SDK%\Lib32 -> appveyor.yml'
- '%VULKAN_SDK%\runtime -> appveyor.yml'
#-------------------------------------------------------------------
# Accessing Windows build worker via Remote Desktop (RDP)
#-------------------------------------------------------------------
# Enable RDP session to Appveyor server by enabling the two on_finish lines.
# You connect using a remote desktop connection (e.g. using mstsc.exe).
# Use PW from APPVEYOR_RDP_PASSWORD above. A session lasts 60min max.
# Do not forget to disable the following lines, when you solved the problem.
#on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment