Niccolò Maggioni
4 years ago
No known key found for this signature in database
GPG Key ID: 4874B0C841E33264
5 changed files with
69 additions and
27 deletions
.dockerignore
Dockerfile
build.sh
cmake/docker.sh
docs/development/Building in Docker.md
@ -1,2 +1,7 @@
.git/
.vagrant/
obj/
.vscode/
/build/
/obj/
/tools/
/downloads/
@ -1,26 +1,14 @@
FROM ubuntu:bionic
FROM ubuntu:focal
# Configuration
VOLUME /home/src/
WORKDIR /home/src/
ARG TOOLCHAIN_VERSION_SHORT
ENV TOOLCHAIN_VERSION_SHORT ${ TOOLCHAIN_VERSION_SHORT :- "9-2019q4" }
ARG TOOLCHAIN_VERSION_LONG
ENV TOOLCHAIN_VERSION_LONG ${ TOOLCHAIN_VERSION_LONG :- "9-2019-q4-major" }
ENV DEBIAN_FRONTEND noninteractive
# Essentials
RUN mkdir -p /home/src && \
apt-get update && \
apt-get install -y software-properties-common ruby make git gcc wget curl bzip2
# Toolchain
RUN wget -P /tmp " https://developer.arm.com/-/media/Files/downloads/gnu-rm/ $TOOLCHAIN_VERSION_SHORT /gcc-arm-none-eabi- $TOOLCHAIN_VERSION_LONG -x86_64-linux.tar.bz2 "
RUN mkdir -p /opt && \
cd /opt && \
tar xvjf " /tmp/gcc-arm-none-eabi- $TOOLCHAIN_VERSION_LONG -x86_64-linux.tar.bz2 " -C /opt && \
chmod -R -w " /opt/gcc-arm-none-eabi- $TOOLCHAIN_VERSION_LONG "
ENV PATH = " /opt/gcc-arm-none-eabi- $TOOLCHAIN_VERSION_LONG /bin: $PATH "
RUN apt-get update && apt-get install -y git cmake make ruby gcc
RUN useradd inav
USER inav
VOLUME /src
WORKDIR /src/build
ENTRYPOINT [ "/src/cmake/docker.sh" ]
@ -1,12 +1,32 @@
if [ -z " $1 " ] ; then
echo "Usage syntax: ./build.sh <TARGET>"
set -e
if [ [ $# = = 0 ] ] ; then
echo -e " \
Usage syntax: ./build.sh <TARGET>
Notes:
* You can specify multiple targets.
* If no targets are specified, *all* of them will be built.
* To clean a target prefix it with \" clean_\" .
* To clean all targets just use \" clean\" ."
exit 1
fi
if [ -z " $( docker images -q inav-build) " ] ; then
echo -e "*** Building image\n"
docker build -t inav-build .
echo -ne "\n"
fi
if [ ! -d ./build ] ; then
echo -e "*** Creating build directory\n"
mkdir ./build
fi
echo -e " *** Building target $1 \n "
docker run --rm -v " $( pwd ) " :/home/src/ inav-build make TARGET = " $1 "
echo -e " *** Building targets [ $@ ]\n "
docker run --rm -it -v " $( pwd ) " :/src inav-build $@
if ls ./build/*.hex & > /dev/null; then
echo -e "\n*** Built targets in ./build:"
stat -c "%n (%.19y)" ./build/*.hex
fi
@ -0,0 +1,29 @@
#!/bin/bash
set -e
LAST_CMAKE_AT_REV_FILE = "docker_cmake.rev"
CURR_REV = " $( git rev-parse HEAD) "
initialize_cmake( ) {
echo -e "*** CMake was not initialized yet, doing it now.\n"
cmake ..
echo " $CURR_REV " > " $LAST_CMAKE_AT_REV_FILE "
}
# Check if CMake has never been initialized
if [ ! -f Makefile ] ; then
initialize_cmake
fi
# Check if CMake was initialized for a different Git revision (new targets may have been added)
if [ -f " $LAST_CMAKE_AT_REV_FILE " ] ; then
LAST_CMAKE_AT_REV = " $( cat $LAST_CMAKE_AT_REV_FILE ) "
if [ [ " $LAST_CMAKE_AT_REV " != "SKIP" ] ] && [ [ " $LAST_CMAKE_AT_REV " != " $CURR_REV " ] ] ; then
initialize_cmake
fi
else
initialize_cmake
fi
# Let Make handle the arguments coming from the build script
make " $@ "
@ -28,7 +28,7 @@ You'll have to manually execute the same steps that the build script does:
1. `docker build -t inav-build .`
+ This step is only needed the first time.
2. `docker run --rm -v <PATH_TO_REPO>:/home/ src/ inav-build make TARGET= <TARGET>`
2. `docker run --rm -it - v <PATH_TO_REPO>:/src inav-build <TARGET>`
+ Where `<PATH_TO_REPO>` must be replaced with the absolute path of where you cloned this repo (see above), and `<TARGET>` with the name of the target that you want to build.
Refer to the [Linux ](#Linux ) instructions or the [build script ](/build.sh ) for more details.