diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0630159..312f34ca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: run: | apt-get update apt-get upgrade -y - apt-get install -y git curl unzip clang gpg + apt-get install -y git curl unzip clang gpg just - uses: actions/checkout@v4 with: @@ -25,8 +25,6 @@ jobs: - name: Install dependencies run: | apt-get install -y libdbus-1-dev pkg-config libgtk-4-dev libadwaita-1-dev gettext libfuse2 - - name: Install cargo-make - run: cargo install cargo-make - name: Install appimage-builder run: | curl --location -o appimage-builder https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage @@ -92,19 +90,10 @@ jobs: rust:p pkg-config:p - # cargo-make does not use the current shell to run "cargo build". It spawns a new shell, and on Windows, that's cmd. - # Rather than trying to get cargo-make to conditionally use the msys2 shell, we can just get anything that would - # interfere out of the path. - # We want to use the msys2 cargo and linker, so that means cargo and visual studio need to be removed from the path. - - name: Remove Visual Studio and cargo from path - run: | - Move-Item -Path "C:\Program Files\Microsoft Visual Studio" -Destination "C:\Program Files\_Microsoft Visual Studio" - Move-Item -Path "~\.cargo" -Destination "~\._cargo" - - - name: Install cargo-make + - name: Install just shell: msys2 {0} run: | - cargo install cargo-make + cargo install just - name: Build gui shell: msys2 {0} run: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 89cdd89d..4f70390f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,32 +4,24 @@ on: - push jobs: - rustfmt: + format-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: true + - name: Install just + # todo switch to apt once ubuntu-24.04 is available + # run: sudo apt-get install -y just + run: sudo snap install --edge --classic just + - uses: actions/setup-java@v4 + with: + distribution: temurin # See 'Supported distributions' for available options + java-version: 17 - name: Install rust uses: dtolnay/rust-toolchain@stable with: components: rustfmt - - name: Install cargo-make - uses: davidB/rust-cargo-make@v1 - name: Check formatting - run: cargo make fmt-check + run: just format-check - ktlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - uses: actions/setup-java@v4 - with: - distribution: temurin # See 'Supported distributions' for available options - java-version: 17 - - name: Run ktlint - run: | - cd android - ./gradlew ktlintCheck diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c0a8aef..adb6fde3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: - name: Install basic requirements run: | apt-get update - apt-get install -y git curl unzip clang + apt-get install -y git curl unzip clang just - uses: actions/checkout@v4 with: @@ -27,14 +27,12 @@ jobs: uses: dtolnay/rust-toolchain@stable - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - - name: Install cargo-make - uses: davidB/rust-cargo-make@v1 - name: Cache cargo dependencies uses: Swatinem/rust-cache@v2 - name: Run rust tests - run: xvfb-run --auto-servernum cargo make test-cov + run: xvfb-run --auto-servernum just test-cov - name: Generate HTML test coverage report - run: cargo make test-cov-report-html + run: just test-cov-report-html - name: Upload coverage report uses: actions/upload-artifact@v4 with: @@ -48,14 +46,14 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + - name: Install just + run: choco install just - name: Install rust uses: dtolnay/rust-toolchain@stable - name: Cache cargo dependencies uses: Swatinem/rust-cache@v2 - - name: Install cargo-make - uses: davidB/rust-cargo-make@v1 - - name: Run rust tests - run: cargo make integration-test + - name: Run lib tests + run: just lib/ test android_test: runs-on: ubuntu-latest diff --git a/Makefile.toml b/Makefile.toml deleted file mode 100644 index ace8de0d..00000000 --- a/Makefile.toml +++ /dev/null @@ -1,100 +0,0 @@ -[env] -CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true -CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = "" -OPENSCQ30_BUILD_DEMO_MODE = false -CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["uniffi-bindgen"] - -[env.demo] -OPENSCQ30_BUILD_DEMO_MODE = true - -[tasks.build] -clear = true -env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = ["gui", "cli"] } -script_runner = "@duckscript" -script.pre = ''' -cargo_build_flags = set "" -if eq ${CARGO_MAKE_PROFILE} "release" - cargo_build_flags = set --release - set_env OPENSCQ30_BUILD_DIR ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/release -else - set_env OPENSCQ30_BUILD_DIR ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/debug -end - -if eq ${OPENSCQ30_BUILD_DEMO_MODE} "true" - cargo_build_flags = concat ${cargo_build_flags} " --no-default-features --features demo" -end - -set_env OPENSCQ30_BUILD_FLAGS ${cargo_build_flags} -''' - -[tasks.test] -clear = true -dependencies = ["unit-test", "integration-test"] - -[tasks.integration-test] -env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = ["cli"] } - -[tasks.test-cov] -clear = true -workspace = false -dependencies = [ - "llvm-cov-clean", - "member-unit-test-cov", - "member-integration-test-cov", -] - -[tasks.llvm-cov-clean] -private = true -command = "cargo" -args = ["llvm-cov", "clean", "--workspace"] - -[tasks.member-unit-test-cov] -private = true -run_task = { name = "unit-test-cov", fork = true } - -[tasks.member-integration-test-cov] -private = true -env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = ["cli"] } -run_task = { name = "integration-test-cov", fork = true } - -[tasks.test-cov-report-html] -workspace = false -command = "cargo" -args = ["llvm-cov", "report", "--html"] - -[tasks.test-cov-report-lcov] -workspace = false -command = "cargo" -args = ["llvm-cov", "report", "--lcov", "--output-path", "lcov.info"] - -[tasks.install] -clear = true -env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = ["gui", "cli"] } -script_runner = "@duckscript" -script.pre = ''' -if is_empty ${INSTALL_PREFIX} - echo Please specify INSTALL_PREFIX environment variable. Recommended: /usr - exit 1 -end - -install_prefix = canonicalize ${INSTALL_PREFIX} -echo Install prefix is ${install_prefix} -''' - -[tasks.uninstall] -clear = true -env = { "CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS" = ["gui", "cli"] } -script_runner = "@duckscript" -script.pre = ''' -if is_empty ${INSTALL_PREFIX} - echo Please specify INSTALL_PREFIX environment variable. Recommended: /usr - exit 1 -end - -install_prefix = canonicalize ${INSTALL_PREFIX} -echo Install prefix is ${install_prefix} -''' - -[tasks.fmt-check] -command = "cargo" -args = ["fmt", "--check"] diff --git a/README.md b/README.md index 5354d562..73049b6d 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,4 @@ See [GitHub Releases](https://github.com/Oppzippy/OpenSCQ30/releases). All files ## Running Tests -### Rust - -`cargo make test` will run all unit and integration tests for the Rust code. - -### Web - -`npm run test` will run unit tests, and `npm run e2etest` will run end to end tests. +`just test` will run all unit and integration tests. To run tests for a specific package, use `just gui/ test` for example. diff --git a/android/Makefile.toml b/android/Makefile.toml deleted file mode 100644 index 95dca73c..00000000 --- a/android/Makefile.toml +++ /dev/null @@ -1,7 +0,0 @@ -[tasks.unit-test] -command = "cargo" -args = ["test", "--lib"] - -[tasks.unit-test-cov] -command = "cargo" -args = ["llvm-cov", "--no-report", "--lib"] diff --git a/android/justfile b/android/justfile new file mode 100644 index 00000000..fd3d7eab --- /dev/null +++ b/android/justfile @@ -0,0 +1,30 @@ +build profile='dev': + #!/usr/bin/env bash + set -euo pipefail + + case "{{profile}}" in + dev) + ./gradlew assembleBluetoothDebug + ;; + release) + ./gradlew assembleBluetoothRelease + ;; + *) + echo Invalid profile + exit 1 + esac + +test: + cargo test + ./gradlew testBluetoothDebugUnitTest + +test-cov: + cargo llvm-cov --no-report + +format: + cargo fmt + ./gradlew ktlintFormat + +format-check: + cargo fmt --check + ./gradlew ktlintCheck diff --git a/cli/Makefile.toml b/cli/Makefile.toml deleted file mode 100644 index 3cda2140..00000000 --- a/cli/Makefile.toml +++ /dev/null @@ -1,66 +0,0 @@ -extend = "../Makefile.toml" - -[tasks.build] -script.main = ''' -cm_run_task build-bin -''' - -[tasks.build-bin] -private = true -command = "cargo" -args = ["build", "@@split(OPENSCQ30_BUILD_FLAGS, )"] - -[tasks.unit-test] -command = "cargo" -args = ["test", "--bins"] - -[tasks.integration-test] -command = "cargo" -args = ["test", "--no-default-features", "--features", "demo", "--test", "*"] - -[tasks.unit-test-cov] -command = "cargo" -args = ["llvm-cov", "--no-report", "--bins"] - -[tasks.integration-test-cov] -command = "cargo" -args = [ - "llvm-cov", - "--no-report", - "--no-default-features", - "--features", - "demo", - "--test", - "*", -] - -[tasks.install] -condition.platforms = ["linux"] -script.main = ''' -bin_path = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/release/openscq30_cli -is_bin_built = is_file ${bin_path} -if not ${is_bin_built} - echo Run `cargo make --profile release build` before installing. - exit 1 -end - -echo Installing binary -cp ${bin_path} ${INSTALL_PREFIX}/bin/openscq30_cli -chmod 755 ${INSTALL_PREFIX}/bin/openscq30_cli - -if is_path_exists ${INSTALL_PREFIX}/share/bash-completions/completions - echo Installing bash completions - output = exec ${bin_path} completions bash - bash_completions = set ${output.stdout} - writefile ${INSTALL_PREFIX}/share/bash-completions/completions/openscq30_cli ${bash_completions} -end -''' - -[tasks.uninstall] -condition.platforms = ["linux"] -script.main = ''' -echo Removing binary -rm ${INSTALL_PREFIX}/bin/openscq30_cli -echo Removing bash completions -rm ${INSTALL_PREFIX}/share/bash-completions/completions/openscq30_cli -''' diff --git a/cli/justfile b/cli/justfile new file mode 100644 index 00000000..5429cde1 --- /dev/null +++ b/cli/justfile @@ -0,0 +1,24 @@ +build profile='dev': + cargo build --profile {{profile}} + +test: + cargo test --bins + cargo test --no-default-features --features demo --test '*' + +unit-test-cov: + cargo llvm-cov --no-report + +integration-test-cov: + cargo llvm-cov --no-report --no-default-features --features demo --test '*' + +install prefix: + ./scripts/install.sh "{{prefix}}" + +uninstall prefix: + ./scripts/uninstall.sh "{{prefix}}" + +format: + cargo fmt + +format-check: + cargo fmt --check diff --git a/cli/scripts/install.sh b/cli/scripts/install.sh new file mode 100644 index 00000000..3877b754 --- /dev/null +++ b/cli/scripts/install.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_path="$(readlink -f -- "$0")" +script_dir="$(dirname -- "$script_path")" +cd "$script_dir/.." + +install_prefix="$1" +case "$OSTYPE" in + msys | cygwin) bin_ext=".exe" ;; + *) bin_ext="" ;; +esac + +echo Installing binary +install -Dm755 "../target/release/openscq30_cli$bin_ext" -t "$install_prefix/bin/" + +if [[ -d "$install_prefix/share/bash-completions/completions" ]]; then + echo Installing bash completions + "../target/release/openscq30_cli$bin_ext" completions bash > "$install_prefix/share/bash-completions/completions/openscq30_cli" +else + echo Skipping bash completions +fi diff --git a/cli/scripts/uninstall.sh b/cli/scripts/uninstall.sh new file mode 100644 index 00000000..1f7d830c --- /dev/null +++ b/cli/scripts/uninstall.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_path="$(readlink -f -- "$0")" +script_dir="$(dirname -- "$script_path")" +cd "$script_dir/.." + +install_prefix="$1" +case "$OSTYPE" in + msys | cygwin) bin_ext=".exe" ;; + *) bin_ext="" ;; +esac + +echo Removing binary +rm "$install_prefix/bin/openscq30_cli$bin_ext" || true +echo Removing bash completions +rm "$install_prefix/share/bash-completions/completions/openscq30_cli" || true diff --git a/docs/build-linux.md b/docs/build-linux.md index ad21fe3d..2713567f 100644 --- a/docs/build-linux.md +++ b/docs/build-linux.md @@ -3,7 +3,7 @@ Instructions use Ubuntu package names. Package names may differ on other distros. 1. Install rust -2. Install [cargo-make](https://github.com/sagiegurari/cargo-make#installation) +2. Install [Just](https://just.systems/man/en/chapter_4.html) 3. Install libdbus-1-dev pkg-config libgtk-4-dev libadwaita-1-dev -4. `cd` to the `gui` directory and run `cargo make --profile release build`. Note that `--profile release` must come before `build`. -5. The compiled binary can be found at `target/release/openscq30_gui`. Locale files are in `target/release/share`. +4. Run `just gui/ build release` +5. The compiled binary can be found at `target/release/openscq30_gui`. Locale files are in `gui/share`. diff --git a/docs/build-macos.md b/docs/build-macos.md index 01f8dc1d..b369dc7a 100644 --- a/docs/build-macos.md +++ b/docs/build-macos.md @@ -1,7 +1,7 @@ ## Building OpenSCQ30 on MacOS 1. Install rust -2. Install [cargo-make](https://github.com/sagiegurari/cargo-make#installation) -3. Install gtk4 and libadwaita (`brew install gtk4 libadwaita`) -4. `cd` to the `gui` directory and run `cargo make --profile release build`. Note that `--profile release` must come before `build`. -5. The compiled binary can be found at `target/release/openscq30_gui`. Locale files are in `target/release/share`. +2. Install [Just](https://just.systems/man/en/chapter_4.html): `brew install just` +3. Install gtk4 and libadwaita: `brew install gtk4 libadwaita` +4. Run `just gui/ build release` +5. The compiled binary can be found at `target/release/openscq30_gui`. Locale files are in `gui/share`. diff --git a/docs/build-windows.md b/docs/build-windows.md index e9360e7c..5e207c3b 100644 --- a/docs/build-windows.md +++ b/docs/build-windows.md @@ -2,6 +2,6 @@ 1. Install MSYS2 and run the UCRT64 environment. 2. Install dependencies using `pacman -Syu base-devel mingw-w64-ucrt-x86_64-libadwaita mingw-w64-ucrt-x86_64-rust mingw-w64-ucrt-x86_64-pkg-config`. -3. Install cargo-make: `cargo install cargo-make`. +3. Install [Just](https://just.systems/man/en/chapter_4.html): `cargo install just` 4. Run `./packaging/windows/build.sh` 5. The compiled binary along with all dependencies can be found at `packaging/windows/root`. This can then be moved and run from outside of the MSYS2 environment. diff --git a/gui/Makefile.toml b/gui/Makefile.toml deleted file mode 100644 index 7067433e..00000000 --- a/gui/Makefile.toml +++ /dev/null @@ -1,151 +0,0 @@ -extend = "../Makefile.toml" - -[tasks.build] -script_runner = "@duckscript" -script.main = ''' -cm_run_task build-bin -cm_run_task build-locale -''' - -[tasks.build-bin] -private = true -command = "cargo" -args = ["build", "@@split(OPENSCQ30_BUILD_FLAGS, )"] - -[tasks.build-locale] -private = true -script_runner = "@duckscript" -condition = { files_modified = { input = [ - "./po/**/*", - "Makefile.toml", -], output = [ - "${OPENSCQ30_BUILD_DIR}/share/**/*", -] } } -script = ''' -project_name = set com.oppzippy.OpenSCQ30 -out_dir = set ${OPENSCQ30_BUILD_DIR} - -echo "Building en" -mkdir ${OPENSCQ30_BUILD_DIR}/share/locale/en/LC_MESSAGES -exec msgfmt --output-file ${OPENSCQ30_BUILD_DIR}/share/locale/en/LC_MESSAGES/${project_name}.mo ${CARGO_MAKE_WORKING_DIRECTORY}/po/${project_name}.pot - -paths = glob_array ${CARGO_MAKE_WORKING_DIRECTORY}/po/* -for path in ${paths} - if is_dir ${path} - locale = basename ${path} - echo Building ${locale} - mkdir ${OPENSCQ30_BUILD_DIR}/share/locale/${locale}/LC_MESSAGES - exec msgfmt --output-file ${OPENSCQ30_BUILD_DIR}/share/locale/${locale}/LC_MESSAGES/${project_name}.mo ${CARGO_MAKE_WORKING_DIRECTORY}/po/${locale}/${project_name}.po - end -end -''' - -[tasks.unit-test] -command = "cargo" -env.LC_ALL = "C" -env.LANG = "C" -args = ["test", "--bins"] - -[tasks.unit-test-cov] -command = "cargo" -args = ["llvm-cov", "--no-report", "--bins"] - -[tasks.install] -script_runner = "@duckscript" -script.main = ''' -os = os_family -is_windows = eq ${os} windows -if ${is_windows} - bin_name = set openscq30_gui.exe -else - bin_name = set openscq30_gui -end -bin_path = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/release/${bin_name} - -is_bin_built = is_file ${bin_path} -is_locale_built = is_dir ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/release/share - -if not ${is_bin_built} and ${is_locale_built} - echo Run `cargo make --profile release build` before installing. - exit 1 -end - -echo Installing to ${INSTALL_PREFIX} - -echo Installing bin -cp ${bin_path} ${INSTALL_PREFIX}/bin/${bin_name} -if not ${is_windows} - chmod 755 ${INSTALL_PREFIX}/bin/${bin_name} -end - -echo Installing locales -cp_glob ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/release/share/**/* ${INSTALL_PREFIX}/share/ - -echo Installing icon -cp ${CARGO_MAKE_WORKING_DIRECTORY}/resources/com.oppzippy.OpenSCQ30.svg ${INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/com.oppzippy.OpenSCQ30.svg - -echo Installing desktop file -cp ${CARGO_MAKE_WORKING_DIRECTORY}/resources/com.oppzippy.OpenSCQ30.desktop ${INSTALL_PREFIX}/share/applications/com.oppzippy.OpenSCQ30.desktop - -echo Installing AppStream Catalog XML -cp ${CARGO_MAKE_WORKING_DIRECTORY}/resources/com.oppzippy.OpenSCQ30.metainfo.xml ${INSTALL_PREFIX}/share/metainfo/com.oppzippy.OpenSCQ30.metainfo.xml -''' - -[tasks.uninstall] -script.main = ''' -os = os_family -is_windows = eq ${os} windows -if ${is_windows} - bin_name = set "openscq30_gui.exe" -else - bin_name = set "openscq30_gui" -end - -echo Removing binary -rm ${INSTALL_PREFIX}/bin/${bin_name} - -echo Removing locales -mo_files = glob_array ${INSTALL_PREFIX}/share/locale/*/LC_MESSAGES/com.oppzippy.OpenSCQ30.mo -for path in ${mo_files} - rm ${path} -end - -echo Removing icon -rm ${INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/com.oppzippy.OpenSCQ30.svg - -echo Removing desktop file -rm ${INSTALL_PREFIX}/share/applications/com.oppzippy.OpenSCQ30.desktop - -echo Removing AppStream Catalog XML -rm ${INSTALL_PREFIX}/share/metainfo/com.oppzippy.OpenSCQ30.metainfo.xml -''' - -[tasks.update-po-files] -script_runner = "@duckscript" -script = ''' - -project_name = set com.oppzippy.OpenSCQ30 - -echo Generating template -if is_file ./po/${project_name}.pot - exec xgettext --files-from ./po/POTFILES.in --join-existing --add-comments --sort-output --output ./po/${project_name}.pot -else - exec xgettext --files-from ./po/POTFILES.in --add-comments --sort-output --output ./po/${project_name}.pot -end - -content = readfile ./po/LINGUAS -locales = split ${content} \n - -for locale in ${locales} - is_locale_empty = is_empty ${locale} - if not ${is_locale_empty} - echo "Updating ${locale}" - mkdir ./po/${locale} - if is_file ./po/${locale}/${project_name}.po - exec msgmerge --update ./po/${locale}/${project_name}.po ./po/${project_name}.pot - else - exec msginit --input ./po/${project_name}.pot --locale ${locale} --output ./po/${locale}/${project_name}.po - end - end -end -''' diff --git a/gui/justfile b/gui/justfile new file mode 100644 index 00000000..8d93a728 --- /dev/null +++ b/gui/justfile @@ -0,0 +1,31 @@ +build profile='dev': + #!/usr/bin/env bash + set -euo pipefail + if [[ "{{profile}}" != "dev" && "{{profile}}" != "release" ]]; then + echo "Invalid profile: {{profile}}" + exit 1 + fi + + cargo build --profile {{profile}} + ./scripts/build-locale.sh ./share + +test: + cargo test + +test-cov: + cargo llvm-cov --no-report + +install install_prefix: (build 'release') + ./scripts/install.sh "{{install_prefix}}" + +uninstall install_prefix: + ./scripts/uninstall.sh "{{install_prefix}}" + +update-po-files: + ./scripts/update-po-files.sh + +format: + cargo fmt + +format-check: + cargo fmt --check diff --git a/gui/scripts/build-locale.sh b/gui/scripts/build-locale.sh index 9382335c..0b7d47b3 100755 --- a/gui/scripts/build-locale.sh +++ b/gui/scripts/build-locale.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash -set -e -set -o pipefail +set -euo pipefail PROJECT_NAME="com.oppzippy.OpenSCQ30" script_path="$(readlink -f -- "$0")" -script_dir="$(dirname -- $script_path)" +script_dir="$(dirname -- "$script_path")" gui_dir="$script_dir/.." out_dir=$1 diff --git a/gui/scripts/install.sh b/gui/scripts/install.sh new file mode 100644 index 00000000..b6905a0f --- /dev/null +++ b/gui/scripts/install.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_path="$(readlink -f -- "$0")" +script_dir="$(dirname -- "$script_path")" +cd "$script_dir/.." + +install_prefix="$1" + +case "$OSTYPE" in + msys | cygwin) bin_ext=".exe" ;; + *) bin_ext="" ;; +esac + +echo "Installing to $1" +install -Dm755 "../target/release/openscq30_gui$bin_ext" -t "$install_prefix/bin/" +install -Dm644 ./resources/com.oppzippy.OpenSCQ30.desktop -t "$install_prefix/share/applications" +install -Dm644 ./resources/com.oppzippy.OpenSCQ30.metainfo.xml -t "$install_prefix/share/metainfo" +install -Dm644 ./resources/com.oppzippy.OpenSCQ30.svg -t "$install_prefix/share/icons/hicolor/scalable/apps" +cp -r ./share/* "$install_prefix/" diff --git a/gui/scripts/uninstall.sh b/gui/scripts/uninstall.sh new file mode 100644 index 00000000..5bd88010 --- /dev/null +++ b/gui/scripts/uninstall.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_path="$(readlink -f -- "$0")" +script_dir="$(dirname -- "$script_path")" +cd "$script_dir/.." + +install_prefix="$1" + +case "$OSTYPE" in + msys | cygwin) bin_ext=".exe" ;; + *) bin_ext="" ;; +esac + +echo "Uninstalling from $install_prefix" +echo Removing binary +rm "$install_prefix/bin/openscq30_gui$bin_ext" || true +echo Removing desktop file +rm "$install_prefix/share/applications/com.oppzippy.OpenSCQ30.desktop" || true +echo Removing appstream metainfo +rm "$install_prefix/share/metainfo/com.oppzippy.OpenSCQ30.metainfo.xml" || true +echo Removing icon +rm "$install_prefix/share/icons/hicolor/scalable/apps/com.oppzippy.OpenSCQ30.svg" || true +echo Removing locales +rm "$install_prefix"/share/locale/*/LC_MESSAGES/com.oppzippy.OpenSCQ30.mo || true diff --git a/gui/scripts/update-po-files.sh b/gui/scripts/update-po-files.sh index 3ae3c9b4..1158c74f 100755 --- a/gui/scripts/update-po-files.sh +++ b/gui/scripts/update-po-files.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash -set -e -set -o pipefail +set -euo pipefail PROJECT_NAME="com.oppzippy.OpenSCQ30" script_path="$(readlink -f -- "$0")" -script_dir="$(dirname -- $script_path)" +script_dir="$(dirname -- "$script_path")" cd "$script_dir/.." echo "Updating POTFILES.in" diff --git a/justfile b/justfile new file mode 100644 index 00000000..89b02bf2 --- /dev/null +++ b/justfile @@ -0,0 +1,67 @@ +default: + @just --choose + +build profile='dev': + just gui/ build '{{profile}}' + just cli/ build '{{profile}}' + just android/ build '{{profile}}' + just web/ build '{{profile}}' + +test: + just gui/ test + just cli/ test + just android/ test + just web/ test + +test-cov: + just gui/ test-cov + just cli/ test-cov + just android/ test-cov + just web/ test-cov + +llvm-cov-clean: + cargo llvm-cov clean --workspace + +test-cov-report format='lcov': + #!/usr/bin/env bash + set -eou pipefail + + case '{{format}}' in + lcov) + format_arg="--lcov" + ;; + html) + format_arg="--html" + ;; + *) + echo Invalid format + exit 1 + ;; + esac + + cargo llvm-cov report "$format_arg" --output-path lcov.info + +install prefix: + just gui/ install '{{prefix}}' + just cli/ install '{{prefix}}' + +uninstall prefix: + just gui/ uninstall '{{prefix}}' + just cli/ uninstall '{{prefix}}' + +format: + just android/ format + just cli/ format + just gui/ format + just lib/ format + just lib_protobuf/ format + just web/ format + +format-check: + just android/ format-check + just cli/ format-check + just gui/ format-check + just lib/ format-check + just lib_protobuf/ format-check + just web/ format-check + diff --git a/lib/Makefile.toml b/lib/Makefile.toml deleted file mode 100644 index 5b06b0f0..00000000 --- a/lib/Makefile.toml +++ /dev/null @@ -1,21 +0,0 @@ -[tasks.unit-test] -dependencies = ["unit-test-bluetooth", "unit-test-demo"] - -[tasks.unit-test-bluetooth] -command = "cargo" -args = ["test", "--lib", "--features", "bluetooth"] - -[tasks.unit-test-demo] -command = "cargo" -args = ["test", "--lib", "--features", "demo"] - -[tasks.unit-test-cov] -dependencies = ["unit-test-cov-bluetooth", "unit-test-cov-demo"] - -[tasks.unit-test-cov-bluetooth] -command = "cargo" -args = ["llvm-cov", "--no-report", "--lib", "--features", "bluetooth"] - -[tasks.unit-test-cov-demo] -command = "cargo" -args = ["llvm-cov", "--no-report", "--lib", "--features", "demo"] diff --git a/lib/justfile b/lib/justfile new file mode 100644 index 00000000..35bbd765 --- /dev/null +++ b/lib/justfile @@ -0,0 +1,11 @@ +test: + cargo test + +test-cov: + cargo llvm-cov --no-report + +format: + cargo fmt + +format-check: + cargo fmt --check diff --git a/lib_protobuf/Makefile.toml b/lib_protobuf/Makefile.toml deleted file mode 100644 index 95dca73c..00000000 --- a/lib_protobuf/Makefile.toml +++ /dev/null @@ -1,7 +0,0 @@ -[tasks.unit-test] -command = "cargo" -args = ["test", "--lib"] - -[tasks.unit-test-cov] -command = "cargo" -args = ["llvm-cov", "--no-report", "--lib"] diff --git a/lib_protobuf/justfile b/lib_protobuf/justfile new file mode 100644 index 00000000..35bbd765 --- /dev/null +++ b/lib_protobuf/justfile @@ -0,0 +1,11 @@ +test: + cargo test + +test-cov: + cargo llvm-cov --no-report + +format: + cargo fmt + +format-check: + cargo fmt --check diff --git a/packaging/appimage/AppImageBuilder.yml b/packaging/appimage/AppImageBuilder.yml index 8a4db04a..2e66965f 100644 --- a/packaging/appimage/AppImageBuilder.yml +++ b/packaging/appimage/AppImageBuilder.yml @@ -1,10 +1,7 @@ version: 1 script: - - export CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS="gui" - - export INSTALL_PREFIX="$(pwd)/AppDir/usr" - - cargo make --profile release --cwd ../.. build - rm -rf ./AppDir || true - - cargo make --profile release --cwd ../.. install + - just gui/ install "$PWD/AppDir/usr" AppDir: app_info: diff --git a/packaging/windows/build.ps1 b/packaging/windows/build.ps1 deleted file mode 100644 index aa301ad1..00000000 --- a/packaging/windows/build.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -$ErrorActionPreference = "Stop" -$root = "$PSScriptRoot\..\.." - -cargo make --profile release --env CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS=gui --cwd $root build - -function Write-Filtered-Errors { - param ( - $errors - ) - $errors | ForEach-Object { - if ($_ -notmatch "already exists") { - Write-Error $_ - } - } -} - -$directoriesToCreate = @( - "$root\packaging\windows\root\bin" - "$root\packaging\windows\root\share\locale" - "$root\packaging\windows\root\share\glib-2.0\schemas" -) -$filesToCopyNoOverwrite = @{ - "$root\LICENSE.txt" = "$root\packaging\windows\root"; - "C:\gtk-build\gtk\x64\release\bin\*.dll" = "$root\packaging\windows\root\bin"; - "C:\gtk-build\gtk\x64\release\bin\gdbus.exe" = "$root\packaging\windows\root\bin"; - "C:\gtk-build\gtk\x64\release\share\glib-2.0\schemas\*" = "$root\packaging\windows\root\share\glib-2.0\schemas"; - "C:\gtk-build\gtk\x64\release\share\locale\*" = "$root\packaging\windows\root\share\locale"; -} -$filesToCopy = @{ - "$root\target\release\openscq30_gui.exe" = "$root\packaging\windows\root\bin"; - "$root\target\release\share\*" = "$root\packaging\windows\root\share"; -} - -foreach ($directory in $directoriesToCreate) { - New-Item -Type Directory -Path $directory -ErrorVariable errors -ErrorAction SilentlyContinue - Write-Filtered-Errors $errors -} -foreach ($source in $filesToCopy.Keys) { - Copy-Item -Recurse -Force -Path $source -Destination $filesToCopy[$source] -} -foreach ($source in $filesToCopyNoOverwrite.Keys) { - Copy-Item -Recurse -Path $source -Destination $filesToCopyNoOverwrite[$source] -ErrorVariable errors -ErrorAction SilentlyContinue - Write-Filtered-Errors $errors -} - -& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" "$root\packaging\windows\setup.iss" diff --git a/packaging/windows/build.sh b/packaging/windows/build.sh index dd2d7bff..3e206435 100644 --- a/packaging/windows/build.sh +++ b/packaging/windows/build.sh @@ -11,10 +11,7 @@ package_type="ucrt64" output_dir="$script_dir/root" # Install OpenSCQ30 -export CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS=gui -export INSTALL_PREFIX="$output_dir" -cargo make --profile release --cwd "$project_root" build -cargo make --profile release --cwd "$project_root" install +just "$project_root/gui/" install "$output_dir" # Determine what dlls are required, and which packages those dlls belong to list=$(ldd "$input_exe" | grep "/$package_type" | sed "s/.dll.*/.dll/") diff --git a/web/justfile b/web/justfile new file mode 100644 index 00000000..242f237e --- /dev/null +++ b/web/justfile @@ -0,0 +1,15 @@ +build: + npm run build + +_build-wasm: + npm run build:wasm + +test: (_build-wasm) + npm run test + npm run e2etest + +format: + cd wasm && cargo fmt + +format-check: + cd wasm && cargo fmt --check diff --git a/web/wasm/Makefile.toml b/web/wasm/Makefile.toml deleted file mode 100644 index c8a79296..00000000 --- a/web/wasm/Makefile.toml +++ /dev/null @@ -1,13 +0,0 @@ -[tasks.test] -clear = true -dependencies = ["unit-test"] - -[tasks.unit-test] -command = "cargo" -env = { "RUSTFLAGS" = "--cfg=web_sys_unstable_apis" } -args = ["test", "--lib"] - -[tasks.unit-test-cov] -command = "cargo" -env = { "RUSTFLAGS" = "--cfg=web_sys_unstable_apis" } -args = ["llvm-cov", "--no-report", "--lib"] diff --git a/web/wasm/justfile b/web/wasm/justfile new file mode 100644 index 00000000..c0853072 --- /dev/null +++ b/web/wasm/justfile @@ -0,0 +1,11 @@ +export RUSTFLAGS='--cfg=web_sys_unstable_apis' + +build: + wasm-pack build --no-pack + wasm-pack build --no-pack --dev + +test: + cargo test + +test-cov: + cargo llvm-cov --no-report