From 81501995817fa2a1b0f8f90b3395a18c80e4bc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Fri, 29 Mar 2019 18:08:39 +0100 Subject: [PATCH] Makefile: low verbosity by default --- Makefile | 15 ++++++++++----- README.md | 6 +++--- common.mk | 9 ++++++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 7be1850e7..d62900a05 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ else $(MAKE) LD=$(CC) $(HANDLE_OUTPUT) EXE_SUFFIX := endif -BUILD_NIM := echo "Building the Nim compiler." && \ +BUILD_NIM := echo -e $(BUILD_MSG) "Nim compiler" && \ cd $(NIM_DIR) && \ rm -rf bin/nim_csources csources dist/nimble && \ ln -s ../Nim-csources csources && \ @@ -90,16 +90,21 @@ TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS)) # default target, because it's the first one that doesn't start with '.' all: $(TOOLS) nimbus +#- when the special ".SILENT" target is present, all recipes are silenced as if they all had a "@" prefix +#- by setting SILENT_TARGET_PREFIX to a non-empty value, the name of this target becomes meaningless to `make` +#- idea stolen from http://make.mad-scientist.net/managing-recipe-echoing/ +$(SILENT_TARGET_PREFIX).SILENT: + # builds the tools, wherever they are $(TOOLS): | build deps for D in $(TOOLS_DIRS); do [ -e "$${D}/$@.nim" ] && TOOL_DIR="$${D}" && break; done && \ - $(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ "$${TOOL_DIR}/$@.nim" && \ - echo -e "\nThe binary is in './build/$@'.\n" + echo -e $(BUILD_MSG) "build/$@" && \ + $(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ "$${TOOL_DIR}/$@.nim" # a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated nimbus: | build deps - $(ENV_SCRIPT) nim nimbus $(NIM_PARAMS) nimbus.nims && \ - echo -e "\nThe binary is in './build/nimbus'.\n" + echo -e $(BUILD_MSG) "build/$@" && \ + $(ENV_SCRIPT) nim nimbus $(NIM_PARAMS) nimbus.nims # dir build: diff --git a/README.md b/README.md index b3553c577..c660469f7 100644 --- a/README.md +++ b/README.md @@ -124,11 +124,11 @@ You can now follow those instructions in the previous section by replacing `make - the Premix debugging tools are [documented separately](premix/readme.md) -- you can control the Makefile's verbosity with the V variable (defaults to 1): +- you can control the Makefile's verbosity with the V variable (defaults to 0): ```bash -make V=0 # quiet -make V=2 test # more verbose than usual +make V=1 # verbose +make V=2 test # even more verbose ``` - same for the [Chronicles log level](https://github.com/status-im/nim-chronicles#chronicles_log_level): diff --git a/common.mk b/common.mk index f2b3cc035..3bee5f0ee 100644 --- a/common.mk +++ b/common.mk @@ -3,14 +3,18 @@ SHELL := bash # the shell used internally by "make" #- extra parameters for the Nim compiler #- NIMFLAGS should come from the environment or make's command line NIM_PARAMS := $(NIMFLAGS) + # verbosity level -V := 1 +V := 0 NIM_PARAMS := $(NIM_PARAMS) --verbosity:$(V) HANDLE_OUTPUT := +SILENT_TARGET_PREFIX := disabled ifeq ($(V), 0) NIM_PARAMS := $(NIM_PARAMS) --hints:off --warnings:off HANDLE_OUTPUT := &>/dev/null + SILENT_TARGET_PREFIX := endif + # Chronicles log level LOG_LEVEL := ifdef LOG_LEVEL @@ -22,3 +26,6 @@ COMMA := , EMPTY := SPACE := $(EMPTY) $(EMPTY) +# coloured messages +BUILD_MSG := "\\e[92mBuilding:\\e[39m" +