Skip to content

Commit ee1849d

Browse files
authored
qt_minimal: add example and CI (#1425)
* examples: enable qt_minimal for cargo without cmake * github: add a CI runner to check qt_minimal * qt_minimal: match target platforms directly rather than splitting
1 parent 71eee5f commit ee1849d

File tree

5 files changed

+73
-20
lines changed

5 files changed

+73
-20
lines changed

.github/workflows/github-cxx-qt-tests.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,50 @@ jobs:
129129
path: ./target/debug/lcov.info
130130
if-no-files-found: ignore
131131

132+
build-qt-minimal:
133+
name: Ubuntu 24.04 (gcc) Qt 6 Minimal
134+
needs: [clang_format, license_check, rust_format_check, markdown_lint, shellcheck]
135+
runs-on: ubuntu-24.04
136+
steps:
137+
- name: "Checkout repository"
138+
uses: actions/checkout@v6
139+
- name: Setup toolchain
140+
run: |
141+
rustup default 1.85.0
142+
rustup component add rustfmt
143+
144+
- name: "Install clang-format"
145+
# Note ensure that clang-format runner is updated too
146+
run: |
147+
pip install --user --break-system-packages --verbose clang-format==18.1.8
148+
echo "Checking for path: ${{ matrix.clang_format_path }}"
149+
test -x ${{ matrix.clang_format_path }}
150+
151+
- name: "[Ubuntu] Install dependencies"
152+
if: runner.os == 'Linux'
153+
run: >-
154+
sudo apt-get update &&
155+
sudo apt-get install -y
156+
ninja-build
157+
libdouble-conversion3
158+
libgl1-mesa-dev
159+
libssl-dev
160+
libvulkan-dev
161+
libxkbcommon-dev
162+
pkg-config
163+
valgrind
164+
165+
# Just test that we can build with no Qt install available
166+
#
167+
# NOTE: no compiler cache is needed as build is fast
168+
- name: "Build"
169+
run: cargo build --package qml-minimal-no-cmake
170+
- name: Test output files exist
171+
run: |
172+
! command -v qmake
173+
test -x ./target/debug/qml-minimal-no-cmake
174+
ldd ./target/debug/qml-minimal-no-cmake
175+
132176
build-wasm:
133177
name: Ubuntu 24.04 (wasm_32) Qt 6
134178
needs: [clang_format, license_check, rust_format_check, markdown_lint, shellcheck]

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/qt-build-utils/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ sha2 = { version = "0.10.9", optional = true }
2525
tempfile = { version = "3.25.0", optional = true }
2626
tar = { version = "0.4.44", optional = true }
2727
flate2 = { version = "1.1.9", optional = true }
28-
qt-artifacts = { version = "0.1.0", optional = true }
29-
qt-version = { version = "0.1.3", default-features = false, optional = true }
28+
qt-artifacts = { version = "0.1.2", optional = true }
29+
qt-version = { version = "0.1.4", optional = true }
3030
which = { version = "8.0.0", optional = true }
3131

3232
[features]

crates/qt-build-utils/src/installation/qt_minimal/mod.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,26 +306,30 @@ impl QtInstallationQtMinimal {
306306
artifacts: Vec<ParsedQtArtifact>,
307307
versions: &[semver::Version],
308308
) -> Vec<ParsedQtArtifact> {
309-
// Arch could be x86_64
310-
// OS could be linux
309+
// Map from the TARGET to an arch and OS pair for the artifacts for supported Qt platforms
311310
// https://doc.rust-lang.org/cargo/appendix/glossary.html#target
312-
//
313-
// TODO: is there a better way to find the arch and os ?
314-
// and should this be configurable via env var overrides?
311+
// https://doc.rust-lang.org/stable/rustc/platform-support.html
312+
// https://doc.qt.io/qt-6/supported-platforms.html
315313
println!("cargo::rerun-if-env-changed=TARGET");
316-
let target = std::env::var("TARGET").expect("TARGET to be set");
317-
let target_parts: Vec<_> = target.split("-").collect();
318-
let arch = target_parts
319-
.first()
320-
.expect("TARGET to have a <arch><sub> component");
321-
let os = target_parts
322-
.get(2)
323-
.expect("TARGET to have a <sys> component");
314+
let (arch, os) = match std::env::var("TARGET").expect("TARGET to be set").as_str() {
315+
// Linux
316+
"aarch64-unknown-linux-gnu" => ("arm64", "linux"),
317+
"x86_64-unknown-linux-gnu" => ("x86_64", "linux"),
318+
// macOS
319+
"aarch64-apple-darwin" => ("arm64", "macos"),
320+
"x86_64-apple-darwin" => ("x86_64", "macos"),
321+
// Windows
322+
//
323+
// NOTE: only MSVC currently, how do we map MinGW later?
324+
"aarch64-pc-windows-msvc" => ("arm64", "windows"),
325+
"x86_64-pc-windows-msvc" => ("x86_64", "windows"),
326+
_others => panic!("Unknown TARGET to map to Qt artifact"),
327+
};
324328

325329
artifacts
326330
.into_iter()
327331
.filter(|artifact| {
328-
artifact.arch == *arch && artifact.os == *os && versions.contains(&artifact.version)
332+
artifact.arch == arch && artifact.os == os && versions.contains(&artifact.version)
329333
})
330334
.collect()
331335
}

examples/cargo_without_cmake/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ cxx-qt-lib = { workspace = true, features = ["full"] }
2020
[build-dependencies]
2121
# The link_qt_object_files feature is required for statically linking Qt 6.
2222
cxx-qt-build = { workspace = true, features = [ "link_qt_object_files" ] }
23+
24+
# Enable qt_minimal feature in qt-build-utils and specify a qt-version
25+
# this allows for automatically downloading Qt when not found with qmake
26+
qt-build-utils = { workspace = true, features = ["qt_minimal"] }

0 commit comments

Comments
 (0)