]> git.cworth.org Git - lmno.games/commitdiff
Make the build quieter by default
authorCarl Worth <cworth@cworth.org>
Mon, 25 May 2020 20:27:28 +0000 (13:27 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 26 May 2020 03:52:45 +0000 (20:52 -0700)
Just a simple change to keep the output of make very tidy.

If the user wants to see the complete command output they can use
"make V=1" for that, (and this support is documented in the default
output).

Makefile

index 74233b0ad221be2a3855440d1b5da92a4dac32f1..4b0b4c462e75a1ef55d432d9a9f2297180abf50b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -29,40 +29,61 @@ all: $(JS_TARGETS) $(REACT_DEPS)
 #       or otherwise start in a clean source tree (such as a
 #       after a fresh "git clone" or use "git clean -f -x -d).
 #
+CP=cp
+BABEL=babeljs
 ifeq ($(LMNO_BUILD),production)
 react.js: deps/react.production.min.js
-       cp $^ $@
+       $(call quiet,CP) $^ $@
 
 react-dom.js: deps/react-dom.production.min.js
-       cp $^ $@
+       $(call quiet,CP) $^ $@
 
+export BABEL_ENV=production
 %.js: %.jsx
-       BABEL_ENV=production babeljs $^ --out-file $@
+       $(call quiet,BABEL) $^ --out-file $@
 else
 react.js: deps/react.development.js
-       cp $^ $@
+       $(call quiet,CP) $^ $@
 
 react-dom.js: deps/react-dom.development.js
-       cp $^ $@
+       $(call quiet,CP) $^ $@
 
+export BABEL_ENV=development
 %.js: %.jsx
-       BABEL_ENV=development babeljs $^ --out-file $@
+       $(call quiet,BABEL) $^ --out-file $@
 endif
 
+# The user has not set any verbosity, default to quiet mode and inform the
+# user how to enable verbose compiles.
+ifeq ($(V),)
+quiet_DOC := "Use \"$(MAKE) V=1\" to see the verbose compile lines.\n"
+quiet = @printf $(quiet_DOC)$(eval quiet_DOC:=)"$(1) $(or $(2),$@)\n"; $($(word 1, $(1)))
+WGET_VERBOSE_FLAGS=--quiet
+endif
+# The user has explicitly enabled quiet compilation.
+ifeq ($(V),0)
+quiet = @printf "$(1) $(or $(2),$@)\n"; $($(word 1, $(1)))
+WGET_VERBOSE_FLAGS=--quiet
+endif
+# Otherwise, print the full command line.
+quiet ?= $($(word 1, $(1)))
+WGET_VERBOSE_FLAGS ?= --no-verbose
+
 checksums: $(REACT_DOWNLOADS)
        sha512sum --strict -c checksums.sha512
 
+DOWNLOAD=wget $(WGET_VERBOSE_FLAGS) -nc -P deps
 deps/react.development.js:
-       wget -nv -nc -P deps https://unpkg.com/react@16/umd/react.development.js
+       $(call quiet,DOWNLOAD) https://unpkg.com/react@16/umd/react.development.js
 
 deps/react-dom.development.js:
-       wget -nv -nc -P deps https://unpkg.com/react-dom@16/umd/react-dom.development.js
+       $(call quiet,DOWNLOAD) https://unpkg.com/react-dom@16/umd/react-dom.development.js
 
 deps/react.production.min.js:
-       wget -nv -nc -P deps https://unpkg.com/react@16/umd/react.production.min.js
+       $(call quiet,DOWNLOAD) https://unpkg.com/react@16/umd/react.production.min.js
 
 deps/react-dom.production.min.js:
-       wget -nv -nc -P deps https://unpkg.com/react-dom@16/umd/react-dom.production.min.js
+       $(call quiet,DOWNLOAD) https://unpkg.com/react-dom@16/umd/react-dom.production.min.js
 
 deploy:
        rm -rf .deploy-source
@@ -80,4 +101,4 @@ deploy:
 clean:
        rm -f $(JS_TARGETS)
        rm -f $(REACT_DEPS)
-       rm -f $(REACT_DOWNLOADS)
+       rm -f deps/*.js