From: Simon Ruderich Date: Fri, 16 Mar 2012 17:07:19 +0000 (+0100) Subject: Support non-verbose messages in verbose build for other build systems. X-Git-Tag: 0.01~107 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=c5394f86cae6babdd822c503b56ff53804bf83f0;p=blhc%2Fblhc.git Support non-verbose messages in verbose build for other build systems. CMake isn't the only one doing that. --- diff --git a/bin/blhc b/bin/blhc index ea8291f..f5fbfb8 100755 --- a/bin/blhc +++ b/bin/blhc @@ -115,28 +115,30 @@ sub pic_pie_conflict { sub is_non_verbose_build { my ($line, $next_line, $cc_regex, $skip_ref) = @_; - my $cmake_non_verbose = qr/^\s*\[[\d ]+%\] Building (?:C|CXX) object (.+?)$/; if (not ($line =~ /^checking if you want to see long compiling messages\.\.\. no/ - or $line =~ /^\s*(?:CC|CCLD)\s+/ - or $line =~ /^\s*(?:C|c)ompiling\s+/ - or $line =~ /$cmake_non_verbose/)) { + or $line =~ /^\s*(?:CC|CCLD)\s+(.+?)$/ + or $line =~ /^\s*(?:C|c)ompiling\s+(.+?)$/ + or $line =~ /^\s*(?:B|b)uilding (?:program|shared library)\s+(.+?)$/ + or $line =~ /^\s*\[[\d ]+%\] Building (?:C|CXX) object (.+?)$/)) { return 0; } + my $file = $1; + # On the first pass we only check if this line is verbose or not. return 1 if not defined $next_line; # Second pass, we have access to the next line. ${$skip_ref} = 0; - # CMake prints the non-verbose messages also when building verbose. If a - # compiler and the file name occurs in the next line, treat it as verbose - # build. - if ($line =~ /$cmake_non_verbose/) { + # CMake and other build systems print the non-verbose messages also when + # building verbose. If a compiler and the file name occurs in the next + # line, treat it as verbose build. + if (defined $file) { # Get filename, we can't use the complete path as only parts of it are - # used in the real compiler command ... - $1 =~ m{/([a-zA-Z0-9._-]+)$}; - my $file = $1; + # used in the real compiler command. + $file =~ m{/([a-zA-Z0-9._-]+)$}; + $file = $1; if ($next_line =~ /\Q$file\E/ and $next_line =~ /$cc_regex/) { # We still have to skip the current line as it doesn't contain any diff --git a/t/logs/verbose-build b/t/logs/verbose-build index 8a483e1..18c3193 100644 --- a/t/logs/verbose-build +++ b/t/logs/verbose-build @@ -21,13 +21,28 @@ Byte-compiling python modules (optimized versions) ... Byte-compiling python modules... Byte-compiling python modules (optimized versions) ... -Compiling test/test.cc to ../build/test/test.cc +# Non verbose. +Compiling test/test.cc to ../build/test/test.o +Building shared library ../build/test/libtest.so.1.2.3 +Compiling test.cc to ../build/test/test.o +Building program ../build/bin/test +# Verbose ... +Compiling test/test.cc to ../build/test/test.o +g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -o ../build/test/test.o test/test.cc +Building shared library ../build/test/libtest.so.1.2.3 +g++ -fPIC -DPIC \ + -o ../build/test/libtest.so.1.2.3 -shared \ + ../build/obj/test/test-a.o ../build/obj/test/test-b.o ../build/obj/test/test-c.o +Compiling test.cc to ../build/test/test.o +g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -o ../build/test/test.o test.cc +Building program ../build/bin/test +g++ ../build/obj/test/test.o -o /../build/bin/test # Non verbose. [ 22%] Building CXX object src/CMakeFiles/test/test.cpp.o [ 82%] Building C object src/CMakeFiles/test/test.c.o # Verbose ... [ 45%] Building CXX object src/CMakeFiles/test-verbose.dir/verbose.cpp.o -cd /tmp/test/src && /usr/bin/c++ -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -o CMakeFiles/test-verbose.dir/verbose.cpp.o -c -D_FORTIFY_SOURCE=2 /tmp/test/src/test-verbose/verbose.cpp +cd /tmp/test/src && /usr/bin/c++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -o CMakeFiles/test-verbose.dir/verbose.cpp.o -c -D_FORTIFY_SOURCE=2 /tmp/test/src/test-verbose/verbose.cpp [ 83%] Building C object src/CMakeFiles/test-verbose-c.dir/verbose-c.c.o -cd /tmp/test/src && /usr/bin/gcc -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -o CMakeFiles/test-verbose-c.dir/verbose-c.c.o -c -D_FORTIFY_SOURCE=2 /tmp/test/src/test-verbose-c/verbose-c.c +cd /tmp/test/src && /usr/bin/gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -o CMakeFiles/test-verbose-c.dir/verbose-c.c.o -c -D_FORTIFY_SOURCE=2 /tmp/test/src/test-verbose-c/verbose-c.c diff --git a/t/tests.t b/t/tests.t index bfdcd87..ad30e5b 100644 --- a/t/tests.t +++ b/t/tests.t @@ -299,7 +299,7 @@ LDFLAGS missing (-Wl,-z,relro -Wl,-z,now): /usr/bin/g++ -shared -fpic -o libtest # check the build log is verbose -is_blhc 'verbose-build', '', 4, +is_blhc 'verbose-build', '', 12, 'NONVERBOSE BUILD: checking if you want to see long compiling messages... no NONVERBOSE BUILD: CC libtest-a.lo NONVERBOSE BUILD: CC libtest-b.lo @@ -307,9 +307,19 @@ NONVERBOSE BUILD: CC libtest_c.lo NONVERBOSE BUILD: CC libtest-d.lo NONVERBOSE BUILD: CCLD libtest.la NONVERBOSE BUILD: CC modules/server/test.c -NONVERBOSE BUILD: Compiling test/test.cc to ../build/test/test.cc +NONVERBOSE BUILD: Compiling test/test.cc to ../build/test/test.o +NONVERBOSE BUILD: Building shared library ../build/test/libtest.so.1.2.3 +NONVERBOSE BUILD: Compiling test.cc to ../build/test/test.o +NONVERBOSE BUILD: Building program ../build/bin/test +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -o ../build/test/test.o test/test.cc +LDFLAGS missing (-Wl,-z,relro): g++ -fPIC -DPIC \ -o ../build/test/libtest.so.1.2.3 -shared \ ../build/obj/test/test-a.o ../build/obj/test/test-b.o ../build/obj/test/test-c.o +CFLAGS missing (-Wformat): g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -o ../build/test/test.o test.cc +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -o ../build/test/test.o test.cc +LDFLAGS missing (-Wl,-z,relro): g++ ../build/obj/test/test.o -o /../build/bin/test NONVERBOSE BUILD: [ 22%] Building CXX object src/CMakeFiles/test/test.cpp.o NONVERBOSE BUILD: [ 82%] Building C object src/CMakeFiles/test/test.c.o +CFLAGS missing (-Wformat): cd /tmp/test/src && /usr/bin/c++ -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat-security -Werror=format-security -o CMakeFiles/test-verbose.dir/verbose.cpp.o -c -D_FORTIFY_SOURCE=2 /tmp/test/src/test-verbose/verbose.cpp +CFLAGS missing (-Werror=format-security): cd /tmp/test/src && /usr/bin/gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -o CMakeFiles/test-verbose-c.dir/verbose-c.c.o -c -D_FORTIFY_SOURCE=2 /tmp/test/src/test-verbose-c/verbose-c.c ';