From 2d1af332040a5b0224c4750d5d1d40737d991f1a Mon Sep 17 00:00:00 2001 From: Alain Emilia Anna Zscheile Date: Sat, 16 Nov 2024 16:09:58 +0100 Subject: [PATCH] build: put egui and cli into separate crates * build(ci): try to fix CI * build: use workspace dependencies for deduplication / drift avoidance --- .woodpecker/build_cli.yaml | 6 +- .woodpecker/build_egui.yaml | 6 +- .woodpecker/build_wasm.yaml | 4 +- .woodpecker/test.yaml | 2 +- Cargo.toml | 135 +++++------------- INSTALL.md | 12 +- cli/Cargo.toml | 29 ++++ build.rs => cli/build.rs | 2 +- {src/bin/topola => cli/src}/cli.rs | 0 {src/bin/topola => cli/src}/main.rs | 0 egui/Cargo.toml | 47 ++++++ {src/bin/topola-egui => egui/src}/action.rs | 0 {src/bin/topola-egui => egui/src}/actions.rs | 0 {src/bin/topola-egui => egui/src}/app.rs | 0 {src/bin/topola-egui => egui/src}/config.rs | 0 .../topola-egui => egui/src}/error_dialog.rs | 0 {src/bin/topola-egui => egui/src}/layers.rs | 0 {src/bin/topola-egui => egui/src}/main.rs | 0 {src/bin/topola-egui => egui/src}/menu_bar.rs | 0 {src/bin/topola-egui => egui/src}/overlay.rs | 0 {src/bin/topola-egui => egui/src}/painter.rs | 0 .../topola-egui => egui/src}/status_bar.rs | 0 .../topola-egui => egui/src}/translator.rs | 2 +- {src/bin/topola-egui => egui/src}/viewport.rs | 0 .../bin/topola-egui => egui/src}/workspace.rs | 0 25 files changed, 131 insertions(+), 114 deletions(-) create mode 100644 cli/Cargo.toml rename build.rs => cli/build.rs (91%) rename {src/bin/topola => cli/src}/cli.rs (100%) rename {src/bin/topola => cli/src}/main.rs (100%) create mode 100644 egui/Cargo.toml rename {src/bin/topola-egui => egui/src}/action.rs (100%) rename {src/bin/topola-egui => egui/src}/actions.rs (100%) rename {src/bin/topola-egui => egui/src}/app.rs (100%) rename {src/bin/topola-egui => egui/src}/config.rs (100%) rename {src/bin/topola-egui => egui/src}/error_dialog.rs (100%) rename {src/bin/topola-egui => egui/src}/layers.rs (100%) rename {src/bin/topola-egui => egui/src}/main.rs (100%) rename {src/bin/topola-egui => egui/src}/menu_bar.rs (100%) rename {src/bin/topola-egui => egui/src}/overlay.rs (100%) rename {src/bin/topola-egui => egui/src}/painter.rs (100%) rename {src/bin/topola-egui => egui/src}/status_bar.rs (100%) rename {src/bin/topola-egui => egui/src}/translator.rs (96%) rename {src/bin/topola-egui => egui/src}/viewport.rs (100%) rename {src/bin/topola-egui => egui/src}/workspace.rs (100%) diff --git a/.woodpecker/build_cli.yaml b/.woodpecker/build_cli.yaml index 9bc9540..e5d2e0b 100644 --- a/.woodpecker/build_cli.yaml +++ b/.woodpecker/build_cli.yaml @@ -1,9 +1,9 @@ matrix: include: - CHANNEL: stable - FEATURES: cli + FEATURES: disable_contracts - CHANNEL: nightly - FEATURES: cli + FEATURES: steps: build_cli: @@ -13,6 +13,6 @@ steps: CARGO_TERM_COLOR: always commands: - rustup default "$CHANNEL" - - cargo build --features "$FEATURES" -- + - cargo build -p topola-cli --no-default-features --features "$FEATURES" -- when: event: [pull_request, push, tag] diff --git a/.woodpecker/build_egui.yaml b/.woodpecker/build_egui.yaml index 39b938b..b2720ab 100644 --- a/.woodpecker/build_egui.yaml +++ b/.woodpecker/build_egui.yaml @@ -1,9 +1,9 @@ matrix: include: - CHANNEL: stable - FEATURES: egui,disable_contracts + FEATURES: disable_contracts - CHANNEL: nightly - FEATURES: egui + FEATURES: steps: build_egui: @@ -13,6 +13,6 @@ steps: CARGO_TERM_COLOR: always commands: - rustup default "$CHANNEL" - - cargo build --features "$FEATURES" --bin "topola-egui" + - cargo build -p topola-egui --no-default-features --features "$FEATURES" when: event: [pull_request, push, tag] diff --git a/.woodpecker/build_wasm.yaml b/.woodpecker/build_wasm.yaml index a039d2c..fcce56f 100644 --- a/.woodpecker/build_wasm.yaml +++ b/.woodpecker/build_wasm.yaml @@ -1,9 +1,9 @@ matrix: include: - CHANNEL: stable - FEATURES: egui,disable_contracts + FEATURES: disable_contracts - CHANNEL: nightly - FEATURES: egui + FEATURES: steps: build_wasm: diff --git a/.woodpecker/test.yaml b/.woodpecker/test.yaml index 1533c5e..de576df 100644 --- a/.woodpecker/test.yaml +++ b/.woodpecker/test.yaml @@ -13,6 +13,6 @@ steps: CARGO_TERM_COLOR: always commands: - rustup default "$CHANNEL" - - cargo test --verbose --features "$FEATURES" + - cargo test --verbose --no-default-features --features "$FEATURES" when: event: [pull_request, push, tag] diff --git a/Cargo.toml b/Cargo.toml index a96738e..d40ffc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,111 +1,59 @@ +[workspace] +members = [ + ".", + "cli", + "egui", + "macros/specctra_derive", +] +resolver = "2" + +[workspace.dependencies] +derive-getters = "0.5" +petgraph = { git = "https://codeberg.org/topola/petgraph.git" } +rstar = "0.12" +serde_json = "1.0" +spade = "2.12.1" + +[workspace.dependencies.geo] +version = "0.28" +default-features = false +features = ["spade", "use-serde"] + +[workspace.dependencies.serde] +version = "1" +features = ["derive"] + [package] name = "topola" description = "Work-in-progress free and open-source topological (rubberband) router and autorouter for printed circuit boards (PCBs)" version = "0.1.0" edition = "2021" -default-run = "topola" - -[lib] -name = "topola" - -[[bin]] -name = "topola" -required-features = ["cli"] - -[[bin]] -name = "topola-egui" -required-features = ["egui"] [features] default = ["disable_contracts"] -cli = ["dep:clap"] -egui = [ - "dep:eframe", - "dep:egui", - "dep:env_logger", - "dep:fluent-templates", - "dep:futures-lite", - "dep:icu", - "dep:rfd", - "dep:sys-locale", - "dep:unic-langid", -] disable_contracts = ["contracts-try/disable_contracts"] [dependencies] -thiserror = "1.0" -rstar = "0.12" -petgraph = { git = "https://codeberg.org/topola/petgraph.git" } -spade = "2.12.1" -serde_json = "1.0" -contracts-try = "0.7" -enum_dispatch = "0.3.13" -derive-getters = "0.5.0" bimap = "0.6.3" -log = "0.4" +contracts-try = "0.7" +derive-getters.workspace = true +enum_dispatch = "0.3.13" +geo.workspace = true +petgraph.workspace = true +rstar.workspace = true +serde.workspace = true +spade.workspace = true +thiserror = "1.0" utf8-chars = "3.0.4" [dependencies.specctra_derive] path = "macros/specctra_derive" -[dependencies.geo] -version = "0.28" -default-features = false -features = ["spade", "use-serde"] +[dev-dependencies] +serde_json.workspace = true -[dependencies.serde] -version = "1" -features = ["derive"] - -[dependencies.clap] -optional = true -version = "4.5.18" -features = ["derive"] - -[dependencies.sys-locale] -optional = true -version = "0.3.1" - -[dependencies.unic-langid] -optional = true -version = "0.9.5" -features = ["macros", "serde"] - -[dependencies.fluent-templates] -optional = true -version = "0.11" - -[dependencies.icu] -optional = true -version = "1.5.0" -features = ["experimental"] - -[dependencies.eframe] -optional = true -version = "0.29" -default-features = false -features = ["accesskit", "default_fonts", "glow", "persistence"] - -[dependencies.egui] -optional = true -version = "0.29" - -[dependencies.rfd] -optional = true -version = "0.15" - -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] - -[target.'cfg(not(target_arch = "wasm32"))'.dependencies.futures-lite] -optional = true -version = "2.3" - -[target.'cfg(not(target_arch = "wasm32"))'.dependencies.env_logger] -optional = true -version = "0.11" - -[target.'cfg(target_arch = "wasm32")'.dependencies] -wasm-bindgen-futures = "0.4" +[package.metadata.docs.rs] +cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] [profile.release] opt-level = 2 # fast and small wasm @@ -113,10 +61,3 @@ opt-level = 2 # fast and small wasm # Optimize all dependencies even in debug builds: [profile.dev.package."*"] opt-level = 2 - -[build-dependencies] -clap_mangen = "0.2.23" -clap = {version="4.5.18", features = ["derive"] } - -[package.metadata.docs.rs] -cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] diff --git a/INSTALL.md b/INSTALL.md index 8e3a561..ea97fae 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -36,7 +36,7 @@ Change your working directory to your clone of Topola's repository: Run the following command to build and install Topola's command-line application: - cargo install --locked --path . --features cli + cargo install --locked --path cli The application will now be invokable from your terminal as `topola`. @@ -70,12 +70,12 @@ In the newly opened file dialog, choose the file named If you chose not to install the command-line application, you can build and run it without installing by replacing the `topola` command with -`cargo run --features cli --`. Running the above autorouting example is +`cargo run -p topola-cli --`. Running the above autorouting example is then as follows: ``` cd tests/single_layer/tht_diode_bridge_rectifier/ -cargo run --features cli -- tht_diode_bridge_rectifier.dsn +cargo run -p topola-cli -- tht_diode_bridge_rectifier.dsn ``` Viewing the results is obviously the same. @@ -89,7 +89,7 @@ framework. The following command will build and install Topola's GUI application: - cargo install --locked --path . --features egui --bin topola-egui + cargo install --locked --path egui You can then invoke the application from your terminal by running @@ -103,7 +103,7 @@ If you chose not to install the GUI application, you can build and run it without installing by running ``` -cargo run --features egui --bin topola-egui +cargo run -p topola-egui ``` instead of the above `topola-egui` command. @@ -180,4 +180,4 @@ Of course, you can enable contracts for any build target. For instance, the following command will build the Egui application with debug profile and contracts enabled: - cargo build --features egui --bin topola-egui --no-default-features + cargo build -p topola-egui --no-default-features diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 0000000..9a347c4 --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "topola-cli" +description = "Work-in-progress free and open-source topological (rubberband) router and autorouter for printed circuit boards (PCBs)" +version = "0.1.0" +edition = "2021" + +[[bin]] +name = "topola" +path = "src/main.rs" + +[features] +default = ["disable_contracts"] +disable_contracts = ["topola/disable_contracts"] + +[dependencies] +serde.workspace = true +serde_json.workspace = true + +[dependencies.topola] +path = ".." +default-features = false + +[dependencies.clap] +version = "4.5.18" +features = ["derive"] + +[build-dependencies] +clap_mangen = "0.2.23" +clap = {version="4.5.18", features = ["derive"] } diff --git a/build.rs b/cli/build.rs similarity index 91% rename from build.rs rename to cli/build.rs index e505139..78d593d 100644 --- a/build.rs +++ b/cli/build.rs @@ -1,4 +1,4 @@ -include!("src/bin/topola/cli.rs"); +include!("src/cli.rs"); use clap::CommandFactory; use clap_mangen::Man; use std::fs::{create_dir_all, File}; diff --git a/src/bin/topola/cli.rs b/cli/src/cli.rs similarity index 100% rename from src/bin/topola/cli.rs rename to cli/src/cli.rs diff --git a/src/bin/topola/main.rs b/cli/src/main.rs similarity index 100% rename from src/bin/topola/main.rs rename to cli/src/main.rs diff --git a/egui/Cargo.toml b/egui/Cargo.toml new file mode 100644 index 0000000..939da78 --- /dev/null +++ b/egui/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "topola-egui" +description = "Work-in-progress free and open-source topological (rubberband) router and autorouter for printed circuit boards (PCBs)" +version = "0.1.0" +edition = "2021" + +[features] +default = ["disable_contracts"] +disable_contracts = ["topola/disable_contracts"] + +[dependencies] +derive-getters.workspace = true +egui = "0.29" +fluent-templates = "0.11" +geo.workspace = true +log = "0.4" +petgraph.workspace = true +rfd = "0.15" +rstar.workspace = true +serde.workspace = true +serde_json.workspace = true +spade.workspace = true +sys-locale = "0.3.1" + +[dependencies.topola] +path = ".." +default-features = false + +[dependencies.unic-langid] +version = "0.9.5" +features = ["macros", "serde"] + +[dependencies.icu] +version = "1.5.0" +features = ["experimental"] + +[dependencies.eframe] +version = "0.29" +default-features = false +features = ["accesskit", "default_fonts", "glow", "persistence"] + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +futures-lite = "2.3" +env_logger = "0.11" + +[target.'cfg(target_arch = "wasm32")'.dependencies] +wasm-bindgen-futures = "0.4" diff --git a/src/bin/topola-egui/action.rs b/egui/src/action.rs similarity index 100% rename from src/bin/topola-egui/action.rs rename to egui/src/action.rs diff --git a/src/bin/topola-egui/actions.rs b/egui/src/actions.rs similarity index 100% rename from src/bin/topola-egui/actions.rs rename to egui/src/actions.rs diff --git a/src/bin/topola-egui/app.rs b/egui/src/app.rs similarity index 100% rename from src/bin/topola-egui/app.rs rename to egui/src/app.rs diff --git a/src/bin/topola-egui/config.rs b/egui/src/config.rs similarity index 100% rename from src/bin/topola-egui/config.rs rename to egui/src/config.rs diff --git a/src/bin/topola-egui/error_dialog.rs b/egui/src/error_dialog.rs similarity index 100% rename from src/bin/topola-egui/error_dialog.rs rename to egui/src/error_dialog.rs diff --git a/src/bin/topola-egui/layers.rs b/egui/src/layers.rs similarity index 100% rename from src/bin/topola-egui/layers.rs rename to egui/src/layers.rs diff --git a/src/bin/topola-egui/main.rs b/egui/src/main.rs similarity index 100% rename from src/bin/topola-egui/main.rs rename to egui/src/main.rs diff --git a/src/bin/topola-egui/menu_bar.rs b/egui/src/menu_bar.rs similarity index 100% rename from src/bin/topola-egui/menu_bar.rs rename to egui/src/menu_bar.rs diff --git a/src/bin/topola-egui/overlay.rs b/egui/src/overlay.rs similarity index 100% rename from src/bin/topola-egui/overlay.rs rename to egui/src/overlay.rs diff --git a/src/bin/topola-egui/painter.rs b/egui/src/painter.rs similarity index 100% rename from src/bin/topola-egui/painter.rs rename to egui/src/painter.rs diff --git a/src/bin/topola-egui/status_bar.rs b/egui/src/status_bar.rs similarity index 100% rename from src/bin/topola-egui/status_bar.rs rename to egui/src/status_bar.rs diff --git a/src/bin/topola-egui/translator.rs b/egui/src/translator.rs similarity index 96% rename from src/bin/topola-egui/translator.rs rename to egui/src/translator.rs index de0c345..cfa4d9a 100644 --- a/src/bin/topola-egui/translator.rs +++ b/egui/src/translator.rs @@ -5,7 +5,7 @@ use unic_langid::LanguageIdentifier; static_loader! { static LOCALES = { - locales: "./locales", + locales: "../locales", fallback_language: "en-US", }; } diff --git a/src/bin/topola-egui/viewport.rs b/egui/src/viewport.rs similarity index 100% rename from src/bin/topola-egui/viewport.rs rename to egui/src/viewport.rs diff --git a/src/bin/topola-egui/workspace.rs b/egui/src/workspace.rs similarity index 100% rename from src/bin/topola-egui/workspace.rs rename to egui/src/workspace.rs