Skip to content

Commit fd35cf2

Browse files
committed
fix: update vcpkg cache keys for release triplets
1 parent 10960a0 commit fd35cf2

File tree

4 files changed

+49
-32
lines changed

4 files changed

+49
-32
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ name: Release Build
22

33
on:
44
push:
5-
branches: [ "master", "main" ]
65
tags: [ "v*" ]
7-
pull_request:
8-
branches: [ "master", "main" ]
96
workflow_dispatch:
107

118
env:
@@ -34,9 +31,9 @@ jobs:
3431
uses: actions/cache@v4
3532
with:
3633
path: vcpkg_installed
37-
key: ${{ runner.os }}-vcpkg-static-${{ hashFiles('vcpkg.json') }}
34+
key: ${{ runner.os }}-vcpkg-static-release-${{ hashFiles('vcpkg.json') }}
3835
restore-keys: |
39-
${{ runner.os }}-vcpkg-
36+
${{ runner.os }}-vcpkg-static-release-
4037
4138
- name: Setup vcpkg
4239
uses: lukka/run-vcpkg@v11
@@ -47,7 +44,8 @@ jobs:
4744
runVcpkgInstall: true
4845
env:
4946
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
50-
VCPKG_DEFAULT_TRIPLET: x64-windows-static
47+
VCPKG_DEFAULT_TRIPLET: x64-windows-static-release
48+
VCPKG_OVERLAY_TRIPLETS: ${{ github.workspace }}/triplets
5149

5250
- name: Cargo Chef Prepare
5351
run: cargo chef prepare --recipe-path recipe.json
@@ -65,8 +63,8 @@ jobs:
6563
env:
6664
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
6765
VCPKG_INSTALLED_DIR: ${{ github.workspace }}\vcpkg_installed
68-
VCPKGRS_TRIPLET: x64-windows-static
69-
PKG_CONFIG_PATH: ${{ github.workspace }}\vcpkg_installed\x64-windows-static\lib\pkgconfig
66+
VCPKGRS_TRIPLET: x64-windows-static-release
67+
PKG_CONFIG_PATH: ${{ github.workspace }}\vcpkg_installed\x64-windows-static-release\lib\pkgconfig
7068

7169
- name: Restore Source Code
7270
run: git restore server enginefs libtorrent-sys
@@ -78,8 +76,8 @@ jobs:
7876
env:
7977
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
8078
VCPKG_INSTALLED_DIR: ${{ github.workspace }}\vcpkg_installed
81-
VCPKGRS_TRIPLET: x64-windows-static
82-
PKG_CONFIG_PATH: ${{ github.workspace }}\vcpkg_installed\x64-windows-static\lib\pkgconfig
79+
VCPKGRS_TRIPLET: x64-windows-static-release
80+
PKG_CONFIG_PATH: ${{ github.workspace }}\vcpkg_installed\x64-windows-static-release\lib\pkgconfig
8381

8482
- name: Upload EXE
8583
uses: actions/upload-artifact@v4
@@ -92,16 +90,16 @@ jobs:
9290
env:
9391
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
9492
VCPKG_INSTALLED_DIR: ${{ github.workspace }}\vcpkg_installed
95-
VCPKGRS_TRIPLET: x64-windows-static
96-
PKG_CONFIG_PATH: ${{ github.workspace }}\vcpkg_installed\x64-windows-static\lib\pkgconfig
93+
VCPKGRS_TRIPLET: x64-windows-static-release
94+
PKG_CONFIG_PATH: ${{ github.workspace }}\vcpkg_installed\x64-windows-static-release\lib\pkgconfig
9795

9896
- name: Build MSI Installer
9997
run: cargo wix --package server --no-build --nocapture --target x86_64-pc-windows-msvc
10098
env:
10199
VCPKG_ROOT: ${{ github.workspace }}\vcpkg
102100
VCPKG_INSTALLED_DIR: ${{ github.workspace }}\vcpkg_installed
103-
VCPKGRS_TRIPLET: x64-windows-static
104-
PKG_CONFIG_PATH: ${{ github.workspace }}\vcpkg_installed\x64-windows-static\lib\pkgconfig
101+
VCPKGRS_TRIPLET: x64-windows-static-release
102+
PKG_CONFIG_PATH: ${{ github.workspace }}\vcpkg_installed\x64-windows-static-release\lib\pkgconfig
105103

106104

107105
- name: Upload MSI
@@ -140,9 +138,9 @@ jobs:
140138
uses: actions/cache@v4
141139
with:
142140
path: vcpkg_installed
143-
key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }}
141+
key: ${{ runner.os }}-vcpkg-release-${{ hashFiles('vcpkg.json') }}
144142
restore-keys: |
145-
${{ runner.os }}-vcpkg-
143+
${{ runner.os }}-vcpkg-release-
146144
147145
- name: Setup vcpkg
148146
uses: lukka/run-vcpkg@v11
@@ -153,6 +151,8 @@ jobs:
153151
runVcpkgInstall: true
154152
env:
155153
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
154+
VCPKG_DEFAULT_TRIPLET: x64-linux-release
155+
VCPKG_OVERLAY_TRIPLETS: ${{ github.workspace }}/triplets
156156

157157
- name: Cargo Chef Prepare
158158
run: cargo chef prepare --recipe-path recipe.json
@@ -165,12 +165,12 @@ jobs:
165165

166166
- name: Cargo Chef Cook
167167
run: |
168-
export VCPKG_ROOT=${{ github.workspace }}/vcpkg
169-
cargo chef cook --release --recipe-path recipe.json --features libtorrent --no-default-features
168+
export VCPKG_ROOT=${{ github.workspace }}/vcpkg
169+
cargo chef cook --release --recipe-path recipe.json --features libtorrent --no-default-features
170170
env:
171-
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
172-
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
173-
PKG_CONFIG_PATH: ${{ github.workspace }}/vcpkg_installed/x64-linux/lib/pkgconfig
171+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
172+
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
173+
PKG_CONFIG_PATH: ${{ github.workspace }}/vcpkg_installed/x64-linux-release/lib/pkgconfig
174174

175175
- name: Restore Source Code
176176
run: git restore server enginefs libtorrent-sys
@@ -180,7 +180,7 @@ jobs:
180180
env:
181181
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
182182
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed
183-
PKG_CONFIG_PATH: ${{ github.workspace }}/vcpkg_installed/x64-linux/lib/pkgconfig
183+
PKG_CONFIG_PATH: ${{ github.workspace }}/vcpkg_installed/x64-linux-release/lib/pkgconfig
184184

185185
- name: Build DEB Package
186186
run: cargo deb --package server --no-build

libtorrent-sys/build.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {
2-
let include_paths = find_libtorrent();
2+
let (include_paths, using_vcpkg) = find_libtorrent();
33

44
// Build the cxx bridge
55
let mut build = cxx_build::bridge("src/lib.rs");
@@ -16,9 +16,11 @@ fn main() {
1616
.flag_if_supported("-Wno-unused-parameter")
1717
.flag_if_supported("-Wno-missing-field-initializers");
1818

19-
// Set TORRENT_ABI_VERSION for ALL platforms to match vcpkg-built libtorrent
20-
// This is critical - without it, C++ name mangling differs and linking fails
21-
build.define("TORRENT_ABI_VERSION", "3");
19+
// Only set TORRENT_ABI_VERSION when using vcpkg-built libtorrent
20+
// System packages (e.g., Arch Linux) use their own ABI version and don't need this
21+
if using_vcpkg {
22+
build.define("TORRENT_ABI_VERSION", "3");
23+
}
2224
build.define("TORRENT_USE_OPENSSL", None);
2325

2426
if cfg!(target_os = "windows") {
@@ -40,15 +42,17 @@ fn main() {
4042
println!("cargo:rerun-if-changed=cpp/wrapper.h");
4143
}
4244

43-
fn find_libtorrent() -> Vec<std::path::PathBuf> {
45+
/// Returns (include_paths, using_vcpkg)
46+
/// using_vcpkg is true when vcpkg was used to find the library
47+
fn find_libtorrent() -> (Vec<std::path::PathBuf>, bool) {
4448
let mut errors = String::new();
4549

46-
// Try pkg-config first
50+
// Try pkg-config first (system packages like on Arch Linux)
4751
match pkg_config::Config::new()
4852
.atleast_version("2.0")
4953
.probe("libtorrent-rasterbar")
5054
{
51-
Ok(lib) => return lib.include_paths,
55+
Ok(lib) => return (lib.include_paths, false), // NOT vcpkg
5256
Err(e) => {
5357
errors.push_str(&format!("pkg-config: {}\n", e));
5458
}
@@ -58,7 +62,7 @@ fn find_libtorrent() -> Vec<std::path::PathBuf> {
5862
if cfg!(target_os = "windows") {
5963
unsafe {
6064
std::env::set_var("VCPKGRS_DYNAMIC", "0");
61-
std::env::set_var("VCPKGRS_TRIPLET", "x64-windows-static");
65+
std::env::set_var("VCPKGRS_TRIPLET", "x64-windows-static-release");
6266
}
6367
}
6468

@@ -67,7 +71,7 @@ fn find_libtorrent() -> Vec<std::path::PathBuf> {
6771
.emit_includes(true)
6872
.find_package("libtorrent")
6973
{
70-
Ok(lib) => return lib.include_paths,
74+
Ok(lib) => return (lib.include_paths, true), // IS vcpkg
7175
Err(e) => {
7276
errors.push_str(&format!("vcpkg (libtorrent): {}\n", e));
7377
}
@@ -78,7 +82,7 @@ fn find_libtorrent() -> Vec<std::path::PathBuf> {
7882
.emit_includes(true)
7983
.find_package("libtorrent-rasterbar")
8084
{
81-
Ok(lib) => return lib.include_paths,
85+
Ok(lib) => return (lib.include_paths, true), // IS vcpkg
8286
Err(e) => {
8387
errors.push_str(&format!("vcpkg (libtorrent-rasterbar): {}\n", e));
8488
}

triplets/x64-linux-release.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(VCPKG_TARGET_ARCHITECTURE x64)
2+
set(VCPKG_CRT_LINKAGE dynamic)
3+
set(VCPKG_LIBRARY_LINKAGE static)
4+
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
5+
6+
# Release only - skip debug builds to save time
7+
set(VCPKG_BUILD_TYPE release)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
set(VCPKG_TARGET_ARCHITECTURE x64)
2+
set(VCPKG_CRT_LINKAGE static)
3+
set(VCPKG_LIBRARY_LINKAGE static)
4+
5+
# Release only - skip debug builds to save time
6+
set(VCPKG_BUILD_TYPE release)

0 commit comments

Comments
 (0)