Skip to content

Commit

Permalink
feat: remove python dependency for a build script (#173)
Browse files Browse the repository at this point in the history
* fix: remove python dependency for a build script
* fix: remove python dependency for revision build script
  • Loading branch information
seuros committed Jun 11, 2024
1 parent 5d26a4e commit 7161987
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export STM32F4XX ?= 1
# Set to 1 HYDRAFW_NFC to include HydraNFC extension support
export HYDRAFW_NFC ?= 1
export HYDRAFW_DEBUG ?= 0
export FW_REVISION := $(shell $(PYTHON) build-scripts/hydrafw-revision.py)
export FW_REVISION := $(shell build-scripts/hydrafw-revision)

HYDRAFW_OPTS =

Expand Down Expand Up @@ -341,7 +341,7 @@ FORCE:
%.hdr: FORCE
$(OUT_LOG) echo Creating ./common/hydrafw_version.hdr
$(OUT_CMD) rm -f $(OBJDIR)/common.o
$(OUT_CMD) $(PYTHON) build-scripts/hydrafw-version.py ./common/hydrafw_version.hdr
$(OUT_CMD) build-scripts/hydrafw-version ./common/hydrafw_version.hdr

%.dfu: %.hex $(LDSCRIPT)
$(OUT_LOG) echo Creating $@
Expand Down
14 changes: 14 additions & 0 deletions src/build-scripts/hydrafw-revision
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Get the version description from git
version=$(git describe --tags --always --dirty --long)

# Use regex to match version pattern v(x.x)
if [[ $version =~ v([0-9]+\.[0-9]+).* ]]
then
# If match found, print the version
echo ${BASH_REMATCH[1]}
else
# Print 0.0 if no match is found
echo "0.0"
fi
13 changes: 0 additions & 13 deletions src/build-scripts/hydrafw-revision.py

This file was deleted.

19 changes: 19 additions & 0 deletions src/build-scripts/hydrafw-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

if [ $# -eq 1 ]
then
exec > $1 # directing stdout to the file passed as argument
vermagic=$(git describe --tags --always --dirty --long)
if [[ -n "$GITHUB_CI_PR_SHA" ]]; then
# if GITHUB_CI_PR_SHA is set, then it's GitHub Actions build, so workaround to set a valid tag is required
sha_id=${GITHUB_CI_PR_SHA:0:7}
vermagic=$(echo ${vermagic} | sed "s/-g.*$/-g${sha_id}/")
fi
echo "#define HYDRAFW_GIT_TAG \"$vermagic\""
echo "#define HYDRAFW_CHECKIN_DATE \"$(git show -s --pretty=format:%ai | cut -d' ' -f1)\""
else
echo "usage: $0 outfile.txt"
exit 1
fi
30 changes: 0 additions & 30 deletions src/build-scripts/hydrafw-version.py

This file was deleted.

0 comments on commit 7161987

Please sign in to comment.