Skip to content
Snippets Groups Projects
Commit 697e692b authored by Vincent Templier's avatar Vincent Templier
Browse files

Add Dockerfile system for export compilation

parent be264599
No related branches found
No related tags found
1 merge request!3Refactor module
#####################################################################
##: Different options to compile the export
##: Usage :
##:
##: make / make help
##: display the different options available
##: make build
##: compile the export on host for C/C++ apps
##: (generate an executable in build/bin)
##: make build_image_docker
##: generate the docker image of the arm compiler
##: make build_docker
##: compile the export in a container for C/C++ apps
##: (generate an executable in build/bin)
##: make clean
##: clean up the build and bin folders
##:
#####################################################################
OPENOCD := /usr/local/bin/openocd OPENOCD := /usr/local/bin/openocd
OPENOCD_SCRIPT := /usr/local/share/openocd/scripts/board/stm32h7x3i_eval.cfg OPENOCD_SCRIPT := /usr/local/share/openocd/scripts/board/stm32h7x3i_eval.cfg
MAKEFLAGS := --no-print-directory
DOCKER_COMPILER := tools/arm-none-eabi_compiler.Dockerfile
IMAGE := arm:arm-none-eabi_compiler
BOARD := stm32h7
OBJDIR := build OBJDIR := build
BINDIR := bin BINDIR := bin
...@@ -34,30 +57,49 @@ ASM_OBJS := $(patsubst %.s,$(OBJDIR)/%.s.o,$(ASM_SRCS)) ...@@ -34,30 +57,49 @@ ASM_OBJS := $(patsubst %.s,$(OBJDIR)/%.s.o,$(ASM_SRCS))
all: build all: help
build: ${CC_OBJS} ${CXX_OBJS} ${ASM_OBJS} build: ${CC_OBJS} ${CXX_OBJS} ${ASM_OBJS}
@mkdir -p $(dir ${TARGET}) @mkdir -p $(dir ${TARGET})
${CC} ${CC_OBJS} ${CXX_OBJS} ${ASM_OBJS} ${LINK_FLAGS} -o ${TARGET} ${CC} ${CC_OBJS} ${CXX_OBJS} ${ASM_OBJS} ${LINK_FLAGS} -o ${TARGET}
@chmod -R a+w ${BINDIR}
${OBJDIR}/%.c.o: %.c ${OBJDIR}/%.c.o: %.c
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
${CC} ${CC_FLAGS} ${INCLUDE_DIRS} -o $@ $< ${CC} ${CC_FLAGS} ${INCLUDE_DIRS} -o $@ $<
@chmod -R a+w ${OBJDIR}
${OBJDIR}/%.cpp.o: %.cpp ${OBJDIR}/%.cpp.o: %.cpp
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
${CXX} ${CXX_FLAGS} ${INCLUDE_DIRS} -o $@ $< ${CXX} ${CXX_FLAGS} ${INCLUDE_DIRS} -o $@ $<
@chmod -R a+w ${OBJDIR}
${OBJDIR}/%.s.o: %.s ${OBJDIR}/%.s.o: %.s
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
${ASM} ${ASM_FLAGS} -o $@ $< ${ASM} ${ASM_FLAGS} -o $@ $<
@chmod -R a+w ${OBJDIR}
.PHONY: clean .PHONY: clean help
clean: clean:
if [ -d "${OBJDIR}" ]; then rm -rf ${OBJDIR}; fi if [ -d "${OBJDIR}" ]; then rm -rf ${OBJDIR}; fi
if [ -d "${BINDIR}" ]; then rm -rf ${BINDIR}; fi if [ -d "${BINDIR}" ]; then rm -rf ${BINDIR}; fi
help:
@grep -e "^##:" Makefile;
# Makefile target for building the arm-none-eabi compiler image
.PHONY: build_image_docker
build_image_docker:
@docker build --pull --rm -f "${DOCKER_COMPILER}" -t ${IMAGE} tools/
# Makefile targets for building export app via docker
.PHONY: build_docker
build_docker:
@docker run --rm --name ${BOARD}_compiling -v "${PWD}":/usr/src/export -w /usr/src/export ${IMAGE} make build
-include $(DEPENDENCIES) -include $(DEPENDENCIES)
FROM ubuntu:22.04
# User can change those variables to update the toolchain
ARG ARM_VERSION=10.3-2021.10
ARG ARM_PLATFORM=x86_64
# Install linux packages
RUN apt update \
&& apt install --no-install-recommends -y wget git tar build-essential cmake
# Installation directory for the ARM tools
ENV ARM_TOOLCHAIN_ROOT=/opt/arm_compiler
WORKDIR ${ARM_TOOLCHAIN_ROOT}
# Install GNU Arm Embedded Toolchain
RUN wget --no-check-certificate -c \
https://developer.arm.com/-/media/Files/downloads/gnu-rm/${ARM_VERSION}/gcc-arm-none-eabi-${ARM_VERSION}-${ARM_PLATFORM}-linux.tar.bz2
# Unpack the tarball to the install directory
RUN tar xjf gcc-arm-none-eabi-${ARM_VERSION}-${ARM_PLATFORM}-linux.tar.bz2
# Make accessible the toolchain anywhere
ENV PATH=$PATH:${ARM_TOOLCHAIN_ROOT}/gcc-arm-none-eabi-${ARM_VERSION}/bin
# Workspace directory
WORKDIR /workspace
# Start bash login shell
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/bin/bash", "-i"]
#!/usr/bin/env bash
set -Eeuo pipefail
# first arg is `-f` or `--some-option` or there are no args
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
exec bash "$@"
fi
exec "$@"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment