mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Move to Docker build
This commit is contained in:
1 parent
5f5e007949
commit
c04d73818d
6 files changed
+86
-185
No files matched your search
+39
-173
@@ -1,180 +1,46 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
IMAGE_NAME="uvk5"
|
||||
FIRMWARE_DIR="${PWD}/compiled-firmware"
|
||||
# ---------------------------------------------
|
||||
# Usage:
|
||||
# ./compile-with-docker.sh [Preset]
|
||||
# Example:
|
||||
# ./compile-with-docker.sh Custom
|
||||
# ./compile-with-docker.sh Bandscope
|
||||
# ./compile-with-docker.sh Broadcast
|
||||
# ./compile-with-docker.sh Basic
|
||||
# ./compile-with-docker.sh RescueOps
|
||||
# ./compile-with-docker.sh Game
|
||||
# Default preset: "Custom"
|
||||
# ---------------------------------------------
|
||||
|
||||
# Create firmware output directory if it doesn't exist
|
||||
mkdir -p "$FIRMWARE_DIR"
|
||||
IMAGE=uvk1-uvk5v3
|
||||
PRESET=${1:-Custom}
|
||||
|
||||
# Clean previously compiled firmware files
|
||||
rm -f "$FIRMWARE_DIR"/*
|
||||
|
||||
# Clean up old Docker artifacts
|
||||
echo "🧽 Cleaning up old Docker artifacts..."
|
||||
docker system prune -f --volumes >/dev/null 2>&1 || true
|
||||
|
||||
# Always rebuild the Docker image to ensure latest code changes
|
||||
echo "⚙️ Rebuilding Docker image '$IMAGE_NAME'..."
|
||||
docker rmi "$IMAGE_NAME" 2>/dev/null || true
|
||||
if ! docker build --build-arg BUILDPLATFORM=linux/amd64 -t "$IMAGE_NAME" .; then
|
||||
echo "❌ Failed to build docker image"
|
||||
exit 1
|
||||
# ---------------------------------------------
|
||||
# Validate preset name
|
||||
# ---------------------------------------------
|
||||
if [[ ! "$PRESET" =~ ^(Custom|Bandscope|Broadcast|Basic|RescueOps|Game)$ ]]; then
|
||||
echo "❌ Unknown preset: '$PRESET'"
|
||||
echo "Valid presets are: Custom, Bandscope, Broadcast, Basic, RescueOps, Game"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# -------------------- CLEAN ALL ---------------------
|
||||
# ---------------------------------------------
|
||||
# Build the Docker image (only needed once)
|
||||
# ---------------------------------------------
|
||||
docker build -t "$IMAGE" .
|
||||
|
||||
clean() {
|
||||
echo "🧽 Cleaning all"
|
||||
docker rmi uvk5
|
||||
docker buildx prune -f
|
||||
docker buildx history ls | awk 'NR>1 {print $1}' | xargs docker buildx history rm
|
||||
make clean
|
||||
}
|
||||
# ---------------------------------------------
|
||||
# Clean existing CMake cache to ensure toolchain reload
|
||||
# ---------------------------------------------
|
||||
rm -rf build
|
||||
|
||||
# ------------------ BUILD VARIANTS ------------------
|
||||
|
||||
custom() {
|
||||
echo "🔧 Custom compilation..."
|
||||
docker run --rm -v "$FIRMWARE_DIR:/app/compiled-firmware" "$IMAGE_NAME" /bin/bash -c "\
|
||||
rm -f ./compiled-firmware/* && cd /app && make -s \
|
||||
EDITION_STRING=Custom \
|
||||
TARGET=f4hwn.custom \
|
||||
&& cp f4hwn.custom* compiled-firmware/"
|
||||
}
|
||||
|
||||
standard() {
|
||||
echo "📦 Standard compilation..."
|
||||
docker run --rm -v "$FIRMWARE_DIR:/app/compiled-firmware" "$IMAGE_NAME" /bin/bash -c "\
|
||||
rm -f ./compiled-firmware/* && cd /app && make -s \
|
||||
ENABLE_SPECTRUM=0 \
|
||||
ENABLE_FMRADIO=0 \
|
||||
ENABLE_AIRCOPY=0 \
|
||||
ENABLE_NOAA=0 \
|
||||
EDITION_STRING=Standard \
|
||||
TARGET=f4hwn.standard \
|
||||
&& cp f4hwn.standard* compiled-firmware/"
|
||||
}
|
||||
|
||||
bandscope() {
|
||||
echo "📺 Bandscope compilation..."
|
||||
docker run --rm -v "$FIRMWARE_DIR:/app/compiled-firmware" "$IMAGE_NAME" /bin/bash -c "\
|
||||
rm -f ./compiled-firmware/* && cd /app && make -s \
|
||||
ENABLE_SPECTRUM=1 \
|
||||
ENABLE_FMRADIO=0 \
|
||||
ENABLE_VOX=0 \
|
||||
ENABLE_AIRCOPY=1 \
|
||||
ENABLE_FEAT_F4HWN_SCREENSHOT=1 \
|
||||
ENABLE_FEAT_F4HWN_GAME=0 \
|
||||
ENABLE_FEAT_F4HWN_PMR=1 \
|
||||
ENABLE_FEAT_F4HWN_GMRS_FRS_MURS=1 \
|
||||
ENABLE_NOAA=0 \
|
||||
ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \
|
||||
EDITION_STRING=Bandscope \
|
||||
TARGET=f4hwn.bandscope \
|
||||
&& cp f4hwn.bandscope* compiled-firmware/"
|
||||
}
|
||||
|
||||
broadcast() {
|
||||
echo "📻 Broadcast compilation..."
|
||||
docker run --rm -v "$FIRMWARE_DIR:/app/compiled-firmware" "$IMAGE_NAME" /bin/bash -c "\
|
||||
cd /app && make -s \
|
||||
ENABLE_SPECTRUM=0 \
|
||||
ENABLE_FMRADIO=1 \
|
||||
ENABLE_VOX=1 \
|
||||
ENABLE_AIRCOPY=1 \
|
||||
ENABLE_FEAT_F4HWN_SCREENSHOT=1 \
|
||||
ENABLE_FEAT_F4HWN_GAME=0 \
|
||||
ENABLE_FEAT_F4HWN_PMR=1 \
|
||||
ENABLE_FEAT_F4HWN_GMRS_FRS_MURS=1 \
|
||||
ENABLE_NOAA=0 \
|
||||
ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \
|
||||
EDITION_STRING=Broadcast \
|
||||
TARGET=f4hwn.broadcast \
|
||||
&& cp f4hwn.broadcast* compiled-firmware/"
|
||||
}
|
||||
|
||||
basic() {
|
||||
echo "☘️ Basic compilation..."
|
||||
docker run --rm -v "$FIRMWARE_DIR:/app/compiled-firmware" "$IMAGE_NAME" /bin/bash -c "\
|
||||
cd /app && make -s \
|
||||
ENABLE_SPECTRUM=1 \
|
||||
ENABLE_FMRADIO=1 \
|
||||
ENABLE_VOX=0 \
|
||||
ENABLE_AIRCOPY=0 \
|
||||
ENABLE_FEAT_F4HWN_GAME=0 \
|
||||
ENABLE_FEAT_F4HWN_SPECTRUM=0 \
|
||||
ENABLE_FEAT_F4HWN_PMR=1 \
|
||||
ENABLE_FEAT_F4HWN_GMRS_FRS_MURS=1 \
|
||||
ENABLE_NOAA=0 \
|
||||
ENABLE_AUDIO_BAR=0 \
|
||||
ENABLE_FEAT_F4HWN_RESUME_STATE=0 \
|
||||
ENABLE_FEAT_F4HWN_CHARGING_C=0 \
|
||||
ENABLE_FEAT_F4HWN_INV=1 \
|
||||
ENABLE_FEAT_F4HWN_CTR=0 \
|
||||
ENABLE_FEAT_F4HWN_NARROWER=1 \
|
||||
ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \
|
||||
EDITION_STRING=Basic \
|
||||
TARGET=f4hwn.basic \
|
||||
&& cp f4hwn.basic* compiled-firmware/"
|
||||
}
|
||||
|
||||
rescueops() {
|
||||
echo "🚨 RescueOps compilation..."
|
||||
docker run --rm -v "$FIRMWARE_DIR:/app/compiled-firmware" "$IMAGE_NAME" /bin/bash -c "\
|
||||
cd /app && make -s \
|
||||
ENABLE_SPECTRUM=0 \
|
||||
ENABLE_FMRADIO=0 \
|
||||
ENABLE_VOX=1 \
|
||||
ENABLE_AIRCOPY=1 \
|
||||
ENABLE_FEAT_F4HWN_SCREENSHOT=1 \
|
||||
ENABLE_FEAT_F4HWN_GAME=0 \
|
||||
ENABLE_FEAT_F4HWN_PMR=1 \
|
||||
ENABLE_FEAT_F4HWN_GMRS_FRS_MURS=1 \
|
||||
ENABLE_NOAA=1 \
|
||||
ENABLE_FEAT_F4HWN_RESCUE_OPS=1 \
|
||||
EDITION_STRING=RescueOps \
|
||||
TARGET=f4hwn.rescueops \
|
||||
&& cp f4hwn.rescueops* compiled-firmware/"
|
||||
}
|
||||
|
||||
game() {
|
||||
echo "🎮 Game compilation..."
|
||||
docker run --rm -v "$FIRMWARE_DIR:/app/compiled-firmware" "$IMAGE_NAME" /bin/bash -c "\
|
||||
cd /app && make -s \
|
||||
ENABLE_SPECTRUM=0 \
|
||||
ENABLE_FMRADIO=1 \
|
||||
ENABLE_VOX=0 \
|
||||
ENABLE_AIRCOPY=1 \
|
||||
ENABLE_FEAT_F4HWN_GAME=1 \
|
||||
ENABLE_FEAT_F4HWN_PMR=1 \
|
||||
ENABLE_FEAT_F4HWN_GMRS_FRS_MURS=1 \
|
||||
ENABLE_NOAA=0 \
|
||||
ENABLE_FEAT_F4HWN_RESCUE_OPS=0 \
|
||||
EDITION_STRING=Game \
|
||||
TARGET=f4hwn.game \
|
||||
&& cp f4hwn.game* compiled-firmware/"
|
||||
}
|
||||
|
||||
# ------------------ MENU ------------------
|
||||
|
||||
case "$1" in
|
||||
clean) clean ;;
|
||||
custom) custom ;;
|
||||
standard) standard ;;
|
||||
bandscope) bandscope ;;
|
||||
broadcast) broadcast ;;
|
||||
basic) basic ;;
|
||||
rescueops) rescueops ;;
|
||||
game) game ;;
|
||||
all)
|
||||
bandscope
|
||||
broadcast
|
||||
basic
|
||||
rescueops
|
||||
game
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {clean|custom|standard|bandscope|broadcast|basic|rescueops|game|all}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# ---------------------------------------------
|
||||
# Run CMake inside the container with the selected preset
|
||||
# ---------------------------------------------
|
||||
docker run --rm -it -v "$PWD":/src -w /src "$IMAGE" \
|
||||
bash -c "which arm-none-eabi-gcc && arm-none-eabi-gcc --version && \
|
||||
echo '=== Building preset: ${PRESET} ===' && \
|
||||
cmake --preset ${PRESET} && \
|
||||
cmake --build --preset ${PRESET} -j"
|
||||
Reference in new issue
Block a user