commit:     256a0c415ec93523fa3ddfb0a9362fa7875d4f26
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Thu Aug  7 17:27:03 2025 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Fri Aug  8 17:26:12 2025 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=256a0c41

dev-util/gdmd: Replace SLOTs with USE flags

Replace the multiple dev-util/gdmd:1{2..5} with the single
dev-util/gdmd:0[dlang_targets_gdc-1{2..5}].

This helps with:
- updating the innate package, since there's only 1 ebuild now
- using it for older/newer gcc's through DLANG_COMPAT_OVERRIDE
- installing common files, e.g. the man page

The only downside is handling the conflicts since older D packages would
RDEPEND on gdmd:<SLOT> which gives annoying blocker messages when trying
to update. The issue would not manifest instantaneously, but when one D
package is updated it would then try to pull in gdmd:0 which would
conflict with the gdmd:<SLOT> that is still a dependency on other,
older, D packages. This can be improved by adding "virtual" packages in
the form:
- dev-util/gdmd:15 RDEPENDs on dev-util/gdmd:0[dlang_targets_gdc-15]

After enough time has passed and the D packages have been
rebuilt/updated, the alias packages can simply be dropped.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu <AT> proton.me>

 dev-util/gdmd/Manifest                             |   1 +
 .../gdmd/files/gdmd-20250807-no-dmd-conf.patch     |  13 +++
 dev-util/gdmd/gdmd-12.20250807.ebuild              |  16 +++
 dev-util/gdmd/gdmd-13.20250807.ebuild              |  16 +++
 dev-util/gdmd/gdmd-14.20250807.ebuild              |  16 +++
 dev-util/gdmd/gdmd-15.20250807.ebuild              |  16 +++
 dev-util/gdmd/gdmd-20250807.ebuild                 | 107 +++++++++++++++++++++
 eclass/dlang-utils.eclass                          |   2 +-
 8 files changed, 186 insertions(+), 1 deletion(-)

diff --git a/dev-util/gdmd/Manifest b/dev-util/gdmd/Manifest
index 6ad2503..d38f7d6 100644
--- a/dev-util/gdmd/Manifest
+++ b/dev-util/gdmd/Manifest
@@ -1,2 +1,3 @@
 DIST gdmd-0.1.0.tar.gz 7794 BLAKE2B 
f613c1faf7abb9f72990e21dfdf21e69f4d83fde5d7d6a8a0ccac16a21c0cf39f2d03b2fba7f9b19009b1e2198413c99653635a32cbad48bb8b5dfbf5da1ebab
 SHA512 
54c1b56e252feb024d400a03df7d7b3e5942f98ce6542d77030659ec09bba3770426fc88e143550d24be8272dfa4ff510de8335badfbf9ae6e5f5b6063216fd3
 DIST gdmd-b3b72f59252f09275941f706806ed80d68308db1.tar.gz 9055 BLAKE2B 
6a14c3c3be3fe0cf673d8ac564c898779fd5b94c1ef8a5546826d6d8ab962ea6160d7f49e1cba67554d07552a7b02d5a713989340376ab232a80fb797b55bab1
 SHA512 
e8d1ed3d1a4b4c25157d9ec70369bd6cc209ce8265265921251dc506febc71ef1888f9b2395836f16d5f50d6c7e02d8f50b2169dcd83962dcdc60d5278f444f6
+DIST gdmd-d14f7301b4bbae44996bc962121c9a1e7f7e3f12.tar.gz 9661 BLAKE2B 
2c4444660c288db69f876c2ef232d183f644dfd5c8c7a9f5cb2976893b42d7abe4dea03198525c197972949517a385effbbd6fc86b0a505b87002bf11c95a6b6
 SHA512 
aee9b829d9b0468727f0455974f43ca11746b69085298e48587e1e6a23efd3775b4d091c54a65693a39689a0950d28bd318bece10925486c7ff1bccf928f92a3

diff --git a/dev-util/gdmd/files/gdmd-20250807-no-dmd-conf.patch 
b/dev-util/gdmd/files/gdmd-20250807-no-dmd-conf.patch
new file mode 100644
index 0000000..835c7fc
--- /dev/null
+++ b/dev-util/gdmd/files/gdmd-20250807-no-dmd-conf.patch
@@ -0,0 +1,13 @@
+diff --git i/dmd-script w/dmd-script
+--- i/dmd-script
++++ w/dmd-script
+@@ -327,9 +327,6 @@ sub browse($) {
+     exit 0;
+ }
+ 
+-# Load dmd.conf before before parsing arguments.
+-readINI();
+-
+ # $DFLAGS should go before a -run switch, or at the end of ARGV
+ my @extra_dflags = split(/\s+/, $ENV{DFLAGS} || "");
+ my $extra_dflags_used = 0;

diff --git a/dev-util/gdmd/gdmd-12.20250807.ebuild 
b/dev-util/gdmd/gdmd-12.20250807.ebuild
new file mode 100644
index 0000000..4193a9d
--- /dev/null
+++ b/dev-util/gdmd/gdmd-12.20250807.ebuild
@@ -0,0 +1,16 @@
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Don't use this package, use dev-util/gdmd:0"
+HOMEPAGE="https://www.gdcproject.org/";
+S="${WORKDIR}"
+
+LICENSE="GPL-3+"
+SLOT="$(ver_cut 1)"
+KEYWORDS="~amd64 ~arm64 ~x86"
+RESTRICT="test"
+
+date=$(ver_cut 2)
+RDEPEND=">=dev-util/gdmd-${date}:0[dlang_targets_gdc-${SLOT}(-)]"

diff --git a/dev-util/gdmd/gdmd-13.20250807.ebuild 
b/dev-util/gdmd/gdmd-13.20250807.ebuild
new file mode 100644
index 0000000..4193a9d
--- /dev/null
+++ b/dev-util/gdmd/gdmd-13.20250807.ebuild
@@ -0,0 +1,16 @@
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Don't use this package, use dev-util/gdmd:0"
+HOMEPAGE="https://www.gdcproject.org/";
+S="${WORKDIR}"
+
+LICENSE="GPL-3+"
+SLOT="$(ver_cut 1)"
+KEYWORDS="~amd64 ~arm64 ~x86"
+RESTRICT="test"
+
+date=$(ver_cut 2)
+RDEPEND=">=dev-util/gdmd-${date}:0[dlang_targets_gdc-${SLOT}(-)]"

diff --git a/dev-util/gdmd/gdmd-14.20250807.ebuild 
b/dev-util/gdmd/gdmd-14.20250807.ebuild
new file mode 100644
index 0000000..4193a9d
--- /dev/null
+++ b/dev-util/gdmd/gdmd-14.20250807.ebuild
@@ -0,0 +1,16 @@
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Don't use this package, use dev-util/gdmd:0"
+HOMEPAGE="https://www.gdcproject.org/";
+S="${WORKDIR}"
+
+LICENSE="GPL-3+"
+SLOT="$(ver_cut 1)"
+KEYWORDS="~amd64 ~arm64 ~x86"
+RESTRICT="test"
+
+date=$(ver_cut 2)
+RDEPEND=">=dev-util/gdmd-${date}:0[dlang_targets_gdc-${SLOT}(-)]"

diff --git a/dev-util/gdmd/gdmd-15.20250807.ebuild 
b/dev-util/gdmd/gdmd-15.20250807.ebuild
new file mode 100644
index 0000000..4193a9d
--- /dev/null
+++ b/dev-util/gdmd/gdmd-15.20250807.ebuild
@@ -0,0 +1,16 @@
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DESCRIPTION="Don't use this package, use dev-util/gdmd:0"
+HOMEPAGE="https://www.gdcproject.org/";
+S="${WORKDIR}"
+
+LICENSE="GPL-3+"
+SLOT="$(ver_cut 1)"
+KEYWORDS="~amd64 ~arm64 ~x86"
+RESTRICT="test"
+
+date=$(ver_cut 2)
+RDEPEND=">=dev-util/gdmd-${date}:0[dlang_targets_gdc-${SLOT}(-)]"

diff --git a/dev-util/gdmd/gdmd-20250807.ebuild 
b/dev-util/gdmd/gdmd-20250807.ebuild
new file mode 100644
index 0000000..7f7dd2f
--- /dev/null
+++ b/dev-util/gdmd/gdmd-20250807.ebuild
@@ -0,0 +1,107 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DLANG_COMPAT=( gdc-1{2..5} )
+inherit dlang-r1 prefix
+
+DESCRIPTION="Wrapper script for gdc that emulates the dmd command"
+HOMEPAGE="https://www.gdcproject.org/";
+
+COMMIT="d14f7301b4bbae44996bc962121c9a1e7f7e3f12"
+SRC_URI="https://github.com/D-Programming-GDC/gdmd/archive/${COMMIT}.tar.gz -> 
gdmd-${COMMIT}.tar.gz"
+S="${WORKDIR}/gdmd-${COMMIT}"
+LICENSE="GPL-3+"
+
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~x86"
+RESTRICT="test" # no tests
+
+REQUIRED_USE=${DLANG_REQUIRED_USE}
+# Ignore ${DLANG_DEPS}, we only need gcc[d]
+gen_gccslot_dep() {
+       local impl dep=${1} result=()
+       for impl in "${_DLANG_SUPPORTED_IMPLS[@]}"; do
+               local slot=${impl#gdc-}
+               local req=dlang_targets_${impl}
+
+               local subdep=${dep//\$\{GCC_SLOT\}/${slot}}
+               result+=( "${req}? ( ${subdep} )" )
+       done
+
+       echo "${result[@]}"
+}
+RDEPEND="
+       dev-lang/perl
+       $(gen_gccslot_dep '
+                       sys-devel/gcc:${GCC_SLOT}[d]
+                       !<dev-util/gdmd-${GCC_SLOT}.20250807:${GCC_SLOT}
+       ')
+"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-20250807-no-dmd-conf.patch"
+)
+
+src_prepare() {
+       hprefixify dmd-script
+       default
+
+       dlang_copy_sources
+}
+
+src_compile() {
+       :
+}
+
+src_install() {
+       doinstall() {
+               local slot=${EDC#gdc-}
+               local binPath="/usr/${CHOST}/gcc-bin/${slot}"
+               exeinto "${binPath}"
+               newexe dmd-script "${CHOST}-gdmd"
+               dosym "${CHOST}-gdmd" "${binPath}/gdmd"
+
+               dosym -r "${binPath}/${CHOST}-gdmd" 
"/usr/bin/${CHOST}-gdmd-${slot}"
+               dosym -r "${binPath}/${CHOST}-gdmd" "/usr/bin/gdmd-${slot}"
+       }
+       dlang_foreach_impl doinstall
+
+       newman "${S}/dmd-script.1" gdmd.1
+}
+
+pkg_postinst() {
+       maybe_update_gcc_config
+}
+
+# We can't really call gcc-config in postrm since it won't know which
+# symlinks under /usr/bin were left by us. If it turns out to be a
+# problem we could try to remove the symlink manually.
+
+maybe_update_gcc_config() {
+       # Call gcc-config if the current configuration if for the same slot
+       # we are installing to. This is needed to make gdmd available in
+       # $PATH.
+
+       local CTARGET=${CTARGET:-${CHOST}}
+
+       # Logic taken from toolchain.eclass and simplified a little
+       local curr_config
+       curr_config=$(gcc-config -c ${CTARGET} 2>&1) || return 0
+
+       local curr_config_ver=$(gcc-config -S ${curr_config} | awk '{print $2}')
+       local curr_specs=$(gcc-config -S ${curr_config} | awk '{print $3}')
+       local exp_USE=dlang_targets_gdc-${curr_config_ver}
+
+       # We should call gcc-config to make sure the addition of gdmd is
+       # propagated in $PATH, if the currently eselected gcc matches a slot
+       # that we are targeting. Don't do anything if not on a traditional
+       # layout, the risk of breaking something outweighs having the
+       # script in $PATH.
+       [[ ${curr_specc} ]] && return 0
+       ! has "${exp_USE}" ${IUSE} && return 0
+       ! use "${exp_USE}" && return 0
+
+       gcc-config "${CTARGET}-${curr_config_ver}"
+}

diff --git a/eclass/dlang-utils.eclass b/eclass/dlang-utils.eclass
index f2f6515..89ca344 100644
--- a/eclass/dlang-utils.eclass
+++ b/eclass/dlang-utils.eclass
@@ -1114,7 +1114,7 @@ _dlang_export() {
                                # runtime. Since only the runtime provides 
relevant USE
                                # flags usedep is only applied to it.
                                local 
dmd_dep="dev-lang/dmd:${impl#dmd-}=${usedep}"
-                               local 
gdc_dep="sys-devel/gcc:${impl#gdc-}${usedep} dev-util/gdmd:${impl#gdc-}"
+                               local 
gdc_dep="sys-devel/gcc:${impl#gdc-}${usedep} 
dev-util/gdmd:0[dlang_targets_${impl}(-)]"
                                local ldc_ver="${impl#ldc2-}" ldc_dep
                                if [[ ${impl} == ldc2* ]] && ver_test 
"${ldc_ver}" -ge 1.40; then
                                        ldc_dep="dev-lang/ldc2:${ldc_ver} 
dev-libs/ldc2-runtime:${ldc_ver}=${usedep}"

Reply via email to