Skip to content
Snippets Groups Projects
Commit 66561822 authored by Jan Mach's avatar Jan Mach
Browse files

Improvements in master makefile.

Added more makefile recipes for library code checking, both by pyflakes and pylint. Also the style of the help message was tweaked a bit to look better. (Redmine issue: #3387)
parent ab9a1426
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ DIR_DOC = doc ...@@ -11,6 +11,7 @@ DIR_DOC = doc
DIR_LIB = lib DIR_LIB = lib
BIN_FILES := $(wildcard bin/mentat-*.py) BIN_FILES := $(wildcard bin/mentat-*.py)
LIB_FILES := $(shell find $(DIR_LIB) -name '*.py' | grep -v 'test_')
# #
# Color code definitions for colored terminal output # Color code definitions for colored terminal output
...@@ -19,6 +20,9 @@ BIN_FILES := $(wildcard bin/mentat-*.py) ...@@ -19,6 +20,9 @@ BIN_FILES := $(wildcard bin/mentat-*.py)
RED=\033[0;31m RED=\033[0;31m
GREEN=\033[0;32m GREEN=\033[0;32m
ORANGE=\033[0;33m ORANGE=\033[0;33m
BLUE=\033[0;34m
PURPLE=\033[0;35m
CYAN=\033[0;36m
NC=\033[0m NC=\033[0m
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
...@@ -28,6 +32,9 @@ NC=\033[0m ...@@ -28,6 +32,9 @@ NC=\033[0m
# #
default: help default: help
#
# Check the project code.
#
check: pyflakes pylint test check: pyflakes pylint test
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
...@@ -35,10 +42,12 @@ check: pyflakes pylint test ...@@ -35,10 +42,12 @@ check: pyflakes pylint test
help: help:
@echo "" @echo ""
@echo "${RED}LIST OF MAKE TARGETS:${NC}" @echo " ${GREEN}─────────────────────────────────────────────────${NC}"
@echo " ${GREEN} LIST OF MAKE TARGETS${NC}"
@echo " ${GREEN}─────────────────────────────────────────────────${NC}"
@echo "" @echo ""
@echo " * ${GREEN}default${NC}: alias for help, you have to pick a target" @echo " * ${GREEN}default${NC}: alias for help, you have to pick a target"
@echo " * ${GREEN}help${NC}: print this help and exit" @echo " * ${GREEN}help${NC}: print this help message and exit"
@echo " * ${GREEN}deps${NC}: install various dependencies" @echo " * ${GREEN}deps${NC}: install various dependencies"
@echo " = ${ORANGE}deps-python${NC}: install Python dependencies with pip3" @echo " = ${ORANGE}deps-python${NC}: install Python dependencies with pip3"
@echo " = ${ORANGE}deps-geoip${NC}: install geolocation databases" @echo " = ${ORANGE}deps-geoip${NC}: install geolocation databases"
...@@ -46,13 +55,19 @@ help: ...@@ -46,13 +55,19 @@ help:
@echo " * ${GREEN}docs${NC}: generate local project documentation" @echo " * ${GREEN}docs${NC}: generate local project documentation"
@echo " = ${ORANGE}docs-sync${NC}: synchronize documentation from submodules" @echo " = ${ORANGE}docs-sync${NC}: synchronize documentation from submodules"
@echo " = ${ORANGE}docs-sphinx${NC}: generate local project documentation " @echo " = ${ORANGE}docs-sphinx${NC}: generate local project documentation "
@echo " * ${GREEN}check${NC}: perform extensive code checking" @echo " * ${GREEN}check${NC}: perform extensive project checking"
@echo " = ${ORANGE}pyflakes${NC}: check source code with pyflakes" @echo " = ${ORANGE}pyflakes${NC}: check project with pyflakes"
@echo " - pyflakes-bin" @echo " - pyflakes-bin: check executables with pyflakes"
@echo " = ${ORANGE}pylint${NC}: check source code with pylint" @echo " - pyflakes-lib: check library with pyflakes, exclude test files"
@echo " - pylint-bin" @echo " - pyflakes-lib-all: check library with pyflakes including test files"
@echo " = ${ORANGE}pylint${NC}: check project with pylint"
@echo " - pylint-bin: check executables with pylint"
@echo " - pylint-lib: check library with pylint, exclude test files"
@echo " - pylint-lib-all: check library with pylint including test files"
@echo " = ${ORANGE}test${NC}: run unit tests with nosetest" @echo " = ${ORANGE}test${NC}: run unit tests with nosetest"
@echo "" @echo ""
@echo " ${GREEN}─────────────────────────────────────────────────${NC}"
@echo ""
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
...@@ -86,35 +101,52 @@ docs-sync: FORCE ...@@ -86,35 +101,52 @@ docs-sync: FORCE
docs-sphinx: FORCE docs-sphinx: FORCE
@echo "\n${GREEN}*** Generating project documentation ***${NC}\n" @echo "\n${GREEN}*** Generating project documentation ***${NC}\n"
@#cd $(DIR_DOC)/sphinx && make clean
@#cd $(DIR_DOC)/sphinx && make apidoc
@cd $(DIR_DOC)/sphinx && make html @cd $(DIR_DOC)/sphinx && make html
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
pyflakes: pyflakes-bin pyflakes: pyflakes-bin pyflakes-lib
pyflakes-bin:
@echo "\n${GREEN}*** Checking executables with pyflakes ***${NC}\n"
-@PYTHONPATH=$(DIR_LIB) python3 -m pyflakes $(DIR_BIN)
pyflakes-lib:
@echo "\n${GREEN}*** Checking library with pyflakes - test files excluded ***${NC}\n"
-@for l in ${LIB_FILES}; do\
PYTHONPATH=$(DIR_LIB) python3 -m pyflakes $$l; \
done
pyflakes-lib-all:
@echo "\n${GREEN}*** Checking library with pyflakes - all files ***${NC}\n"
-@PYTHONPATH=$(DIR_LIB) python3 -m pyflakes $(DIR_LIB)
pyflakes-bin: $(DIR_BIN)/mentat-*.py pylint: pylint-bin pylint-lib
@echo "\n${GREEN}*** Checking code with pyflakes ***${NC}\n"
PYTHONPATH=$(DIR_LIB) python3 -m pyflakes $(DIR_BIN)/mentat-*.py
pylint-bin:
@echo "\n${GREEN}*** Checking executables with pylint ***${NC}\n"
-@PYTHONPATH=$(DIR_LIB) python3 -m pylint --rcfile .pylintrc-bin $(DIR_BIN)
pylint: pylint-bin pylint-lib:
@echo "\n${GREEN}*** Checking library with pylint - test files excluded ***${NC}\n"
-@for l in ${LIB_FILES}; do\
PYTHONPATH=$(DIR_LIB) python3 -m pylint --rcfile .pylintrc-lib $$l; \
done
pylint-bin: $(DIR_BIN)/mentat-*.py pylint-lib-all:
@echo "\n${GREEN}*** Checking code with pylint ***${NC}\n" @echo "\n${GREEN}*** Checking library with pylint - all files ***${NC}\n"
PYTHONPATH=$(DIR_LIB) python3 -m pylint --rcfile .pylintrc-bin $(DIR_BIN) -@PYTHONPATH=$(DIR_LIB) python3 -m pylint --rcfile .pylintrc-lib $(DIR_LIB)
test: test:
@echo "\n${GREEN}*** Checking code with nosetests ***${NC}\n" @echo "\n${GREEN}*** Checking code with nosetests ***${NC}\n"
nosetests $(DIR_LIB) @PYTHONPATH=$(DIR_LIB) nosetests
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Empty rule as dependency wil force make to always perform target # Empty rule as dependency will force make to always perform target
# Source: https://www.gnu.org/software/make/manual/html_node/Force-Targets.html # Source: https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
FORCE: FORCE:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment