Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ad hoc build system #6

Merged
merged 6 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 50 additions & 17 deletions Dockerfile → .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ARG REPO=axisecp
ARG SDK=acap-native-sdk
ARG UBUNTU_VERSION=22.04
ARG VERSION=1.14
ARG VERSION=1.15
ARG BASE_IMAGE=debian:bookworm-20240423

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}
FROM --platform=linux/amd64 ${REPO}/${SDK}:${VERSION}-aarch64-ubuntu${UBUNTU_VERSION} AS sdk-aarch64
FROM --platform=linux/amd64 ${REPO}/${SDK}:${VERSION}-armv7hf-ubuntu${UBUNTU_VERSION} AS sdk-armv7hf
FROM --platform=linux/amd64 ${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
Expand All @@ -16,26 +16,49 @@ COPY --from=sdk-armv7hf /opt/axis/acapsdk/sysroots/armv7hf /opt/axis/acapsdk/sys
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 \
&& apt-get install \
--assume-yes \
--no-install-recommends \
build-essential \
ca-certificates \
clang \
curl \
g++-aarch64-linux-gnu \
g++-arm-linux-gnueabihf \
git \
iputils-ping \
libglib2.0-dev \
libssl-dev \
pkg-config \
python3-jsonschema \
wget \
&& rm -rf /var/lib/apt/lists/*
sshpass

ENV RUSTUP_HOME=/usr/local/rustup \
ENV PATH=/usr/local/cargo/bin:$PATH \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUSTUP_HOME=/usr/local/rustup

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
COPY rust-toolchain.toml ./
RUN curl \
--output /tmp/rustup-init \
"https://static.rust-lang.org/rustup/archive/1.26.0/x86_64-unknown-linux-gnu/rustup-init" \
&& echo "0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db /tmp/rustup-init" \
| sha256sum -c - \
&& chmod +x /tmp/rustup-init \
&& ./tmp/rustup-init \
--no-modify-path \
--no-update-default-toolchain \
-y \
&& rm /tmp/rustup-init \
&& rustup show \
&& cargo install \
--locked \
--git https://github.com/AxisCommunications/acap-rs.git \
--rev 5148b09e77e321a215a18f2f4ab75ec64839265c \
acap-ssh-utils \
cargo-acap-build \
cargo-acap-sdk \
device-manager \
&& rm rust-toolchain.toml

ENV \
SYSROOT_AARCH64=/opt/axis/acapsdk/sysroots/aarch64 \
Expand All @@ -44,8 +67,8 @@ ENV \
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++" \
CC_aarch64_unknown_linux_gnu="aarch64-linux-gnu-gcc" \
CXX_aarch64_unknown_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}" \
Expand All @@ -56,3 +79,13 @@ ENV \
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}"

# If neither `CARGO_HOME` nor `HOME` is set when launching a container, then cargo will try to
# download crates to this directory. If launched with the `--user` option then this will fail.
# TODO: Replace the example in the README with something that does not mount any volumes.
RUN mkdir /.cargo \
&& chmod a+w /.cargo/

# TODO: Consider removing the content of `CARGO_HOME` instead of `chmod`ing it;
RUN find $CARGO_HOME $RUSTUP_HOME -type d -exec chmod a+rwx {} +
RUN find $CARGO_HOME $RUSTUP_HOME -type f -exec chmod a+rw {} +
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -1,9 +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"
"version": "2.4.5",
"resolved": "ghcr.io/devcontainers/features/common-utils@sha256:e232c240319c4e019467c1099536c5eefebd762cf017d6d50353ed50fbf66ba3",
"integrity": "sha256:e232c240319c4e019467c1099536c5eefebd762cf017d6d50353ed50fbf66ba3"
}
}
}
9 changes: 3 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"name": "acap-rs-app-template",
"build": {
"dockerfile": "../Dockerfile",
"dockerfile": "Dockerfile",
"context": ".."
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/common-utils:2": {}
},
"remoteUser": "${localEnv:USER}",
"containerEnv": {
"CARGO_HOME": "/home/${localEnv:USER}/.cargo"
}
"remoteUser": "${localEnv:USER}"
}
11 changes: 6 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: cargo install --locked [email protected]
- name: Run checks
- name: Install dev container dependencies
run: npm install -g @devcontainers/[email protected]
- name: Run checks in dev container
run: |
make --always-make check_all
make build
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . make --always-make check_all
devcontainer exec --workspace-folder . make build
27 changes: 0 additions & 27 deletions Cross.toml

This file was deleted.

Loading