Skip to content

Commit c6eb52c

Browse files
committed
try new windows build
1 parent 51cfc52 commit c6eb52c

File tree

3 files changed

+123
-27
lines changed

3 files changed

+123
-27
lines changed

.github/workflows/build-and-release-windows.yml

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,80 @@ on:
66
- main
77

88
jobs:
9+
env:
10+
# Indicates the location of the vcpkg as a Git submodule of the project repository.
11+
# Not using "VCPKG_ROOT" because a variable with the same name is defined in the VS's
12+
# Developer Command Prompt environment in VS 2022 17.6, which would override this one
13+
# if it had the same name.
14+
_VCPKG_: ${{ github.workspace }}/vcpkg
15+
# Tells vcpkg where binary packages are stored.
16+
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache
17+
# Let's use GitHub Action cache as storage for the vcpkg Binary Caching feature.
18+
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
919
build:
1020
name: Build and Upload Artifacts
1121
runs-on: windows-latest
12-
steps:
13-
# Get dependencies
14-
- name: Checkout code
15-
uses: actions/checkout@v3
22+
env:
23+
# Indicates the location of the vcpkg as a Git submodule of the project repository.
24+
# Not using "VCPKG_ROOT" because a variable with the same name is defined in the VS's
25+
# Developer Command Prompt environment in VS 2022 17.6, which would override this one
26+
# if it had the same name.
27+
_VCPKG_: ${{ github.workspace }}/vcpkg
28+
# Tells vcpkg where binary packages are stored.
29+
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache
30+
# Let's use GitHub Action cache as storage for the vcpkg Binary Caching feature.
31+
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
1632

17-
- name: Install dependencies via vcpkg
18-
run: vcpkg.exe install --triplet x64-windows
33+
steps:
34+
# Set env vars needed for vcpkg to leverage the GitHub Action cache as a storage
35+
# for Binary Caching.
36+
- uses: actions/github-script@v7
37+
with:
38+
script: |
39+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
40+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
1941
20-
- name: Cache vcpkg
21-
uses: actions/cache@v3
42+
- uses: actions/checkout@v4
2243
with:
23-
path: |
24-
vcpkg
25-
vcpkg_installed
26-
key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}
44+
submodules: true
45+
- name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'"
46+
run: mkdir -p $VCPKG_DEFAULT_BINARY_CACHE
47+
shell: bash
2748

28-
- name: Get Ninja
29-
uses: seanmiddleditch/gha-setup-ninja@master
49+
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
50+
- uses: lukka/get-cmake@latest
3051

31-
- name: Set up CMake
32-
uses: jwlawson/actions-setup-cmake@v1
52+
# Restore vcpkg from the GitHub Action cache service. Note that packages are restored by vcpkg's binary caching
53+
# when it is being run afterwards by CMake.
54+
- name: Restore vcpkg
55+
uses: actions/cache@v4
3356
with:
34-
cmake-version: '3.16'
57+
# The first path is the location of vcpkg: it contains the vcpkg executable and data files, as long as the
58+
# built package archives (aka binary cache) which are located by VCPKG_DEFAULT_BINARY_CACHE env var.
59+
# The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages.
60+
path: |
61+
${{ env._VCPKG_ }}
62+
!${{ env._VCPKG_ }}/buildtrees
63+
!${{ env._VCPKG_ }}/packages
64+
!${{ env._VCPKG_ }}/downloads
65+
!${{ env._VCPKG_ }}/installed
66+
# The key is composed in a way that it gets properly invalidated whenever a different version of vcpkg is being used.
67+
key: |
68+
${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}
3569
36-
- name: Set up MSVC environment
37-
shell: cmd
38-
run: |
39-
call "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath > vs_install_dir.txt
40-
set /p InstallDir=<vs_install_dir.txt
41-
call "%InstallDir%\VC\Auxiliary\Build\vcvarsall.bat" x64
70+
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly.
71+
# As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
72+
- uses: ilammy/msvc-dev-cmd@v1
4273

4374
# Configure CMake (Windows)
4475
- name: Configure CMake (Windows)
4576
shell: cmd
4677
run: |
47-
cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release
78+
cmake --preset ninja-multi-vcpkg -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release
4879
4980
# 4. Build the project
5081
- name: Build PlatypusGui
51-
run: cmake --build build --config Release --target PlatypusGui
82+
run: cmake --preset ninja-vcpkg-release --build build --config Release --target PlatypusGui
5283

5384
- name: Deploy Qt Dependencies (Windows)
5485
shell: cmd

CMakePresets.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"version": 8,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 21,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "ninja-multi-vcpkg",
11+
"displayName": "Ninja Multi-Config",
12+
"description": "Configure with vcpkg toolchain and generate Ninja project files for all configurations",
13+
"binaryDir": "${sourceDir}/builds/${presetName}",
14+
"generator": "Ninja Multi-Config",
15+
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
16+
}
17+
],
18+
"buildPresets": [
19+
{
20+
"name": "ninja-vcpkg-debug",
21+
"configurePreset": "ninja-multi-vcpkg",
22+
"displayName": "Build (Debug)",
23+
"description": "Build with Ninja/vcpkg (Debug)",
24+
"configuration": "Debug"
25+
},
26+
{
27+
"name": "ninja-vcpkg-release",
28+
"configurePreset": "ninja-multi-vcpkg",
29+
"displayName": "Build (Release)",
30+
"description": "Build with Ninja/vcpkg (Release)",
31+
"configuration": "Release"
32+
},
33+
{
34+
"name": "ninja-vcpkg",
35+
"configurePreset": "ninja-multi-vcpkg",
36+
"displayName": "Build",
37+
"description": "Build with Ninja/vcpkg"
38+
}
39+
],
40+
"testPresets": [
41+
{
42+
"name": "test-ninja-vcpkg",
43+
"configurePreset": "ninja-multi-vcpkg",
44+
"hidden": true
45+
},
46+
{
47+
"name": "test-debug",
48+
"description": "Test (Debug)",
49+
"displayName": "Test (Debug)",
50+
"configuration": "Debug",
51+
"inherits": [
52+
"test-ninja-vcpkg"
53+
]
54+
},
55+
{
56+
"name": "test-release",
57+
"description": "Test (Release)",
58+
"displayName": "Test (Release)",
59+
"configuration": "Release",
60+
"inherits": [
61+
"test-ninja-vcpkg"
62+
]
63+
}
64+
]
65+
}

vcpkg.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "platypus",
33
"version": "0.0.1",
44
"dependencies": [
5-
"opencv4[core,default-features,fs,gapi,highgui,intrinsics,jpeg,png,quirc,thread,tiff]",
6-
"qt5[activeqt,core,declarative,essentials,imageformats,multimedia,svg,tools,translations]:x64-windows"
5+
"opencv4",
6+
"qt5:x64-windows"
77
]
88
}

0 commit comments

Comments
 (0)