cmake-utils.eclass: Add QA check for broken buildsystems
authorDavid Seifert <soap@gentoo.org>
Sun, 24 Sep 2017 09:07:36 +0000 (11:07 +0200)
committerDavid Seifert <soap@gentoo.org>
Sun, 24 Sep 2017 10:34:34 +0000 (12:34 +0200)
Closes: https://github.com/gentoo/gentoo/pull/4757

eclass/cmake-utils.eclass

index c6a52b8d9ae7b301c887bfdb75ed9d91372f6115..148fbc3cff3311b3690f65651f497525c0a1e2cd 100644 (file)
@@ -93,6 +93,12 @@ _CMAKE_UTILS_ECLASS=1
 # for econf and is needed to pass TRY_RUN results when cross-compiling.
 # Should be set by user in a per-package basis in /etc/portage/package.env.
 
+# @ECLASS-VARIABLE: CMAKE_UTILS_QA_SRC_DIR_READONLY
+# @DESCRIPTION:
+# After running cmake-utils_src_prepare, sets ${S} to read-only. This is
+# a user flag and should under _no circumstances_ be set in the ebuild.
+# Helps in improving QA of build systems that write to source tree.
+
 case ${EAPI} in
        5) : ${CMAKE_WARN_UNUSED_CLI:=no} ;;
        6) : ${CMAKE_WARN_UNUSED_CLI:=yes} ;;
@@ -442,6 +448,11 @@ cmake-utils_src_prepare() {
 
        popd > /dev/null || die
 
+       # make ${S} read-only in order to detect broken build-systems
+       if [[ ${CMAKE_UTILS_QA_SRC_DIR_READONLY} && ! ${CMAKE_IN_SOURCE_BUILD} ]]; then
+               chmod -R a-w "${S}"
+       fi
+
        _CMAKE_UTILS_SRC_PREPARE_HAS_RUN=1
 }