From 60257b615d20b3fa37b21224e16fdd8d31b137ae Mon Sep 17 00:00:00 2001 From: Nathan Schulte Date: Wed, 5 Jul 2023 01:44:16 -0500 Subject: [PATCH] add docker build; firmware, simulator --- build-base.Dockerfile | 25 ++++++++ firmware.Dockerfile | 20 ++++++ firmware/docker_build.sh | 129 +++++++++++++++++++++++++++++++++++++++ fome.docker-compose.yml | 30 +++++++++ simulator.Dockerfile | 17 ++++++ 5 files changed, 221 insertions(+) create mode 100644 build-base.Dockerfile create mode 100644 firmware.Dockerfile create mode 100644 firmware/docker_build.sh create mode 100644 fome.docker-compose.yml create mode 100644 simulator.Dockerfile diff --git a/build-base.Dockerfile b/build-base.Dockerfile new file mode 100644 index 0000000000..e1dad713ef --- /dev/null +++ b/build-base.Dockerfile @@ -0,0 +1,25 @@ +# FOME base build Docker image + +ARG UBUNTU_VERSION=22.04 +FROM ubuntu:${UBUNTU_VERSION} + +ARG FOME_DIR=/fome + +WORKDIR ${FOME_DIR} + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes build-essential gcc-multilib g++-multilib \ + gcc-mingw-w64 g++-mingw-w64 \ + ant curl dosfstools file lsb-release mtools openjdk-8-jdk wget xxd zip git rsync && \ + apt-get remove --assume-yes openjdk-11-jre-headless + +ADD firmware/provide_gcc.sh . +RUN ./provide_gcc.sh + +ADD java_tools/gradlew ./ +ADD java_tools/gradle ./gradle +RUN ./gradlew --version + +WORKDIR ./fome/firmware +ENV PATH="$PATH:$FOME_DIR/gcc-arm-none-eabi/bin" +ENTRYPOINT ["sh", "-c", "uname --all && lsb_release --all && gcc -v && arm-none-eabi-gcc -v"] diff --git a/firmware.Dockerfile b/firmware.Dockerfile new file mode 100644 index 0000000000..a2d47a0d5b --- /dev/null +++ b/firmware.Dockerfile @@ -0,0 +1,20 @@ +# FOME firmware build Docker image + +ARG UBUNTU_VERSION=22.04 +FROM fome/build-base:ubuntu-${UBUNTU_VERSION} + +ARG FOME_DIR=/fome +#ARG PROJECT_BOARD +#ENV PROJECT_BOARD=${PROJECT_BOARD:-} +#ARG PROJECT_CPU +#ENV PROJECT_CPU=${PROJECT_CPU:-} +#ARG COMPILE_ARGS="PROJECT_BOARD=${PROJECT_BOARD} PROJECT_CPU=${PROJECT_CPU}" +#ENV COMPILE_ARGS=${COMPILE_ARGS:-} +#ARG BUILD_ARGS +#ENV BUILD_ARGS=${BUILD_ARGS:-} + +WORKDIR ${FOME_DIR} + +WORKDIR ./fome/firmware +ENV PATH="$PATH:$FOME_DIR/gcc-arm-none-eabi/bin" +ENTRYPOINT ["bash", "./docker_build.sh"] diff --git a/firmware/docker_build.sh b/firmware/docker_build.sh new file mode 100644 index 0000000000..9863161850 --- /dev/null +++ b/firmware/docker_build.sh @@ -0,0 +1,129 @@ +#!/usr/bin/env bash + +set -e + +PROJECT_BOARD="${1}"; [ "$#" -ge 1 ] && shift + +# -- + +log_message() { + message="${1}" + echo -e "\033[31;1;4m\n# ${message}\n\033[0m" +} + +get_board_params() { + board="${1}" + + target= + folder= + ini= + + case "${board}" in + *) + target="${board}" + folder="config/boards/${board}" + ini="fome_${board}.ini" + ;;& + alphax-*|harley81|hellen*) + folder="config/boards/hellen/${board}" + ;;& + hellen88bmw*) + ini="fome_hellen88bmw.ini" + ;; + hellenNA6) + folder="hellen/hellen64_miataNA6_94" + ini="fome_hellenNA6.ini" + ;; + hellen128) + ini="fome_hellen128mercedes.ini" + ;; + kinetis) + ini="fome_kin.ini" + ;; + mre_*) + folder="config/boards/microrusefi" + ;;& + mre_f4*) + ini="fome_mre_f4.ini" + ;; + mre_f7*) + # TODO(nms): console-settings: firmware/config/boards/nucleo_f767/rusefi_console_properties.xml + ini="fome_mre_f7.ini" + ;; + prometheus_*) + folder="config/boards/prometheus" + ;; + proteus_*) + folder="config/boards/proteus" + ;;& + proteus_f4_*) + ini="fome_proteus_f4.ini" + ;; + proteus_f7_*|proteus_legacy) + ini="fome_proteus_f7.ini" + ;; + stm32*_nucleo) + ;;& + stm32f429_nucleo) + folder="config/boards/nucleo_f429" + ;; + stm32f767_nucleo) + # TODO(nms): console-settings: firmware/config/boards/nucleo_f767/rusefi_console_properties.xml + folder="config/boards/nucleo_f767" + ;; + stm32h743_nucleo) + folder="config/boards/nucleo_h743" + ;; + subaru_eg33_f7) + folder="config/boards/subaru_eg33" + ;; + esac + + echo "${target} ${folder} ${ini}" +} + +# -- + +board_params=($(get_board_params "${PROJECT_BOARD}")) +params_target="${board_params[0]}" +params_folder="${board_params[1]}" +params_ini="${board_params[2]}" + +log_message "Generate Live Documentation" +./gen_live_documentation.sh + +log_message "Generate Enum Strings" +./gen_enum_to_string.sh + +log_message "Generate Default Config" +./gen_config_default.sh + +log_message "Generate \$PROJECT_BOARD=${PROJECT_BOARD} Config" +case "${PROJECT_BOARD}" in + kinetis) + ./config/boards/kinetis/config/gen_kinetis_config.sh + ;; + cypress) + ./config/boards/cypress/config/gen_cypress_config.sh + ;; + subaru_eg33_f7) + ./config/boards/subaru_eg33/config/gen_subaru_config.sh + ;; + *) + ./gen_config_board.sh "${params_folder}" "${params_target}" "${params_ini}" + ;; +esac + +log_message "Build Console" +pushd ..; ./misc/jenkins/build_java_console.sh; popd + +log_message "Build Simulator" +pushd ..; ./misc/jenkins/build_simulator.sh; popd +#OS="Windows_NT" ../misc/jenkins/build_simulator.sh + +log_message "Build Firmware" +make clean; pushd ${params_folder}; ./compile_${params_target}.sh; popd +#../misc/jenkins/compile_other_versions/compile.sh "${params_folder}" "${params_target}" +#./clean_compile_two_versions.sh "PROJECT_BOARD=${PROJECT_BOARD}" "$@" +#cd ..; OS="Windows_NT" misc/jenkins/functional_test_and_build_bundle/build_current_bundle.sh +#cd ..; misc/jenkins/functional_test_and_build_bundle/build_current_bundle.sh diff --git a/fome.docker-compose.yml b/fome.docker-compose.yml new file mode 100644 index 0000000000..02233cfefd --- /dev/null +++ b/fome.docker-compose.yml @@ -0,0 +1,30 @@ +version: "3.7" + +services: + build-base: + image: fome/build-base:ubuntu-${UBUNTU_VERSION:-22.04} + build: + dockerfile: build-base.Dockerfile + context: . + network_mode: host + user: '1000' + + firmware: + image: fome/firmware:ubuntu-${UBUNTU_VERSION:-22.04} + build: + dockerfile: firmware.Dockerfile + context: . + volumes: + - .:/fome/fome + network_mode: host + user: '1000' + + simulator: + image: fome/simulator:ubuntu-${UBUNTU_VERSION:-22.04} + build: + dockerfile: simulator.Dockerfile + context: . + volumes: + - .:/fome/fome + network_mode: host + user: '1000' diff --git a/simulator.Dockerfile b/simulator.Dockerfile new file mode 100644 index 0000000000..bc535465b9 --- /dev/null +++ b/simulator.Dockerfile @@ -0,0 +1,17 @@ +# FOME simulator build Docker image + +ARG UBUNTU_VERSION=22.04 +FROM fome/build-base:ubuntu-${UBUNTU_VERSION} + +ARG FOME_DIR=/fome +ARG PROJECT_BOARD +ENV PROJECT_BOARD=${PROJECT_BOARD:-} +ARG PROJECT_CPU +ENV PROJECT_CPU=${PROJECT_CPU:-} +ARG COMPILE_ARGS="PROJECT_BOARD=${PROJECT_BOARD} PROJECT_CPU=${PROJECT_CPU}" +ENV COMPILE_ARGS=${COMPILE_ARGS:-} + +WORKDIR ${FOME_DIR} + +WORKDIR ./fome/simulator +ENTRYPOINT ["sh", "-c", "./compile.sh ${COMPILE_ARGS}"]