Skip to content

Commit ff0069c

Browse files
committed
Update CI
1 parent d96285b commit ff0069c

File tree

6 files changed

+97
-27
lines changed

6 files changed

+97
-27
lines changed

.github/actions/initialize-build-environment/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ runs:
1818
if: runner.os == 'Windows'
1919
shell: pwsh
2020
run: |
21-
choco install innosetup
21+
choco install ccache
2222
2323
- name: Install build tools (Ubuntu)
2424
if: runner.os == 'Linux'

.github/actions/initialize-vcpkg/action.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,41 @@ runs:
1414
- name: Prepare vcpkg
1515
shell: pwsh
1616
run: |
17-
Write-Output VCPKG_DEFAULT_BINARY_CACHE=${{ github.workspace }}/vcpkg_archives >> $env:GITHUB_ENV
17+
New-Item -ItemType Directory -Path ${{ github.workspace }}/../vcpkg_archives -Force
18+
Write-Output VCPKG_DEFAULT_BINARY_CACHE=$(Resolve-Path ${{ github.workspace }}/../vcpkg_archives) >> $env:GITHUB_ENV
1819
1920
- name: Restore vcpkg binary cache
2021
id: cache_vcpkg
2122
uses: actions/cache/restore@v4
2223
with:
2324
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
24-
key: ${{ runner.os }}-vcpkg-${{ inputs.ref }}
25+
key: ${{ runner.os }}-vcpkg-${{ inputs.ref }}-${{ github.sha }}
2526
restore-keys: |
26-
${{ runner.os }}-vcpkg-${{ inputs.ref }}
27+
${{ runner.os }}-vcpkg-${{ inputs.ref }}-
2728
2829
- name: Install vcpkg dependencies
2930
env:
3031
QT_DIR: ${{ env.Qt_ROOT_DIR }}/lib/cmake/Qt6
3132
Qt6_DIR: ${{ env.Qt_ROOT_DIR }}/lib/cmake/Qt6
3233
VCPKG_CMAKE_RELEASE_BUILD_TYPE: "RelWithDebInfo"
33-
VCPKG_KEEP_ENV_VARS: "QT_DIR;Qt6_DIR;VCPKG_CMAKE_RELEASE_BUILD_TYPE"
34+
VCPKG_KEEP_ENV_VARS: "QT_DIR;Qt6_DIR;VCPKG_CMAKE_RELEASE_BUILD_TYPE;VCPKG_BUILD_TYPE"
3435
shell: pwsh
3536
run: |
3637
if (!(Test-Path $env:VCPKG_DEFAULT_BINARY_CACHE)) {
3738
New-Item $env:VCPKG_DEFAULT_BINARY_CACHE -ItemType directory
3839
}
40+
Set-Location ${{ github.workspace }}/..
3941
git clone https://github.com/microsoft/vcpkg.git
4042
Set-Location vcpkg
43+
Write-Output VCPKG_ROOT_DIR=$(Resolve-Path .) >> $env:GITHUB_ENV
4144
git checkout ${{ inputs.ref }}
4245
${{ runner.os == 'Windows' && './bootstrap-vcpkg.bat' || 'sh ./bootstrap-vcpkg.sh' }}
4346
./vcpkg install `
4447
--x-manifest-root=${{ github.workspace }}/scripts/vcpkg-manifest `
4548
--x-install-root=./installed
46-
Write-Output VCPKG_ROOT_DIR=$(Resolve-Path .) >> $env:GITHUB_ENV
4749
4850
- name: Save vcpkg binary cache
4951
uses: actions/cache/save@v4
5052
with:
5153
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
52-
key: ${{ runner.os }}-vcpkg-${{ inputs.ref }}
54+
key: ${{ runner.os }}-vcpkg-${{ inputs.ref }}-${{ github.sha }}

.github/workflows/dev-build.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ on:
2222
description: 'Version identifier'
2323
required: false
2424
type: string
25+
use_ccache:
26+
description: 'Use CCache'
27+
required: false
28+
type: boolean
29+
default: true
2530

2631
defaults:
2732
run:
@@ -41,7 +46,10 @@ jobs:
4146
QT_VERSION: 6.9.2
4247
VCPKG_REF: 74e6536215718009aae747d86d84b78376bf9e09
4348
INNOSETUP_REF: is-6_5_4
44-
VERSION_IDENTIFIER: ${{ github.sha }}${{ github.event.input.identifier && '.' || '' }}${{ github.event.input.identifier }}
49+
VERSION_IDENTIFIER: ${{ github.sha }}${{ github.event.inputs.identifier && '.' || '' }}${{ github.event.inputs.identifier }}
50+
BUILD_DIR: ${{ github.workspace }}/build/build
51+
INSTALL_DIR: ${{ github.workspace }}/build/install
52+
CCACHE_DIR: ${{ github.workspace }}/build/ccache
4553

4654
runs-on: ${{ matrix.os }}
4755

@@ -61,17 +69,37 @@ jobs:
6169
with:
6270
ref: ${{ env.VCPKG_REF }}
6371

72+
- name: Restore CCache cache
73+
uses: actions/cache/restore@v4
74+
if: ${{ github.event.inputs.use_ccache == 'true' }}
75+
with:
76+
path: ${{ env.CCACHE_DIR }}
77+
key: ${{ runner.os }}-ccache-${{ github.sha }}
78+
restore-keys: |
79+
${{ runner.os }}-ccache-
80+
6481
- name: Build
6582
run: |
66-
$output = & ./scripts/ci/Build.ps1 -BuildType dev -VcpkgRootDir $env:VCPKG_ROOT_DIR -VersionIdentifier $env:VERSION_IDENTIFIER
83+
$output = & ./scripts/ci/Build.ps1 `
84+
-BuildType dev `
85+
-VcpkgRootDir $env:VCPKG_ROOT_DIR `
86+
-BuildDir $env:BUILD_DIR `
87+
-InstallDir $env:INSTALL_DIR `
88+
-VersionIdentifier $env:VERSION_IDENTIFIER `
89+
${{ github.event.inputs.use_ccache == 'true' && '-CCache' || '' }}
6790
Write-Output ARTIFACT_NAME=$($output.ApplicationName)_$($output.Semver -replace '[\.\-\+]', '_') >> $env:GITHUB_ENV
68-
Write-Output BUILD_DIR=$($output.BuildDir) >> $env:GITHUB_ENV
69-
Write-Output INSTALLED_DIR=$($output.InstalledDir) >> $env:GITHUB_ENV
7091
Write-Output INSTALLER_FILE_BASE=$($output.InstallerFileBase) >> $env:GITHUB_ENV
7192
93+
- name: Save CCache cache
94+
uses: actions/cache/save@v4
95+
if: ${{ github.event.inputs.use_ccache == 'true' }}
96+
with:
97+
path: ${{ env.CCACHE_DIR }}
98+
key: ${{ runner.os }}-ccache-${{ github.sha }}
99+
72100
- name: Collect symbol files
73101
run: |
74-
$output = & ./scripts/ci/Collect-Symbol-Files.ps1 -VcpkgRootDir $env:VCPKG_ROOT_DIR -InstalledDir $env:INSTALLED_DIR
102+
$output = & ./scripts/ci/Collect-Symbol-Files.ps1 -VcpkgRootDir $env:VCPKG_ROOT_DIR -InstallDir $env:INSTALL_DIR
75103
Write-Output SYMBOL_FILES_PATH=$($output.Path) >> $env:GITHUB_ENV
76104
77105
- name: Pack

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cmake_minimum_required(VERSION 3.19)
2+
cmake_policy(SET CMP0141 NEW)
23

34
project(DiffScope VERSION 0.2.0 LANGUAGES CXX)
45

@@ -31,6 +32,10 @@ endif()
3132
if(APPLICATION_INSTALL)
3233
include(GNUInstallDirs)
3334
include(CMakePackageConfigHelpers)
35+
if(MSVC)
36+
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "")
37+
include(InstallRequiredSystemLibraries)
38+
endif()
3439
endif()
3540

3641
# ----------------------------------

scripts/ci/Build.ps1

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,32 @@ param(
77
[ValidateNotNullOrEmpty()]
88
[string]$VcpkgRootDir,
99

10-
[string]$VersionIdentifier = "0"
10+
[Parameter(Mandatory = $true)]
11+
[ValidateNotNullOrEmpty()]
12+
[string]$BuildDir,
13+
14+
[Parameter(Mandatory = $true)]
15+
[ValidateNotNullOrEmpty()]
16+
[string]$InstallDir,
17+
18+
[string]$VersionIdentifier = "0",
19+
20+
[switch]$CCache = $false
1121
)
1222

1323
if (-not (Test-Path $VcpkgRootDir)) {
1424
throw "Vcpkg root directory does not exist: $VcpkgRootDir"
1525
}
1626

27+
New-Item $BuildDir -ItemType Directory -Force
28+
New-Item $InstallDir -ItemType Directory -Force
29+
1730
Write-Host "Build type: $BuildType"
18-
Write-Host "Commit: $Commit"
1931
Write-Host "Vcpkg root directory: $VcpkgRootDir"
32+
Write-Host "Build directory: $(Resolve-Path $BuildDir)"
33+
Write-Host "Install directory: $(Resolve-Path $InstallDir)"
34+
Write-Host "Version identifier: $VersionIdentifier"
35+
Write-Host "Use CCache: $CCache"
2036

2137
$cmakeListsPath = "CMakeLists.txt"
2238

@@ -62,9 +78,12 @@ Write-Host "Semver: $semver"
6278

6379
$installerFileBase = "${applicationName}_$($semver -replace '[\.\-\+]', '_')_installer"
6480

65-
cmake -B build -G Ninja `
81+
cmake -S . -B $(Resolve-Path $BuildDir) -G Ninja `
6682
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
6783
"-DCMAKE_TOOLCHAIN_FILE=$(Join-Path $VcpkgRootDir scripts/buildsystems/vcpkg.cmake)" `
84+
"-DCMAKE_C_COMPILER_LAUNCHER=$($CCache ? 'ccache' : '')" `
85+
"-DCMAKE_CXX_COMPILER_LAUNCHER=$($CCache ? 'ccache' : '')" `
86+
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded `
6887
-DCK_ENABLE_CONSOLE:BOOL=FALSE `
6988
-DAPPLICATION_INSTALL:BOOL=ON `
7089
-DAPPLICATION_CONFIGURE_INSTALLER:BOOL=ON `
@@ -74,19 +93,35 @@ cmake -B build -G Ninja `
7493
"-DAPPLICATION_NAME=$applicationName" `
7594
"-DAPPLICATION_DISPLAY_NAME=$applicationDisplayName" `
7695
"-DAPPLICATION_SEMVER=$semver" `
77-
-DCMAKE_INSTALL_PREFIX=installed | Write-Host
96+
"-DCMAKE_INSTALL_PREFIX=$(Resolve-Path $InstallDir)" | Write-Host
97+
if ($LASTEXITCODE -ne 0) {
98+
throw "Configure failed"
99+
}
100+
101+
if ($CCache) {
102+
ccache --zero-stats | Write-Host
103+
}
104+
105+
cmake --build $(Resolve-Path $BuildDir) --target all | Write-Host
106+
if ($LASTEXITCODE -ne 0) {
107+
throw "Build failed"
108+
}
109+
110+
if ($CCache) {
111+
ccache --show-stats | Write-Host
112+
}
78113

79-
cmake --build build --target all | Write-Host
80-
cmake --build build --target install | Write-Host
114+
cmake --build $(Resolve-Path $BuildDir) --target install | Write-Host
115+
if ($LASTEXITCODE -ne 0) {
116+
throw "Install failed"
117+
}
81118

82119
$buildResult = @{
83120
ProjectName = $projectName
84121
Version = $version
85122
ApplicationName = $applicationName
86123
ApplicationDisplayName = $applicationDisplayName
87124
Semver = $semver
88-
BuildDir = $(Resolve-Path "build")
89-
InstalledDir = $(Resolve-Path "installed")
90125
InstallerFileBase = $installerFileBase
91126
}
92127

scripts/ci/Collect-Symbol-Files.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ param(
55

66
[Parameter(Mandatory = $true)]
77
[ValidateNotNullOrEmpty()]
8-
[string]$InstalledDir
8+
[string]$InstallDir
99
)
1010

1111
$symbolFilesDirectory = [System.IO.Path]::GetTempPath() + "DiffScope-Symbols"
@@ -15,14 +15,14 @@ if ($IsWindows) {
1515
$PATTERN = "PDB file found at.*'(.*)'"
1616
$env:_NT_ALT_SYMBOL_PATH = $(Join-Path $VcpkgRootDir "/installed/x64-windows/bin")
1717

18-
Push-Location $InstalledDir
18+
Push-Location $InstallDir
1919
$dllFiles = Get-ChildItem -Path . -Recurse | Where-Object { $_.Extension -eq '.exe' -or $_.Extension -eq '.dll' }
2020
foreach ($dllFile in $dllFiles) {
2121
dumpbin /PDBPATH:VERBOSE $dllFile.FullName | Write-Host
2222
$dumpbinOutput = dumpbin /PDBPATH $dllFile.FullName
23-
$matches = [regex]::Matches($dumpbinOutput, $PATTERN)
24-
if ($matches.Count -gt 0) {
25-
$pdbPath = $matches.Groups[1].Value
23+
$m = [regex]::Matches($dumpbinOutput, $PATTERN)
24+
if ($m.Count -gt 0) {
25+
$pdbPath = $m.Groups[1].Value
2626
Write-Host "$dllFile -> $pdbPath"
2727
$pdbTargetDirectory = "$symbolFilesDirectory/$(Split-Path $(Resolve-Path $dllFile.FullName -Relative))"
2828
if (!(Test-Path $pdbTargetDirectory)) {
@@ -35,7 +35,7 @@ if ($IsWindows) {
3535
}
3636
Pop-Location
3737
} elseif ($IsMacOS) {
38-
Push-Location $InstalledDir
38+
Push-Location $InstallDir
3939
$dllFiles = Get-ChildItem -Path . -Recurse | Where-Object { (file $_) -match "Mach-O 64-bit" }
4040
foreach ($dllFile in $dllFiles) {
4141
$dsymutilOutput = dsymutil -s $dllFile.FullName
@@ -53,7 +53,7 @@ if ($IsWindows) {
5353
}
5454
Pop-Location
5555
} else {
56-
Push-Location $InstalledDir
56+
Push-Location $InstallDir
5757
$dllFiles = Get-ChildItem -Path . -Recurse | Where-Object { (file $_) -match "ELF 64-bit" }
5858
foreach ($dllFile in $dllFiles) {
5959
file $dllFile.FullName

0 commit comments

Comments
 (0)