roema / Open-Glider-Network-Groundstation

Open Glider Network Receiver based on TTGO T-Beam ESP32 hardware.
https://ros-it.ch/open-glider-network-base-station/
GNU General Public License v3.0
1 stars 0 forks source link

The version number on WebUI includes git sha such as 0.1.0-26-1-gd529… #31

Open CazYokoyama opened 2 years ago

CazYokoyama commented 2 years ago

…363.

You need to run the following commands.

cat <<EOF >make-git-version
#!/bin/bash

Go to the source directory.

[ -n "\$1" ] && cd "$1" || exit 1

Build a version string with git.

version=\$(git describe --tags --always --dirty 2> /dev/null)

If this is not a git repository, fallback to the compilation date.

[ -n "\$version" ] || version=\$(date -I)

Save this in git-version.h.

echo "#define GIT_VERSION \"\$version\"" > \$2/sketch/git-version.h
EOF
chmod +x make-git-version
sudo mv make-git-version /usr/local/bin/
echo recipe.hooks.sketch.prebuild.1.pattern=make-git-version "{build.source.path}" "{build.path}" >~/.arduino15/packages/esp32/hardware/esp32/1.0.6/platform.local.txt
touch software/firmware/source/SoftRF/git-version.h

By above commands, arduino runs /usr/local/bin/make-git-version on compile. It creates /tmp/arduino_build_XXXXXX/sketch/git-version.h which has

define GIT_VERSION "0.1.0-26-1-gd529363"

for example.