Skip to content

Commit 03b164f

Browse files
anchaoxiaoxiang781216
authored andcommitted
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 <[email protected]>
1 parent dff2192 commit 03b164f

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

arch/sim/src/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ $(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
285285
$(call COMPILE, $<, $@)
286286

287287
$(HOSTOBJS) $(HEADOBJ): %$(OBJEXT): %.c
288-
$(Q) echo "CC: $<"
288+
$(Q) $(ECHO_BEGIN)"CC: $<"
289289
$(Q) "$(CC)" -c $(HOSTCFLAGS) $< -o $@
290+
$(Q) $(ECHO_END)
290291

291292
# The architecture-specific library
292293

tools/Config.mk

+33-12
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@
2222

2323
.SUFFIXES:
2424

25-
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
26-
export SHELL=cmd
27-
endif
28-
2925
# Control build verbosity
3026
#
27+
# V=0: Exit silent mode
3128
# V=1,2: Enable echo of commands
3229
# V=2: Enable bug/verbose options in tools and scripts
3330

@@ -39,6 +36,22 @@ else
3936
export Q := @
4037
endif
4138

39+
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
40+
export SHELL=cmd
41+
else ifeq ($(V),)
42+
BASHCMD := $(shell command -v bash 2> /dev/null)
43+
ifneq ($(BASHCMD),)
44+
export SHELL=$(BASHCMD)
45+
export ECHO_BEGIN=@echo -ne "\033[1K\r"
46+
export ECHO_END=$(ECHO_BEGIN)
47+
endif
48+
endif
49+
50+
ifeq ($(ECHO_BEGIN),)
51+
export ECHO_BEGIN=@echo
52+
export ECHO_END=
53+
endif
54+
4255
# These are configuration variables that are quoted by configuration tool
4356
# but which must be unquoted when used in the build system.
4457

@@ -267,8 +280,9 @@ endif
267280
# <filename>.S)
268281

269282
define PREPROCESS
270-
@echo "CPP: $1->$2"
283+
$(ECHO_BEGIN)"CPP: $1->$2 "
271284
$(Q) $(CPP) $(CPPFLAGS) $($(strip $1)_CPPFLAGS) $(abspath $1) -o $(abspath $2)
285+
$(ECHO_END)
272286
endef
273287

274288
# COMPILE - Default macro to compile one C file
@@ -284,8 +298,9 @@ endef
284298
# change the options used with the single file <filename>.c
285299

286300
define COMPILE
287-
@echo "CC: $1"
301+
$(ECHO_BEGIN)"CC: $1 "
288302
$(Q) $(CCACHE) $(CC) -c $(CFLAGS) $3 $($(strip $1)_CFLAGS) $(abspath $1) -o $(abspath $2)
303+
$(ECHO_END)
289304
endef
290305

291306
# COMPILEXX - Default macro to compile one C++ file
@@ -302,8 +317,9 @@ endef
302317
# extension .cpp could also be used. The same applies mutatis mutandis.
303318

304319
define COMPILEXX
305-
@echo "CXX: $1"
320+
$(ECHO_BEGIN)"CXX: $1 "
306321
$(Q) $(CCACHE) $(CXX) -c $(CXXFLAGS) $3 $($(strip $1)_CXXFLAGS) $(abspath $1) -o $(abspath $2)
322+
$(ECHO_END)
307323
endef
308324

309325
# COMPILERUST - Default macro to compile one Rust file
@@ -320,8 +336,9 @@ endef
320336
# applies mutatis mutandis.
321337

322338
define COMPILERUST
323-
@echo "RUSTC: $1"
339+
$(ECHO_BEGIN)"RUSTC: $1 "
324340
$(Q) $(RUSTC) --emit obj $(RUSTFLAGS) $($(strip $1)_RUSTFLAGS) $(abspath $1) -o $(abspath $2)
341+
$(ECHO_END)
325342
endef
326343

327344
# COMPILEZIG - Default macro to compile one Zig file
@@ -338,8 +355,9 @@ endef
338355
# applies mutatis mutandis.
339356

340357
define COMPILEZIG
341-
@echo "ZIG: $1"
358+
$(ECHO_BEGIN)"ZIG: $1 "
342359
$(Q) $(ZIG) build-obj $(ZIGFLAGS) $($(strip $1)_ZIGFLAGS) --name $(basename $2) $1
360+
$(ECHO_END)
343361
endef
344362

345363
# ASSEMBLE - Default macro to assemble one assembly language file
@@ -363,16 +381,18 @@ endef
363381
# is used by some toolchains. The same applies mutatis mutandis.
364382

365383
define ASSEMBLE
366-
@echo "AS: $1"
384+
$(ECHO_BEGIN)"AS: $1 "
367385
$(Q) $(CCACHE) $(CC) -c $(AFLAGS) $(abspath $1) $($(strip $1)_AFLAGS) -o $(abspath $2)
386+
$(ECHO_END)
368387
endef
369388

370389
# INSTALL_LIB - Install a library $1 into target $2
371390
# Example: $(call INSTALL_LIB, libabc.a, $(TOPDIR)/staging/)
372391

373392
define INSTALL_LIB
374-
@echo "IN: $1 -> $2"
393+
$(ECHO_BEGIN)"IN: $1 -> $2 "
375394
$(Q) install -m 0644 $(abspath $1) $(abspath $2)
395+
$(ECHO_END)
376396
endef
377397

378398
# ARCHIVE_ADD - Add a list of files to an archive
@@ -392,8 +412,9 @@ endef
392412
# CONFIG_WINDOWS_NATIVE - Defined for a Windows native build
393413

394414
define ARCHIVE_ADD
395-
@echo "AR (add): ${shell basename $(1)} $(2)"
415+
$(ECHO_BEGIN)"AR (add): ${shell basename $(1)} $(2) "
396416
$(Q) $(AR) $(abspath $1) $(abspath $2)
417+
$(ECHO_END)
397418
endef
398419

399420
# ARCHIVE - Same as above, but ensure the archive is

tools/Unix.mk

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
export TOPDIR := ${shell echo $(CURDIR) | sed -e 's/ /\\ /g'}
2222

23+
ifeq ($(V),)
24+
MAKE := $(MAKE) -s --no-print-directory
25+
endif
26+
2327
# Build any necessary tools needed early in the build.
2428
# incdir - Is needed immediately by all Make.defs file.
2529

@@ -664,7 +668,7 @@ savedefconfig: apps_preconfig
664668
# that the archiver is 'ar'
665669

666670
export: $(NUTTXLIBS)
667-
$(Q) MAKE=${MAKE} $(MKEXPORT) $(MKEXPORT_ARGS) -l "$(EXPORTLIBS)"
671+
$(Q) MAKE="${MAKE}" $(MKEXPORT) $(MKEXPORT_ARGS) -l "$(EXPORTLIBS)"
668672

669673
# General housekeeping targets: dependencies, cleaning, etc.
670674
#

tools/mkexport.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ cd "${TOPDIR}" || \
418418
{ echo "MK: 'cd ${TOPDIR}' failed"; exit 1; }
419419

420420
if [ -e "${APPDIR}/Makefile" ]; then
421-
"${MAKE}" -C "${APPDIR}" EXPORTDIR="$(cd "${EXPORTSUBDIR}" ; pwd )" TOPDIR="${TOPDIR}" export || \
421+
${MAKE} -C "${APPDIR}" EXPORTDIR="$(cd "${EXPORTSUBDIR}" ; pwd )" TOPDIR="${TOPDIR}" export || \
422422
{ echo "MK: call make export for APPDIR not supported"; }
423423
fi
424424

0 commit comments

Comments
 (0)