commit:     460260affe1c3ac55992d94581672a49abdb2fcf
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Oct  1 12:09:04 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Oct  1 12:22:28 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=460260af

sys-devel/llvm: Add target obsolescence check

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 sys-devel/llvm/llvm-10.0.0.9999.ebuild | 35 ++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/sys-devel/llvm/llvm-10.0.0.9999.ebuild 
b/sys-devel/llvm/llvm-10.0.0.9999.ebuild
index a58ed35b541..6bfea01a739 100644
--- a/sys-devel/llvm/llvm-10.0.0.9999.ebuild
+++ b/sys-devel/llvm/llvm-10.0.0.9999.ebuild
@@ -90,6 +90,38 @@ python_check_deps() {
        has_version -b "dev-python/sphinx[${PYTHON_USEDEP}]"
 }
 
+check_live_ebuild() {
+       local prod_targets=(
+               $(sed -n -e '/set(LLVM_ALL_TARGETS/,/)/p' CMakeLists.txt \
+                       | tail -n +2 | head -n -1)
+       )
+       local all_targets=(
+               lib/Target/*/
+       )
+       all_targets=( "${all_targets[@]#lib/Target/}" )
+       all_targets=( "${all_targets[@]%/}" )
+
+       local exp_targets=() i
+       for i in "${all_targets[@]}"; do
+               has "${i}" "${prod_targets[@]}" || exp_targets+=( "${i}" )
+       done
+       # reorder
+       all_targets=( "${prod_targets[@]}" "${exp_targets[@]}" )
+
+       if [[ ${exp_targets[*]} != ${ALL_LLVM_EXPERIMENTAL_TARGETS[*]} ]]; then
+               ewarn "ALL_LLVM_EXPERIMENTAL_TARGETS is outdated!"
+               ewarn "    Have: ${ALL_LLVM_EXPERIMENTAL_TARGETS[*]}"
+               ewarn "Expected: ${exp_targets[*]}"
+               ewarn
+       fi
+
+       if [[ ${all_targets[*]} != ${ALL_LLVM_TARGETS[*]#llvm_targets_} ]]; then
+               ewarn "ALL_LLVM_TARGETS is outdated!"
+               ewarn "    Have: ${ALL_LLVM_TARGETS[*]#llvm_targets_}"
+               ewarn "Expected: ${all_targets[*]}"
+       fi
+}
+
 src_prepare() {
        # Fix llvm-config for shared linking and sane flags
        # https://bugs.gentoo.org/show_bug.cgi?id=565358
@@ -100,6 +132,9 @@ src_prepare() {
 
        # User patches + QA
        cmake-utils_src_prepare
+
+       # Verify that the live ebuild is up-to-date
+       check_live_ebuild
 }
 
 # Is LLVM being linked against libc++?

Reply via email to