From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 93273158015 for ; Sun, 17 Dec 2023 11:58:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B53562BC017; Sun, 17 Dec 2023 11:58:10 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 839D92BC021 for ; Sun, 17 Dec 2023 11:58:10 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6181633FD24 for ; Sun, 17 Dec 2023 11:58:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B8F8E1320 for ; Sun, 17 Dec 2023 11:58:07 +0000 (UTC) From: "Marco Leise" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Marco Leise" Message-ID: <1702245234.8c977f9dc9d15ebcf73032411eed7acf033782fb.mleise@gentoo> Subject: [gentoo-commits] repo/user/dlang:master commit in: eclass/ X-VCS-Repository: repo/user/dlang X-VCS-Files: eclass/dlang.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mleise X-VCS-Committer-Name: Marco Leise X-VCS-Revision: 8c977f9dc9d15ebcf73032411eed7acf033782fb X-VCS-Branch: master Date: Sun, 17 Dec 2023 11:58:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 47f0a447-68a6-4457-8048-7d73fe4ab6bf X-Archives-Hash: 434ff8aee2d85c44b3520b221c66ac8b commit: 8c977f9dc9d15ebcf73032411eed7acf033782fb Author: Horodniceanu Andrei proton me> AuthorDate: Thu Nov 30 19:32:20 2023 +0000 Commit: Marco Leise gmx de> CommitDate: Sun Dec 10 21:53:54 2023 +0000 URL: https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=8c977f9d dlang.eclass: Support DLANG_COMPILER_DISABLED_BACKENDS Add support for filtering out possible compilers by their backend, on top of the frontend version filtering already implemented. This allows packages that do not support a particular compiler backend not to advertise USE flags that will fail to build. Signed-off-by: Horodniceanu Andrei proton.me> eclass/dlang.eclass | 91 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 31 deletions(-) diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass index ab41b18..5c7d3f9 100644 --- a/eclass/dlang.eclass +++ b/eclass/dlang.eclass @@ -30,6 +30,14 @@ # @DESCRIPTION: # The path that is used to install include files. A sub-directory specific to the package should be used. +# @ECLASS_VARIABLE: DLANG_COMPILER_DISABLED_BACKENDS +# @PRE_INHERIT +# @DEFAULT_UNSET +# @DESCRIPTION: +# Optional list of D compiler backends to disable as a Bash array. +# Possible values include dmd, ldc2, and gdc. +# Set before inheritting the eclass. + if [[ ${_ECLASS_ONCE_DLANG} != "recur -_+^+_- spank" ]] ; then _ECLASS_ONCE_DLANG="recur -_+^+_- spank" @@ -402,39 +410,45 @@ _dlang_compiler_masked_archs_for_version_range() { _dlang_filter_compilers() { local dc_version mapping iuse depend - # filter for DMD (hardcoding support for x86 and amd64 only) - for dc_version in "${!_dlang_dmd_frontend[@]}"; do - mapping="${_dlang_dmd_frontend[${dc_version}]}" - iuse="dmd-$(ver_rs 1- _ $dc_version)" - if [ "${DLANG_PACKAGE_TYPE}" == "multi" ]; then - depend="[${MULTILIB_USEDEP}]" - else - depend="" - fi - depend="dev-lang/dmd:$dc_version=$depend" - _dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2" - done + if _dlang_compiler_backend_is_enabled "dmd"; then + # filter for DMD (hardcoding support for x86 and amd64 only) + for dc_version in "${!_dlang_dmd_frontend[@]}"; do + mapping="${_dlang_dmd_frontend[${dc_version}]}" + iuse="dmd-$(ver_rs 1- _ $dc_version)" + if [ "${DLANG_PACKAGE_TYPE}" == "multi" ]; then + depend="[${MULTILIB_USEDEP}]" + else + depend="" + fi + depend="dev-lang/dmd:$dc_version=$depend" + _dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2" + done + fi - # GDC (doesn't support sub-slots, to stay compatible with upstream GCC) - for dc_version in "${!_dlang_gdc_frontend[@]}"; do - mapping="${_dlang_gdc_frontend[${dc_version}]}" - iuse="gdc-${dc_version}" - depend="sys-devel/gcc:$dc_version[d,-d-bootstrap(-)]" - _dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2" - done + if _dlang_compiler_backend_is_enabled "gdc"; then + # GDC (doesn't support sub-slots, to stay compatible with upstream GCC) + for dc_version in "${!_dlang_gdc_frontend[@]}"; do + mapping="${_dlang_gdc_frontend[${dc_version}]}" + iuse="gdc-${dc_version}" + depend="sys-devel/gcc:$dc_version[d,-d-bootstrap(-)]" + _dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2" + done + fi - # filter for LDC2 - for dc_version in "${!_dlang_ldc2_frontend[@]}"; do - mapping="${_dlang_ldc2_frontend[${dc_version}]}" - iuse=ldc2-$(ver_rs 1- _ $dc_version) - if [ "${DLANG_PACKAGE_TYPE}" == "multi" ]; then - depend="[${MULTILIB_USEDEP}]" - else - depend="" - fi - depend="dev-lang/ldc2:$dc_version=$depend" - _dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2" - done + if _dlang_compiler_backend_is_enabled "ldc2"; then + # filter for LDC2 + for dc_version in "${!_dlang_ldc2_frontend[@]}"; do + mapping="${_dlang_ldc2_frontend[${dc_version}]}" + iuse=ldc2-$(ver_rs 1- _ $dc_version) + if [ "${DLANG_PACKAGE_TYPE}" == "multi" ]; then + depend="[${MULTILIB_USEDEP}]" + else + depend="" + fi + depend="dev-lang/ldc2:$dc_version=$depend" + _dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2" + done + fi } # @FUNCTION: _dlang_filter_versions @@ -762,6 +776,21 @@ _dlang_additional_flags() { $(_dlang_prefix_words "${DLANG_LINKER_FLAG}-l" $libs) } +# @FUNCTION: _dlang_compiler_backend_is_enabled +# @USAGE: _dlang_compiler_backend_is_enabled +# @RETURN: Truth if the backend is enabled +# @INTERNAL +# @DESCRIPTION: +# Check if the given backend is enabled. +# Possible values for the backend are: dmd, ldc2 and gdc +_dlang_compiler_backend_is_enabled() { + local disabled_backend + for disabled_backend in "${DLANG_COMPILER_DISABLED_BACKENDS[@]}"; do + [[ ${disabled_backend} == ${1} ]] && return 1 + done + return 0 +} + # Setting DLANG_USE_COMPILER skips the generation of USE-flags for compilers if [ -z ${DLANG_USE_COMPILER+x} ]; then set -f; _dlang_filter_versions; set +f