From 03b164f59ce40a3f5677b0588af2aee8d9697bf6 Mon Sep 17 00:00:00 2001 From: chao an Date: Tue, 31 Jan 2023 18:26:42 +0800 Subject: [PATCH] tools/makefile: silent all compile output In order to make compilation warnings and errors easier to be found out, this commit will disable the printing of the compilation process as much as possible, and also if you want to restore the log information of the compilation process, please enable verbose build on command line: $ make V=0 OR $ make V=1 | V=0: Exit silent mode | V=1,2: Enable echo of commands | V=2: Enable bug/verbose options in tools and scripts Signed-off-by: chao an --- arch/sim/src/Makefile | 3 ++- tools/Config.mk | 45 +++++++++++++++++++++++++++++++------------ tools/Unix.mk | 6 +++++- tools/mkexport.sh | 2 +- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 63cb1e0af34..b5c2da974d8 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -285,8 +285,9 @@ $(COBJS) $(LINKOBJS): %$(OBJEXT): %.c $(call COMPILE, $<, $@) $(HOSTOBJS) $(HEADOBJ): %$(OBJEXT): %.c - $(Q) echo "CC: $<" + $(Q) $(ECHO_BEGIN)"CC: $<" $(Q) "$(CC)" -c $(HOSTCFLAGS) $< -o $@ + $(Q) $(ECHO_END) # The architecture-specific library diff --git a/tools/Config.mk b/tools/Config.mk index 7096fa1b4de..8630026e71f 100644 --- a/tools/Config.mk +++ b/tools/Config.mk @@ -22,12 +22,9 @@ .SUFFIXES: -ifeq ($(CONFIG_WINDOWS_NATIVE),y) -export SHELL=cmd -endif - # Control build verbosity # +# V=0: Exit silent mode # V=1,2: Enable echo of commands # V=2: Enable bug/verbose options in tools and scripts @@ -39,6 +36,22 @@ else export Q := @ endif +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + export SHELL=cmd +else ifeq ($(V),) + BASHCMD := $(shell command -v bash 2> /dev/null) + ifneq ($(BASHCMD),) + export SHELL=$(BASHCMD) + export ECHO_BEGIN=@echo -ne "\033[1K\r" + export ECHO_END=$(ECHO_BEGIN) + endif +endif + +ifeq ($(ECHO_BEGIN),) + export ECHO_BEGIN=@echo + export ECHO_END= +endif + # These are configuration variables that are quoted by configuration tool # but which must be unquoted when used in the build system. @@ -267,8 +280,9 @@ endif # .S) define PREPROCESS - @echo "CPP: $1->$2" + $(ECHO_BEGIN)"CPP: $1->$2 " $(Q) $(CPP) $(CPPFLAGS) $($(strip $1)_CPPFLAGS) $(abspath $1) -o $(abspath $2) + $(ECHO_END) endef # COMPILE - Default macro to compile one C file @@ -284,8 +298,9 @@ endef # change the options used with the single file .c define COMPILE - @echo "CC: $1" + $(ECHO_BEGIN)"CC: $1 " $(Q) $(CCACHE) $(CC) -c $(CFLAGS) $3 $($(strip $1)_CFLAGS) $(abspath $1) -o $(abspath $2) + $(ECHO_END) endef # COMPILEXX - Default macro to compile one C++ file @@ -302,8 +317,9 @@ endef # extension .cpp could also be used. The same applies mutatis mutandis. define COMPILEXX - @echo "CXX: $1" + $(ECHO_BEGIN)"CXX: $1 " $(Q) $(CCACHE) $(CXX) -c $(CXXFLAGS) $3 $($(strip $1)_CXXFLAGS) $(abspath $1) -o $(abspath $2) + $(ECHO_END) endef # COMPILERUST - Default macro to compile one Rust file @@ -320,8 +336,9 @@ endef # applies mutatis mutandis. define COMPILERUST - @echo "RUSTC: $1" + $(ECHO_BEGIN)"RUSTC: $1 " $(Q) $(RUSTC) --emit obj $(RUSTFLAGS) $($(strip $1)_RUSTFLAGS) $(abspath $1) -o $(abspath $2) + $(ECHO_END) endef # COMPILEZIG - Default macro to compile one Zig file @@ -338,8 +355,9 @@ endef # applies mutatis mutandis. define COMPILEZIG - @echo "ZIG: $1" + $(ECHO_BEGIN)"ZIG: $1 " $(Q) $(ZIG) build-obj $(ZIGFLAGS) $($(strip $1)_ZIGFLAGS) --name $(basename $2) $1 + $(ECHO_END) endef # ASSEMBLE - Default macro to assemble one assembly language file @@ -363,16 +381,18 @@ endef # is used by some toolchains. The same applies mutatis mutandis. define ASSEMBLE - @echo "AS: $1" + $(ECHO_BEGIN)"AS: $1 " $(Q) $(CCACHE) $(CC) -c $(AFLAGS) $(abspath $1) $($(strip $1)_AFLAGS) -o $(abspath $2) + $(ECHO_END) endef # INSTALL_LIB - Install a library $1 into target $2 # Example: $(call INSTALL_LIB, libabc.a, $(TOPDIR)/staging/) define INSTALL_LIB - @echo "IN: $1 -> $2" + $(ECHO_BEGIN)"IN: $1 -> $2 " $(Q) install -m 0644 $(abspath $1) $(abspath $2) + $(ECHO_END) endef # ARCHIVE_ADD - Add a list of files to an archive @@ -392,8 +412,9 @@ endef # CONFIG_WINDOWS_NATIVE - Defined for a Windows native build define ARCHIVE_ADD - @echo "AR (add): ${shell basename $(1)} $(2)" + $(ECHO_BEGIN)"AR (add): ${shell basename $(1)} $(2) " $(Q) $(AR) $(abspath $1) $(abspath $2) + $(ECHO_END) endef # ARCHIVE - Same as above, but ensure the archive is diff --git a/tools/Unix.mk b/tools/Unix.mk index 6b199b25ab8..9b52454a7a3 100644 --- a/tools/Unix.mk +++ b/tools/Unix.mk @@ -20,6 +20,10 @@ export TOPDIR := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'} +ifeq ($(V),) + MAKE := $(MAKE) -s --no-print-directory +endif + # Build any necessary tools needed early in the build. # incdir - Is needed immediately by all Make.defs file. @@ -664,7 +668,7 @@ savedefconfig: apps_preconfig # that the archiver is 'ar' export: $(NUTTXLIBS) - $(Q) MAKE=${MAKE} $(MKEXPORT) $(MKEXPORT_ARGS) -l "$(EXPORTLIBS)" + $(Q) MAKE="${MAKE}" $(MKEXPORT) $(MKEXPORT_ARGS) -l "$(EXPORTLIBS)" # General housekeeping targets: dependencies, cleaning, etc. # diff --git a/tools/mkexport.sh b/tools/mkexport.sh index d13c604d89a..c32edf9e2ab 100755 --- a/tools/mkexport.sh +++ b/tools/mkexport.sh @@ -418,7 +418,7 @@ cd "${TOPDIR}" || \ { echo "MK: 'cd ${TOPDIR}' failed"; exit 1; } if [ -e "${APPDIR}/Makefile" ]; then - "${MAKE}" -C "${APPDIR}" EXPORTDIR="$(cd "${EXPORTSUBDIR}" ; pwd )" TOPDIR="${TOPDIR}" export || \ + ${MAKE} -C "${APPDIR}" EXPORTDIR="$(cd "${EXPORTSUBDIR}" ; pwd )" TOPDIR="${TOPDIR}" export || \ { echo "MK: call make export for APPDIR not supported"; } fi