Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove python dependency for a build script #173

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.