Skip to content

Commit

Permalink
fix(embedded_web_page): Put web page in html/ (#30)
Browse files Browse the repository at this point in the history
The `acap-build` tool establishes the convention that the `html/`
and `lib/` directories in the current working directory are special and
always included. This seems convenient, so going forward the tools and
examples in this project will follow that convention.

Disable unit tests on host because it is not obvious how to implement
`html_dir`.
  • Loading branch information
apljungquist authored Jun 25, 2024
1 parent d3a58cd commit 191cb3f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,12 @@ target/%/$(PACKAGE)/LICENSE: apps/$(PACKAGE)/LICENSE
# at some point we need to map one to the other. It might as well be here.
target/aarch64/$(PACKAGE)/_envoy: target/aarch64-unknown-linux-gnu/release/$(PACKAGE)
target/armv7hf/$(PACKAGE)/_envoy: target/thumbv7neon-unknown-linux-gnueabihf/release/$(PACKAGE)
target/%/$(PACKAGE)/_envoy: apps/$(PACKAGE)/manifest.json apps/$(PACKAGE)/LICENSE $(wildcard apps/$(PACKAGE)/otherfiles/*)
target/%/$(PACKAGE)/_envoy: apps/$(PACKAGE)/manifest.json apps/$(PACKAGE)/LICENSE
# Make sure we don't include any obsolete files in the `.eap`
if [ -d $(@D) ]; then rm -r $(@D); fi
mkdir -p $(@D)
if [ -d apps/$(PACKAGE)/html ]; then cp -r apps/$(PACKAGE)/html $(@D); fi
if [ -d apps/$(PACKAGE)/lib ]; then cp -r apps/$(PACKAGE)/lib $(@D); fi
cp -r $^ $(@D)
$(DOCKER_RUN) sh -c ". /opt/axis/acapsdk/environment-setup-* && acap-build --build no-build ."
touch $@
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions apps/embedded_web_page/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,25 @@
//! All applications require a program, but for this example it doesn't need to do anything,
//! hence the empty main function.
fn main() {}

// TODO: Figure out how to resolve paths on host
// It is not particularly interesting for this app, but once the reverse proxy example is added it
// becomes feasible to serve the embedded web page also when testing on host.
#[cfg(not(target_arch = "x86_64"))]
#[cfg(test)]
mod tests {
use std::{env, path::PathBuf};

fn html_dir() -> PathBuf {
env::current_exe().unwrap().parent().unwrap().join("html")
}
#[test]
fn html_files_are_installed() {
assert!(html_dir().join("index.html").is_file())
}

#[test]
fn html_nested_files_are_installed() {
assert!(html_dir().join("css").join("main.css").is_file())
}
}

0 comments on commit 191cb3f

Please sign in to comment.