Skip to content

Commit e6acae7

Browse files
authored
Merge pull request #1 from thdaele/cli-only
enable cli only build gated by cargo features
2 parents 13a47f1 + 45e5621 commit e6acae7

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

.github/workflows/publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ jobs:
5454
toolchain: stable
5555
- uses: Swatinem/rust-cache@v2
5656
- run: rustup target add ${{ matrix.target }}
57+
# Build the CLI only binary
58+
- run: cargo build --no-default-features --release --target ${{ matrix.target }}
59+
- run: mv "target/${{ matrix.target }}/release/ornithe-installer-rs" "target/${{ matrix.target }}/release/ornithe-installer-rs-cli.bin"
60+
if: runner.os != 'Windows'
61+
- run: mv "target/${{ matrix.target }}/release/ornithe-installer-rs.exe" "target/${{ matrix.target }}/release/ornithe-installer-rs-cli.exe"
62+
if: runner.os == 'Windows'
63+
# Regular build with GUI
5764
- run: cargo build --release --target ${{ matrix.target }}
5865
- run: mv "target/${{ matrix.target }}/release/ornithe-installer-rs" "target/${{ matrix.target }}/release/ornithe-installer-rs.bin"
5966
if: runner.os != 'Windows'

Cargo.toml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@ base64 = "0.22.1"
1212
chrono = { version = "0.4.40", features = ["serde"] }
1313
clap = { version = "4.5.35", features = ["cargo", "derive", "string"] }
1414
cli-clipboard = "0.4.0"
15-
eframe = { version = "0.31.1", features = ["wgpu"] }
16-
egui = "0.31.1"
17-
egui-dropdown = "0.13.0"
15+
eframe = { version = "0.31.1", features = ["wgpu"], optional = true }
16+
egui = { version = "0.31.1", optional = true }
17+
egui-dropdown = { version = "0.13.0", optional = true }
1818
env_logger = "0.11.8"
1919
log = "0.4.27"
2020
reqwest = { version = "0.12.15", features = ["json"] }
21-
rfd = "0.15.3"
21+
rfd = { version = "0.15.3", optional = true }
2222
serde = { version = "1.0.219", features = ["derive"] }
2323
serde_json = { version = "1.0.140", features = ["preserve_order"] }
2424
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] }
25-
webbrowser = "1.0.4"
25+
webbrowser = { version = "1.0.4", optional = true }
2626
zip = { version = "2.6.1", features = ["deflate-flate2"] }
2727

28+
[features]
29+
default = ["gui"]
30+
31+
gui = ["dep:eframe", "dep:egui", "dep:egui-dropdown", "dep:rfd", "dep:webbrowser"]
32+
2833
[build-dependencies]
2934
embed-resource = "1.6.0"
3035
winres = "0.1.11"

build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ publishing {
4040
"exe" else "bin"
4141
)
4242
}
43+
artifact (
44+
file(
45+
"$projectDir/target/$target/release/ornithe-installer-rs-cli." + if (os?.contains("windows") == true) // thanks kotlin
46+
"exe" else "bin"
47+
)
48+
) {
49+
classifier = "cli"
50+
}
4351
}
4452
}
4553

src/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::{fmt::Debug, path::StripPrefixError};
33
#[derive(Debug)]
44
pub struct InstallerError(pub String);
55

6+
#[cfg(feature = "gui")]
67
impl From<eframe::Error> for InstallerError {
78
fn from(value: eframe::Error) -> Self {
89
InstallerError(format!("{:?}", value))

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ async fn main() {
1818
info!("Ornithe Installer v{}", VERSION);
1919

2020
// The first argument is the binary name
21+
#[cfg(feature = "gui")]
2122
if std::env::args().count() <= 1 {
2223
if let Ok(_) = crate::ui::gui::run().await {
2324
return;

src/ui/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::path::PathBuf;
22

33
pub mod cli;
4+
5+
#[cfg(feature = "gui")]
46
pub mod gui;
57

68
#[derive(PartialEq, Clone, Copy, Debug)]

0 commit comments

Comments
 (0)