Makefile: low verbosity by default

This commit is contained in:
Ștefan Talpalaru 2019-03-29 18:08:39 +01:00
parent 716b51bc2a
commit 8150199581
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
3 changed files with 21 additions and 9 deletions

View File

@ -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:

View File

@ -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):

View File

@ -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"