build: put egui and cli into separate crates

* build(ci): try to fix CI
* build: use workspace dependencies for deduplication / drift avoidance
This commit is contained in:
Alain Emilia Anna Zscheile 2024-11-16 16:09:58 +01:00
parent 9dad83d221
commit 2d1af33204
25 changed files with 131 additions and 114 deletions

View File

@ -1,9 +1,9 @@
matrix: matrix:
include: include:
- CHANNEL: stable - CHANNEL: stable
FEATURES: cli FEATURES: disable_contracts
- CHANNEL: nightly - CHANNEL: nightly
FEATURES: cli FEATURES:
steps: steps:
build_cli: build_cli:
@ -13,6 +13,6 @@ steps:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
commands: commands:
- rustup default "$CHANNEL" - rustup default "$CHANNEL"
- cargo build --features "$FEATURES" -- - cargo build -p topola-cli --no-default-features --features "$FEATURES" --
when: when:
event: [pull_request, push, tag] event: [pull_request, push, tag]

View File

@ -1,9 +1,9 @@
matrix: matrix:
include: include:
- CHANNEL: stable - CHANNEL: stable
FEATURES: egui,disable_contracts FEATURES: disable_contracts
- CHANNEL: nightly - CHANNEL: nightly
FEATURES: egui FEATURES:
steps: steps:
build_egui: build_egui:
@ -13,6 +13,6 @@ steps:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
commands: commands:
- rustup default "$CHANNEL" - rustup default "$CHANNEL"
- cargo build --features "$FEATURES" --bin "topola-egui" - cargo build -p topola-egui --no-default-features --features "$FEATURES"
when: when:
event: [pull_request, push, tag] event: [pull_request, push, tag]

View File

@ -1,9 +1,9 @@
matrix: matrix:
include: include:
- CHANNEL: stable - CHANNEL: stable
FEATURES: egui,disable_contracts FEATURES: disable_contracts
- CHANNEL: nightly - CHANNEL: nightly
FEATURES: egui FEATURES:
steps: steps:
build_wasm: build_wasm:

View File

@ -13,6 +13,6 @@ steps:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
commands: commands:
- rustup default "$CHANNEL" - rustup default "$CHANNEL"
- cargo test --verbose --features "$FEATURES" - cargo test --verbose --no-default-features --features "$FEATURES"
when: when:
event: [pull_request, push, tag] event: [pull_request, push, tag]

View File

@ -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] [package]
name = "topola" name = "topola"
description = "Work-in-progress free and open-source topological (rubberband) router and autorouter for printed circuit boards (PCBs)" description = "Work-in-progress free and open-source topological (rubberband) router and autorouter for printed circuit boards (PCBs)"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
default-run = "topola"
[lib]
name = "topola"
[[bin]]
name = "topola"
required-features = ["cli"]
[[bin]]
name = "topola-egui"
required-features = ["egui"]
[features] [features]
default = ["disable_contracts"] 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"] disable_contracts = ["contracts-try/disable_contracts"]
[dependencies] [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" 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" utf8-chars = "3.0.4"
[dependencies.specctra_derive] [dependencies.specctra_derive]
path = "macros/specctra_derive" path = "macros/specctra_derive"
[dependencies.geo] [dev-dependencies]
version = "0.28" serde_json.workspace = true
default-features = false
features = ["spade", "use-serde"]
[dependencies.serde] [package.metadata.docs.rs]
version = "1" cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
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"
[profile.release] [profile.release]
opt-level = 2 # fast and small wasm 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: # Optimize all dependencies even in debug builds:
[profile.dev.package."*"] [profile.dev.package."*"]
opt-level = 2 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"]

View File

@ -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 Run the following command to build and install Topola's command-line
application: application:
cargo install --locked --path . --features cli cargo install --locked --path cli
The application will now be invokable from your terminal as `topola`. 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 If you chose not to install the command-line application, you can build
and run it without installing by replacing the `topola` command with 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: then as follows:
``` ```
cd tests/single_layer/tht_diode_bridge_rectifier/ 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. Viewing the results is obviously the same.
@ -89,7 +89,7 @@ framework.
The following command will build and install Topola's GUI application: 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 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 it without installing by running
``` ```
cargo run --features egui --bin topola-egui cargo run -p topola-egui
``` ```
instead of the above `topola-egui` command. 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 the following command will build the Egui application with debug profile
and contracts enabled: and contracts enabled:
cargo build --features egui --bin topola-egui --no-default-features cargo build -p topola-egui --no-default-features

29
cli/Cargo.toml Normal file
View File

@ -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"] }

View File

@ -1,4 +1,4 @@
include!("src/bin/topola/cli.rs"); include!("src/cli.rs");
use clap::CommandFactory; use clap::CommandFactory;
use clap_mangen::Man; use clap_mangen::Man;
use std::fs::{create_dir_all, File}; use std::fs::{create_dir_all, File};

47
egui/Cargo.toml Normal file
View File

@ -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"

View File

@ -5,7 +5,7 @@ use unic_langid::LanguageIdentifier;
static_loader! { static_loader! {
static LOCALES = { static LOCALES = {
locales: "./locales", locales: "../locales",
fallback_language: "en-US", fallback_language: "en-US",
}; };
} }