commit:     a03d0f3d4b6aa58df7b6f9dd9d76c45128455ec1
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 25 09:07:36 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jan 26 06:40:02 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=a03d0f3d

install-qa-check.d: Scan build log for CMake unused var warnings

Scan build log and report verbosely CMake warnings about unused
variables. This is a quite common problem, yet currently it is hard
to notice it since the warning is mixed with src_configure() output.
Repeat it verbosely after the install.

This check outputs warnings such as:

 * One or more CMake variables were not used by the project:
 *   CMAKE_USER_MAKE_RULES_OVERRIDE

Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>

 bin/install-qa-check.d/90cmake-warnings | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/bin/install-qa-check.d/90cmake-warnings 
b/bin/install-qa-check.d/90cmake-warnings
new file mode 100644
index 000000000..a6e901efc
--- /dev/null
+++ b/bin/install-qa-check.d/90cmake-warnings
@@ -0,0 +1,28 @@
+# Check for CMake invalid option warnings
+
+cmake_warn_check() {
+       if [[ -n ${PORTAGE_LOG_FILE} && -r ${PORTAGE_LOG_FILE} ]] ; then
+               local cat=cat
+               [[ ${PORTAGE_LOG_FILE} == *.gz ]] && cat=zcat
+
+               local vars=()
+               while read -r l; do
+                       vars+=( "${l}" )
+               done < <( "${cat}" "${PORTAGE_LOG_FILE}" \
+                       | sed -n -e '/Manually-specified variables were not 
used by the project/,/^--/{/^    /p}' \
+                       | LC_ALL=C sort -u)
+
+               if [[ ${vars} ]]; then
+                       eqawarn "One or more CMake variables were not used by 
the project:"
+                       local v
+                       for v in "${vars[@]}"; do
+                               eqawarn "  ${v}"
+                       done
+               fi
+       fi
+}
+
+cmake_warn_check
+: # guarantee successful exit
+
+# vim:ft=sh

Reply via email to