feat: MSYS2 build script enhancements (#3165)

* enhance msys2 build script
- stop on error
- support different branch's (not only main)
- add all the radio option on top of the script
- support re-run of the build (handle existing dir & git pull)
- add logs to follow the progress steps (especially in case of failure)
Authored-by: oshmuely <AbCd321654>
This commit is contained in:
Offer Shmuely
2023-02-15 10:10:06 +01:00
committed by GitHub
parent 27bf42d038
commit f696470ea8
+174 -12
View File
@@ -1,12 +1,142 @@
#! /usr/bin/env bash
## Bash script to show how to get EdgeTX source from GitHub (main branch),
## Bash script to show how to get EdgeTX source from GitHub,
## how to build TX16S firmware, Companion, Simulator, radio simulator
## library and how to create an installation package.
## Let it run as normal user in MSYS2 MinGW 64-bit console (blue icon).
##
## Note: This script works properly only for branches stemming from EdgeTX v2.8 or newer
# -----------------------------------------------------------------------------
export BRANCH_NAME="main" # main|2.8|2.9|...
export RADIO_TYPE="tx16s" # tx16s|x10|x10-access|x12s|x9d|x9dp|x9lite|x9lites|x7|x7-access|t12|tx12|tx12mk2|boxer|t8|zorro|tlite|tpro|lr3pro|xlite|xlites|x9dp2019|x9e|x9e-hall|t16|t18|nv14|commando8|
export BUILD_OPTIONS="-DDEFAULT_MODE=2 -DGVARS=YES -DPPM_UNIT=US"
echo "Building ${fw_name}"
case $RADIO_TYPE in
x9lite)
BUILD_OPTIONS+=" -DPCB=X9LITE"
;;
x9lites)
BUILD_OPTIONS+=" -DPCB=X9LITES"
;;
x7)
BUILD_OPTIONS+=" -DPCB=X7"
;;
x7-access)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=ACCESS -DPXX1=YES"
;;
t12)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=T12 -DINTERNAL_MODULE_MULTI=ON"
;;
tx12)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=TX12"
;;
tx12mk2)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=TX12MK2"
;;
boxer)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=BOXER"
;;
t8)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=T8"
;;
zorro)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=ZORRO"
;;
tlite)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=TLITE"
;;
tpro)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=TPRO"
;;
lr3pro)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=LR3PRO"
;;
xlite)
BUILD_OPTIONS+=" -DPCB=XLITE"
;;
xlites)
BUILD_OPTIONS+=" -DPCB=XLITES"
;;
x9d)
BUILD_OPTIONS+=" -DPCB=X9D"
;;
x9dp)
BUILD_OPTIONS+=" -DPCB=X9D+"
;;
x9dp2019)
BUILD_OPTIONS+=" -DPCB=X9D+ -DPCBREV=2019"
;;
x9e)
BUILD_OPTIONS+=" -DPCB=X9E"
;;
x9e-hall)
BUILD_OPTIONS+=" -DPCB=X9E -DSTICKS=HORUS"
;;
x10)
BUILD_OPTIONS+=" -DPCB=X10"
;;
x10-access)
BUILD_OPTIONS+=" -DPCB=X10 -DPCBREV=EXPRESS -DPXX1=YES"
;;
x12s)
BUILD_OPTIONS+=" -DPCB=X12S"
;;
t16)
BUILD_OPTIONS+=" -DPCB=X10 -DPCBREV=T16 -DINTERNAL_MODULE_MULTI=ON"
;;
t18)
BUILD_OPTIONS+=" -DPCB=X10 -DPCBREV=T18"
;;
tx16s)
BUILD_OPTIONS+=" -DPCB=X10 -DPCBREV=TX16S"
;;
nv14)
BUILD_OPTIONS+=" -DPCB=NV14"
;;
commando8)
BUILD_OPTIONS+=" -DPCB=X7 -DPCBREV=COMMANDO8"
;;
*)
echo "Unknown target: $RADIO_TYPE"
exit 1
;;
esac
PAUSEAFTEREACHLINE="false" # true|false
# -----------------------------------------------------------------------------
export PROJ_DIR="${HOME}/edgetx"
export SOURCE_DIR="${HOME}/edgetx/edgetx_${BRANCH_NAME}"
export BUILD_OUTPUT_DIR="${SOURCE_DIR}/build-output-${RADIO_TYPE}"
function log() {
echo ""
echo "=== [INFO] $*"
}
function fail() {
echo "=== [ERROR] $*"
exit 1
}
function check_command() {
result=$1
cli_info=$2
if [[ $result -ne 0 ]]; then
fail "${cli_info} (exit-code=$result)"
else
log "${cli_info} - OK"
return 0
fi
}
echo "RADIO_TYPE: ${RADIO_TYPE}"
echo "BRANCH_NAME: ${BRANCH_NAME}"
echo "SOURCE_DIR: ${SOURCE_DIR}"
echo "BUILD_OUTPUT_DIR: ${BUILD_OUTPUT_DIR}"
echo "BUILD_OPTIONS: ${BUILD_OPTIONS}"
PAUSEAFTEREACHLINE="false"
STEP=1
# Parse argument(s)
for arg in "$@"
do
@@ -15,29 +145,48 @@ do
fi
done
STEP=1
echo "=== Step $((STEP++)): Creating a directory for EdgeTX ==="
mkdir ~/edgetx && cd ~/edgetx
mkdir -p ${PROJ_DIR} && cd ${PROJ_DIR}
check_command $? "mkdir -p ${PROJ_DIR} && cd ${PROJ_DIR}"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
fi
echo "=== Step $((STEP++)): Fetching EdgeTX source tree (main branch) from GitHub ==="
git clone --recursive -b main https://github.com/EdgeTX/edgetx.git edgetx_main
if [[ ! -d "${SOURCE_DIR}" ]]; then
echo "=== Step $((STEP++)): Fetching EdgeTX source tree (${BRANCH_NAME} branch) from GitHub ==="
git clone --recursive -b ${BRANCH_NAME} https://github.com/EdgeTX/edgetx.git ${SOURCE_DIR}
check_command $? "git clone --recursive -b ${BRANCH_NAME} https://github.com/EdgeTX/edgetx.git ${SOURCE_DIR}"
cd ${SOURCE_DIR}
else
echo "=== Step $((STEP++)): updating EdgeTX source tree (${BRANCH_NAME} branch) from GitHub ==="
cd ${SOURCE_DIR}
check_command $? "cd ${SOURCE_DIR}"
git checkout ${BRANCH_NAME}
check_command $? "git checkout ${BRANCH_NAME}"
git pull
check_command $? "git pull"
git submodule update --init --recursive
check_command $? "git submodule update --init --recursive"
fi
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
fi
echo "=== Step $((STEP++)): Creating build output directory ==="
cd edgetx_main && mkdir build-output && cd build-output
[[ -d ${BUILD_OUTPUT_DIR} ]] && rm -rf ${BUILD_OUTPUT_DIR}
mkdir -p ${BUILD_OUTPUT_DIR} && cd ${BUILD_OUTPUT_DIR}
check_command $? "mkdir -p ${BUILD_OUTPUT_DIR} && cd ${BUILD_OUTPUT_DIR}"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
fi
echo "=== Step $((STEP++)): Running CMake for TX16S as an example ==="
cmake -G "MSYS Makefiles" -Wno-dev -DCMAKE_PREFIX_PATH=$HOME/5.12.9/mingw73_64 -DSDL_LIBRARY_PATH=/mingw64/bin/ -DPCB=X10 -DPCBREV=TX16S -DDEFAULT_MODE=2 -DGVARS=YES -DPPM_UNIT=US -DHELI=NO -DLUA=YES -DCMAKE_BUILD_TYPE=Release ../
echo "=== Step $((STEP++)): Running CMake for ${RADIO_TYPE} as an example ==="
cmake -G "MSYS Makefiles" -Wno-dev -DCMAKE_PREFIX_PATH=$HOME/5.12.9/mingw73_64 -DSDL_LIBRARY_PATH=/mingw64/bin/ ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release ../
check_command $? "cmake -G MSYS Makefiles -Wno-dev -DCMAKE_PREFIX_PATH=$HOME/5.12.9/mingw73_64 -DSDL_LIBRARY_PATH=/mingw64/bin/ ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release ../"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
@@ -45,6 +194,7 @@ fi
echo "=== Step $((STEP++)): Running Make configure ==="
make configure
check_command $? "make configure"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
@@ -52,13 +202,15 @@ fi
echo "=== Step $((STEP++)): Building firmware binary ==="
make -C arm-none-eabi -j`nproc` firmware
check_command $? "make -C arm-none-eabi -j`nproc` firmware"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
fi
echo "=== Step $((STEP++)): Renaming firmware binary ==="
mv arm-none-eabi/firmware.bin arm-none-eabi/fw_edgetx_main_tx16s_lua-ppmus-mode2_release.bin
mv arm-none-eabi/firmware.bin arm-none-eabi/fw_${RADIO_TYPE}_release.bin
check_command $? "mv arm-none-eabi/firmware.bin arm-none-eabi/fw_${RADIO_TYPE}_release.bin"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
@@ -66,6 +218,7 @@ fi
echo "=== Step $((STEP++)): Building Companion ==="
make -C native -j`nproc` companion
check_command $? "make -C native -j`nproc` companion"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
@@ -73,6 +226,7 @@ fi
echo "=== Step $((STEP++)): Building Simulator ==="
make -C native -j`nproc` simulator
check_command $? "make -C native -j`nproc` simulator"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
@@ -80,6 +234,7 @@ fi
echo "=== Step $((STEP++)): Building radio simulator library ==="
make -C native -j`nproc` libsimulator
check_command $? "make -C native -j`nproc` libsimulator"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
@@ -87,9 +242,16 @@ fi
echo "=== Step $((STEP++)): Making an installer ==="
make -C native installer
check_command $? "make -C native installer"
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
fi
echo "Finished. You can find the TX16S firmware in ~/edgetx/edgetx_main/build-output/arm-none-eabi"
echo "and Companion installer packet in ~/edgetx/edgetx_main/build-output/native/companion"
echo "Done. \n\n"
echo "RADIO_TYPE=${RADIO_TYPE}"
echo ""
echo "firmware (${RADIO_TYPE}): ${BUILD_OUTPUT_DIR}/arm-none-eabi/fw_${RADIO_TYPE}_release.bin"
echo "Companion installer: ${BUILD_OUTPUT_DIR}/native/companion/companion-windows-x.x.x.exe"
echo "Companion : ${BUILD_OUTPUT_DIR}/native/Release/companion.exe"
echo "Simulator : ${BUILD_OUTPUT_DIR}/native/Release/simulator.exe"
echo "Simulator library : ${BUILD_OUTPUT_DIR}/native/Release/libedgetx-${RADIO_TYPE}-simulator.dll"