diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9522aa1f..0cb7eb01 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,6 +17,8 @@ env: RUSTDOCFLAGS: -D warnings RUST_BACKTRACE: 1 RUST_LOG: debug + JUST_VERBOSE: 1 + JUST_COLOR: always jobs: check: @@ -42,6 +44,7 @@ jobs: with: targets: ${{matrix.TARGET}} - uses: Swatinem/rust-cache@v2 + - run: sudo apt-get update && sudo apt-get install libhdf5-dev - run: cargo check ${{matrix.flags}} --target ${{matrix.TARGET}} audit: @@ -70,8 +73,22 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@nextest + - uses: extractions/setup-just@v2 - uses: Swatinem/rust-cache@v2 - - run: cargo nextest run --workspace --profile ci + + - name: Install HDF5 + shell: bash + run: just init::install-hdf5-headers + + - name: Run MSI installer (windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + cd just\hdf + msiexec /i HDF5-1.14.0-win64.msi /quiet /qn /norestart + + - name: Run tests + run: cargo nextest run --workspace --profile ci format: runs-on: ubuntu-latest @@ -91,6 +108,7 @@ jobs: with: components: clippy - uses: Swatinem/rust-cache@v2 + - run: sudo apt-get update && sudo apt-get install libhdf5-dev - name: Lint native run: cargo clippy --workspace --all-features -- -D warnings -W clippy::all - name: Lint WASM @@ -112,84 +130,8 @@ jobs: - name: Build run: ./trunk build - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - include: - - os: macos-latest - # macos-latest seems to already run on arm64(=aarch64): - # https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories - TARGET: aarch64-apple-darwin - - - os: macos-13 - TARGET: x86_64-apple-darwin - # even though the runner uses arm64, MacOS on arm64 seems to support building for amd64. - # which makes sense, would be bad for devs otherwise. - cross: false - - - os: ubuntu-latest - TARGET: aarch64-unknown-linux-gnu - cross: true - - - os: ubuntu-latest - TARGET: armv7-unknown-linux-gnueabihf - cross: true - - - os: ubuntu-latest - TARGET: x86_64-unknown-linux-gnu - - - os: windows-latest - TARGET: x86_64-pc-windows-msvc - EXTENSION: .exe - - steps: - - name: Install cross - # Github doesnt have runners with exotic architectures (eg. arm64/aarch64 on anything but macos). - # Thus we use cross. - # It's necessary to use an up-to-date cross from the git repository to avoid glibc problems on linux - # Ref: https://github.com/cross-rs/cross/issues/1510 - if: matrix.cross - run: | - echo "Resetting RUSTFLAGS as a temporary fix for: https://github.com/cross-rs/cross/issues/1561" - RUSTFLAGS="" cargo install cross --git https://github.com/cross-rs/cross --rev 1b8cf50d20180c1a394099e608141480f934b7f7 - - - name: Building ${{ matrix.TARGET }} - run: echo "${{ matrix.TARGET }}" - - - uses: actions/checkout@master - - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.TARGET }} - - - uses: Swatinem/rust-cache@v2 - with: - # this is required to avoid failures due to caching of artifacts for different architectures - # The reason is the potential usage of cross. - # The cache checks the rustc host which doesn't record us targeting - # different architectures (and native) with cross on the generic ubuntu-latest. - key: ${{ matrix.TARGET }} - - - if: ${{ !matrix.cross }} - name: Cargo Build - run: cargo build --verbose --release --target=${{ matrix.TARGET }} - - - if: matrix.cross - name: Cross Build - run: cross build --verbose --release --target=${{ matrix.TARGET }} - - - name: Rename - run: cp target/${{ matrix.TARGET }}/release/${{ github.event.repository.name }}${{ matrix.EXTENSION }} ${{ github.event.repository.name }}-${{ matrix.TARGET }}${{ matrix.EXTENSION }} - - - uses: actions/upload-artifact@master - with: - name: ${{ github.event.repository.name }}-${{ matrix.TARGET }}${{ matrix.EXTENSION }} - path: ${{ github.event.repository.name }}-${{ matrix.TARGET }}${{ matrix.EXTENSION }} - tag-release: - needs: [check, audit, test, format, lint, trunk, build] + needs: [check, audit, test, format, lint, trunk] runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' && success() permissions: diff --git a/.github/workflows/build-setup.yml b/.github/workflows/build-setup.yml new file mode 100644 index 00000000..d0b52e80 --- /dev/null +++ b/.github/workflows/build-setup.yml @@ -0,0 +1,12 @@ +- name: Install Just + uses: extractions/setup-just@v2 +- name: Install HDF5 + shell: bash + run: just init::install-hdf5-headers + +- name: Run MSI installer (windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + cd just\hdf + msiexec /i HDF5-1.14.0-win64.msi /quiet /qn /norestart diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d17ef807..2dde8db9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -125,6 +125,17 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y echo "$HOME/.cargo/bin" >> $GITHUB_PATH fi + - name: "Install Just" + uses: "extractions/setup-just@v2" + - name: "Install HDF5" + run: "just init::install-hdf5-headers" + shell: "bash" + - name: "Run MSI installer (windows)" + if: "runner.os == 'Windows'" + run: | + cd just\hdf + msiexec /i HDF5-1.14.0-win64.msi /quiet /qn /norestart + shell: "pwsh" - uses: swatinem/rust-cache@v2 with: key: ${{ join(matrix.targets, '-') }} diff --git a/Cargo.lock b/Cargo.lock index 5e22497a..3069e380 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -760,15 +760,6 @@ dependencies = [ "error-code", ] -[[package]] -name = "cmake" -version = "0.1.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e" -dependencies = [ - "cc", -] - [[package]] name = "codespan-reporting" version = "0.11.1" @@ -1813,22 +1804,12 @@ dependencies = [ "syn", ] -[[package]] -name = "hdf5-metno-src" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956b57b8b4e133bcfbc874a2c9c6d4020e0da420dcfa05aea79091888f2b0763" -dependencies = [ - "cmake", -] - [[package]] name = "hdf5-metno-sys" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de20d5ba22c244493bdfefb91d8e9de08e3e58d96a792532da5e0df545aed279" dependencies = [ - "hdf5-metno-src", "libc", "libloading", "parking_lot", @@ -3072,7 +3053,7 @@ dependencies = [ ] [[package]] -name = "plotinator3000" +name = "plotinator-lib" version = "1.6.4" dependencies = [ "axoupdater", @@ -3104,6 +3085,20 @@ dependencies = [ "zip", ] +[[package]] +name = "plotinator3000" +version = "1.6.4" +dependencies = [ + "plotinator-lib", +] + +[[package]] +name = "plotinator3000-h5" +version = "1.6.4" +dependencies = [ + "plotinator-lib", +] + [[package]] name = "png" version = "0.17.16" diff --git a/Cargo.toml b/Cargo.toml index 1a53dcc9..a3158165 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,27 +1,35 @@ -[package] -name = "plotinator3000" -description = "Log viewer app for viewing plots of data from projects such as motor and generator control" -authors = ["SkyTEM Surveys", "Marc Beck König"] +[workspace] +members = ["crates/*"] +resolver = "2" + +[workspace.package] version = "1.6.4" +authors = ["SkyTEM Surveys", "Marc Beck König"] edition = "2021" -repository = "https://github.com/luftkode/plotinator3000" -homepage = "https://github.com/luftkode/plotinator3000" license = "MIT OR Apache-2.0" - -[package.metadata.wix] -upgrade-guid = "7063C05B-24FE-4CE5-A338-6D750F3F10CE" -path-guid = "025605DB-83DB-4162-B505-26B36C02D0B9" -license = false -eula = false -product-icon = "assets/favicon.ico" - - -[workspace] -members = ["crates/*"] +description = "Log viewer app for viewing plots of data from projects such as motor and generator control" +homepage = "https://github.com/luftkode/plotinator3000" +repository = "https://github.com/luftkode/plotinator3000" [workspace.dependencies] +plotinator-lib = { version = "*", path = "crates/plotinator-lib" } +skytem_logs = { version = "*", path = "crates/skytem_logs" } +log_if = { version = "*", path = "crates/log_if" } +plot_util = { version = "*", path = "crates/plot_util" } +skytem_hdf = { version = "*", path = "crates/skytem_hdf" } +eframe = { version = "0.30", default-features = false, features = [ + "default_fonts", # Embed the default egui fonts. + "glow", # Use the glow rendering backend. Alternative: "wgpu". + "persistence", # Enable restoring app state when restarting the app. + "wayland", + "x11" +] } egui = { version = "0.30", features = ["rayon"] } egui_plot = { version = "0.30", features = ["serde"] } +rfd = "0.15" +egui-phosphor = "0.8.0" +egui-notify = "0.18.0" +tokio = "1.43.0" log = "0.4" serde = { version = "1", features = ["derive"] } serde-big-array = "0.5.1" @@ -43,58 +51,6 @@ pretty_assertions = "1.4.1" tempfile = "3.15.0" reqwest = "0.12.12" -[dependencies] -skytem_logs = { version = "*", path = "crates/skytem_logs" } -log_if = { version = "*", path = "crates/log_if" } -plot_util = { version = "*", path = "crates/plot_util" } -skytem_hdf = { version = "*", path = "crates/skytem_hdf" } -egui_plot.workspace = true -log.workspace = true -serde.workspace = true -strum.workspace = true -strum_macros.workspace = true -chrono.workspace = true -getset.workspace = true -semver.workspace = true -egui.workspace = true -eframe = { version = "0.30", default-features = false, features = [ - "default_fonts", # Embed the default egui fonts. - "glow", # Use the glow rendering backend. Alternative: "wgpu". - "persistence", # Enable restoring app state when restarting the app. - "wayland", - "x11" -] } -rfd = "0.15" -egui-phosphor = "0.8.0" -egui-notify = "0.18.0" -tokio = "1.43.0" - -[dev-dependencies] -testresult.workspace = true -tempfile.workspace = true -reqwest.workspace = true - -[features] -default = ["selfupdater"] -hdf = [] -selfupdater = [] - -# native: -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -env_logger = "0.11" -zip = "2.2.2" -axoupdater = { version = "0.9.0", features = ["blocking"] } - - -# web: -[target.'cfg(target_arch = "wasm32")'.dependencies] -wasm-bindgen-futures = "0.4" -web-sys = "0.3.70" - -# windows -[target.'cfg(target_os = "windows")'.dependencies] -elevated-command.workspace = true - [profile.release] opt-level = 3 debug = false @@ -111,9 +67,6 @@ opt-level = 2 [profile.dist] inherits = "release" -[lints] -workspace = true - [workspace.lints.rust] missing_debug_implementations = "warn" missing_copy_implementations = "warn" diff --git a/Justfile b/Justfile index 2d1461bb..70d237c1 100644 --- a/Justfile +++ b/Justfile @@ -1,5 +1,6 @@ import 'just/default_cmd.just' mod ci 'just/ci.just' +mod init 'just/init.just' PROJECT_NAME := "plotinator3000" @@ -17,10 +18,6 @@ export PLOTINATOR_BYPASS_UPDATES := env_var_or_default("PLOTINATOR_BYPASS_UPDATE @_default: just --list --no-aliases -[group("Init")] -init: install-devtools - echo "Run 'install-extra-devtools' for some adittional productivity tools that fit into the existent workflow" - [doc("Checks both native and wasm"), no-exit-message] check-all: check check-wasm @@ -82,25 +79,6 @@ update: audit *ARGS: cargo audit {{ ARGS }} -# Trunk is used to serve the app with a webserver, cargo-dist is used to generate and update workflows for distributing installers for various platforms -[doc("Install the required tools for performing all dev tasks for the project")] -install-devtools: - cargo install trunk --locked - cargo install cargo-dist --locked - cargo install typos-cli --locked - cargo install cargo-audit --locked - -# Install nice-to-have devtools -[group("Init")] -install-extra-devtools: - cargo install cargo-nextest --locked - cargo install cargo-limit --locked - cargo install bacon --locked - -[group("Init")] -apt-install-hdf5-header: - sudo apt install libhdf5-dev - # Requires firebase CLI and access to MKI firebase account [group("Web")] firebase-deploy: diff --git a/crates/plotinator-lib/Cargo.toml b/crates/plotinator-lib/Cargo.toml new file mode 100644 index 00000000..dc5afa1d --- /dev/null +++ b/crates/plotinator-lib/Cargo.toml @@ -0,0 +1,59 @@ +[package] +name = "plotinator-lib" +description.workspace = true +authors.workspace = true +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +license.workspace = true + +[features] +default = ["selfupdater"] +hdf = ["dep:skytem_hdf"] +selfupdater = ["dep:axoupdater"] + +[dependencies] +skytem_hdf = { workspace = true, optional = true } +skytem_logs.workspace = true +log_if.workspace = true +plot_util.workspace = true +egui_plot.workspace = true +log.workspace = true +serde.workspace = true +strum.workspace = true +strum_macros.workspace = true +chrono.workspace = true +getset.workspace = true +semver.workspace = true +egui.workspace = true +eframe.workspace = true +rfd.workspace = true +egui-phosphor.workspace = true +egui-notify.workspace = true +tokio.workspace = true + +[dev-dependencies] +testresult.workspace = true +tempfile.workspace = true +reqwest.workspace = true + + +# native: +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +env_logger = "0.11" +zip = "2.2.2" +axoupdater = { version = "0.9.0", features = ["blocking"], optional = true } + + +# web: +[target.'cfg(target_arch = "wasm32")'.dependencies] +wasm-bindgen-futures = "0.4" +web-sys = "0.3.70" + +# windows +[target.'cfg(target_os = "windows")'.dependencies] +elevated-command.workspace = true + +[lints] +workspace = true diff --git a/src/app.rs b/crates/plotinator-lib/src/app.rs similarity index 100% rename from src/app.rs rename to crates/plotinator-lib/src/app.rs diff --git a/src/app/dropped_files.rs b/crates/plotinator-lib/src/app/dropped_files.rs similarity index 100% rename from src/app/dropped_files.rs rename to crates/plotinator-lib/src/app/dropped_files.rs diff --git a/src/app/dropped_files/preview_dropped.rs b/crates/plotinator-lib/src/app/dropped_files/preview_dropped.rs similarity index 100% rename from src/app/dropped_files/preview_dropped.rs rename to crates/plotinator-lib/src/app/dropped_files/preview_dropped.rs diff --git a/src/app/file_dialog.rs b/crates/plotinator-lib/src/app/file_dialog.rs similarity index 100% rename from src/app/file_dialog.rs rename to crates/plotinator-lib/src/app/file_dialog.rs diff --git a/src/app/file_dialog/native.rs b/crates/plotinator-lib/src/app/file_dialog/native.rs similarity index 100% rename from src/app/file_dialog/native.rs rename to crates/plotinator-lib/src/app/file_dialog/native.rs diff --git a/src/app/file_dialog/web.rs b/crates/plotinator-lib/src/app/file_dialog/web.rs similarity index 100% rename from src/app/file_dialog/web.rs rename to crates/plotinator-lib/src/app/file_dialog/web.rs diff --git a/src/app/supported_formats.rs b/crates/plotinator-lib/src/app/supported_formats.rs similarity index 100% rename from src/app/supported_formats.rs rename to crates/plotinator-lib/src/app/supported_formats.rs diff --git a/src/app/supported_formats/hdf.rs b/crates/plotinator-lib/src/app/supported_formats/hdf.rs similarity index 100% rename from src/app/supported_formats/hdf.rs rename to crates/plotinator-lib/src/app/supported_formats/hdf.rs diff --git a/src/app/supported_formats/logs.rs b/crates/plotinator-lib/src/app/supported_formats/logs.rs similarity index 100% rename from src/app/supported_formats/logs.rs rename to crates/plotinator-lib/src/app/supported_formats/logs.rs diff --git a/src/app/supported_formats/logs/parse_info.rs b/crates/plotinator-lib/src/app/supported_formats/logs/parse_info.rs similarity index 100% rename from src/app/supported_formats/logs/parse_info.rs rename to crates/plotinator-lib/src/app/supported_formats/logs/parse_info.rs diff --git a/src/app/supported_formats/util.rs b/crates/plotinator-lib/src/app/supported_formats/util.rs similarity index 100% rename from src/app/supported_formats/util.rs rename to crates/plotinator-lib/src/app/supported_formats/util.rs diff --git a/src/app/util.rs b/crates/plotinator-lib/src/app/util.rs similarity index 100% rename from src/app/util.rs rename to crates/plotinator-lib/src/app/util.rs diff --git a/src/main.rs b/crates/plotinator-lib/src/lib.rs similarity index 63% rename from src/main.rs rename to crates/plotinator-lib/src/lib.rs index c0b16050..0eab5b7c 100644 --- a/src/main.rs +++ b/crates/plotinator-lib/src/lib.rs @@ -1,14 +1,45 @@ #![warn(clippy::all, rust_2018_idioms)] -#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release + +use semver::Version; +use std::sync::OnceLock; +mod app; +use crate::app::App; + +pub const APP_NAME: &str = env!("CARGO_PKG_NAME"); +pub const APP_OWNER: &str = "luftkode"; + +#[cfg(not(target_arch = "wasm32"))] +pub const APP_ICON: &[u8] = include_bytes!("../../../assets/skytem-icon-256.png"); + +pub const APP_VERSION_MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR"); +pub const APP_VERSION_MINOR: &str = env!("CARGO_PKG_VERSION_MINOR"); +pub const APP_VERSION_PATCH: &str = env!("CARGO_PKG_VERSION_PATCH"); + +pub static APP_VERSION: OnceLock = OnceLock::new(); +pub fn get_app_version() -> &'static Version { + APP_VERSION.get_or_init(|| { + Version::new( + APP_VERSION_MAJOR.parse().expect("Invalid major version"), + APP_VERSION_MINOR.parse().expect("Invalid minor version"), + APP_VERSION_PATCH.parse().expect("Invalid patch version"), + ) + }) +} + +pub mod plot; +#[cfg(feature = "selfupdater")] +#[cfg(not(target_arch = "wasm32"))] +pub mod updater; +pub mod util; // When compiling natively: #[cfg(not(target_arch = "wasm32"))] -fn main() -> eframe::Result { +pub fn run_app() -> eframe::Result { // Log to stderr (if run with `RUST_LOG=debug`). env_logger::init(); #[cfg(feature = "selfupdater")] - match plotinator3000::updater::update_if_applicable() { + match crate::updater::update_if_applicable() { Ok(needs_restart) => { if needs_restart { return Ok(()); @@ -27,21 +58,20 @@ fn main() -> eframe::Result { .with_min_inner_size([100.0, 80.0]) .with_drag_and_drop(true) .with_icon( - eframe::icon_data::from_png_bytes(plotinator3000::APP_ICON) - .expect("Failed to load icon"), + eframe::icon_data::from_png_bytes(crate::APP_ICON).expect("Failed to load icon"), ), ..Default::default() }; eframe::run_native( &format!("Plotinator3000 v{}", env!("CARGO_PKG_VERSION")), native_options, - Box::new(|cc| Ok(Box::new(plotinator3000::App::new(cc)))), + Box::new(|cc| Ok(Box::new(App::new(cc)))), ) } // When compiling to web using trunk: #[cfg(target_arch = "wasm32")] -fn main() { +pub fn run_app() -> eframe::Result { use eframe::wasm_bindgen::JsCast as _; // Redirect `log` message to `console.log` and friends: _ = eframe::WebLogger::init(log::LevelFilter::Debug).ok(); @@ -64,7 +94,7 @@ fn main() { .start( canvas, web_options, - Box::new(|cc| Ok(Box::new(plotinator3000::App::new(cc)))), + Box::new(|cc| Ok(Box::new(App::new(cc)))), ) .await; @@ -83,4 +113,5 @@ fn main() { } } }); + Ok(()) } diff --git a/src/plot.rs b/crates/plotinator-lib/src/plot.rs similarity index 100% rename from src/plot.rs rename to crates/plotinator-lib/src/plot.rs diff --git a/src/plot/axis_config.rs b/crates/plotinator-lib/src/plot/axis_config.rs similarity index 100% rename from src/plot/axis_config.rs rename to crates/plotinator-lib/src/plot/axis_config.rs diff --git a/src/plot/axis_config/axis_lock.rs b/crates/plotinator-lib/src/plot/axis_config/axis_lock.rs similarity index 100% rename from src/plot/axis_config/axis_lock.rs rename to crates/plotinator-lib/src/plot/axis_config/axis_lock.rs diff --git a/src/plot/click_delta.rs b/crates/plotinator-lib/src/plot/click_delta.rs similarity index 100% rename from src/plot/click_delta.rs rename to crates/plotinator-lib/src/plot/click_delta.rs diff --git a/src/plot/plot_graphics.rs b/crates/plotinator-lib/src/plot/plot_graphics.rs similarity index 100% rename from src/plot/plot_graphics.rs rename to crates/plotinator-lib/src/plot/plot_graphics.rs diff --git a/src/plot/plot_settings.rs b/crates/plotinator-lib/src/plot/plot_settings.rs similarity index 100% rename from src/plot/plot_settings.rs rename to crates/plotinator-lib/src/plot/plot_settings.rs diff --git a/src/plot/plot_settings/date_settings.rs b/crates/plotinator-lib/src/plot/plot_settings/date_settings.rs similarity index 100% rename from src/plot/plot_settings/date_settings.rs rename to crates/plotinator-lib/src/plot/plot_settings/date_settings.rs diff --git a/src/plot/plot_settings/loaded_logs.rs b/crates/plotinator-lib/src/plot/plot_settings/loaded_logs.rs similarity index 100% rename from src/plot/plot_settings/loaded_logs.rs rename to crates/plotinator-lib/src/plot/plot_settings/loaded_logs.rs diff --git a/src/plot/plot_settings/mipmap_settings.rs b/crates/plotinator-lib/src/plot/plot_settings/mipmap_settings.rs similarity index 100% rename from src/plot/plot_settings/mipmap_settings.rs rename to crates/plotinator-lib/src/plot/plot_settings/mipmap_settings.rs diff --git a/src/plot/plot_settings/plot_filter.rs b/crates/plotinator-lib/src/plot/plot_settings/plot_filter.rs similarity index 100% rename from src/plot/plot_settings/plot_filter.rs rename to crates/plotinator-lib/src/plot/plot_settings/plot_filter.rs diff --git a/src/plot/plot_settings/plot_visibility_config.rs b/crates/plotinator-lib/src/plot/plot_settings/plot_visibility_config.rs similarity index 100% rename from src/plot/plot_settings/plot_visibility_config.rs rename to crates/plotinator-lib/src/plot/plot_settings/plot_visibility_config.rs diff --git a/src/plot/plot_ui.rs b/crates/plotinator-lib/src/plot/plot_ui.rs similarity index 100% rename from src/plot/plot_ui.rs rename to crates/plotinator-lib/src/plot/plot_ui.rs diff --git a/src/plot/util.rs b/crates/plotinator-lib/src/plot/util.rs similarity index 100% rename from src/plot/util.rs rename to crates/plotinator-lib/src/plot/util.rs diff --git a/src/updater.rs b/crates/plotinator-lib/src/updater.rs similarity index 100% rename from src/updater.rs rename to crates/plotinator-lib/src/updater.rs diff --git a/src/updater/ui.rs b/crates/plotinator-lib/src/updater/ui.rs similarity index 100% rename from src/updater/ui.rs rename to crates/plotinator-lib/src/updater/ui.rs diff --git a/src/updater/ui/error_window.rs b/crates/plotinator-lib/src/updater/ui/error_window.rs similarity index 100% rename from src/updater/ui/error_window.rs rename to crates/plotinator-lib/src/updater/ui/error_window.rs diff --git a/src/updater/ui/pre_admin_window.rs b/crates/plotinator-lib/src/updater/ui/pre_admin_window.rs similarity index 100% rename from src/updater/ui/pre_admin_window.rs rename to crates/plotinator-lib/src/updater/ui/pre_admin_window.rs diff --git a/src/updater/ui/updates_disabled.rs b/crates/plotinator-lib/src/updater/ui/updates_disabled.rs similarity index 100% rename from src/updater/ui/updates_disabled.rs rename to crates/plotinator-lib/src/updater/ui/updates_disabled.rs diff --git a/src/util.rs b/crates/plotinator-lib/src/util.rs similarity index 100% rename from src/util.rs rename to crates/plotinator-lib/src/util.rs diff --git a/crates/plotinator3000-h5/Cargo.toml b/crates/plotinator3000-h5/Cargo.toml new file mode 100644 index 00000000..ed04a2ec --- /dev/null +++ b/crates/plotinator3000-h5/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "plotinator3000-h5" +description = "Log viewer app for viewing plots of data from projects such as motor and generator control" +authors = ["SkyTEM Surveys", "Marc Beck König"] +version = "1.6.4" +edition = "2021" +repository = "https://github.com/luftkode/plotinator3000" +homepage = "https://github.com/luftkode/plotinator3000" +license = "MIT OR Apache-2.0" + +[package.metadata.wix] +upgrade-guid = "F0BD0082-87A7-43DA-930A-6CFC1B3BCC52" +path-guid = "04977CE9-B016-4331-8DA5-FCD7DC6D9BE0" +license = false +eula = false + + +[dependencies] +plotinator-lib = { workspace = true, features = ["selfupdater", "hdf"] } + +[lints] +workspace = true diff --git a/crates/plotinator3000-h5/src/main.rs b/crates/plotinator3000-h5/src/main.rs new file mode 100644 index 00000000..f303d874 --- /dev/null +++ b/crates/plotinator3000-h5/src/main.rs @@ -0,0 +1,6 @@ +#![warn(clippy::all, rust_2018_idioms)] +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release + +fn main() { + plotinator_lib::run_app().expect("Plotinator3000 failed"); +} diff --git a/crates/plotinator3000-h5/wix/main.wxs b/crates/plotinator3000-h5/wix/main.wxs new file mode 100644 index 00000000..541a82dd --- /dev/null +++ b/crates/plotinator3000-h5/wix/main.wxs @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + + diff --git a/crates/plotinator3000/Cargo.toml b/crates/plotinator3000/Cargo.toml new file mode 100644 index 00000000..e98772f3 --- /dev/null +++ b/crates/plotinator3000/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "plotinator3000" +description.workspace = true +authors.workspace = true +version.workspace = true +edition.workspace = true +repository.workspace = true +homepage.workspace = true +license.workspace = true + + +[package.metadata.wix] +upgrade-guid = "7063C05B-24FE-4CE5-A338-6D750F3F10CE" +path-guid = "025605DB-83DB-4162-B505-26B36C02D0B9" +license = false +eula = false +product-icon = "assets/favicon.ico" + + +[dependencies] +plotinator-lib.workspace = true + +[lints] +workspace = true diff --git a/crates/plotinator3000/src/main.rs b/crates/plotinator3000/src/main.rs new file mode 100644 index 00000000..f303d874 --- /dev/null +++ b/crates/plotinator3000/src/main.rs @@ -0,0 +1,6 @@ +#![warn(clippy::all, rust_2018_idioms)] +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release + +fn main() { + plotinator_lib::run_app().expect("Plotinator3000 failed"); +} diff --git a/crates/plotinator3000/wix/main.wxs b/crates/plotinator3000/wix/main.wxs new file mode 100644 index 00000000..afbc2d8d --- /dev/null +++ b/crates/plotinator3000/wix/main.wxs @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + + diff --git a/crates/skytem_hdf/Cargo.toml b/crates/skytem_hdf/Cargo.toml index 9f01b1af..40e20296 100644 --- a/crates/skytem_hdf/Cargo.toml +++ b/crates/skytem_hdf/Cargo.toml @@ -24,7 +24,7 @@ toml.workspace = true ndarray = "0.16.1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -hdf5 = { package = "hdf5-metno", version = "0.9", features = ["static"] } +hdf5 = { package = "hdf5-metno", version = "0.9" } [dev-dependencies] testresult.workspace = true diff --git a/crates/skytem_logs/src/lib.rs b/crates/skytem_logs/src/lib.rs index 08495a5b..1e233477 100644 --- a/crates/skytem_logs/src/lib.rs +++ b/crates/skytem_logs/src/lib.rs @@ -7,6 +7,9 @@ pub mod mbed_motor_control; pub mod navsys; pub mod util; +#[cfg(test)] +mod test_util; + /// Parse the unique description string from a 128-byte array /// /// A log header has a unique description, e.g. `MBED-MOTOR-CONTROL-STATUS-LOG` diff --git a/crates/skytem_logs/src/mbed_motor_control/pid/pidlog.rs b/crates/skytem_logs/src/mbed_motor_control/pid/pidlog.rs index 707a27ab..f0c9927d 100644 --- a/crates/skytem_logs/src/mbed_motor_control/pid/pidlog.rs +++ b/crates/skytem_logs/src/mbed_motor_control/pid/pidlog.rs @@ -273,6 +273,7 @@ mod tests { use std::fs::{self, File}; use testresult::TestResult; + use crate::test_util::example_mbed_logs::MBED_MOTOR_CONTROL_PID_V1; const TEST_DATA_V1: &str = "../../test_data/mbed_motor_control/v1/20240926_121708/pid_20240926_121708_00.bin"; const TEST_DATA_V2: &str = diff --git a/crates/skytem_logs/src/test_util.rs b/crates/skytem_logs/src/test_util.rs new file mode 100644 index 00000000..893b47bd --- /dev/null +++ b/crates/skytem_logs/src/test_util.rs @@ -0,0 +1 @@ +pub mod example_mbed_logs; diff --git a/crates/skytem_logs/src/test_util/example_mbed_logs.rs b/crates/skytem_logs/src/test_util/example_mbed_logs.rs new file mode 100644 index 00000000..23249fd4 --- /dev/null +++ b/crates/skytem_logs/src/test_util/example_mbed_logs.rs @@ -0,0 +1,14 @@ +macro_rules! mbed_log { + ($file:expr) => { + concat!("../../../../test_data/mbed_motor_control/", $file) + }; +} + +pub const MBED_MOTOR_CONTROL_PID_V1: &str = + mbed_log!("v1/20240926_121708/pid_20240926_121708_00.bin"); + +const TEST_DATA_V1: &str = + "../../test_data/mbed_motor_control/v1/20240926_121708/pid_20240926_121708_00.bin"; +const TEST_DATA_V2: &str = + "../../test_data/mbed_motor_control/v2/20241014_080729/pid_20241014_080729_00.bin"; +const TEST_DATA_V4: &str = "../../test_data/mbed_motor_control/v4/pid_20250120_092446_00.bin"; diff --git a/dist-workspace.toml b/dist-workspace.toml index 5e546cfb..d665c909 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -17,3 +17,8 @@ install-path = "CARGO_HOME" install-updater = false # Which actions to run on pull requests pr-run-mode = "upload" +github-build-setup = "build-setup.yml" + +[dist.github-custom-runners] +x86_64-apple-darwin = "macos-13" +aarch64-apple-darwin = "macos-14" # 14-15 are arm64 diff --git a/just/init.just b/just/init.just new file mode 100644 index 00000000..b908cb55 --- /dev/null +++ b/just/init.just @@ -0,0 +1,51 @@ +init: install-devtools install-hdf5-headers + echo "Run 'install-extra-devtools' for some adittional productivity tools that fit into the existent workflow" + +# Trunk is used to serve the app with a webserver, cargo-dist is used to generate and update workflows for distributing installers for various platforms +[doc("Install the required tools for performing all dev tasks for the project")] +install-devtools: + cargo install trunk --locked + cargo install cargo-dist --locked + cargo install typos-cli --locked + cargo install cargo-audit --locked + +# Install nice-to-have devtools +install-extra-devtools: + cargo install cargo-nextest --locked + cargo install cargo-limit --locked + cargo install bacon --locked + +[linux] +apt-install-hdf5-headers: + sudo apt install libhdf5-dev + +[windows] +msi-install-hdf5-headers: + #!/usr/bin/env bash + set -eo pipefail + VERSION="1.14.0" + DL_URL="https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-${VERSION}/bin/windows/hdf5-${VERSION}-Std-win10_64-vs16.zip" + # Download and extract HDF5 + curl -L -o hdf5.zip "${DL_URL}" + unzip hdf5.zip + if [[ "${GITHUB_ACTIONS}" == "true" ]]; then + just init::set-github-hdf5-env-vars "${VERSION}" + fi + +[windows] +set-github-hdf5-env-vars VERSION: + echo "HDF5_DIR=C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}" >> $GITHUB_ENV + echo "C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}\\bin" >> $GITHUB_PATH + +[macos] +brew-install-hdf5-headers: + brew install hdf5 + +[linux] +install-hdf5-headers: apt-install-hdf5-headers + +[macos] +install-hdf5-headers: brew-install-hdf5-headers + +[windows] +install-hdf5-headers: msi-install-hdf5-headers diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 35b1fc77..92d7c2a5 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.82" -components = [ "rustfmt", "clippy" ] -targets = [ "wasm32-unknown-unknown" ] \ No newline at end of file +channel = "1.81" +components = ["rustfmt", "clippy"] +targets = ["wasm32-unknown-unknown"] diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 1cadf417..00000000 --- a/src/lib.rs +++ /dev/null @@ -1,34 +0,0 @@ -#![warn(clippy::all, rust_2018_idioms)] - -use std::sync::OnceLock; - -pub use app::App; -use semver::Version; -mod app; - -pub const APP_NAME: &str = env!("CARGO_PKG_NAME"); -pub const APP_OWNER: &str = "luftkode"; - -#[cfg(not(target_arch = "wasm32"))] -pub const APP_ICON: &[u8] = include_bytes!("../assets/skytem-icon-256.png"); - -pub const APP_VERSION_MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR"); -pub const APP_VERSION_MINOR: &str = env!("CARGO_PKG_VERSION_MINOR"); -pub const APP_VERSION_PATCH: &str = env!("CARGO_PKG_VERSION_PATCH"); - -pub static APP_VERSION: OnceLock = OnceLock::new(); -pub fn get_app_version() -> &'static Version { - APP_VERSION.get_or_init(|| { - Version::new( - APP_VERSION_MAJOR.parse().expect("Invalid major version"), - APP_VERSION_MINOR.parse().expect("Invalid minor version"), - APP_VERSION_PATCH.parse().expect("Invalid patch version"), - ) - }) -} - -pub mod plot; -#[cfg(feature = "selfupdater")] -#[cfg(not(target_arch = "wasm32"))] -pub mod updater; -pub mod util; diff --git a/wix/main.wxs b/wix/main.wxs index afbc2d8d..6b173455 100644 --- a/wix/main.wxs +++ b/wix/main.wxs @@ -128,6 +128,14 @@ Source='$(var.CargoTargetBinDir)\plotinator3000.exe' KeyPath='yes'/> + + + @@ -150,6 +158,7 @@ +