From 43bc8eafa9f7eb038d4b9f99210646401eb3d2a7 Mon Sep 17 00:00:00 2001 From: Jan Mach <jan.mach@cesnet.cz> Date: Mon, 18 Feb 2019 09:33:51 +0100 Subject: [PATCH] Moved part of the Makefile functionality to included library. Reason is better reuse in other projects. (Redmine issue: #4216,#3387) --- Makefile | 63 +++++++++++++++++----------------------------------- Makefile.inc | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 43 deletions(-) create mode 100644 Makefile.inc diff --git a/Makefile b/Makefile index 7a8e66e5..8b6a97c8 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,19 @@ # Use of this source is governed by an MIT license, see LICENSE file. #------------------------------------------------------------------------------- + +# +# Default make target, alias for 'help', you must explicitly choose the target. +# +default: help + + +#=============================================================================== + + +PROJECT_ID = mentat +PROJECT_NAME = Mentat + DIR_BIN = bin DIR_DOC = doc DIR_LIB = lib @@ -22,7 +35,7 @@ LIB_FILES := $(shell find $(DIR_LIB) -name '*.py' | grep -v 'test_') VENV_PYTHON = python3 VENV_PATH = venv -PYTHON = python +PYTHON = python3 PIP = pip NOSETESTS = nosetests TWINE = twine @@ -31,35 +44,18 @@ PYBABEL = pybabel CURRENT_DIR = $(shell pwd) # -# Include local customized configurations. +# Include common makefile configurations. # -include Makefile.cfg +include Makefile.inc # -# Color code definitions for colored terminal output. -# -# Resource: -# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux -# https://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html -# https://linux.die.net/man/1/tput +# Include local customized configurations. # +include Makefile.cfg -RED=\033[0;31m -GREEN=\033[0;32m -ORANGE=\033[0;33m -BLUE=\033[0;34m -PURPLE=\033[0;35m -CYAN=\033[0;36m -NC=\033[0m -BOLD=\033[1m -FAINT=\033[2m #=============================================================================== -# -# Default make target, alias for 'help', you must explicitly choose the target. -# -default: help # # Display extensive help information page. @@ -143,26 +139,6 @@ help: #------------------------------------------------------------------------------- -# -# Show current project version. This can be used by various automated systems to -# verify/mark the version that is actually being built. -# -show-version: FORCE - @PYTHONPATH=lib $(PYTHON) -c "import mentat; print(mentat.__version__);" - -# -# Show information about current development environment. This may be very handy -# be executed on some automated build systems to determine the state of the build -# environment prior to the build. -# -show-envstamp: FORCE - @echo "System info: `uname -a`" - @echo "Pip version: `$(PIP) --version`" - @echo "Python version: `$(PYTHON) --version`" - @echo "Project version: `PYTHONPATH=lib $(PYTHON) -c 'import mentat; print(mentat.__version__);'`" - @echo "Pip libraries:" - @$(PIP) freeze - # # Install and configure project locally for development. This target will perform # following tasks for you: @@ -255,7 +231,7 @@ deps-prerequisites: FORCE @echo "\n$(GREEN)*** Checking for development prerequisites ***$(NC)\n" @for prereq in $(PYTHON) $(PIP) yarn grunt psql ; do \ if command -v $$prereq >/dev/null 2>&1; then \ - echo "Prerequisite: $$prereq"; \ + echo "Prerequisite: $$prereq (`$$prereq --version | tr '\n' ',' | sed -e s/,$$//g;`)"; \ else \ echo "$(RED)PREREQUISITE: $$prereq (missing).$(NC)\n"; \ echo "You have to install this prerequisite manually.\n"; \ @@ -543,6 +519,7 @@ build-package-deb: FORCE @grunt deb-build @echo "" + # Empty rule as dependency will force make to always perform target # Source: https://www.gnu.org/software/make/manual/html_node/Force-Targets.html FORCE: diff --git a/Makefile.inc b/Makefile.inc new file mode 100644 index 00000000..52ec735c --- /dev/null +++ b/Makefile.inc @@ -0,0 +1,60 @@ +#------------------------------------------------------------------------------- +# This file is part of MyDojo package (https://github.com/honzamach/mydojo). +# +# Copyright (C) since 2018 Honza Mach <honza.mach.ml@gmail.com> +# Use of this source is governed by the MIT license, see LICENSE file. +#------------------------------------------------------------------------------- + +# +# Color code definitions for colored terminal output. +# +# Resource: +# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux +# https://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html +# https://linux.die.net/man/1/tput +# +BLACK = $(shell tput setaf 0) +RED = $(shell tput setaf 1) +GREEN = $(shell tput setaf 2) +ORANGE = $(shell tput setaf 3) +BLUE = $(shell tput setaf 4) +PURPLE = $(shell tput setaf 5) +CYAN = $(shell tput setaf 6) +WHITE = $(shell tput setaf 7) +NC = $(shell tput sgr0) + +B_BLACK = $(shell tput setab 0) +B_RED = $(shell tput setab 1) +B_GREEN = $(shell tput setab 2) +B_ORANGE = $(shell tput setab 3) +B_BLUE = $(shell tput setab 4) +B_PURPLE = $(shell tput setab 5) +B_CYAN = $(shell tput setab 6) +B_WHITE = $(shell tput setab 7) + +BOLD = $(shell tput bold) +FAINT = $(shell tput dim) + +# +# Show current project version. This can be used by various automated systems to +# verify/mark the version that is actually being built. +# +show-version: FORCE + @PYTHONPATH=. $(PYTHON) -c "import $(PROJECT_ID); print($(PROJECT_ID).__version__);" + +# +# Show information about current development environment. This may be very handy +# be executed on some automated build systems to determine the state of the build +# environment prior to the build. +# +show-envstamp: FORCE + @echo "System info: `uname -a`" + @echo "Python version: `$(PYTHON) --version`" + @echo "Pip version: `$(PIP) --version`" + @echo "Yarn version: `yarn --version`" + @echo "Grunt version: `grunt --version | tr '\n' ','`" + @echo "Psql version: `psql --version`" + @echo "Project: $(PROJECT_NAME) ($(PROJECT_ID))" + @echo "Project version: `PYTHONPATH=lib $(PYTHON) -c 'import $(PROJECT_ID); print($(PROJECT_ID).__version__);'`" + @echo "Pip libraries:" + @$(PIP) freeze -- GitLab