Skip to content

Commit

Permalink
Build System: Convert Python scripts to python3 (#138)
Browse files Browse the repository at this point in the history
* Build System: Convert Python scripts to `python3`

Change `Makefile` to invoke the Python scripts using the `python3` interpreter,
as well as using the `2to3` suggested changes to the scripts. Please note that
the s/long/int/ change is not taken, as the python3-git module has a "long" option
(for a `git describe` binding) which is obviously not an integer type but requests
the long listing format...

* Fix 2to3 oddities
  • Loading branch information
jbglaw committed Mar 24, 2023
1 parent 31012c4 commit f2c4c1b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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 python3 build-scripts/hydrafw-revision.py)

HYDRAFW_OPTS =

Expand Down Expand Up @@ -316,19 +316,19 @@ FORCE:
ifeq ($(USE_VERBOSE_COMPILE),yes)
echo Creating ./common/hydrafw_version.hdr
-rm -f $(OBJDIR)/common.o
python build-scripts/hydrafw-version.py ./common/hydrafw_version.hdr
python3 build-scripts/hydrafw-version.py ./common/hydrafw_version.hdr
else
@echo Creating ./common/hydrafw_version.hdr
@rm -f $(OBJDIR)/common.o
@python build-scripts/hydrafw-version.py ./common/hydrafw_version.hdr
@python3 build-scripts/hydrafw-version.py ./common/hydrafw_version.hdr
endif

%.dfu: %.hex $(LDSCRIPT)
ifeq ($(USE_VERBOSE_COMPILE),yes)
python build-scripts/dfu-convert.py -r $(FW_REVISION) -i $< $@
python3 build-scripts/dfu-convert.py -r $(FW_REVISION) -i $< $@
else
@echo Creating $@
@python build-scripts/dfu-convert.py -r $(FW_REVISION) -i $< $@
@python3 build-scripts/dfu-convert.py -r $(FW_REVISION) -i $< $@
endif

# This rule hook is defined in the ChibiOS build system
Expand Down
2 changes: 1 addition & 1 deletion src/build-scripts/dfu-convert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2
#!/usr/bin/env python3

# Written by Antonio Galea - 2010/11/18
# Distributed under Gnu LGPL 3.0
Expand Down
2 changes: 2 additions & 0 deletions src/build-scripts/hydrafw-revision.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

from git import *
import re

Expand Down
2 changes: 2 additions & 0 deletions src/build-scripts/hydrafw-version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

import sys
from optparse import OptionParser
from datetime import *
Expand Down

0 comments on commit f2c4c1b

Please sign in to comment.