diff --git a/.github/workflows/build_artifacts.yml b/.github/workflows/build_artifacts.yml new file mode 100644 index 0000000..ba35dd8 --- /dev/null +++ b/.github/workflows/build_artifacts.yml @@ -0,0 +1,56 @@ +name: Build Artifacts + +on: + workflow_dispatch: + push: + +jobs: + build-linux: + name: Build Linux + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: 'true' + - uses: arduino/setup-protoc@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install deps + run: | + git submodule update --init --recursive + sudo apt update + sudo apt install libwebkit2gtk-4.0-dev \ + build-essential \ + curl \ + wget \ + file \ + libssl-dev \ + libgtk-3-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + yarn + npm i -g vite + cd Ecdar-GUI-Web + npm install + git submodule update --init --recursive + cd .. + cargo install tauri-cli + cargo tauri build + - name: cargo build --release + uses: clechasseur/rs-cargo@v1 + with: + command: build + args: --release + - uses: actions/upload-artifact@v3 + with: + name: ecdar_app + path: target/release/ecdar_app + if-no-files-found: error + retention-days: 7 diff --git a/.github/workflows/check_format.yml b/.github/workflows/check_format.yml new file mode 100644 index 0000000..80b0001 --- /dev/null +++ b/.github/workflows/check_format.yml @@ -0,0 +1,54 @@ +name: Check formatting + +on: + workflow_dispatch: + push: + +jobs: + fmt: + name: cargo fmt & Clippy lint and check + runs-on: ubuntu-latest + steps: + - run: sudo apt-get install llvm protobuf-compiler + - uses: actions/checkout@v3 + with: + submodules: 'true' + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install deps + run: | + git submodule update --init --recursive + sudo apt update + sudo apt install libwebkit2gtk-4.0-dev \ + build-essential \ + curl \ + wget \ + file \ + libssl-dev \ + libgtk-3-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + yarn + npm i -g vite + cd Ecdar-GUI-Web + npm install + git submodule update --init --recursive + cd .. + cargo install tauri-cli + cargo tauri build + - name: cargo fmt --all + uses: clechasseur/rs-cargo@v1 + with: + command: fmt + args: --all -- --check + - name: clippy --all-targets --all-features + uses: clechasseur/rs-clippy-check@v3 + with: + args: --all-targets --all-features -- -D warnings diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..32f1376 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,49 @@ +name: Tests + +on: + workflow_dispatch: + push: + +jobs: + test-linux: + name: Tests Ubuntu + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: 'true' + - uses: arduino/setup-protoc@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install deps + run: | + git submodule update --init --recursive + sudo apt update + sudo apt install libwebkit2gtk-4.0-dev \ + build-essential \ + curl \ + wget \ + file \ + libssl-dev \ + libgtk-3-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev + npm i -g vite + cd Ecdar-GUI-Web + npm install + git submodule update --init --recursive + cd .. + cargo install tauri-cli + - name: cargo test + uses: clechasseur/rs-cargo@v1 + with: + command: test diff --git a/.github/workflows/test_format.yaml b/.github/workflows/test_format.yaml deleted file mode 100644 index 8753f0d..0000000 --- a/.github/workflows/test_format.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: Check formatting - -on: - push: - branches: [main] - pull_request: - branches: [main] - -permissions: - contents: read - -jobs: - fmt: - name: Cargo fmt lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - uses: Swatinem/rust-cache@v2 - - - name: Run fmt lint - run: cargo fmt --all -- --check - - clippy: - name: Cargo clippy lint - runs-on: ubuntu-latest - steps: - - # DO NOT EDIT THIS MANUALLY, please only use the official installation instructions from: - # https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux - - name: Install native Tauri dependencies - run: sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev - - - name: Install protobuf compiler - run: sudo apt-get install protobuf-compiler - - - uses: actions/checkout@v4 - with: - submodules: true - - - uses: Swatinem/rust-cache@v2 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: lts/* - cache: yarn - cache-dependency-path: 'Ecdar-GUI-Web/yarn.lock' - - - name: Install yarn dependencies - run: cd Ecdar-GUI-Web && yarn install - - - name: Run clippy lint - run: cargo clippy --all-targets -- -D warnings diff --git a/.gitignore b/.gitignore index 6985cf1..7aa7025 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + +.idea diff --git a/.gitmodules b/.gitmodules index f51a327..4af84f0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,7 @@ [submodule "Ecdar-GUI-Web"] path = Ecdar-GUI-Web - url = https://github.com/ECDAR-AAU-SW-P5/Ecdar-GUI-Web.git + url = https://github.com/Ecdar/Ecdar-GUI-Web +[submodule "Ecdar-ProtoBuf"] + path = Ecdar-ProtoBuf + url = https://github.com/Ecdar/Ecdar-ProtoBuf + branch = SW5 diff --git a/Cargo.toml b/Cargo.toml index c2ac7a8..49e3c39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,40 @@ -[workspace] -resolver = "2" -members = [ - "src-tauri", - "ecdar-gui-macros" -] +[package] +name = "ecdar_app" +version = "0.1.0" +description = "A Tauri App" +authors = ["Thomas Krogh Lohse"] +build = "src/build.rs" +license = "" +repository = "" +default-run = "ecdar_app" +edition = "2021" + +[lib] +proc-macro = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = { version = "1.4.0", features = [ ] } +tonic-build = "0.11.0" + +[dependencies] +serde_json = "1.0" +serde = { version = "1.0", features = ["derive"] } +tauri = { version = "1.4.0", features = [ "dialog-confirm", "dialog-save", "dialog-open", "fs-read-dir", "fs-create-dir", "fs-remove-dir", "fs-read-file", "fs-write-file", "fs-remove-file", "path-all" ] } +tauri-plugin-persisted-scope = "0.1.3" +tonic = "0.11.0" +prost = "0.12.3" +rand = "0.8.5" +tokio = "1.33.0" +ecdar-protobuf-transpiler = { git = "https://github.com/ECDAR-AAU-SW-P5/Ecdar-ProtoBuf-Transpiler-rs", version = "0.1.0" } +proc-macro2 = "1.0.69" +quote = "1.0.33" + + +[features] +# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled. +# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes. +# DO NOT REMOVE!! +custom-protocol = [ "tauri/custom-protocol" ] diff --git a/Ecdar-GUI-Web b/Ecdar-GUI-Web index 7b93e3f..699f37f 160000 --- a/Ecdar-GUI-Web +++ b/Ecdar-GUI-Web @@ -1 +1 @@ -Subproject commit 7b93e3f8f03a538fb992c86fcbe53eafda5deed2 +Subproject commit 699f37f72637871ad9f7e276cff2481585d24c17 diff --git a/Ecdar-ProtoBuf b/Ecdar-ProtoBuf new file mode 160000 index 0000000..f5ae959 --- /dev/null +++ b/Ecdar-ProtoBuf @@ -0,0 +1 @@ +Subproject commit f5ae9598ebd6de74e17a7a03ae1b0896ae322ef7 diff --git a/README.md b/README.md index 99c3e0d..b267c5d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ $ git clone https://github.com/ECDAR-AAU-SW-P5/Ecdar-GUI-Web.git #### Linux -Install `node`, `npm` and `cargo` +Install `node`, `npm` and `cargo`, along with [this guide for Tauri](https://tauri.app/v1/guides/getting-started/prerequisites/#setting-up-linux) ###### Arch ``` $ sudo pacman -S cargo nodejs npm @@ -32,8 +32,9 @@ $ sudo apt install cargo node npm ### Npm Dependencies ``` $ npm i -g vite -$ cd Ecdar-GUI-WEB +$ cd Ecdar-GUI-Web $ npm install +$ git submodule update --init --recursive $ cd .. ``` ### Cargo dependencies diff --git a/ecdar-gui-macros/Cargo.toml b/ecdar-gui-macros/Cargo.toml deleted file mode 100644 index 4e0418a..0000000 --- a/ecdar-gui-macros/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "ecdar-gui-macros" -version = "0.1.0" -edition = "2021" - -[lib] -proc-macro = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -ecdar-protobuf-transpiler = { git = "https://github.com/ECDAR-AAU-SW-P5/Ecdar-ProtoBuf-Transpiler-rs", version = "0.1.0" } -proc-macro2 = "1.0.69" -quote = "1.0.33" diff --git a/src-tauri/icons/128x128.png b/icons/128x128.png similarity index 100% rename from src-tauri/icons/128x128.png rename to icons/128x128.png diff --git a/src-tauri/icons/128x128@2x.png b/icons/128x128@2x.png similarity index 100% rename from src-tauri/icons/128x128@2x.png rename to icons/128x128@2x.png diff --git a/src-tauri/icons/32x32.png b/icons/32x32.png similarity index 100% rename from src-tauri/icons/32x32.png rename to icons/32x32.png diff --git a/src-tauri/icons/Square107x107Logo.png b/icons/Square107x107Logo.png similarity index 100% rename from src-tauri/icons/Square107x107Logo.png rename to icons/Square107x107Logo.png diff --git a/src-tauri/icons/Square142x142Logo.png b/icons/Square142x142Logo.png similarity index 100% rename from src-tauri/icons/Square142x142Logo.png rename to icons/Square142x142Logo.png diff --git a/src-tauri/icons/Square150x150Logo.png b/icons/Square150x150Logo.png similarity index 100% rename from src-tauri/icons/Square150x150Logo.png rename to icons/Square150x150Logo.png diff --git a/src-tauri/icons/Square284x284Logo.png b/icons/Square284x284Logo.png similarity index 100% rename from src-tauri/icons/Square284x284Logo.png rename to icons/Square284x284Logo.png diff --git a/src-tauri/icons/Square30x30Logo.png b/icons/Square30x30Logo.png similarity index 100% rename from src-tauri/icons/Square30x30Logo.png rename to icons/Square30x30Logo.png diff --git a/src-tauri/icons/Square310x310Logo.png b/icons/Square310x310Logo.png similarity index 100% rename from src-tauri/icons/Square310x310Logo.png rename to icons/Square310x310Logo.png diff --git a/src-tauri/icons/Square44x44Logo.png b/icons/Square44x44Logo.png similarity index 100% rename from src-tauri/icons/Square44x44Logo.png rename to icons/Square44x44Logo.png diff --git a/src-tauri/icons/Square71x71Logo.png b/icons/Square71x71Logo.png similarity index 100% rename from src-tauri/icons/Square71x71Logo.png rename to icons/Square71x71Logo.png diff --git a/src-tauri/icons/Square89x89Logo.png b/icons/Square89x89Logo.png similarity index 100% rename from src-tauri/icons/Square89x89Logo.png rename to icons/Square89x89Logo.png diff --git a/src-tauri/icons/StoreLogo.png b/icons/StoreLogo.png similarity index 100% rename from src-tauri/icons/StoreLogo.png rename to icons/StoreLogo.png diff --git a/src-tauri/icons/icon.icns b/icons/icon.icns similarity index 100% rename from src-tauri/icons/icon.icns rename to icons/icon.icns diff --git a/src-tauri/icons/icon.ico b/icons/icon.ico similarity index 100% rename from src-tauri/icons/icon.ico rename to icons/icon.ico diff --git a/src-tauri/icons/icon.png b/icons/icon.png similarity index 100% rename from src-tauri/icons/icon.png rename to icons/icon.png diff --git a/src-tauri/.gitignore b/src-tauri/.gitignore deleted file mode 100644 index aba21e2..0000000 --- a/src-tauri/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml deleted file mode 100644 index 5aa4acd..0000000 --- a/src-tauri/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "app" -version = "0.1.0" -description = "A Tauri App" -authors = ["you"] -license = "" -repository = "" -default-run = "app" -edition = "2021" -rust-version = "1.60" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[build-dependencies] -tauri-build = { version = "1.4.0", features = [ ] } - -[dependencies] -serde_json = "1.0" -serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.4.0", features = [ "dialog-confirm", "dialog-save", "dialog-open", "fs-read-dir", "fs-create-dir", "fs-remove-dir", "fs-read-file", "fs-write-file", "fs-remove-file", "path-all" ] } -tauri-plugin-persisted-scope = "0.1.3" -tonic = "0.10.2" -rand = "0.8.5" -tokio = "1.33.0" -ecdar-protobuf = { git = "https://github.com/ECDAR-AAU-SW-P5/Ecdar-ProtoBuf-rs", version = "0.1.0", features = ["client", "serde"] } -ecdar-gui-macros = { version = "0.1.0", path = "../ecdar-gui-macros" } - -[features] -# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled. -# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes. -# DO NOT REMOVE!! -custom-protocol = [ "tauri/custom-protocol" ] diff --git a/src-tauri/build.rs b/src-tauri/build.rs deleted file mode 100644 index d860e1e..0000000 --- a/src-tauri/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - tauri_build::build() -} diff --git a/src/build.rs b/src/build.rs new file mode 100644 index 0000000..30bbe91 --- /dev/null +++ b/src/build.rs @@ -0,0 +1,7 @@ +fn main() { + tonic_build::compile_protos("Ecdar-ProtoBuf/services.proto").unwrap(); + // Tell cargo to invalidate the crate when the protobuf repository changes + println!("cargo:rerun-if-changed=Ecdar-ProtoBuf"); + + tauri_build::build() +} diff --git a/ecdar-gui-macros/src/lib.rs b/src/lib.rs similarity index 100% rename from ecdar-gui-macros/src/lib.rs rename to src/lib.rs diff --git a/src-tauri/src/main.rs b/src/main.rs similarity index 67% rename from src-tauri/src/main.rs rename to src/main.rs index daf2e89..6a4d828 100644 --- a/src-tauri/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] -use tauri::Manager; +tonic::include_proto!("ecdar_proto_buf"); #[derive(serde::Serialize, serde::Deserialize)] pub enum GrpcError { @@ -9,19 +9,20 @@ pub enum GrpcError { FailedResponse, } -ecdar_gui_macros::create_functions!(); +//ecdar_app::create_functions!(); fn main() { tauri::Builder::default() .plugin(tauri_plugin_persisted_scope::init()) - .setup(|app| { + .setup(|_app| { #[cfg(debug_assertions)] { - app.get_window("main").unwrap().open_devtools(); + use tauri::Manager; + _app.get_window("main").unwrap().open_devtools(); } Ok(()) }) - .invoke_handler(ecdar_gui_macros::generate_handler![]) + //.invoke_handler(ecdar_app::generate_handler![]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/src-tauri/tauri.conf.json b/tauri.conf.json similarity index 97% rename from src-tauri/tauri.conf.json rename to tauri.conf.json index 26a966a..96671a7 100644 --- a/src-tauri/tauri.conf.json +++ b/tauri.conf.json @@ -3,7 +3,7 @@ "beforeBuildCommand": "yarn --cwd=./Ecdar-GUI-Web/ build", "beforeDevCommand": "yarn --cwd=./Ecdar-GUI-Web/ dev", "devPath": "http://localhost:5173", - "distDir": "../Ecdar-GUI-Web/build/", + "distDir": "./Ecdar-GUI-Web/build/", "withGlobalTauri" : true }, "package": {