From b96cbc53114daa0443d427567380da0538623406 Mon Sep 17 00:00:00 2001 From: Marc <72197092+CramBL@users.noreply.github.com> Date: Wed, 15 Jan 2025 22:41:44 +0100 Subject: [PATCH 01/36] enabled hdf feature for testing build --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6d02fbfb..00aca2ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,7 +73,7 @@ tempfile.workspace = true reqwest.workspace = true [features] -default = ["selfupdater"] +default = ["selfupdater", "hdf"] hdf = [] selfupdater = [] From 4d1441cd43ea4b9229329b1637e13d36131b7413 Mon Sep 17 00:00:00 2001 From: Marc <72197092+CramBL@users.noreply.github.com> Date: Wed, 15 Jan 2025 22:53:29 +0100 Subject: [PATCH 02/36] disable static linking crt on windows for testing --- .cargo/config.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ac2b23f8..b60f02d1 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ -[target.x86_64-pc-windows-msvc] -rustflags = ["-C", "target-feature=+crt-static"] +#[target.x86_64-pc-windows-msvc] +#rustflags = ["-C", "target-feature=+crt-static"] From 82c48b12537dde997ec02734d87ecd6434d3ae97 Mon Sep 17 00:00:00 2001 From: Marc <72197092+CramBL@users.noreply.github.com> Date: Fri, 17 Jan 2025 18:28:15 +0100 Subject: [PATCH 03/36] try remove hdf5 static feature --- crates/skytem_hdf/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ac81f73330ea21a4b185c1198e60cc94230aca30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 11:36:16 +0100 Subject: [PATCH 04/36] install hdf5 in check step --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9522aa1f..db6d5e86 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -42,6 +42,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: From a19239701fbbb363ddfe6e3e275818beca38ca46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 11:48:33 +0100 Subject: [PATCH 05/36] add hdf5 installs to test job --- .github/workflows/CI.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index db6d5e86..ec26b3a0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -72,7 +72,25 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: taiki-e/install-action@nextest - uses: Swatinem/rust-cache@v2 - - run: cargo nextest run --workspace --profile ci + + - name: Install HDF5 (Linux) + if: ${{ runner.os == 'Linux' }} + run: sudo apt-get update && sudo apt-get install -y libhdf5-dev + + - name: Install HDF5 (macOS) + if: ${{ runner.os == 'macOS' }} + run: brew install hdf5 + + - name: Install HDF5 (Windows) + if: ${{ runner.os == 'Windows' }} + run: | + git clone https://github.com/microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.bat -disableMetrics + ./vcpkg install hdf5:x64-windows + echo "VCPKG_ROOT=$(pwd)" >> $GITHUB_ENV + - name: Run tests + run: cargo nextest run --workspace --profile ci format: runs-on: ubuntu-latest From 99154c8a0f270f54b1c245696f24d8c07a262422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 13:08:58 +0100 Subject: [PATCH 06/36] use msi to install hdf5 on windows --- .github/workflows/CI.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ec26b3a0..d4991a63 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -83,12 +83,23 @@ jobs: - name: Install HDF5 (Windows) if: ${{ runner.os == 'Windows' }} + shell: bash run: | - git clone https://github.com/microsoft/vcpkg.git - cd vcpkg - ./bootstrap-vcpkg.bat -disableMetrics - ./vcpkg install hdf5:x64-windows - echo "VCPKG_ROOT=$(pwd)" >> $GITHUB_ENV + set -euo 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 + wget -q -O hdf5.zip "${DL_URL}" + 7z x hdf5.zip -y + + # Find and install MSI + MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) + msiexec /i "${MSI_PATH}" /quiet /qn /norestart + + # Set environment variables + echo "HDF5_DIR=C:\\Program Files\\HDF_Group\\HDF5\\${VERSION}" >> $GITHUB_ENV + echo "C:\\Program Files\\HDF_Group\\HDF5\\${VERSION}\\bin" >> $GITHUB_PATH - name: Run tests run: cargo nextest run --workspace --profile ci From 27d4261cf8c909d80091b719da96b0697cff8965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 13:10:14 +0100 Subject: [PATCH 07/36] install hdf5 headers for lint job --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d4991a63..fc27b466 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -121,6 +121,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 From bcce29c88bde1860b7aad54d672bf0e9debc37e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 13:44:41 +0100 Subject: [PATCH 08/36] add inits for hdf5 headers and move init recipes to init.just --- Justfile | 24 +--------------------- just/init.just | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 just/init.just 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/just/init.just b/just/init.just new file mode 100644 index 00000000..bf048fb0 --- /dev/null +++ b/just/init.just @@ -0,0 +1,55 @@ +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 RUNS_ON="native": + #!/usr/bin/env bash + set -euo 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}" + 7z x hdf5.zip -y + # Find and install MSI + MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) + msiexec /i "${MSI_PATH}" /quiet /qn /norestart + if [[ {{RUNS_ON}} == "GITHUB" ]]; then + just set-github-hdf5-env-vars ${VERSION} + fi + +[windows] +set-github-hdf5-env-vars VERSION: + #!/usr/bin/env bash + 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 From 57c7bf1ca5ba03c40702703e6ef5d351b21a8771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 13:44:47 +0100 Subject: [PATCH 09/36] use just for init recipes --- .github/workflows/CI.yml | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fc27b466..060d435d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -71,35 +71,12 @@ 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 - - name: Install HDF5 (Linux) - if: ${{ runner.os == 'Linux' }} - run: sudo apt-get update && sudo apt-get install -y libhdf5-dev - - - name: Install HDF5 (macOS) - if: ${{ runner.os == 'macOS' }} - run: brew install hdf5 - - - name: Install HDF5 (Windows) - if: ${{ runner.os == 'Windows' }} + - name: Install HDF5 shell: bash - run: | - set -euo 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 - wget -q -O hdf5.zip "${DL_URL}" - 7z x hdf5.zip -y - - # Find and install MSI - MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) - msiexec /i "${MSI_PATH}" /quiet /qn /norestart - - # Set environment variables - echo "HDF5_DIR=C:\\Program Files\\HDF_Group\\HDF5\\${VERSION}" >> $GITHUB_ENV - echo "C:\\Program Files\\HDF_Group\\HDF5\\${VERSION}\\bin" >> $GITHUB_PATH + run: just install-hdf5-headers - name: Run tests run: cargo nextest run --workspace --profile ci From 8f5abb4c1285f2f8615edb2e37048dcd03cde557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 13:49:32 +0100 Subject: [PATCH 10/36] set github env vars if the github env var is set to true --- just/init.just | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/just/init.just b/just/init.just index bf048fb0..3d6c7dc4 100644 --- a/just/init.just +++ b/just/init.just @@ -20,9 +20,9 @@ apt-install-hdf5-headers: sudo apt install libhdf5-dev [windows] -msi-install-hdf5-headers RUNS_ON="native": +msi-install-hdf5-headers: #!/usr/bin/env bash - set -euo pipefail + 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 @@ -31,7 +31,7 @@ msi-install-hdf5-headers RUNS_ON="native": # Find and install MSI MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) msiexec /i "${MSI_PATH}" /quiet /qn /norestart - if [[ {{RUNS_ON}} == "GITHUB" ]]; then + if [[ "${GITHUB_ACTIONS}" == "true" ]]; then just set-github-hdf5-env-vars ${VERSION} fi From 3794bac11f47225b3ed75230aa51733f920825e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 13:49:46 +0100 Subject: [PATCH 11/36] set just module --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 060d435d..949ad6b0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -76,7 +76,7 @@ jobs: - name: Install HDF5 shell: bash - run: just install-hdf5-headers + run: just init::install-hdf5-headers - name: Run tests run: cargo nextest run --workspace --profile ci From 905c14c3243684afd9a13985d6185d521532e78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 14:05:27 +0100 Subject: [PATCH 12/36] use unzip instead of 7z --- just/init.just | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/just/init.just b/just/init.just index 3d6c7dc4..4a9cc628 100644 --- a/just/init.just +++ b/just/init.just @@ -27,7 +27,7 @@ msi-install-hdf5-headers: 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}" - 7z x hdf5.zip -y + unzip hdf5.zip # Find and install MSI MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) msiexec /i "${MSI_PATH}" /quiet /qn /norestart From 696640ed579d6eca730b4a76708c4ad1fa773458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 14:31:23 +0100 Subject: [PATCH 13/36] run the MSI installer in a separate step to ensure it's run through powershell --- .github/workflows/CI.yml | 8 ++++++++ just/init.just | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 949ad6b0..0b2e40fb 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: @@ -77,6 +79,12 @@ jobs: - name: Install HDF5 shell: bash run: just init::install-hdf5-headers + + - name: Run MSI installer (windows) + if: runner.os == 'Windows' + shell: pwsh + run: just run-msi-installer "${HDF5_MSI_INSTALLER_PATH}" + - name: Run tests run: cargo nextest run --workspace --profile ci diff --git a/just/init.just b/just/init.just index 4a9cc628..79101873 100644 --- a/just/init.just +++ b/just/init.just @@ -30,14 +30,17 @@ msi-install-hdf5-headers: unzip hdf5.zip # Find and install MSI MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) - msiexec /i "${MSI_PATH}" /quiet /qn /norestart if [[ "${GITHUB_ACTIONS}" == "true" ]]; then - just set-github-hdf5-env-vars ${VERSION} + just init::set-github-hdf5-env-vars ${VERSION} fi +[windows] +run-msi-installer MSI_PATH: + msiexec /i "{{MSI_PATH}}" /quiet /qn /norestart + [windows] set-github-hdf5-env-vars VERSION: - #!/usr/bin/env bash + echo "HDF5_MSI_INSTALLER_PATH" >> $GITHUB_ENV echo "HDF5_DIR=C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}" >> $GITHUB_ENV echo "C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}\\bin" >> $GITHUB_PATH From c77a3034d59523a63b909a6aca996a98db4a6266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 14:36:40 +0100 Subject: [PATCH 14/36] forgot to set msi installer path --- just/init.just | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/just/init.just b/just/init.just index 79101873..ea5ed9c2 100644 --- a/just/init.just +++ b/just/init.just @@ -31,7 +31,7 @@ msi-install-hdf5-headers: # Find and install MSI MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) if [[ "${GITHUB_ACTIONS}" == "true" ]]; then - just init::set-github-hdf5-env-vars ${VERSION} + just init::set-github-hdf5-env-vars "${VERSION}" "${MSI_PATH}" fi [windows] @@ -39,8 +39,8 @@ run-msi-installer MSI_PATH: msiexec /i "{{MSI_PATH}}" /quiet /qn /norestart [windows] -set-github-hdf5-env-vars VERSION: - echo "HDF5_MSI_INSTALLER_PATH" >> $GITHUB_ENV +set-github-hdf5-env-vars VERSION HDF5_MSI_INSTALLER_PATH: + echo "HDF5_MSI_INSTALLER_PATH={{HDF5_MSI_INSTALLER_PATH}}" >> $GITHUB_ENV echo "HDF5_DIR=C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}" >> $GITHUB_ENV echo "C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}\\bin" >> $GITHUB_PATH From ad40dcfdab1ef34fc24cccdc6ef71585e2b6a1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 14:40:45 +0100 Subject: [PATCH 15/36] set just module --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0b2e40fb..cee8459b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -83,7 +83,7 @@ jobs: - name: Run MSI installer (windows) if: runner.os == 'Windows' shell: pwsh - run: just run-msi-installer "${HDF5_MSI_INSTALLER_PATH}" + run: just init::run-msi-installer "${HDF5_MSI_INSTALLER_PATH}" - name: Run tests run: cargo nextest run --workspace --profile ci From 08d8c52af0e537f96ee8b6d6d57b0499fb0be237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 14:55:03 +0100 Subject: [PATCH 16/36] powershell style --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cee8459b..db5c563b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -83,7 +83,7 @@ jobs: - name: Run MSI installer (windows) if: runner.os == 'Windows' shell: pwsh - run: just init::run-msi-installer "${HDF5_MSI_INSTALLER_PATH}" + run: just init::run-msi-installer "$env:HDF5_MSI_INSTALLER_PATH" - name: Run tests run: cargo nextest run --workspace --profile ci From 6929db1a81e312a1ecbc4c4ec31b3fd13ec20392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 15:10:29 +0100 Subject: [PATCH 17/36] run msiexec directly and not through just --- .github/workflows/CI.yml | 2 +- just/init.just | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index db5c563b..b4e30d6b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -83,7 +83,7 @@ jobs: - name: Run MSI installer (windows) if: runner.os == 'Windows' shell: pwsh - run: just init::run-msi-installer "$env:HDF5_MSI_INSTALLER_PATH" + run: msiexec /i ${{env.HDF5_MSI_INSTALLER_PATH}} /quiet /qn /norestart - name: Run tests run: cargo nextest run --workspace --profile ci diff --git a/just/init.just b/just/init.just index ea5ed9c2..0ad9b9da 100644 --- a/just/init.just +++ b/just/init.just @@ -34,10 +34,6 @@ msi-install-hdf5-headers: just init::set-github-hdf5-env-vars "${VERSION}" "${MSI_PATH}" fi -[windows] -run-msi-installer MSI_PATH: - msiexec /i "{{MSI_PATH}}" /quiet /qn /norestart - [windows] set-github-hdf5-env-vars VERSION HDF5_MSI_INSTALLER_PATH: echo "HDF5_MSI_INSTALLER_PATH={{HDF5_MSI_INSTALLER_PATH}}" >> $GITHUB_ENV From 573079b3b7115540578cf0774f0c747a14196dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 15:20:03 +0100 Subject: [PATCH 18/36] resolve MSI_PATH to absolute path --- just/init.just | 1 + 1 file changed, 1 insertion(+) diff --git a/just/init.just b/just/init.just index 0ad9b9da..b382245a 100644 --- a/just/init.just +++ b/just/init.just @@ -30,6 +30,7 @@ msi-install-hdf5-headers: unzip hdf5.zip # Find and install MSI MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) + MSI_PATH=$(realpath "${MSI_PATH}") if [[ "${GITHUB_ACTIONS}" == "true" ]]; then just init::set-github-hdf5-env-vars "${VERSION}" "${MSI_PATH}" fi From 215bda08aa31d40c7f9ac84aaab7e862e4d9942f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 15:25:30 +0100 Subject: [PATCH 19/36] hardcode path --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b4e30d6b..f9743e0a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -83,7 +83,7 @@ jobs: - name: Run MSI installer (windows) if: runner.os == 'Windows' shell: pwsh - run: msiexec /i ${{env.HDF5_MSI_INSTALLER_PATH}} /quiet /qn /norestart + run: msiexec /i .\just\hdf\HDF5-1.14.0-win64.msi /quiet /qn /norestart - name: Run tests run: cargo nextest run --workspace --profile ci From 42a696f66e4340c112e8cac06bdcf37bc49c4369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 16:15:31 +0100 Subject: [PATCH 20/36] ls directory contents --- .github/workflows/CI.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f9743e0a..709e4bef 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -83,7 +83,11 @@ jobs: - name: Run MSI installer (windows) if: runner.os == 'Windows' shell: pwsh - run: msiexec /i .\just\hdf\HDF5-1.14.0-win64.msi /quiet /qn /norestart + run: | + ls + ls just + ls .\just\hdf + msiexec /i .\just\hdf\HDF5-1.14.0-win64.msi /quiet /qn /norestart - name: Run tests run: cargo nextest run --workspace --profile ci From b482db3b84814673997a0269673cf1371eaedfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 16:17:36 +0100 Subject: [PATCH 21/36] list contents --- .github/workflows/CI.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 709e4bef..296370c7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -87,7 +87,12 @@ jobs: ls ls just ls .\just\hdf - msiexec /i .\just\hdf\HDF5-1.14.0-win64.msi /quiet /qn /norestart + ls .\just\hdf\*msi + + - name: Run MSI installer (windows) + if: runner.os == 'Windows' + shell: pwsh + run: msiexec /i .\just\hdf\HDF5-1.14.0-win64.msi /quiet /qn /norestart - name: Run tests run: cargo nextest run --workspace --profile ci From 58eba0cde8c7209cad7e48e9c187cacb2037ad69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 16:25:45 +0100 Subject: [PATCH 22/36] tweak --- .github/workflows/CI.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 296370c7..ca5f62fe 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -83,16 +83,15 @@ jobs: - name: Run MSI installer (windows) if: runner.os == 'Windows' shell: pwsh - run: | - ls - ls just - ls .\just\hdf - ls .\just\hdf\*msi + run: ls .\just\hdf - name: Run MSI installer (windows) if: runner.os == 'Windows' shell: pwsh - run: msiexec /i .\just\hdf\HDF5-1.14.0-win64.msi /quiet /qn /norestart + working-directory: just\hdf + run: | + ls + msiexec /i HDF5-1.14.0-win64.msi /quiet /qn /norestart - name: Run tests run: cargo nextest run --workspace --profile ci From e96a9b0c414433d3f0262d4975cca536cfbb5853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 16:35:56 +0100 Subject: [PATCH 23/36] dont set MSI_PATH --- just/init.just | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/just/init.just b/just/init.just index b382245a..b2f810ac 100644 --- a/just/init.just +++ b/just/init.just @@ -28,16 +28,12 @@ msi-install-hdf5-headers: # Download and extract HDF5 curl -L -o hdf5.zip "${DL_URL}" unzip hdf5.zip - # Find and install MSI - MSI_PATH=$(find . -name "HDF5-${VERSION}-win64.msi" | head -n 1) - MSI_PATH=$(realpath "${MSI_PATH}") if [[ "${GITHUB_ACTIONS}" == "true" ]]; then - just init::set-github-hdf5-env-vars "${VERSION}" "${MSI_PATH}" + just init::set-github-hdf5-env-vars "${VERSION}" fi [windows] set-github-hdf5-env-vars VERSION HDF5_MSI_INSTALLER_PATH: - echo "HDF5_MSI_INSTALLER_PATH={{HDF5_MSI_INSTALLER_PATH}}" >> $GITHUB_ENV echo "HDF5_DIR=C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}" >> $GITHUB_ENV echo "C:\\Program Files\\HDF_Group\\HDF5\\{{VERSION}}\\bin" >> $GITHUB_PATH From 181ed3eed107c241fb8db978188d41f6c60af10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 16:36:02 +0100 Subject: [PATCH 24/36] simplify --- .github/workflows/CI.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ca5f62fe..693d2f86 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -83,14 +83,8 @@ jobs: - name: Run MSI installer (windows) if: runner.os == 'Windows' shell: pwsh - run: ls .\just\hdf - - - name: Run MSI installer (windows) - if: runner.os == 'Windows' - shell: pwsh - working-directory: just\hdf run: | - ls + cd just\hdf msiexec /i HDF5-1.14.0-win64.msi /quiet /qn /norestart - name: Run tests From 9f866d7ab41dcd7417c4200f9e36318b43f2edb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 16:39:41 +0100 Subject: [PATCH 25/36] tweak --- .github/workflows/CI.yml | 15 +++++++++++++-- just/init.just | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 693d2f86..7e83a4c3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -176,12 +176,12 @@ jobs: - name: Building ${{ matrix.TARGET }} run: echo "${{ matrix.TARGET }}" - - uses: actions/checkout@master - + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.TARGET }} + - uses: extractions/setup-just@v2 - uses: Swatinem/rust-cache@v2 with: # this is required to avoid failures due to caching of artifacts for different architectures @@ -190,6 +190,17 @@ jobs: # different architectures (and native) with cross on the generic ubuntu-latest. key: ${{ matrix.TARGET }} + - 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 + - if: ${{ !matrix.cross }} name: Cargo Build run: cargo build --verbose --release --target=${{ matrix.TARGET }} diff --git a/just/init.just b/just/init.just index b2f810ac..b908cb55 100644 --- a/just/init.just +++ b/just/init.just @@ -33,7 +33,7 @@ msi-install-hdf5-headers: fi [windows] -set-github-hdf5-env-vars VERSION HDF5_MSI_INSTALLER_PATH: +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 From ad4d46bb3e33476515209dbdb6055526ef4950b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 18:16:53 +0100 Subject: [PATCH 26/36] add build-setup for installing hdf headers --- .github/workflows/build-setup.yml | 12 ++++++++++++ .github/workflows/release.yml | 11 +++++++++++ Cargo.toml | 1 - dist-workspace.toml | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-setup.yml 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.toml b/Cargo.toml index 666274fb..11d382c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,6 @@ license = false eula = false product-icon = "assets/favicon.ico" - [workspace] members = ["crates/*"] diff --git a/dist-workspace.toml b/dist-workspace.toml index 5e546cfb..e9da81c6 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -17,3 +17,4 @@ install-path = "CARGO_HOME" install-updater = false # Which actions to run on pull requests pr-run-mode = "upload" +github-build-setup = "build-setup.yml" From 22c512d2b0ec65b8e86a7970f802af1016985181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 18:46:31 +0100 Subject: [PATCH 27/36] set runners for macos archs --- dist-workspace.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dist-workspace.toml b/dist-workspace.toml index e9da81c6..d665c909 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -18,3 +18,7 @@ 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 From 8d509c0479e3572f4a1e81dc6036021d396aa48e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 18:57:18 +0100 Subject: [PATCH 28/36] remove superfluous builds --- .github/workflows/CI.yml | 89 +--------------------------------------- 1 file changed, 1 insertion(+), 88 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7e83a4c3..0cb7eb01 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -130,95 +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@v4 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.TARGET }} - - - uses: extractions/setup-just@v2 - - 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 }} - - - 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 - - - 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: From b6ee73c831a93e07856e754b20d893af4c34be91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 19:01:51 +0100 Subject: [PATCH 29/36] re-enable static vsCRT linking --- .cargo/config.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index b60f02d1..ac2b23f8 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ -#[target.x86_64-pc-windows-msvc] -#rustflags = ["-C", "target-feature=+crt-static"] +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"] From b2dfd6f39b1dd8c037c3d70e04192efc07b17d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 20:11:23 +0100 Subject: [PATCH 30/36] minimal main --- src/lib.rs | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 82 +-------------------------------------------------- 2 files changed, 85 insertions(+), 81 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1cadf417..1cb5b9fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,3 +32,87 @@ pub mod plot; #[cfg(not(target_arch = "wasm32"))] pub mod updater; pub mod util; + +// When compiling natively: +#[cfg(not(target_arch = "wasm32"))] +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() { + Ok(needs_restart) => { + if needs_restart { + return Ok(()); + } + } + Err(e) => { + return Err(eframe::Error::AppCreation( + format!("Error in updater: {e}").into(), + )) + } + } + + let native_options = eframe::NativeOptions { + viewport: egui::ViewportBuilder::default() + .with_inner_size([800.0, 800.0]) + .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"), + ), + ..Default::default() + }; + eframe::run_native( + &format!("Plotinator3000 v{}", env!("CARGO_PKG_VERSION")), + native_options, + Box::new(|cc| Ok(Box::new(plotinator3000::App::new(cc)))), + ) +} + +// When compiling to web using trunk: +#[cfg(target_arch = "wasm32")] +pub fn run_app() { + use eframe::wasm_bindgen::JsCast as _; + // Redirect `log` message to `console.log` and friends: + _ = eframe::WebLogger::init(log::LevelFilter::Debug).ok(); + + let web_options = eframe::WebOptions::default(); + + wasm_bindgen_futures::spawn_local(async { + let document = web_sys::window() + .expect("No window") + .document() + .expect("No document"); + + let canvas = document + .get_element_by_id("the_canvas_id") + .expect("Failed to find the_canvas_id") + .dyn_into::() + .expect("the_canvas_id was not a HtmlCanvasElement"); + + let start_result = eframe::WebRunner::new() + .start( + canvas, + web_options, + Box::new(|cc| Ok(Box::new(plotinator3000::App::new(cc)))), + ) + .await; + + // Remove the loading text and spinner: + if let Some(loading_text) = document.get_element_by_id("loading_text") { + match start_result { + Ok(_) => { + loading_text.remove(); + } + Err(e) => { + loading_text.set_inner_html( + "

The app has crashed. See the developer console for details.

", + ); + panic!("Failed to start eframe: {e:?}"); + } + } + } + }); +} diff --git a/src/main.rs b/src/main.rs index c0b16050..f9833704 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,86 +1,6 @@ #![warn(clippy::all, rust_2018_idioms)] #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release -// When compiling natively: -#[cfg(not(target_arch = "wasm32"))] fn main() -> eframe::Result { - // Log to stderr (if run with `RUST_LOG=debug`). - env_logger::init(); - - #[cfg(feature = "selfupdater")] - match plotinator3000::updater::update_if_applicable() { - Ok(needs_restart) => { - if needs_restart { - return Ok(()); - } - } - Err(e) => { - return Err(eframe::Error::AppCreation( - format!("Error in updater: {e}").into(), - )) - } - } - - let native_options = eframe::NativeOptions { - viewport: egui::ViewportBuilder::default() - .with_inner_size([800.0, 800.0]) - .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"), - ), - ..Default::default() - }; - eframe::run_native( - &format!("Plotinator3000 v{}", env!("CARGO_PKG_VERSION")), - native_options, - Box::new(|cc| Ok(Box::new(plotinator3000::App::new(cc)))), - ) -} - -// When compiling to web using trunk: -#[cfg(target_arch = "wasm32")] -fn main() { - use eframe::wasm_bindgen::JsCast as _; - // Redirect `log` message to `console.log` and friends: - _ = eframe::WebLogger::init(log::LevelFilter::Debug).ok(); - - let web_options = eframe::WebOptions::default(); - - wasm_bindgen_futures::spawn_local(async { - let document = web_sys::window() - .expect("No window") - .document() - .expect("No document"); - - let canvas = document - .get_element_by_id("the_canvas_id") - .expect("Failed to find the_canvas_id") - .dyn_into::() - .expect("the_canvas_id was not a HtmlCanvasElement"); - - let start_result = eframe::WebRunner::new() - .start( - canvas, - web_options, - Box::new(|cc| Ok(Box::new(plotinator3000::App::new(cc)))), - ) - .await; - - // Remove the loading text and spinner: - if let Some(loading_text) = document.get_element_by_id("loading_text") { - match start_result { - Ok(_) => { - loading_text.remove(); - } - Err(e) => { - loading_text.set_inner_html( - "

The app has crashed. See the developer console for details.

", - ); - panic!("Failed to start eframe: {e:?}"); - } - } - } - }); + crate::run_app() } From 107e3f5046e4816be79f631e605cbd0fc3867ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 20:21:26 +0100 Subject: [PATCH 31/36] tweak --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1cb5b9fe..720095c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![warn(clippy::all, rust_2018_idioms)] use std::sync::OnceLock; - +use eframe::App; pub use app::App; use semver::Version; mod app; @@ -40,7 +40,7 @@ pub fn run_app() -> eframe::Result { 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(()); @@ -59,7 +59,7 @@ pub fn run_app() -> 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) + eframe::icon_data::from_png_bytes(crate::APP_ICON) .expect("Failed to load icon"), ), ..Default::default() @@ -67,7 +67,7 @@ pub fn run_app() -> eframe::Result { 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)))), ) } @@ -96,7 +96,7 @@ pub fn run_app() { .start( canvas, web_options, - Box::new(|cc| Ok(Box::new(plotinator3000::App::new(cc)))), + Box::new(|cc| Ok(Box::new(App::new(cc)))), ) .await; From bd8a15929d5b77d90b9fc927e1c51aee790f8c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 21:14:56 +0100 Subject: [PATCH 32/36] tweaks --- src/lib.rs | 6 +++--- src/main.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 720095c0..9c9f2528 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,9 @@ #![warn(clippy::all, rust_2018_idioms)] use std::sync::OnceLock; -use eframe::App; -pub use app::App; use semver::Version; mod app; +use crate::app::App; pub const APP_NAME: &str = env!("CARGO_PKG_NAME"); pub const APP_OWNER: &str = "luftkode"; @@ -73,7 +72,7 @@ pub fn run_app() -> eframe::Result { // When compiling to web using trunk: #[cfg(target_arch = "wasm32")] -pub fn run_app() { +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(); @@ -115,4 +114,5 @@ pub fn run_app() { } } }); + Ok(()) } diff --git a/src/main.rs b/src/main.rs index f9833704..8c76e9af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,5 +2,5 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release fn main() -> eframe::Result { - crate::run_app() + plotinator3000::run_app() } From ed6ca9901ce450d411512def4e812d874605ee07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 21:17:21 +0100 Subject: [PATCH 33/36] fmt --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9c9f2528..1a404a99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![warn(clippy::all, rust_2018_idioms)] -use std::sync::OnceLock; use semver::Version; +use std::sync::OnceLock; mod app; use crate::app::App; @@ -58,8 +58,7 @@ pub fn run_app() -> eframe::Result { .with_min_inner_size([100.0, 80.0]) .with_drag_and_drop(true) .with_icon( - eframe::icon_data::from_png_bytes(crate::APP_ICON) - .expect("Failed to load icon"), + eframe::icon_data::from_png_bytes(crate::APP_ICON).expect("Failed to load icon"), ), ..Default::default() }; From c77ecbca1544547ba4af875bcc471ff93f116d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 21:21:12 +0100 Subject: [PATCH 34/36] lockfile --- Cargo.lock | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e22497a..d632df21 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", From 8ed85f903b785a6c5242af4e57521f006f70333a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Beck=20K=C3=B6nig?= Date: Sat, 1 Feb 2025 23:07:38 +0100 Subject: [PATCH 35/36] build another binary alongside with hdf5 features --- Cargo.toml | 21 ++++++++++++++++----- src/main_h5.rs | 9 +++++++++ wix/main.wxs | 9 +++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 src/main_h5.rs diff --git a/Cargo.toml b/Cargo.toml index 11d382c3..99298687 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,21 @@ repository = "https://github.com/luftkode/plotinator3000" homepage = "https://github.com/luftkode/plotinator3000" license = "MIT OR Apache-2.0" +[[bin]] +name = "plotinator3000" +path = "src/main.rs" +required-features = ["selfupdater"] + +[[bin]] +name = "plotinator3000-h5" +path = "src/main_h5.rs" +required-features = ["hdf"] + +[features] +default = ["selfupdater"] +hdf = ["skytem_hdf"] +selfupdater = [] + [package.metadata.wix] upgrade-guid = "7063C05B-24FE-4CE5-A338-6D750F3F10CE" path-guid = "025605DB-83DB-4162-B505-26B36C02D0B9" @@ -46,7 +61,7 @@ reqwest = "0.12.12" 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" } +skytem_hdf = { version = "*", path = "crates/skytem_hdf", optional = true } egui_plot.workspace = true log.workspace = true serde.workspace = true @@ -73,10 +88,6 @@ testresult.workspace = true tempfile.workspace = true reqwest.workspace = true -[features] -default = ["selfupdater", "hdf"] -hdf = [] -selfupdater = [] # native: [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/src/main_h5.rs b/src/main_h5.rs new file mode 100644 index 00000000..b7b8bb62 --- /dev/null +++ b/src/main_h5.rs @@ -0,0 +1,9 @@ +#[cfg(feature = "hdf")] +fn main() -> eframe::Result { + plotinator3000::run_app() +} + +#[cfg(not(feature = "hdf"))] +fn main() { + panic!("This binary requires the HDF feature to be enabled"); +} 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 @@ + Date: Sun, 2 Feb 2025 13:15:18 +0100 Subject: [PATCH 36/36] wip --- Cargo.lock | 16 +- Cargo.toml | 107 ++------ crates/plotinator-lib/Cargo.toml | 59 +++++ {src => crates/plotinator-lib/src}/app.rs | 0 .../plotinator-lib/src}/app/dropped_files.rs | 0 .../src}/app/dropped_files/preview_dropped.rs | 0 .../plotinator-lib/src}/app/file_dialog.rs | 0 .../src}/app/file_dialog/native.rs | 0 .../src}/app/file_dialog/web.rs | 0 .../src}/app/supported_formats.rs | 0 .../src}/app/supported_formats/hdf.rs | 0 .../src}/app/supported_formats/logs.rs | 0 .../app/supported_formats/logs/parse_info.rs | 0 .../src}/app/supported_formats/util.rs | 0 .../plotinator-lib/src}/app/util.rs | 0 {src => crates/plotinator-lib/src}/lib.rs | 2 +- {src => crates/plotinator-lib/src}/plot.rs | 0 .../plotinator-lib/src}/plot/axis_config.rs | 0 .../src}/plot/axis_config/axis_lock.rs | 0 .../plotinator-lib/src}/plot/click_delta.rs | 0 .../plotinator-lib/src}/plot/plot_graphics.rs | 0 .../plotinator-lib/src}/plot/plot_settings.rs | 0 .../src}/plot/plot_settings/date_settings.rs | 0 .../src}/plot/plot_settings/loaded_logs.rs | 0 .../plot/plot_settings/mipmap_settings.rs | 0 .../src}/plot/plot_settings/plot_filter.rs | 0 .../plot_settings/plot_visibility_config.rs | 0 .../plotinator-lib/src}/plot/plot_ui.rs | 0 .../plotinator-lib/src}/plot/util.rs | 0 {src => crates/plotinator-lib/src}/updater.rs | 0 .../plotinator-lib/src}/updater/ui.rs | 0 .../src}/updater/ui/error_window.rs | 0 .../src}/updater/ui/pre_admin_window.rs | 0 .../src}/updater/ui/updates_disabled.rs | 0 {src => crates/plotinator-lib/src}/util.rs | 0 crates/plotinator3000-h5/Cargo.toml | 22 ++ {src => crates/plotinator3000-h5/src}/main.rs | 4 +- crates/plotinator3000-h5/wix/main.wxs | 228 ++++++++++++++++++ crates/plotinator3000/Cargo.toml | 24 ++ crates/plotinator3000/src/main.rs | 6 + crates/plotinator3000/wix/main.wxs | 226 +++++++++++++++++ crates/skytem_logs/src/lib.rs | 3 + .../src/mbed_motor_control/pid/pidlog.rs | 1 + crates/skytem_logs/src/test_util.rs | 1 + .../src/test_util/example_mbed_logs.rs | 14 ++ rust-toolchain.toml | 6 +- src/main_h5.rs | 9 - 47 files changed, 630 insertions(+), 98 deletions(-) create mode 100644 crates/plotinator-lib/Cargo.toml rename {src => crates/plotinator-lib/src}/app.rs (100%) rename {src => crates/plotinator-lib/src}/app/dropped_files.rs (100%) rename {src => crates/plotinator-lib/src}/app/dropped_files/preview_dropped.rs (100%) rename {src => crates/plotinator-lib/src}/app/file_dialog.rs (100%) rename {src => crates/plotinator-lib/src}/app/file_dialog/native.rs (100%) rename {src => crates/plotinator-lib/src}/app/file_dialog/web.rs (100%) rename {src => crates/plotinator-lib/src}/app/supported_formats.rs (100%) rename {src => crates/plotinator-lib/src}/app/supported_formats/hdf.rs (100%) rename {src => crates/plotinator-lib/src}/app/supported_formats/logs.rs (100%) rename {src => crates/plotinator-lib/src}/app/supported_formats/logs/parse_info.rs (100%) rename {src => crates/plotinator-lib/src}/app/supported_formats/util.rs (100%) rename {src => crates/plotinator-lib/src}/app/util.rs (100%) rename {src => crates/plotinator-lib/src}/lib.rs (97%) rename {src => crates/plotinator-lib/src}/plot.rs (100%) rename {src => crates/plotinator-lib/src}/plot/axis_config.rs (100%) rename {src => crates/plotinator-lib/src}/plot/axis_config/axis_lock.rs (100%) rename {src => crates/plotinator-lib/src}/plot/click_delta.rs (100%) rename {src => crates/plotinator-lib/src}/plot/plot_graphics.rs (100%) rename {src => crates/plotinator-lib/src}/plot/plot_settings.rs (100%) rename {src => crates/plotinator-lib/src}/plot/plot_settings/date_settings.rs (100%) rename {src => crates/plotinator-lib/src}/plot/plot_settings/loaded_logs.rs (100%) rename {src => crates/plotinator-lib/src}/plot/plot_settings/mipmap_settings.rs (100%) rename {src => crates/plotinator-lib/src}/plot/plot_settings/plot_filter.rs (100%) rename {src => crates/plotinator-lib/src}/plot/plot_settings/plot_visibility_config.rs (100%) rename {src => crates/plotinator-lib/src}/plot/plot_ui.rs (100%) rename {src => crates/plotinator-lib/src}/plot/util.rs (100%) rename {src => crates/plotinator-lib/src}/updater.rs (100%) rename {src => crates/plotinator-lib/src}/updater/ui.rs (100%) rename {src => crates/plotinator-lib/src}/updater/ui/error_window.rs (100%) rename {src => crates/plotinator-lib/src}/updater/ui/pre_admin_window.rs (100%) rename {src => crates/plotinator-lib/src}/updater/ui/updates_disabled.rs (100%) rename {src => crates/plotinator-lib/src}/util.rs (100%) create mode 100644 crates/plotinator3000-h5/Cargo.toml rename {src => crates/plotinator3000-h5/src}/main.rs (67%) create mode 100644 crates/plotinator3000-h5/wix/main.wxs create mode 100644 crates/plotinator3000/Cargo.toml create mode 100644 crates/plotinator3000/src/main.rs create mode 100644 crates/plotinator3000/wix/main.wxs create mode 100644 crates/skytem_logs/src/test_util.rs create mode 100644 crates/skytem_logs/src/test_util/example_mbed_logs.rs delete mode 100644 src/main_h5.rs diff --git a/Cargo.lock b/Cargo.lock index d632df21..3069e380 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3053,7 +3053,7 @@ dependencies = [ ] [[package]] -name = "plotinator3000" +name = "plotinator-lib" version = "1.6.4" dependencies = [ "axoupdater", @@ -3085,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 99298687..a3158165 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,41 +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" - -[[bin]] -name = "plotinator3000" -path = "src/main.rs" -required-features = ["selfupdater"] - -[[bin]] -name = "plotinator3000-h5" -path = "src/main_h5.rs" -required-features = ["hdf"] - -[features] -default = ["selfupdater"] -hdf = ["skytem_hdf"] -selfupdater = [] - -[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" @@ -57,54 +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", optional = 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 = { 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 - - -# 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 @@ -121,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/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/lib.rs b/crates/plotinator-lib/src/lib.rs similarity index 97% rename from src/lib.rs rename to crates/plotinator-lib/src/lib.rs index 1a404a99..0eab5b7c 100644 --- a/src/lib.rs +++ b/crates/plotinator-lib/src/lib.rs @@ -9,7 +9,7 @@ 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_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"); 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/src/main.rs b/crates/plotinator3000-h5/src/main.rs similarity index 67% rename from src/main.rs rename to crates/plotinator3000-h5/src/main.rs index 8c76e9af..f303d874 100644 --- a/src/main.rs +++ b/crates/plotinator3000-h5/src/main.rs @@ -1,6 +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() -> eframe::Result { - plotinator3000::run_app() +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_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/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/main_h5.rs b/src/main_h5.rs deleted file mode 100644 index b7b8bb62..00000000 --- a/src/main_h5.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[cfg(feature = "hdf")] -fn main() -> eframe::Result { - plotinator3000::run_app() -} - -#[cfg(not(feature = "hdf"))] -fn main() { - panic!("This binary requires the HDF feature to be enabled"); -}