Skip to content

Commit

Permalink
Makefile: Add version checking for Python
Browse files Browse the repository at this point in the history
Add version checking that the version of Python should >= 3.5 to
compile PikoRT correctly.
Use the rule `check_cc`, and every compiler checking should include in this rule.
  • Loading branch information
lecopzer committed Mar 21, 2018
1 parent d397f22 commit 3f6072a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ OBJS := $(sort $(OBJS))

deps := $(OBJS:%.o=.%.o.d)

.PHONY: all check clean distclean
.PHONY: all check clean distclean check_cc

all: $(CMSIS)/$(PLAT) $(NAME).lds $(NAME).bin
all: check_cc $(CMSIS)/$(PLAT) $(NAME).lds $(NAME).bin

# generic build rules
include mk/flags.mk
Expand All @@ -48,9 +48,17 @@ include mk/cmsis.mk

prebuild: $(CMSIS)/$(PLAT)

check:
check: check_cc
$(PYTHON) -m tests -p $(PLAT) --qemu $(QEMU_SYSTEM_ARM) --cc $(CC)

check_cc:
@$(eval PYTHON_VERSION=$(shell echo `$(PYTHON) --version 2>&1 | grep -oE '[^ ]+$$'`))
@$(eval PYTHON_VERSION=$(shell echo $(PYTHON_VERSION) | awk -F "." '{print $$1$$2 0}'))
@if [ $(PYTHON_VERSION) -lt 350 ]; then \
echo "Error: Python version must >= 3.5, use PYTHON=/python/binary/path"; \
return 1;\
fi;

clean:
find . -name "*.o" -type f -delete
find . -name "*.o.d" -type f -delete
Expand Down
3 changes: 1 addition & 2 deletions mk/flags.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ OBJCOPY = $(CROSS_COMPILE)objcopy
GDB = $(CROSS_COMPILE)gdb
HOSTCC = gcc
WGET = wget
# FIXME: check version >= 3.5
PYTHON = python3
PYTHON ?= python
QEMU_SYSTEM_ARM ?= qemu-system-arm

# FIXME: configurable via menuconfig or command line
Expand Down

0 comments on commit 3f6072a

Please sign in to comment.