Skip to content

Commit 3e0a64a

Browse files
committed
build: Add macOS stub compilation support
This is the start of work on #21 Gate Linux-only modules and dependencies with #[cfg(target_os = "linux")] so the crate compiles on macOS. For now only the `ephemeral` verb exists as a stub that errors out, but the idea is we can fill that in. Also replace std::process::exit(0) with Ok(()) for proper cleanup. Assisted-by: OpenCode (Claude claude-opus-4-5@20251101) Assisted-by: OpenCode (Claude claude-opus-4-6) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 24de649 commit 3e0a64a

File tree

10 files changed

+177
-34
lines changed

10 files changed

+177
-34
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ env:
1414

1515

1616
jobs:
17+
build-macos:
18+
runs-on: macos-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Setup Rust
23+
uses: dtolnay/rust-toolchain@stable
24+
25+
- name: Check build
26+
run: cargo check --all-targets
27+
28+
- name: Run unit tests
29+
run: cargo test --lib
30+
1731
build:
1832
runs-on: ubuntu-24.04
1933

@@ -181,10 +195,11 @@ jobs:
181195
# Sentinel job for required checks - configure this job name in repository settings
182196
required-checks:
183197
if: always()
184-
needs: [build, integration-tests]
198+
needs: [build-macos, build, integration-tests]
185199
runs-on: ubuntu-latest
186200
steps:
187201
- run: exit 1
188202
if: >-
203+
needs.build-macos.result != 'success' ||
189204
needs.build.result != 'success' ||
190205
needs.integration-tests.result != 'success'

Cargo.lock

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

crates/kit/Cargo.toml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ edition = "2021"
55
publish = false
66

77
[dependencies]
8-
bcvk-qemu = { path = "../bcvk-qemu" }
98
base64 = "0.22"
10-
# For some recent APIs, TODO switch back to published version
11-
cap-std-ext = { git = "https://github.com/coreos/cap-std-ext", rev = "cfdb25d51ffc697e70aa0d8d3cefe9ec2133bd0a" }
129
chrono = { version = "0.4", features = ["serde"] }
1310
const_format = { workspace = true }
1411
color-eyre = { workspace = true }
@@ -17,12 +14,9 @@ clap_mangen = { version = "0.2.20", optional = true }
1714
data-encoding = { version = "2.9" }
1815
dirs = "5.0"
1916
fn-error-context = { version = "0.2" }
20-
bootc-mount = { git = "https://github.com/bootc-dev/bootc", rev = "93b22f4dbc2d54f7cca7c1df3ee59fcdec0b2cf1" }
21-
bootc-utils = { git = "https://github.com/bootc-dev/bootc", rev = "93b22f4dbc2d54f7cca7c1df3ee59fcdec0b2cf1" }
2217
indicatif = "0.17"
2318
notify = "6.1"
2419
thiserror = "1.0"
25-
rustix = { "version" = "1", features = ["thread", "net", "fs", "pipe", "system", "process", "mount"] }
2620
serde = { version = "1.0.199", features = ["derive"] }
2721
serde_json = "1.0.116"
2822
serde_yaml = "0.9"
@@ -41,9 +35,6 @@ cfg-if = { workspace = true }
4135
indoc = "2.0.6"
4236
regex = "1.10"
4337
itertools = "0.14.0"
44-
vsock = "0.5"
45-
nix = { version = "0.29", features = ["socket"] }
46-
libc = "0.2"
4738
camino = "1.1.12"
4839
comfy-table = "7.1"
4940
strum = { version = "0.26", features = ["derive"] }
@@ -53,6 +44,18 @@ sha2 = "0.10"
5344
which = "7.0"
5445
cpio = "0.4"
5546

47+
# Linux-only dependencies
48+
[target.'cfg(target_os = "linux")'.dependencies]
49+
bcvk-qemu = { path = "../bcvk-qemu" }
50+
# For some recent APIs, TODO switch back to published version
51+
cap-std-ext = { git = "https://github.com/coreos/cap-std-ext", rev = "cfdb25d51ffc697e70aa0d8d3cefe9ec2133bd0a" }
52+
bootc-mount = { git = "https://github.com/bootc-dev/bootc", rev = "93b22f4dbc2d54f7cca7c1df3ee59fcdec0b2cf1" }
53+
bootc-utils = { git = "https://github.com/bootc-dev/bootc", rev = "93b22f4dbc2d54f7cca7c1df3ee59fcdec0b2cf1" }
54+
rustix = { version = "1", features = ["thread", "net", "fs", "pipe", "system", "process", "mount"] }
55+
vsock = "0.5"
56+
nix = { version = "0.29", features = ["socket"] }
57+
libc = "0.2"
58+
5659
[dev-dependencies]
5760
similar-asserts = "1.5"
5861

crates/kit/src/cpio.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
//! The Linux kernel supports concatenating multiple CPIO archives,
44
//! so we can simply append our files to an existing initramfs.
55
6+
// On non-Linux, this module is unused as it's for initramfs manipulation
7+
#![cfg_attr(not(target_os = "linux"), allow(dead_code))]
8+
69
use std::io::{self, Write};
710

811
use cpio::newc::Builder as NewcBuilder;

crates/kit/src/install_options.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
//! operations, ensuring consistency across to-disk, libvirt-upload-disk,
55
//! and other installation-related commands.
66
7+
// On non-Linux, this module is unused as it's for installation operations
8+
#![cfg_attr(not(target_os = "linux"), allow(dead_code))]
9+
710
use camino::Utf8PathBuf;
811
use clap::Parser;
912

crates/kit/src/instancetypes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
//!
1111
//! Source: https://github.com/kubevirt/common-instancetypes
1212
13+
// On non-Linux, this module is unused as it's for VM instance types
14+
#![cfg_attr(not(target_os = "linux"), allow(dead_code))]
15+
1316
/// Instance type variants with associated vCPU and memory specifications
1417
///
1518
/// Source: https://github.com/kubevirt/common-instancetypes/blob/main/instancetypes/u/1/sizes.yaml

crates/kit/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! bcvk library - exposes internal modules for testing
22
33
pub mod cpio;
4-
pub mod kernel;
54
pub mod qemu_img;
65
pub mod xml_utils;
6+
7+
// Linux-only modules
8+
#[cfg(target_os = "linux")]
9+
pub mod kernel;

0 commit comments

Comments
 (0)