Skip to content
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
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ FROM ubuntu:jammy

ARG USER_ID
ARG GROUP_ID
ENV DEBIAN_FRONTEND noninteractive
ARG GDB

RUN apt-get update && apt-get install -y git cmake make ruby gcc python3 python3-pip gcc-arm-none-eabi ninja-build
ENV DEBIAN_FRONTEND=noninteractive

RUN if [ "$GDB" = "yes" ]; then apt-get install -y gdb; fi
RUN apt-get update && apt-get install -y git cmake make ruby gcc python3 python3-yaml ninja-build gcc-arm-none-eabi

RUN pip install pyyaml
RUN if [ "$GDB" = "yes" ]; then apt-get install -y gdb; fi

# if either of these are already set the same as the user's machine, leave them be and ignore the error
RUN addgroup --gid $GROUP_ID inav; exit 0;
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID inav; exit 0;
# If a group and user with the same IDs already exist, rename the group and recreate the user after deleting the existing one.
RUN GROUP="$(id -n -g $GROUP_ID)"; if [ -n "$GROUP" ]; then groupmod -n inav "$GROUP"; else groupadd --gid $GROUP_ID inav; fi
RUN USER="$(id -n -u $USER_ID)"; if [ -n "$USER" ]; then userdel -r "$USER"; fi && useradd -m --uid $USER_ID --gid $GROUP_ID inav

USER inav

RUN git config --global --add safe.directory /src

VOLUME /src

WORKDIR /src/build

ENTRYPOINT ["/src/cmake/docker.sh"]
44 changes: 34 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -euo pipefail

if [[ $# == 0 ]]; then
echo -e "\
Expand All @@ -8,6 +8,10 @@ Usage syntax: ./build.sh <TARGET>
Notes:
* You can specify multiple targets.
./build.sh <TARGET_1> <TARGET_2> <TARGET_N>
* To get a list of release targets use \"release_targets\"
./build.sh release_targets
* To get a list of valid targets use \"valid_targets\"
./build.sh valid_targets
* To get a list of all targets use \"help\". Hint: pipe the output through a pager.
./build.sh help | less
* To build all targets use \"all\"
Expand All @@ -19,10 +23,20 @@ Notes:
exit 1
fi

run_docker() {
docker run --rm -it -v "$(pwd)":/src inav-build "$@"
}

if [ -z "$(docker images -q inav-build)" ]; then
echo -e "*** Building image\n"
docker build -t inav-build --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" .
echo -ne "\n"
echo "*** Building Docker image"
docker build -t inav-build \
--build-arg USER_ID="$(id -u)" \
--build-arg GROUP_ID="$(id -g)" .
else
docker build -q -t inav-build \
--build-arg USER_ID="$(id -u)" \
--build-arg GROUP_ID="$(id -g)" . >/dev/null ||
{ echo "*** Building Docker image: ERROR"; exit 1; }
fi

if [ ! -d ./build ]; then
Expand All @@ -40,10 +54,20 @@ if [ ! -d ./tools ]; then
mkdir ./tools && chmod 777 ./tools
fi

echo -e "*** Building targets [$@]\n"
docker run --rm -it -v "$(pwd)":/src inav-build $@
case "$1" in
release_targets)
run_docker targets | sed -n 's/^Release targets: \(.*\)/\1/p'|tr ' ' '\n'
;;
valid_targets)
run_docker targets | sed -n 's/^Valid targets: \(.*\)/\1/p'|tr ' ' '\n'
;;
*)
echo -e "*** Building targets [$@]\n"
run_docker "$@"
if ls ./build/*.hex &> /dev/null; then
echo -e "\n*** Built targets in ./build:"
stat -c "%n (%.19y)" ./build/*.hex
fi
;;
esac

if [ -z "$(ls ./build/*.hex &> /dev/null)" ]; then
echo -e "\n*** Built targets in ./build:"
stat -c "%n (%.19y)" ./build/*.hex
fi
11 changes: 11 additions & 0 deletions cmake/arm-none-eabi-checks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,23 @@ function(arm_none_eabi_gcc_check)
if(NOT version)
message("-- could not find ${prog}")
arm_none_eabi_gcc_install()
gcc_get_version(version
TRIPLET ${arm_none_eabi_triplet}
PROGRAM_NAME prog
PROGRAM_PATH prog_path
)
return()
endif()
message("-- found ${prog} ${version} at ${prog_path}")
if(COMPILER_VERSION_CHECK AND NOT arm_none_eabi_gcc_version STREQUAL version)
message("-- expecting ${prog} version ${arm_none_eabi_gcc_version}, but got version ${version} instead")
arm_none_eabi_gcc_install()
unset(gcc CACHE)
gcc_get_version(version
TRIPLET ${arm_none_eabi_triplet}
PROGRAM_NAME prog
PROGRAM_PATH prog_path
)
return()
endif()
endfunction()
Expand Down
2 changes: 1 addition & 1 deletion cmake/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ initialize_cmake() {
}

# Check if CMake has never been initialized
if [ ! -f Makefile ]; then
if [ ! -f build.ninja ]; then
initialize_cmake
fi

Expand Down
Loading