From 10f71579896c3887c2e52149a382342eb70f4ad8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 18:33:03 +0200 Subject: [PATCH 1/6] chore(deps): bump the default group with 3 updates (#13) Bumps the default group with 3 updates: [env_logger](https://github.com/rust-cli/env_logger), [libc](https://github.com/rust-lang/libc) and [log](https://github.com/rust-lang/log). Updates `env_logger` from 0.11.2 to 0.11.3 - [Release notes](https://github.com/rust-cli/env_logger/releases) - [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-cli/env_logger/compare/v0.11.2...v0.11.3) Updates `libc` from 0.2.153 to 0.2.154 - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.153...0.2.154) Updates `log` from 0.4.20 to 0.4.21 - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.20...0.4.21) --- updated-dependencies: - dependency-name: env_logger dependency-type: direct:production update-type: version-update:semver-patch dependency-group: default - dependency-name: libc dependency-type: direct:production update-type: version-update:semver-patch dependency-group: default - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch dependency-group: default ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6290b0..f0bd6c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c012a26a7f605efc424dd53697843a72be7dc86ad2d01f7814337794a12231d" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" dependencies = [ "anstream", "anstyle", @@ -295,9 +295,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libloading" @@ -345,9 +345,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "match_cfg" From 60457c6eb1913334a13a437bea281490d5296115 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 10:26:15 +0200 Subject: [PATCH 2/6] chore(deps): bump thiserror from 1.0.59 to 1.0.60 in the default group (#20) --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f0bd6c8..c603b12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -560,18 +560,18 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", From 9d9b5e87f2ade1dbabd67db35f30ab65ca1313c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 08:17:07 +0200 Subject: [PATCH 3/6] chore(deps): bump the default group with 2 updates (#21) Bumps the default group with 2 updates: [libc](https://github.com/rust-lang/libc) and [thiserror](https://github.com/dtolnay/thiserror). Updates `libc` from 0.2.154 to 0.2.155 - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.154...0.2.155) Updates `thiserror` from 1.0.60 to 1.0.61 - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.60...1.0.61) --- updated-dependencies: - dependency-name: libc dependency-type: direct:production update-type: version-update:semver-patch dependency-group: default - dependency-name: thiserror dependency-type: direct:production update-type: version-update:semver-patch dependency-group: default ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c603b12..783114b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -295,9 +295,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" @@ -560,18 +560,18 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", From 9dec3688b02dd72884d32d455c0831113f9a2771 Mon Sep 17 00:00:00 2001 From: AP Ljungquist Date: Thu, 30 May 2024 10:53:32 +0200 Subject: [PATCH 4/6] Factor out `app_logging` modules to lib crate (#24) This change is prompted by wanting to demonstrate how to use library crates from this repo in acap-rs-app-template. But it also makes sense in the context of only this repo where verbatim copies of the `app_logging` module are included in all current and upcoming example apps; factoring it out will prevent the copies from accidentally diverging. --- Cargo.lock | 15 ++++++--- Cargo.toml | 1 + apps/hello_world/Cargo.toml | 4 +-- apps/hello_world/src/main.rs | 4 +-- apps/licensekey_handler/Cargo.toml | 5 ++- apps/licensekey_handler/src/app_logging.rs | 32 ------------------- apps/licensekey_handler/src/main.rs | 2 -- crates/app-logging/Cargo.toml | 9 ++++++ .../app-logging/src/lib.rs | 4 +-- 9 files changed, 28 insertions(+), 48 deletions(-) delete mode 100644 apps/licensekey_handler/src/app_logging.rs create mode 100644 crates/app-logging/Cargo.toml rename apps/hello_world/src/app_logging.rs => crates/app-logging/src/lib.rs (86%) diff --git a/Cargo.lock b/Cargo.lock index 783114b..4cf29ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,6 +59,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "app-logging" +version = "0.0.0" +dependencies = [ + "env_logger", + "log", + "syslog", +] + [[package]] name = "bindgen" version = "0.69.4" @@ -225,9 +234,8 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" name = "hello_world" version = "1.0.0" dependencies = [ - "env_logger", + "app-logging", "log", - "syslog", ] [[package]] @@ -331,10 +339,9 @@ dependencies = [ name = "licensekey_handler" version = "1.0.0" dependencies = [ - "env_logger", + "app-logging", "licensekey", "log", - "syslog", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b8a8ce3..9f298ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ syslog = "6.1.1" thiserror = "1.0.57" licensekey = { path = "crates/licensekey" } +app-logging = { path = "crates/app-logging" } [workspace.package] edition = "2021" diff --git a/apps/hello_world/Cargo.toml b/apps/hello_world/Cargo.toml index 13172ba..5cd09fc 100644 --- a/apps/hello_world/Cargo.toml +++ b/apps/hello_world/Cargo.toml @@ -5,5 +5,5 @@ edition.workspace = true [dependencies] log = { workspace = true } -env_logger = { workspace = true } -syslog = { workspace = true } + +app-logging = { workspace = true } diff --git a/apps/hello_world/src/main.rs b/apps/hello_world/src/main.rs index 18d9a12..4011eec 100644 --- a/apps/hello_world/src/main.rs +++ b/apps/hello_world/src/main.rs @@ -1,13 +1,11 @@ //! A simple hello world application //! -//! Uses some common logging crates to demonstrate +//! Uses some common app-logging crates to demonstrate //! 1. how to use them in an application, and //! 2. how to build and bundle them as an application. use log::info; -mod app_logging; - fn main() { app_logging::init_logger(); info!("Hello World!"); diff --git a/apps/licensekey_handler/Cargo.toml b/apps/licensekey_handler/Cargo.toml index 387c0d3..34a8f53 100644 --- a/apps/licensekey_handler/Cargo.toml +++ b/apps/licensekey_handler/Cargo.toml @@ -5,7 +5,6 @@ edition.workspace = true [dependencies] log = { workspace = true } -env_logger = { workspace = true } -syslog = { workspace = true } -licensekey = { workspace = true } \ No newline at end of file +licensekey = { workspace = true } +app-logging = { workspace = true } diff --git a/apps/licensekey_handler/src/app_logging.rs b/apps/licensekey_handler/src/app_logging.rs deleted file mode 100644 index edb8609..0000000 --- a/apps/licensekey_handler/src/app_logging.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! Utilities for managing logging in an application. - -use std::env; -use std::io::IsTerminal; - -use log::debug; - -fn init_syslog() { - let formatter = syslog::Formatter3164::default(); - let logger = syslog::unix(formatter).unwrap(); - log::set_boxed_logger(Box::new(syslog::BasicLogger::new(logger))).unwrap(); - log::set_max_level(log::LevelFilter::Debug); -} - -/// Set up logging as appropriate for the environment, then run the provided function. -/// -/// If stdout is a terminal, write to stderr. -/// Otherwise, write to the system logger. -pub fn init_logger() { - // Using `su -pc "..."` just says the "Connection to ... closed", and - // I have not found another way to run as the SDK user over ssh and allocate a tty, so - // if we detect an `env_logger` configuration we write to stderr anyway. - if std::io::stdout().is_terminal() - || env::var_os("RUST_LOG").is_some() - || env::var_os("RUST_LOG_STYLE").is_some() - { - env_logger::init(); - } else { - init_syslog(); - } - debug!("Logging initialized"); -} diff --git a/apps/licensekey_handler/src/main.rs b/apps/licensekey_handler/src/main.rs index d0090cc..78a6626 100644 --- a/apps/licensekey_handler/src/main.rs +++ b/apps/licensekey_handler/src/main.rs @@ -4,8 +4,6 @@ use log::{info, warn}; use std::ffi::{CStr, CString}; use std::os::unix::ffi::OsStrExt; -mod app_logging; - const APP_ID: i32 = 0; const MAJOR_VERSION: i32 = 1; const MINOR_VERSION: i32 = 0; diff --git a/crates/app-logging/Cargo.toml b/crates/app-logging/Cargo.toml new file mode 100644 index 0000000..aaa717b --- /dev/null +++ b/crates/app-logging/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "app-logging" +version = "0.0.0" +edition.workspace = true + +[dependencies] +log = { workspace = true } +env_logger = { workspace = true } +syslog = { workspace = true } \ No newline at end of file diff --git a/apps/hello_world/src/app_logging.rs b/crates/app-logging/src/lib.rs similarity index 86% rename from apps/hello_world/src/app_logging.rs rename to crates/app-logging/src/lib.rs index edb8609..6cd3e09 100644 --- a/apps/hello_world/src/app_logging.rs +++ b/crates/app-logging/src/lib.rs @@ -1,4 +1,4 @@ -//! Utilities for managing logging in an application. +//! Utilities for managing app-logging in an application. use std::env; use std::io::IsTerminal; @@ -12,7 +12,7 @@ fn init_syslog() { log::set_max_level(log::LevelFilter::Debug); } -/// Set up logging as appropriate for the environment, then run the provided function. +/// Set up app-logging as appropriate for the environment, then run the provided function. /// /// If stdout is a terminal, write to stderr. /// Otherwise, write to the system logger. From 1c5083e41134644d2411f4e91551047c04902393 Mon Sep 17 00:00:00 2001 From: AP Ljungquist Date: Mon, 3 Jun 2024 09:44:18 +0200 Subject: [PATCH 5/6] Demonstrate containerized builds (#17) This should make it easier to build the example apps in CI systems where setting up docker-in-docker is difficult. As desirable side effect of this is that it becomes easier to build the example apps on any system, including those where following the advanced setup may be difficult. To be able to build both inside and outside docker containers branching is introduced in the makefile. The added complexity is unfortunate but worthwhile in order to better support containerized builds. The goal is to eventually replace most of the makefile with a cargo plugin. --- .dockerignore | 3 +++ Dockerfile | 58 ++++++++++++++++++++++++++++++++++++++++++ Makefile | 11 ++++++++ README.md | 29 ++++++++++++++------- docker/install_rust.sh | 15 +++++++++++ 5 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 docker/install_rust.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5e18096 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!/docker/ +!/rust-toolchain.toml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..788d448 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +ARG REPO=axisecp +ARG SDK=acap-native-sdk +ARG UBUNTU_VERSION=22.04 +ARG VERSION=1.14 +ARG BASE_IMAGE=debian:bookworm-20240423-slim + +FROM ${REPO}/${SDK}:${VERSION}-aarch64-ubuntu${UBUNTU_VERSION} AS sdk-aarch64 +FROM ${REPO}/${SDK}:${VERSION}-armv7hf-ubuntu${UBUNTU_VERSION} AS sdk-armv7hf +FROM ${BASE_IMAGE} + +COPY --from=sdk-aarch64 /opt/axis/acapsdk/axis-acap-manifest-tools /opt/axis/acapsdk/axis-acap-manifest-tools +COPY --from=sdk-aarch64 /opt/axis/acapsdk/environment-setup-cortexa53-crypto-poky-linux /opt/axis/acapsdk/environment-setup-cortexa53-crypto-poky-linux +COPY --from=sdk-armv7hf /opt/axis/acapsdk/environment-setup-cortexa9hf-neon-poky-linux-gnueabi /opt/axis/acapsdk/environment-setup-cortexa9hf-neon-poky-linux-gnueabi +COPY --from=sdk-aarch64 /opt/axis/acapsdk/sysroots/aarch64 /opt/axis/acapsdk/sysroots/aarch64 +COPY --from=sdk-armv7hf /opt/axis/acapsdk/sysroots/armv7hf /opt/axis/acapsdk/sysroots/armv7hf +COPY --from=sdk-aarch64 /opt/axis/acapsdk/sysroots/x86_64-pokysdk-linux /opt/axis/acapsdk/sysroots/x86_64-pokysdk-linux + +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + clang \ + g++-aarch64-linux-gnu \ + g++-arm-linux-gnueabihf \ + pkg-config \ + python3-jsonschema \ + wget \ + && rm -rf /var/lib/apt/lists/* + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +COPY docker/install_rust.sh rust-toolchain.toml ./ +RUN ./install_rust.sh \ + && rustup target add \ + aarch64-unknown-linux-gnu \ + thumbv7neon-unknown-linux-gnueabihf \ + && rm install_rust.sh rust-toolchain.toml + +ENV \ + SYSROOT_AARCH64=/opt/axis/acapsdk/sysroots/aarch64 \ + SYSROOT_ARMV7HF=/opt/axis/acapsdk/sysroots/armv7hf +# The above makes the below easier to read +ENV \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="aarch64-linux-gnu-gcc" \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-args=--sysroot=${SYSROOT_AARCH64}" \ + CC_aarch64_axis_linux_gnu="aarch64-linux-gnu-gcc" \ + CXX_aarch64_axis_linux_gnu="aarch64-linux-gnu-g++" \ + PKG_CONFIG_LIBDIR_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}/usr/lib/pkgconfig:${SYSROOT_AARCH64}/usr/share/pkgconfig" \ + PKG_CONFIG_PATH_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}/usr/lib/pkgconfig:${SYSROOT_AARCH64}/usr/share/pkgconfig" \ + PKG_CONFIG_SYSROOT_DIR_aarch64_unknown_linux_gnu="${SYSROOT_AARCH64}" \ + CARGO_TARGET_THUMBV7NEON_UNKNOWN_LINUX_GNUEABIHF_LINKER="arm-linux-gnueabihf-gcc" \ + CARGO_TARGET_THUMBV7NEON_UNKNOWN_LINUX_GNUEABIHF_RUSTFLAGS="-C link-args=--sysroot=${SYSROOT_ARMV7HF}" \ + CC_thumbv7neon_unknown_linux_gnueabihf="arm-linux-gnueabihf-gcc" \ + CXX_thumbv7neon_unknown_linux_gnueabihf="arm-linux-gnueabihf-g++" \ + PKG_CONFIG_LIBDIR_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}/usr/lib/pkgconfig:${SYSROOT_ARMV7HF}/usr/share/pkgconfig" \ + PKG_CONFIG_PATH_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}/usr/lib/pkgconfig:${SYSROOT_ARMV7HF}/usr/share/pkgconfig" \ + PKG_CONFIG_SYSROOT_DIR_thumbv7neon_unknown_linux_gnueabihf="${SYSROOT_ARMV7HF}" \ No newline at end of file diff --git a/Makefile b/Makefile index 6c70315..b640cb2 100644 --- a/Makefile +++ b/Makefile @@ -197,9 +197,16 @@ crates/%-sys/src/bindings.rs: FORCE # Use the `_envoy` file as a target because # * `.DELETE_ON_ERROR` does not work for directories, and # * the name of the `.eap` file is annoying to predict. +# When building for all targets using a single image we cannot rely on wildcard matching. +target/aarch64/$(PACKAGE)/_envoy: ENVIRONMENT_SETUP=environment-setup-cortexa53-crypto-poky-linux +target/armv7hf/$(PACKAGE)/_envoy: ENVIRONMENT_SETUP=environment-setup-cortexa9hf-neon-poky-linux-gnueabi target/%/$(PACKAGE)/_envoy: ARCH=$* target/%/$(PACKAGE)/_envoy: target/%/$(PACKAGE)/$(PACKAGE) target/%/$(PACKAGE)/manifest.json target/%/$(PACKAGE)/LICENSE +ifeq (0, $(shell test -e /.dockerenv; echo $$?)) + . /opt/axis/acapsdk/$(ENVIRONMENT_SETUP) && cd $(@D) && acap-build --build no-build . +else $(DOCKER_RUN) sh -c ". /opt/axis/acapsdk/environment-setup-* && acap-build --build no-build ." +endif touch $@ target/%/$(PACKAGE)/manifest.json: apps/$(PACKAGE)/manifest.json @@ -222,4 +229,8 @@ target/armv7hf/$(PACKAGE)/$(PACKAGE): target/thumbv7neon-unknown-linux-gnueabihf # Always rebuild the executable because configuring accurate cache invalidation is annoying. target/%/release/$(PACKAGE): FORCE +ifeq (0, $(shell test -e /.dockerenv; echo $$?)) + cargo -v build --release --target $* --package $(PACKAGE) +else cross -v build --release --target $* --package $(PACKAGE) +endif diff --git a/README.md b/README.md index b8e4827..81c5e18 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,25 @@ _Easy and safe [ACAP] apps using [Rust]_ ## Quickstart guide +Build the `hello_world` example and create `.eap` files in the `target/acap/` directory like + +```sh +docker build --tag acap-rs . +docker run \ + --interactive \ + --rm \ + --tty \ + --user $(id -u):$(id -g) \ + --volume $(pwd):$(pwd) \ + --workdir $(pwd) \ + acap-rs \ + make build PACKAGE=hello_world +``` + +This works with any of the [example applications](#example-applications). + +## Advanced setup + Ensure global prerequisites are installed: * Docker @@ -22,15 +41,7 @@ source ./init_env.sh make sync_env ``` -Build the `hello_world` example and create `.eap` files in the `target/acap/` directory like - -```sh -PACKAGE=hello_world make build -``` - -This works with any of the [example applications](#example-applications). - -Other important workflows are documented in the [Makefile](./Makefile) and can be listed with `make help`. +Important workflows are documented in the [Makefile](./Makefile) and can now be listed with `make help`. ## Example applications diff --git a/docker/install_rust.sh b/docker/install_rust.sh new file mode 100755 index 0000000..1bbbdb3 --- /dev/null +++ b/docker/install_rust.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env sh +set -eux +wget "https://static.rust-lang.org/rustup/archive/1.26.0/x86_64-unknown-linux-gnu/rustup-init" +echo "0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db rustup-init" | sha256sum -c - +chmod +x rustup-init + +./rustup-init \ + --default-host x86_64-unknown-linux-gnu \ + --default-toolchain $(grep "channel" rust-toolchain.toml | cut -d '"' -f 2) \ + --no-modify-path \ + --profile minimal \ + -y + +rm rustup-init +chmod -R a+w $RUSTUP_HOME $CARGO_HOME \ No newline at end of file From 0a5bc56771d2098d4716db97b5ec7e517c2fbbdf Mon Sep 17 00:00:00 2001 From: AP Ljungquist Date: Mon, 10 Jun 2024 09:12:13 +0200 Subject: [PATCH 6/6] chore: Group and sort imports (#23) This allows me to pay no attention to how I or my IDE adds imports adds imports. Don't group and sort imports automatically because this functionality is unstable. --- apps/licensekey_handler/src/main.rs | 7 +++++-- crates/app-logging/src/lib.rs | 3 +-- crates/licensekey/src/flex.rs | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/licensekey_handler/src/main.rs b/apps/licensekey_handler/src/main.rs index 78a6626..5a69d87 100644 --- a/apps/licensekey_handler/src/main.rs +++ b/apps/licensekey_handler/src/main.rs @@ -1,8 +1,11 @@ //! A simple example application demonstrating how the licensekey crate may be used +use std::{ + ffi::{CStr, CString}, + os::unix::ffi::OsStrExt, +}; + use log::{info, warn}; -use std::ffi::{CStr, CString}; -use std::os::unix::ffi::OsStrExt; const APP_ID: i32 = 0; const MAJOR_VERSION: i32 = 1; diff --git a/crates/app-logging/src/lib.rs b/crates/app-logging/src/lib.rs index 6cd3e09..af0f1e4 100644 --- a/crates/app-logging/src/lib.rs +++ b/crates/app-logging/src/lib.rs @@ -1,7 +1,6 @@ //! Utilities for managing app-logging in an application. -use std::env; -use std::io::IsTerminal; +use std::{env, io::IsTerminal}; use log::debug; diff --git a/crates/licensekey/src/flex.rs b/crates/licensekey/src/flex.rs index b79c1e0..37cf9f8 100644 --- a/crates/licensekey/src/flex.rs +++ b/crates/licensekey/src/flex.rs @@ -123,10 +123,12 @@ pub fn licensekey_get_state_string(state_code: c_int) -> Option { #[cfg(not(target_arch = "x86_64"))] #[cfg(test)] mod tests { - use super::*; - use licensekey_sys::LicenseKeyState; use std::ffi::CString; + use licensekey_sys::LicenseKeyState; + + use super::*; + #[test] fn licensekey_verify_does_not_panic() { let app_name = CString::new("test_app").unwrap();