Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into add_vapix_access_ex…
Browse files Browse the repository at this point in the history
…ample

* upstream/main:
  Generate app `LICENSE` files (#44)
  Add acap-ssh-utils bin and lib crate (#19)
  • Loading branch information
apljungquist committed Jul 19, 2024
2 parents 173eb83 + 456d8ab commit 5c5bd51
Show file tree
Hide file tree
Showing 33 changed files with 719 additions and 156 deletions.
3 changes: 2 additions & 1 deletion .devhost/install-system-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ apt-get install \
iputils-ping \
libglib2.0-dev \
pkg-config \
python3-venv
python3-venv \
sshpass
4 changes: 3 additions & 1 deletion .devhost/install-venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ rm /tmp/node-v18.16.1-linux-x64.tar.gz
# Install `devcontainer` into venv
npm install -g @devcontainers/[email protected]

# Install `cargo-acap-build` into venv
# Install rust programs
cargo install --locked --root ${VIRTUAL_ENV} --target-dir /tmp/target [email protected]
cargo install --root ${VIRTUAL_ENV} --target-dir /tmp/target --path ../crates/acap-ssh-utils
cargo install --root ${VIRTUAL_ENV} --target-dir /tmp/target --path ../crates/cargo-acap-build

rm -r /tmp/target
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*
!/.devhost/
!/crates/acap-ssh-utils
!/crates/cargo-acap-build
!/rust-toolchain.toml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/.env
/.idea/
/init_env.sh
/target/
/apps/*/LICENSE
106 changes: 99 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 27 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
# 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.
AXIS_PACKAGE ?= hello_world
export AXIS_PACKAGE ?= hello_world

# The architecture that will be assumed when interacting with the device.
AXIS_DEVICE_ARCH ?= aarch64
export AXIS_DEVICE_ARCH ?= aarch64

# The IP address of the device to interact with.
AXIS_DEVICE_IP ?= 192.168.0.90
export AXIS_DEVICE_IP ?= 192.168.0.90

# The username to use when interacting with the device.
export AXIS_DEVICE_USER ?= root

# The password to use when interacting with the device.
AXIS_DEVICE_PASS ?= pass
export AXIS_DEVICE_PASS ?= pass

# Other
# -----
Expand Down Expand Up @@ -52,7 +55,7 @@ help:
@mkhelp print_docs $(firstword $(MAKEFILE_LIST)) help

## Build <AXIS_PACKAGE> for <AXIS_DEVICE_ARCH>
build:
build: apps/$(AXIS_PACKAGE)/LICENSE
cargo-acap-build --target $(AXIS_DEVICE_ARCH) -- -p $(AXIS_PACKAGE)

## Install <AXIS_PACKAGE> on <AXIS_DEVICE_IP> using password <AXIS_DEVICE_PASS> and assuming architecture <AXIS_DEVICE_ARCH>
Expand Down Expand Up @@ -91,9 +94,11 @@ stop:
## * The device is added to `knownhosts`.
run:
cargo-acap-build --target $(AXIS_DEVICE_ARCH) -- -p $(AXIS_PACKAGE)
scp target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)/$(AXIS_PACKAGE) root@$(AXIS_DEVICE_IP):/usr/local/packages/$(AXIS_PACKAGE)/$(AXIS_PACKAGE)
ssh root@$(AXIS_DEVICE_IP) \
"cd /usr/local/packages/$(AXIS_PACKAGE) && su - acap-$(AXIS_PACKAGE) -s /bin/sh --preserve-environment -c '$(if $(RUST_LOG_STYLE),RUST_LOG_STYLE=$(RUST_LOG_STYLE) )$(if $(RUST_LOG),RUST_LOG=$(RUST_LOG) )./$(AXIS_PACKAGE)'"
acap-ssh-utils patch target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)/*.eap
acap-ssh-utils run-app \
--environment RUST_LOG=debug \
--environment RUST_LOG_STYLE=always \
$(AXIS_PACKAGE)

## Build and execute unit tests for <AXIS_PACKAGE> on <AXIS_DEVICE_IP> assuming architecture <AXIS_DEVICE_ARCH>
##
Expand All @@ -113,9 +118,11 @@ test:
# The `scp` command below needs the wildcard to match exactly one file.
rm -r target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)-*/$(AXIS_PACKAGE) ||:
cargo-acap-build --target $(AXIS_DEVICE_ARCH) -- -p $(AXIS_PACKAGE) --tests
scp target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)-*/$(AXIS_PACKAGE) root@$(AXIS_DEVICE_IP):/usr/local/packages/$(AXIS_PACKAGE)/$(AXIS_PACKAGE)
ssh root@$(AXIS_DEVICE_IP) \
"cd /usr/local/packages/$(AXIS_PACKAGE) && su - acap-$(AXIS_PACKAGE) -s /bin/sh --preserve-environment -c '$(if $(RUST_LOG_STYLE),RUST_LOG_STYLE=$(RUST_LOG_STYLE) )$(if $(RUST_LOG),RUST_LOG=$(RUST_LOG) )./$(AXIS_PACKAGE)'"
acap-ssh-utils patch target/$(AXIS_DEVICE_ARCH)/$(AXIS_PACKAGE)-*/*.eap
acap-ssh-utils run-app \
--environment RUST_LOG=debug \
--environment RUST_LOG_STYLE=always \
$(AXIS_PACKAGE)

## Checks
## ------
Expand All @@ -125,7 +132,7 @@ 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:
check_build: $(patsubst %/,%/LICENSE,$(wildcard apps/*/))
cargo build \
--exclude consume_analytics_metadata \
--exclude licensekey \
Expand All @@ -137,6 +144,7 @@ check_build:
cargo-acap-build \
--target aarch64 \
-- \
--exclude acap-ssh-utils \
--exclude cargo-acap-build \
--workspace

Expand Down Expand Up @@ -220,5 +228,12 @@ fix_lint:
--output-file $@ \
$^

# TODO: Find a convenient way to integrate this with cargo-acap-build
apps/%/LICENSE: apps/%/Cargo.toml about.hbs
cargo-about generate \
--manifest-path apps/$*/Cargo.toml \
--output-file $@ \
about.hbs

crates/%-sys/src/bindings.rs: FORCE
cp $(firstword $(wildcard target/*/*/build/$*-sys-*/out/bindings.rs)) $@
12 changes: 12 additions & 0 deletions about.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

Third Party Software Licenses


{{#each licenses}}
{{#each used_by}}
Software license for {{{crate.name}}} {{{crate.version}}}

{{{../text}}}

{{/each}}
{{/each}}
8 changes: 8 additions & 0 deletions about.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
accepted = [
"MIT",
"Apache-2.0",
"Unicode-DFS-2016",
]
ignore-build-dependencies = true
ignore-dev-dependencies = true
private = { ignore = true }
1 change: 1 addition & 0 deletions apps/consume_analytics_metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "consume_analytics_metadata"
version = "1.0.0"
edition.workspace = true
publish = false

[dependencies]
libc = { workspace = true }
Expand Down
21 changes: 0 additions & 21 deletions apps/consume_analytics_metadata/LICENSE

This file was deleted.

1 change: 1 addition & 0 deletions apps/embedded_web_page/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
name = "embedded_web_page"
version = "1.0.0"
edition.workspace = true
publish = false
Loading

0 comments on commit 5c5bd51

Please sign in to comment.