From 8ab0a002d1d612abcf0fffe1403d183f3b2544a7 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Mon, 12 Oct 2020 02:23:59 +0200 Subject: [PATCH] Fix dfuse and python check --- make/linux.mk | 66 +++++++++++++++++++++++-------------------------- make/macosx.mk | 66 +++++++++++++++++++++++-------------------------- make/tools.mk | 32 ------------------------ src/utils/dfuse-pack.py | 2 +- 4 files changed, 63 insertions(+), 103 deletions(-) rewrite make/linux.mk (68%) rewrite make/macosx.mk (69%) diff --git a/make/linux.mk b/make/linux.mk dissimilarity index 68% index ba1744fcb..9656c2372 100644 --- a/make/linux.mk +++ b/make/linux.mk @@ -1,35 +1,31 @@ -# linux.mk -# -# Goals: -# Configure an environment that will allow Taulabs GCS and firmware to be built -# on a Linux system. The environment will support the current versions of Qt SDK -# and the ARM toolchain installed to either the Taulabs/tools directory, their -# respective default installation locations, or made available on the system path. - -# Check for and find Python 2 - -# Get Python version, separate major/minor/patch, then put into wordlist -PYTHON_VERSION_=$(wordlist 2,4,$(subst ., ,$(shell python -V 2>&1))) -# Get major version from aforementioned list -PYTHON_MAJOR_VERSION_=$(word 1,$(PYTHON_VERSION_)) -# Just in case Make has some weird scope stuff -PYTHON=0 -# If the major Python version is the one we want.. -ifeq ($(PYTHON_MAJOR_VERSION_),2) - # Then we can just use the normal Python executable - PYTHON:=python -else - # However, this isn't always the case.. - # Let's look for `python2`. If `which` doesn't return a null value, then - # it exists! - ifneq ($(shell which python2), "") - PYTHON:=python2 - else - # And if it doesn't exist, let's use the default Python, and warn the user. - # PYTHON NOT FOUND. - PYTHON:=python - echo "Python not found." - endif -endif - -export PYTHON +# linux.mk +# +# Goals: +# Configure an environment that will allow Taulabs GCS and firmware to be built +# on a Linux system. The environment will support the current versions of Qt SDK +# and the ARM toolchain installed to either the Taulabs/tools directory, their +# respective default installation locations, or made available on the system path. + +# First look for `python3`. If `which` doesn't return a null value, then it exists! +ifneq ($(shell which python3), "") + PYTHON:=python3 +else + # Get Python version, separate major/minor/patch, then put into wordlist + PYTHON_VERSION_=$(wordlist 2,4,$(subst ., ,$(shell python -V 2>&1))) + # Get major version from aforementioned list + PYTHON_MAJOR_VERSION_=$(word 1,$(PYTHON_VERSION_)) + # Just in case Make has some weird scope stuff + PYTHON=0 + # If the major Python version is the one we want.. + ifeq ($(PYTHON_MAJOR_VERSION_),3) + # Then we can just use the normal Python executable + PYTHON:=python + else + # And if it doesn't exist, let's use the default Python, and warn the user. + # PYTHON NOT FOUND. + PYTHON:=python + echo "Python not found." + endif +endif + +export PYTHON diff --git a/make/macosx.mk b/make/macosx.mk dissimilarity index 69% index 7f15c4fba..d2ccc3fa1 100644 --- a/make/macosx.mk +++ b/make/macosx.mk @@ -1,35 +1,31 @@ -# macosx.mk -# -# Goals: -# Configure an environment that will allow Taulabs GCS and firmware to be built -# on a Mac OSX system. The environment will support the current version of the -# ARM toolchain installed to either their respective default installation -# locations, the tools directory or made available on the system path. - -# Check for and find Python 2 - -# Get Python version, separate major/minor/patch, then put into wordlist -PYTHON_VERSION_=$(wordlist 2,4,$(subst ., ,$(shell python -V 2>&1))) -# Get major version from aforementioned list -PYTHON_MAJOR_VERSION_=$(word 1,$(PYTHON_VERSION_)) -# Just in case Make has some weird scope stuff -PYTHON=0 -# If the major Python version is the one we want.. -ifeq ($(PYTHON_MAJOR_VERSION_),2) - # Then we can just use the normal Python executable - PYTHON:=python -else - # However, this isn't always the case.. - # Let's look for `python2`. If `which` doesn't return a null value, then - # it exists! - ifneq ($(shell which python2), "") - PYTHON:=python2 - else - # And if it doesn't exist, let's use the default Python, and warn the user. - # PYTHON NOT FOUND. - PYTHON:=python - echo "Python not found." - endif -endif - -export PYTHON +# macosx.mk +# +# Goals: +# Configure an environment that will allow Taulabs GCS and firmware to be built +# on a Mac OSX system. The environment will support the current version of the +# ARM toolchain installed to either their respective default installation +# locations, the tools directory or made available on the system path. + +# First look for `python3`. If `which` doesn't return a null value, then it exists! +ifneq ($(shell which python3), "") + PYTHON:=python3 +else + # Get Python version, separate major/minor/patch, then put into wordlist + PYTHON_VERSION_=$(wordlist 2,4,$(subst ., ,$(shell python -V 2>&1))) + # Get major version from aforementioned list + PYTHON_MAJOR_VERSION_=$(word 1,$(PYTHON_VERSION_)) + # Just in case Make has some weird scope stuff + PYTHON=0 + # If the major Python version is the one we want.. + ifeq ($(PYTHON_MAJOR_VERSION_),3) + # Then we can just use the normal Python executable + PYTHON:=python + else + # And if it doesn't exist, let's use the default Python, and warn the user. + # PYTHON NOT FOUND. + PYTHON:=python + echo "Python not found." + endif +endif + +export PYTHON diff --git a/make/tools.mk b/make/tools.mk index 96b03c964..a7d773d9d 100644 --- a/make/tools.mk +++ b/make/tools.mk @@ -196,38 +196,6 @@ stm32flash_clean: @echo " CLEAN $(STM32FLASH_DIR)" $(V1) [ ! -d "$(STM32FLASH_DIR)" ] || $(RM) -r "$(STM32FLASH_DIR)" -DFUUTIL_DIR := $(TOOLS_DIR)/dfu-util - -.PHONY: dfuutil_install -dfuutil_install: DFUUTIL_URL := http://dfu-util.sourceforge.net/releases/dfu-util-0.8.tar.gz -dfuutil_install: DFUUTIL_FILE := $(notdir $(DFUUTIL_URL)) -dfuutil_install: | $(DL_DIR) $(TOOLS_DIR) -dfuutil_install: dfuutil_clean - # download the source - @echo " DOWNLOAD $(DFUUTIL_URL)" - $(V1) curl -L -k -o "$(DL_DIR)/$(DFUUTIL_FILE)" "$(DFUUTIL_URL)" - - # extract the source - @echo " EXTRACT $(DFUUTIL_FILE)" - $(V1) [ ! -d "$(DL_DIR)/dfuutil-build" ] || $(RM) -r "$(DL_DIR)/dfuutil-build" - $(V1) mkdir -p "$(DL_DIR)/dfuutil-build" - $(V1) tar -C $(DL_DIR)/dfuutil-build -xf "$(DL_DIR)/$(DFUUTIL_FILE)" - - # build - @echo " BUILD $(DFUUTIL_DIR)" - $(V1) mkdir -p "$(DFUUTIL_DIR)" - $(V1) ( \ - cd $(DL_DIR)/dfuutil-build/dfu-util-0.8 ; \ - ./configure --prefix="$(DFUUTIL_DIR)" ; \ - $(MAKE) ; \ - $(MAKE) install ; \ - ) - -.PHONY: dfuutil_clean -dfuutil_clean: - @echo " CLEAN $(DFUUTIL_DIR)" - $(V1) [ ! -d "$(DFUUTIL_DIR)" ] || $(RM) -r "$(DFUUTIL_DIR)" - # Set up uncrustify tools UNCRUSTIFY_DIR := $(TOOLS_DIR)/uncrustify-0.61 UNCRUSTIFY_BUILD_DIR := $(DL_DIR)/uncrustify diff --git a/src/utils/dfuse-pack.py b/src/utils/dfuse-pack.py index 2d2ad46db..9749aa416 100755 --- a/src/utils/dfuse-pack.py +++ b/src/utils/dfuse-pack.py @@ -135,7 +135,7 @@ if __name__=="__main__": try: address = address & 0xFFFFFFFF except ValueError: - print "Address %s invalid." % address + print("Address %s invalid." % address) sys.exit(1) target.append({ 'address': address, 'data': ih.tobinstr(start=address, end=end-1)}) -- 2.11.4.GIT