-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into add_ssh_utils
* upstream/main: Rename environment variables controlling the Makefile (#26) Adopt dev container as primary environment (#39) Make the `build` verb build for only one target (#31) chore(deps): bump ghcr.io/devcontainers/features/common-utils (#38) chore(deps): bump log from 0.4.21 to 0.4.22 in the default group (#37) Add dev container (#36) Add link to acap-rs-app-template in `README.md` (#34) Document `python3-venv` dependency (#35) fix: Repair `Makefile` (#32) fix(embedded_web_page): Put web page in `html/` (#30) Organize dependencies consistently (#29) chore(deps): bump glib-sys from 0.19.5 to 0.19.8 in the default group (#28) chore: Explain more make targets (#27) Add embedded web page example (#14)
- Loading branch information
Showing
18 changed files
with
252 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"version": "2.4.4", | ||
"resolved": "ghcr.io/devcontainers/features/common-utils@sha256:85c6505e809cc7c400b21997d7ae6f50811720d591813243f14d98cf2c577041", | ||
"integrity": "sha256:85c6505e809cc7c400b21997d7ae6f50811720d591813243f14d98cf2c577041" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "acap-rs", | ||
"build": { | ||
"dockerfile": "../Dockerfile", | ||
"context": ".." | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": {}, | ||
}, | ||
"remoteUser": "${localEnv:USER}", | ||
"containerEnv": { | ||
"CARGO_HOME": "/home/${localEnv:USER}/.cargo" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,16 @@ jobs: | |
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
- name: Install dev container dependencies | ||
run: npm install -g @devcontainers/[email protected] | ||
- name: Run checks in dev container | ||
run: | | ||
devcontainer up --workspace-folder . | ||
devcontainer exec --workspace-folder . make --always-make check_all | ||
devcontainer exec --workspace-folder . make build AXIS_PACKAGE=licensekey_handler | ||
devcontainer exec --workspace-folder . make build AXIS_PACKAGE=embedded_web_page | ||
- name: Install host dependencies | ||
run: cargo install cross | ||
- name: Run checks | ||
- name: Run checks on host | ||
run: | | ||
make --always-make check_all | ||
PACKAGE=licensekey_handler make build | ||
make check_all |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,16 @@ | |
# Name of package containing the app to be built. | ||
# Rust does not enforce that the path to the package matches the package name, but | ||
# this makefile does to keep things simple. | ||
PACKAGE ?= hello_world | ||
AXIS_PACKAGE ?= hello_world | ||
|
||
# The architecture that will be assumed when interacting with the device. | ||
ARCH ?= aarch64 | ||
AXIS_DEVICE_ARCH ?= aarch64 | ||
|
||
# The IP address of the device to interact with. | ||
DEVICE_IP ?= 192.168.0.90 | ||
AXIS_DEVICE_IP ?= 192.168.0.90 | ||
|
||
# The password to use when interacting with the device. | ||
PASS ?= pass | ||
AXIS_DEVICE_PASS ?= pass | ||
|
||
# Other | ||
# ----- | ||
|
@@ -28,52 +28,77 @@ PASS ?= pass | |
# the target is up to date. | ||
.DELETE_ON_ERROR: ; | ||
|
||
# Don't remove intermediate files. | ||
.SECONDARY: | ||
|
||
# Prevent pesky default rules from creating unexpected dependency graphs. | ||
.SUFFIXES: ; | ||
|
||
# Rebuild targets when marking them as phony directly is not enough. | ||
FORCE:; | ||
.PHONY: FORCE | ||
|
||
# Use the current environment when already in a container. | ||
ifeq (0, $(shell test -e /.dockerenv; echo $$?)) | ||
|
||
ACAP_BUILD = . /opt/axis/acapsdk/$(ENVIRONMENT_SETUP) && cd $(@D) && acap-build --build no-build . | ||
|
||
CROSS := cargo | ||
|
||
# It doesn't matter which SDK is sourced for installing, but using a wildcard would fail since there are multiple in the container. | ||
EAP_INSTALL = cd $(CURDIR)/target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)/ \ | ||
&& . /opt/axis/acapsdk/environment-setup-cortexa53-crypto-poky-linux && eap-install.sh $(AXIS_DEVICE_IP) $(AXIS_DEVICE_PASS) $@ | ||
|
||
# Use a containerized environment when running on host. | ||
else | ||
|
||
# Bare minimum to make the output from the container available on host with correct permissions. | ||
DOCKER_RUN = docker run \ | ||
--volume ${CURDIR}/target/$(ARCH)/$(PACKAGE)/:/opt/app \ | ||
--volume ${CURDIR}/target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)/:/opt/app \ | ||
--user $(shell id -u):$(shell id -g) \ | ||
axisecp/acap-native-sdk:1.12-$(ARCH)-ubuntu22.04 | ||
axisecp/acap-native-sdk:1.12-$(AXIS_DEVICE_ARCH)-ubuntu22.04 | ||
|
||
ACAP_BUILD = $(DOCKER_RUN) sh -c ". /opt/axis/acapsdk/environment-setup-* && acap-build --build no-build ." | ||
|
||
CROSS := cross | ||
|
||
EAP_INSTALL = $(DOCKER_RUN) sh -c ". /opt/axis/acapsdk/environment-setup-* && eap-install.sh $(AXIS_DEVICE_IP) $(AXIS_DEVICE_PASS) $@" | ||
|
||
endif | ||
|
||
|
||
## Verbs | ||
## ===== | ||
|
||
help: | ||
@mkhelp print_docs $(firstword $(MAKEFILE_LIST)) help | ||
|
||
## Build <PACKAGE> for all architectures | ||
build: target/aarch64/$(PACKAGE)/_envoy target/armv7hf/$(PACKAGE)/_envoy | ||
## Build <AXIS_PACKAGE> for <AXIS_DEVICE_ARCH> | ||
build: target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)/_envoy | ||
mkdir -p target/acap | ||
cp $(patsubst %/_envoy,%/*.eap,$^) target/acap | ||
|
||
|
||
|
||
## Install <PACKAGE> on <DEVICE_IP> using password <PASS> and assuming architecture <ARCH> | ||
## Install <AXIS_PACKAGE> on <AXIS_DEVICE_IP> using password <AXIS_DEVICE_PASS> and assuming architecture <AXIS_DEVICE_ARCH> | ||
install: | ||
@ $(DOCKER_RUN) sh -c ". /opt/axis/acapsdk/environment-setup-* && eap-install.sh $(DEVICE_IP) $(PASS) install" \ | ||
@ $(EAP_INSTALL) \ | ||
| grep -v '^to start your application type$$' \ | ||
| grep -v '^ eap-install.sh start$$' | ||
|
||
## Remove <PACKAGE> from <DEVICE_IP> using password <PASS> and assuming architecture <ARCH> | ||
## Remove <AXIS_PACKAGE> from <AXIS_DEVICE_IP> using password <AXIS_DEVICE_PASS> and assuming architecture <AXIS_DEVICE_ARCH> | ||
remove: | ||
@ $(DOCKER_RUN) sh -c ". /opt/axis/acapsdk/environment-setup-* && eap-install.sh $(DEVICE_IP) $(PASS) remove" | ||
@ $(EAP_INSTALL) | ||
|
||
## Start <PACKAGE> on <DEVICE_IP> using password <PASS> and assuming architecture <ARCH> | ||
## Start <AXIS_PACKAGE> on <AXIS_DEVICE_IP> using password <AXIS_DEVICE_PASS> and assuming architecture <AXIS_DEVICE_ARCH> | ||
start: | ||
@ $(DOCKER_RUN) sh -c ". /opt/axis/acapsdk/environment-setup-* && eap-install.sh $(DEVICE_IP) $(PASS) start" \ | ||
@ $(EAP_INSTALL) \ | ||
| grep -v '^to stop your application type$$' \ | ||
| grep -v '^ eap-install.sh stop$$' | ||
|
||
## Stop <PACKAGE> on <DEVICE_IP> using password <PASS> and assuming architecture <ARCH> | ||
## Stop <AXIS_PACKAGE> on <AXIS_DEVICE_IP> using password <AXIS_DEVICE_PASS> and assuming architecture <AXIS_DEVICE_ARCH> | ||
stop: | ||
@ $(DOCKER_RUN) sh -c ". /opt/axis/acapsdk/environment-setup-* && eap-install.sh $(DEVICE_IP) $(PASS) stop" | ||
@ $(EAP_INSTALL) | ||
|
||
## Build and run <PACKAGE> directly on <DEVICE_IP> assuming architecture <ARCH> | ||
## Build and run <AXIS_PACKAGE> directly on <AXIS_DEVICE_IP> assuming architecture <AXIS_DEVICE_ARCH> | ||
## | ||
## Forwards the following environment variables to the remote process: | ||
## | ||
|
@@ -85,18 +110,20 @@ stop: | |
## * The app is installed on the device. | ||
## * The app is stopped. | ||
## * The device has SSH enabled the ssh user root configured. | ||
run: target/$(ARCH)/$(PACKAGE)/_envoy | ||
acap-ssh-utils --host $(DEVICE_IP) --user root --pass $(PASS) patch $(<D)/*.eap | ||
acap-ssh-utils --host $(DEVICE_IP) --user root --pass $(PASS) run-app \ | ||
run: target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)/_envoy | ||
acap-ssh-utils --host $(AXIS_DEVICE_IP) --user root --pass $(AXIS_DEVICE_PASS) patch $(<D)/*.eap | ||
acap-ssh-utils --host $(AXIS_DEVICE_IP) --user root --pass $(AXIS_DEVICE_PASS) run-app \ | ||
--environment RUST_LOG=debug \ | ||
--environment RUST_LOG_STYLE=always \ | ||
$(PACKAGE) | ||
$(AXIS_PACKAGE) | ||
|
||
## Install development dependencies | ||
sync_env: | ||
sync_env: venv/bin/npm | ||
|
||
cargo install --root venv --target-dir $(CURDIR)/target --path $(CURDIR)/crates/acap-ssh-utils | ||
cargo install --root venv --target-dir $(CURDIR)/target cross | ||
PIP_CONSTRAINT=constraints.txt pip install --requirement requirements.txt | ||
npm install -g @devcontainers/[email protected] | ||
|
||
## Checks | ||
## ------ | ||
|
@@ -106,13 +133,13 @@ check_all: check_build check_docs check_format check_lint check_tests check_gene | |
.PHONY: check_all | ||
|
||
## Check that all crates can be built | ||
check_build: target/aarch64/$(PACKAGE)/_envoy target/armv7hf/$(PACKAGE)/_envoy | ||
check_build: target/aarch64/$(AXIS_PACKAGE)/_envoy target/armv7hf/$(AXIS_PACKAGE)/_envoy | ||
cargo build \ | ||
--exclude licensekey \ | ||
--exclude licensekey-sys \ | ||
--exclude licensekey_handler \ | ||
--workspace | ||
cross build \ | ||
$(CROSS) build \ | ||
--exclude acap-ssh-utils \ | ||
--target aarch64-unknown-linux-gnu \ | ||
--workspace | ||
|
@@ -122,15 +149,15 @@ check_build: target/aarch64/$(PACKAGE)/_envoy target/armv7hf/$(PACKAGE)/_envoy | |
## Check that docs can be built | ||
check_docs: | ||
RUSTDOCFLAGS="-Dwarnings" cargo doc | ||
RUSTDOCFLAGS="-Dwarnings" cross doc \ | ||
RUSTDOCFLAGS="-Dwarnings" $(CROSS) doc \ | ||
--document-private-items \ | ||
--exclude acap-ssh-utils \ | ||
--no-deps \ | ||
--target aarch64-unknown-linux-gnu \ | ||
--workspace | ||
.PHONY: check_docs | ||
|
||
## _ | ||
## Check that the code is formatted correctly | ||
check_format: | ||
cargo fmt --check | ||
.PHONY: check_format | ||
|
@@ -141,8 +168,7 @@ check_generated_files: $(patsubst %/,%/src/bindings.rs,$(wildcard crates/*-sys/) | |
git --no-pager diff --exit-code HEAD -- $^ | ||
.PHONY: check_generated_files | ||
|
||
|
||
## _ | ||
## Check that the code is free of lints | ||
check_lint: | ||
RUSTFLAGS="-Dwarnings" cargo clippy \ | ||
--all-targets \ | ||
|
@@ -151,7 +177,7 @@ check_lint: | |
--exclude licensekey-sys \ | ||
--exclude licensekey_handler \ | ||
--workspace | ||
RUSTFLAGS="-Dwarnings" cross clippy \ | ||
RUSTFLAGS="-Dwarnings" $(CROSS) clippy \ | ||
--all-targets \ | ||
--exclude acap-ssh-utils \ | ||
--no-deps \ | ||
|
@@ -171,12 +197,12 @@ check_tests: | |
## Fixes | ||
## ----- | ||
|
||
## _ | ||
## Attempt to fix formatting automatically | ||
fix_format: | ||
cargo fmt | ||
.PHONY: fix_format | ||
|
||
## _ | ||
## Attempt to fix lints automatically | ||
fix_lint: | ||
cargo clippy --fix | ||
.PHONY: fix_lint | ||
|
@@ -204,39 +230,51 @@ crates/%-sys/src/bindings.rs: FORCE | |
# * `.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 | ||
target/aarch64/$(AXIS_PACKAGE)/_envoy: ENVIRONMENT_SETUP=environment-setup-cortexa53-crypto-poky-linux | ||
target/armv7hf/$(AXIS_PACKAGE)/_envoy: ENVIRONMENT_SETUP=environment-setup-cortexa9hf-neon-poky-linux-gnueabi | ||
target/%/$(AXIS_PACKAGE)/_envoy: AXIS_DEVICE_ARCH=$* | ||
target/%/$(AXIS_PACKAGE)/_envoy: target/%/$(AXIS_PACKAGE)/lib target/%/$(AXIS_PACKAGE)/html target/%/$(AXIS_PACKAGE)/$(AXIS_PACKAGE) target/%/$(AXIS_PACKAGE)/manifest.json target/%/$(AXIS_PACKAGE)/LICENSE | ||
$(ACAP_BUILD) | ||
touch $@ | ||
|
||
target/%/$(PACKAGE)/manifest.json: apps/$(PACKAGE)/manifest.json | ||
target/%/$(AXIS_PACKAGE)/html: FORCE | ||
mkdir -p $(dir $@) | ||
if [ -d $@ ]; then rm -r $@; fi | ||
if [ -d apps/$(AXIS_PACKAGE)/html ]; then cp -r apps/$(AXIS_PACKAGE)/html $@; fi | ||
|
||
target/%/$(AXIS_PACKAGE)/lib: FORCE | ||
mkdir -p $(dir $@) | ||
if [ -d $@ ]; then rm -r $@; fi | ||
if [ -d apps/$(AXIS_PACKAGE)/lib ]; then cp -r apps/$(AXIS_PACKAGE)/lib $@; fi | ||
|
||
target/%/$(AXIS_PACKAGE)/manifest.json: apps/$(AXIS_PACKAGE)/manifest.json | ||
mkdir -p $(dir $@) | ||
cp $< $@ | ||
|
||
target/%/$(PACKAGE)/LICENSE: apps/$(PACKAGE)/LICENSE | ||
target/%/$(AXIS_PACKAGE)/LICENSE: apps/$(AXIS_PACKAGE)/LICENSE | ||
mkdir -p $(dir $@) | ||
cp $< $@ | ||
|
||
# The target triple and the name of the docker image do not match, so | ||
# at some point we need to map one to the other. It might as well be here. | ||
target/aarch64/$(PACKAGE)/$(PACKAGE): target/aarch64-unknown-linux-gnu/release/$(PACKAGE) | ||
target/aarch64/$(AXIS_PACKAGE)/$(AXIS_PACKAGE): target/aarch64-unknown-linux-gnu/release/$(AXIS_PACKAGE) | ||
mkdir -p $(dir $@) | ||
cp $< $@ | ||
|
||
target/armv7hf/$(PACKAGE)/$(PACKAGE): target/thumbv7neon-unknown-linux-gnueabihf/release/$(PACKAGE) | ||
target/armv7hf/$(AXIS_PACKAGE)/$(AXIS_PACKAGE): target/thumbv7neon-unknown-linux-gnueabihf/release/$(AXIS_PACKAGE) | ||
mkdir -p $(dir $@) | ||
cp $< $@ | ||
|
||
# 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 | ||
target/%/release/$(AXIS_PACKAGE): FORCE | ||
$(CROSS) -v build --release --target $* --package $(AXIS_PACKAGE) | ||
touch $@ # This is a hack to make the `_envoy` target above always build | ||
|
||
|
||
venv/bin/npm: venv/downloads/node-v18.16.1-linux-x64.tar.gz | ||
tar -xf "$<" --strip-components 1 -C venv | ||
|
||
venv/downloads/node-v18.16.1-linux-x64.tar.gz: | ||
mkdir -p $(@D) | ||
curl -L -o "$@" "https://nodejs.org/dist/v18.16.1/node-v18.16.1-linux-x64.tar.gz" | ||
echo "59582f51570d0857de6333620323bdeee5ae36107318f86ce5eca24747cabf5b $@" | sha256sum -c - |
Oops, something went wrong.