diff --git a/CHANGELOG.md b/CHANGELOG.md index bf7ea37f..1918483f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Please add a note of your changes below this heading if you make a Pull Request. * Unit Testing with Doctest has been started for select algorithms, see [Firmware/Tests/test_runner.cpp](Firmware/Tests/test_runner.cpp) * Added support for Flylint VSCode Extension for static code analysis * Using an STM32F405 .svd file allows CortexDebug to view registers during debugging +* Added scripts for building via docker. ### Changed * Changed ratiometric `motor.config.current_lim_tolerance` to absolute `motor.config.current_lim_margin` diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9739928c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:bionic + +# Prepare the build environment and dependencies +RUN apt-get update +RUN apt-get -y install software-properties-common +RUN add-apt-repository ppa:team-gcc-arm-embedded/ppa +RUN add-apt-repository ppa:jonathonf/tup +RUN apt-get update +RUN apt-get -y upgrade +RUN apt-get -y install gcc-arm-embedded openocd tup python3.7 build-essential git + +# Build step below does not know about debian's python naming schemme +RUN ln -s /usr/bin/python3.7 /usr/bin/python + +# Copy the firmware tree into the container +RUN mkdir ODrive +COPY . ODrive +WORKDIR ODrive/Firmware + +# Hack around Tup's dependency on FUSE +RUN tup generate build.sh +RUN ./build.sh diff --git a/dockerbuild.sh b/dockerbuild.sh new file mode 100755 index 00000000..779b9bf1 --- /dev/null +++ b/dockerbuild.sh @@ -0,0 +1,47 @@ +function cleanup { + echo "Removing previous build artifacts" + rm -rf build + docker rm odrive-build-cont +} + +function gc { + cleanup + docker rmi odrive-build-img + docker image prune +} + +function build { + cleanup + + echo "Building the firmware" + docker build -t odrive-build-img . + + echo "Create container" + docker create --name odrive-build-cont odrive-build-img:latest + + echo "Extract build artifacts" + docker cp odrive-build-cont:ODrive/Firmware/build . +} + +function usage { + echo "usage: $0 (build | cleanup | gc)" + echo + echo "build -- build in docker and extract the artifacts." + echo "cleanup -- remove build artifacts from previous build" + echo "gc -- remove all build images and containers" +} + +case $1 in + build) + build + ;; + cleanup) + cleanup + ;; + gc) + gc + ;; + *) + usage + ;; +esac