public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-07-22 14:13 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-07-22 14:13 UTC (permalink / raw
  To: gentoo-commits

commit:     9e1a32ae03e9dd8798a95c6aab5953cd74646bdc
Author:     Marco Leise <marco.leise <AT> gmx <DOT> de>
AuthorDate: Sat Jul 22 14:09:43 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Sat Jul 22 14:09:43 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=9e1a32ae

Fixed pkgcheck documentation errors.

Signed-off-by: Marco Leise <marco.leise <AT> gmx.de>

 eclass/dlang-compilers.eclass |   9 ++++
 eclass/dlang.eclass           | 111 +++++++++++++++++++++++++++++-------------
 eclass/dmd.eclass             |  22 +++++++++
 3 files changed, 107 insertions(+), 35 deletions(-)

diff --git a/eclass/dlang-compilers.eclass b/eclass/dlang-compilers.eclass
index 5d1c924..59ace86 100644
--- a/eclass/dlang-compilers.eclass
+++ b/eclass/dlang-compilers.eclass
@@ -8,6 +8,15 @@
 if [[ ${_ECLASS_ONCE_DLANG_COMPILERS} != "recur -_+^+_- spank" ]] ; then
 _ECLASS_ONCE_DLANG_COMPILERS="recur -_+^+_- spank"
 
+# @FUNCTION: dlang-compilers_declare_versions
+# @DESCRIPTION:
+# Exports an associative array of all available Dlang compiler versions and their corresponding language support as well
+# as the list of stable and unstable keywords. The language support is basically the DMD front-end version that the
+# compiler is based on. For DMD it will be the same as the compiler version, while for GDC and LDC2 it will differ.
+# The keywords are required, because we offer many compilers to be used for Dlang packages and pull them in as build
+# time dependencies. A stable package cannot depend on an unstable package though, so short of manually looking for
+# KEYWORDS in compiler ebuilds we just keep them up-to-date here. GDC in particular needs constant attention as
+# architectures get markes stable all the time.
 dlang-compilers_declare_versions() {
 	declare -gA _dlang_dmd_frontend
 	declare -gA _dlang_gdc_frontend

diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass
index 751dde4..b86f3bc 100644
--- a/eclass/dlang.eclass
+++ b/eclass/dlang.eclass
@@ -20,6 +20,15 @@
 # and RDEPEND for Dlang compilers based on above variables. The ebuild is responsible
 # for providing them as required by the function it uses from this eclass.
 
+# @ECLASS_VARIABLE: DLANG_COMPILER_USE
+# @DESCRIPTION:
+# Holds the active Dlang compiler for an application as a USE flag to be passed on to depencencies (libraries).
+# Using this variable one can ensure that all required libraries must be compiled with the same compiler.
+
+# @ECLASS_VARIABLE: DLANG_IMPORT_DIR
+# @DESCRIPTION:
+# The path that is used to install include files. A sub-directory specific to the package should be used.
+
 if [[ ${_ECLASS_ONCE_DLANG} != "recur -_+^+_- spank" ]] ; then
 _ECLASS_ONCE_DLANG="recur -_+^+_- spank"
 
@@ -66,8 +75,6 @@ dlang-compilers_declare_versions
 #   as a prefix for a single argument that should be passed to the linker.
 #   dmd: -L, gdc: -Xlinker, ldc: -L=
 # DLANG_LIB_DIR: The compiler and compiler version specific library directory.
-# DLANG_IMPORT_DIR: This is actually set globally. Place includes in a
-#   sub-directory.
 dlang_foreach_config() {
 	debug-print-function ${FUNCNAME} "${@}"
 
@@ -96,8 +103,9 @@ dlang_foreach_config() {
 	multibuild_foreach_variant multibuild_wrapper "${@}"
 }
 
-export DLANG_IMPORT_DIR="usr/include/dlang"
-
+# @FUNCTION: dlang_single_config
+# @DESCRIPTION:
+# Wrapper for build phases when only a single build configuraion is used. See `dlang_foreach_config()` for more details.
 dlang_single_config() {
 	debug-print-function ${FUNCNAME} "${@}"
 
@@ -106,6 +114,7 @@ dlang_single_config() {
 	_dlang_use_build_vars "${@}"
 }
 
+export DLANG_IMPORT_DIR="usr/include/dlang"
 
 # @FUNCTION: dlang_src_prepare
 # @DESCRIPTION:
@@ -306,24 +315,25 @@ declare -a _dlang_compiler_iuse
 declare -a _dlang_compiler_iuse_mask
 declare -a _dlang_depends
 
+# @FUNCTION: _dlang_compiler_masked_archs_for_version_range
+# @DESCRIPTION:
+# Given a Dlang compiler represented through an IUSE flag (e.g. "ldc2-1_1")
+# and DEPEND atom (e.g. "dev-lang/ldc2:1.1="), this function tests if the
+# current ebuild can depend and thus be compiled with that compiler on
+# one or more architectures.
+# A compiler that is less stable than the current ebuild for all
+# architectures, is dropped completely. A compiler that disqualifies
+# for only some, but not all architectures, on the other hand, is disabled
+# though REQUIRED_USE (e.g. "!amd64? ( ldc2-1_1? ( dev-lang/ldc2:1.1= ) )").
+# Available compilers are accumulated in the _dlang_compiler_iuse array,
+# which is later turned into the IUSE variable.
+# Partially available compilers are additionally masked out for particular
+# architectures by adding them to the _dlang_compiler_iuse_mask array,
+# which is later appended to REQUIRED_USE.
+# Finally, the _dlang_depends array receives the USE-flag enabled
+# dependencies on Dlang compilers, which is later turned into DEPEND and
+# RDEPEND.
 _dlang_compiler_masked_archs_for_version_range() {
-	# Given a Dlang compiler represented through an IUSE flag (e.g. "ldc2-1_1")
-	# and DEPEND atom (e.g. "dev-lang/ldc2:1.1="), this function tests if the
-	# current ebuild can depend and thus be compiled with that compiler on
-	# one or more architectures.
-	# A compiler that is less stable than the current ebuild for all
-	# architectures, is dropped completely. A compiler that disqualifies
-	# for only some, but not all architectures, on the other hand, is disabled
-	# though REQUIRED_USE (e.g. "!amd64? ( ldc2-1_1? ( dev-lang/ldc2:1.1= ) )").
-	# Available compilers are accumulated in the _dlang_compiler_iuse array,
-	# which is later turned into the IUSE variable.
-	# Partially available compilers are additionally masked out for particular
-	# architectures by adding them to the _dlang_compiler_iuse_mask array,
-	# which is later appended to REQUIRED_USE.
-	# Finally, the _dlang_depends array receives the USE-flag enabled
-	# dependencies on Dlang compilers, which is later turned into DEPEND and
-	# RDEPEND.
-
 	local iuse=$1
 	if [[ "$iuse" == gdc* ]]; then
 		local depend="$iuse? ( $2 dev-util/gdmd:$(ver_cut 1 ${iuse#gdc-}) )"
@@ -384,13 +394,13 @@ _dlang_compiler_masked_archs_for_version_range() {
 	_dlang_depends+=( "$depend" )
 }
 
+# @FUNCTION: _dlang_filter_compilers
+# @DESCRIPTION:
+# Given a range of Dlang front-end version that the current ebuild can be built with, this function goes through each
+# compatible Dlang compilers as provided by the file dlang-compilers.eclass and then calls
+# _dlang_compiler_masked_archs_for_version_range where they will be further scrutinized for architecture stability
+# requirements and then either dropped as option or partially masked.
 _dlang_filter_compilers() {
-	# Given a range of Dlang front-end version that the current ebuild can be built with,
-	# this function goes through each compatible Dlang compilers as provided by the file
-	# dlang-compilers.eclass and then calls _dlang_compiler_masked_archs_for_version_range
-	# where they will be further scrutinized for architecture stability requirements and
-	# then either dropped as option or partially masked.
-
 	local dc_version mapping iuse depend
 
 	# filter for DMD (hardcoding support for x86 and amd64 only)
@@ -428,15 +438,16 @@ _dlang_filter_compilers() {
 	done
 }
 
+# @FUNCTION: _dlang_filter_versions
+# @DESCRIPTION:
+# This function sets up the preliminary REQUIRED_USE, DEPEND and RDEPEND ebuild
+# variables with compiler requirements for the current ebuild.
+# If DLANG_VERSION_RANGE is set in the ebuild, this variable will be parsed to
+# limit the search on the known compatible Dlang front-end versions.
+# DLANG_PACKAGE_TYPE determines whether the current ebuild can be compiled for
+# multiple Dlang compilers (i.e. is a library to be installed for different
+# versions of dmd, gdc or ldc2) or a single compiler (i.e. is an application).
 _dlang_filter_versions() {
-	# This function sets up the preliminary REQUIRED_USE, DEPEND and RDEPEND ebuild
-	# variables with compiler requirements for the current ebuild.
-	# If DLANG_VERSION_RANGE is set in the ebuild, this variable will be parsed to
-	# limit the search on the known compatible Dlang front-end versions.
-	# DLANG_PACKAGE_TYPE determines whether the current ebuild can be compiled for
-	# multiple Dlang compilers (i.e. is a library to be installed for different
-	# versions of dmd, gdc or ldc2) or a single compiler (i.e. is an application).
-
 	local range start stop matches d_version versions do_start
 	local -A valid
 
@@ -488,6 +499,12 @@ _dlang_filter_versions() {
 	DLANG_COMPILER_USE="${DLANG_COMPILER_USE:0:-1}"
 }
 
+# @FUNCTION: _dlang_phase_wrapper
+# @DESCRIPTION:
+# A more or less typical ebuild phase wrapper that invokes `d_src_*` phases if defined in an ebuild or calls Portage's
+# default implementation otherwise. when multiple build configurations are provided it also takes care of invoking
+# phases once for each configuration as well as calling `d_src_*_all` if defined after the phase has been run for each
+# individual build configuration.
 _dlang_phase_wrapper() {
 	dlang_phase() {
 		if declare -f d_src_${1} >/dev/null ; then
@@ -508,6 +525,11 @@ _dlang_phase_wrapper() {
 	fi
 }
 
+# @FUNCTION: _dlang_compiler_to_dlang_version
+# @DESCRIPTION:
+# Given two arguments, a compiler vendor and a compiler version, this function retrieves the corresponding supported
+# Dlang front-end (language) version. This is used in filtering compilers offering incompatible language versions for
+# some packages. The resulting language version is echo'd.
 _dlang_compiler_to_dlang_version() {
 	local mapping
 	case "$1" in
@@ -525,6 +547,12 @@ _dlang_compiler_to_dlang_version() {
 	echo "${mapping}"
 }
 
+# @FUNCTION: _dlang_build_configurations
+# @DESCRIPTION:
+# Creates a list of all the build configurations we are going to compile. As all Dlang compilers have different ABIs,
+# potentially changing from one release to the next, I decided to distinguish the compiler vendor, compiler version and
+# architecture. An application typically only uses on build configuration, but libraries like GtkD may be installed for
+# many compiler versions as well as in 32-bit and 64-bit at the same time on multilib. The result is echo'd.
 _dlang_build_configurations() {
 	local variants version_component use_flag use_flags
 
@@ -574,6 +602,10 @@ _dlang_build_configurations() {
 	echo ${variants}
 }
 
+# @FUNCTION: _dlang_use_build_vars
+# @DESCRIPTION:
+# Sets and exports important environment variables pertaining to the current build configuration.
+# LDFLAGS are also converted into their compiler specific equivalents here.
 _dlang_use_build_vars() {
 	# Now we define some variables and then call the function.
 	# LIBDIR_${ABI} is used by the dolib.* functions, that's why we override it per compiler.
@@ -667,12 +699,21 @@ _dlang_use_build_vars() {
 	"${@}"
 }
 
+# @FUNCTION: _dlang_prefix_words
+# @DESCRIPTION:
+# A simple helper function that prefixes the first argument to all other arguments and echo's the resulting line.
 _dlang_prefix_words() {
 	for arg in ${*:2}; do
 		echo -n " $1$arg"
 	done
 }
 
+# @FUNCTION: _dlang_additional_flags
+# @DESCRIPTION:
+# This function is internally used by the dlang_compile_bin/lib/so functions. When `debug` is among the enabled IUSE
+# flags, this function ensures that a debug build of the Dlang package is produced. It also provides the additional
+# flags for any imports and libraries mentioned in an ebuild in the compiler specific syntax. The resulting flags are
+# echo'd.
 _dlang_additional_flags() {
 	# For info on debug use flags see:
 	# https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces#debug_USE_flag

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 15770c1..f972961 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -6,6 +6,18 @@
 # Helps with the maintenance of the various DMD versions by capturing common
 # logic.
 
+# @ECLASS_VARIABLE: MAJOR
+# @DESCRIPTION:
+# Major DMD version (usually 2)
+
+# @ECLASS_VARIABLE: MINOR
+# @DESCRIPTION:
+# Minor DMD version without leading zeroes (e.g. 78)
+
+# @ECLASS_VARIABLE: MULTILIB_COMPAT
+# @DESCRIPTION:
+# See Gentoo's multilib-build.eclass
+
 if [[ ${_ECLASS_ONCE_DMD} != "recur -_+^+_- spank" ]] ; then
 _ECLASS_ONCE_DMD="recur -_+^+_- spank"
 
@@ -22,14 +34,24 @@ MULTILIB_COMPAT=( abi_x86_{32,64} )
 
 inherit multilib-build eapi7-ver toolchain-funcs
 
+# @FUNCTION: dmd_eq
+# @DESCRIPTION:
+# Returns `true` if the DMD version we are installing is equal to the one given as the argument.
 dmd_eq() {
 	[[ ${MAJOR} -eq ${1%.*} ]] && [[ ${MINOR} -eq $((10#${1#*.})) ]]
 }
 
+# @FUNCTION: dmd_ge
+# @DESCRIPTION:
+# Returns `true` if the DMD version we are installing is greater or equal to the one given as the argument.
 dmd_ge() {
 	[[ ${MAJOR} -ge ${1%.*} ]] && [[ ${MINOR} -ge $((10#${1#*.})) ]]
 }
 
+# @FUNCTION: dmd_gen_exe_dir
+# @DESCRIPTION:
+# Returns the relative directory that the compiler executable will be found in. This directory is used both for
+# installing the binary as well as setting the compiler during compilation of druntime and Phobos.
 dmd_gen_exe_dir() {
 	if dmd_ge 2.074; then
 		echo dmd/generated/linux/release/$(dmd_arch_to_model)


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-08-30  7:58 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-08-30  7:58 UTC (permalink / raw
  To: gentoo-commits

commit:     6ae057a58e69f38894c98b77f94670a0debd5015
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Wed Aug 14 13:27:45 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Fri Aug 30 07:32:54 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=6ae057a5

dub.eclass: new eclass

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

 eclass/dub.eclass | 312 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 312 insertions(+)

diff --git a/eclass/dub.eclass b/eclass/dub.eclass
new file mode 100644
index 0000000..41fff29
--- /dev/null
+++ b/eclass/dub.eclass
@@ -0,0 +1,312 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: dub.eclass
+# @MAINTAINER:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# @AUTHOR:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# @BUGREPORTS:
+# Please report bugs via https://github.com/gentoo/dlang/issues
+# @VCSURL: https://github.com/gentoo/dlang
+# @SUPPORTED_EAPIS: 8
+# @BLURB: common functions and variables for dub builds
+# @DESCRIPTION:
+# This eclass provides a wrapper for calling dub as well as default
+# implementations for src_compile and src_test.  It also provides
+# dub_src_unpack which will make dub dependencies available as well
+# as configure it to work best in an ebuild environment.
+#
+# By default this eclass will set *DEPEND to depend on both dub and a D
+# compiler.  For this reason you *must* inherit either dlang-single or
+# dlang-r1 before inheriting dub.  The only alternative is using
+# DUB_OPTIONAL.
+# @EXAMPLE:
+# A program using dub.eclass:
+#
+# @CODE
+# DLANG_COMPAT=( dmd-2_109 gdc-1{3,4} ldc2-1_39 )
+# DUB_DEPENDENCIES=(
+#     "automem@0.6.9"
+#     "cachetools@0.4.1"
+#     "dcd@0.16.0-beta.2"
+#     "program@8.0.3"
+#     "silly@1.1.1"
+# )
+# inherit dlang-single dub
+# SRC_URI="${DUB_DEPENDENCIES_URIS}"
+#
+# src_install() {
+#     dobin "${S}/program"
+# }
+# @CODE
+
+case ${EAPI} in
+	8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_DUB_ECLASS} ]]; then
+_DUB_ECLASS=1
+
+inherit dlang-utils edo
+
+# @ECLASS_VARIABLE: DUB_DEPEND
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# Dependency string on dev-util/dub and other needed programs that can
+# be used in BDEPEND when DUB_OPTIONAL is set.  When DUB_OPTIONAL is
+# empty the dependency is added automatically to BDEPEND.
+DUB_DEPEND=">=dev-util/dub-1.38.0 app-arch/unzip"
+# 1.38 - respect skipRegistry value in configuration file
+
+EDUB_HOME="${WORKDIR}/dub_home"
+
+# @ECLASS_VARIABLE: DUB_OPTIONAL
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# Setting this to a non-empty value inhibits the eclass from modifying
+# variables like *DEPEND and REQUIRED_USE and from exporting phase
+# functions.
+#
+# If set, you may need to call dub_gen_settings or dub_src_unpack
+# manually.
+
+# @ECLASS_VARIABLE: DUB_DEPENDENCIES
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# A bash array of dub dependencies.  Each dependency should be a string
+# in the form `name@version`.
+#
+# Example:
+# @CODE
+# DUB_DEPENDENCIES=(
+#     "dfmt@0.15.1"
+#     "silly@1.1.1"
+# )
+# @CODE
+
+# @ECLASS_VARIABLE: DUB_DEPENDENCIES_URIS
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# The transformed DUB_DEPENDENCIES as a string to be placed in
+# SRC_URI
+
+# @FUNCTION: dub_dependencies_uris
+# @USAGE: [dependencies]...
+# @DESCRIPTION:
+# print a string to be placed in SRC_URI for all the dependencies given
+# as arguments.  Each dependency should be in the form `name@version`,
+# just like the elements in DUB_DEPENDENCIES.
+dub_dependencies_uris() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local registry="https://code.dlang.org/packages"
+	local dep name ver
+	for dep; do
+		name="${dep%@*}"
+		ver="${dep#*@}"
+		echo "${registry}/${name}/${ver}.zip -> ${name}-${ver}.zip"
+	done
+}
+
+# @FUNCTION: _handle_dub_variables
+# @INTERNAL
+# @DESCRIPTION:
+# Verify that DUB_DEPENDENCIES is set appropriately, transform it into
+# DUB_DEPENDENCIES_URIS, and set any other variables.
+_handle_dub_variables() {
+	[[ -v DUB_DEPENDENCIES && ${DUB_DEPENDENCIES@a} != *a* ]] \
+		&& die "DUB_DEPENDENCIES must be an array"
+	export DUB_DEPENDENCIES_URIS="$(dub_dependencies_uris "${DUB_DEPENDENCIES[@]}")"
+
+	[[ ${DUB_OPTIONAL} ]] && return
+
+	if ! has dlang-single ${INHERITED} && ! has dlang-r1 ${INHERITED}; then
+		eerror
+		eerror "dlang-single or dlang-r1 have not been inherited before dub.eclass"
+		eerror "and DUB_OPTIONAL has not been set."
+		eerror "Please inherit dlang-single or dlang-r1 before inheriting dub."
+		die "Neither dlang-single nor dlang-r1 are inherited"
+	fi
+
+	[[ ${CATEGORY}/${PN} != dev-util/dub ]] \
+		&& BDEPEND="${DUB_DEPEND}"
+
+	BDEPEND+=" ${DLANG_DEPS}"
+	DEPEND="${DLANG_DEPS}"
+	RDEPEND="${DLANG_DEPS}"
+	REQUIRED_USE="${DLANG_REQUIRED_USE}"
+}
+_handle_dub_variables
+unset -f _handle_dub_variables
+
+# @FUNCTION: edub
+# @USAGE: [dub_args]...
+# @DESCRIPTION:
+# A dub wrapper that will automatically set relevant variables and die
+# on failure.  nonfatal can be used with edub.
+#
+# Meaningful variables for this function are:
+#
+# $DC - typically set by dlang-r1.eclass or dlang-single.eclass to point
+# to the D compiler and respected by dub.
+#
+# $DFLAGS - dub will use these flags when compiling + linking.  If the
+# variable is unset (empty does not count) this eclass will default to
+# "${DCFLAGS} ${DLANG_LDFLAGS} /-Wno-error/" for its value.
+#
+# $NO_COLOR - if non-empty dub will not print colors
+edub() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local -x DFLAGS=${DFLAGS-${DCFLAGS} ${DLANG_LDFLAGS} $(dlang_get_wno_error_flag)}
+	local -x DC=${DC} NO_COLOR=${NO_COLOR}
+	# FIXME dub directly calls pkg-config without a way to configure it
+
+	debug-print "${FUNCNAME}: DC=${DC}"
+	debug-print "${FUNCNAME}: DFLAGS=${DFLAGS}"
+
+	edo dub --verbose "${@}"
+}
+
+# @ECLASS_VARIABLE: DUB_LOCAL_REGISTRY
+# @DESCRIPTION:
+# A directory in which dub package archives can be placed for dub to be
+# able to fetch them in the future.  This is useful only if dub _must_
+# perform a fetch operation, perhaps as part of tests, in all other
+# cases DUB_DEPENDENCIES should be used instead.
+#
+# You can use dub_copy_dependencies_locally as a convenience function.
+#
+# Example:
+# @CODE
+# src_unpack() {
+#   dub_src_unpack
+#   use test && dub_copy_dependencies_locally "my_packages@1.1.0"
+# }
+# src_test() {
+#   dub_src_test
+#
+#   # additional test that performs `dub fetch my_package@1.1.0`
+# }
+# @CODE
+DUB_LOCAL_REGISTRY="${EDUB_HOME}/local_registry"
+
+# @FUNCTION: dub_copy_dependencies_locally
+# @USAGE: [dependencies]...
+# @DESCRIPTION:
+# Copy the given dependencies to ${DUB_LOCAL_REGISTRY}.  This function
+# can only be called inside src_unpack.
+#
+# The format of the arguments is the same as the format of
+# ${DUB_DEPENDENCIES}.
+dub_copy_dependencies_locally() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${EBUILD_PHASE} == unpack ]] \
+		|| die "${FUNCNAME} must only be called inside src_unpack"
+
+	local dep
+	for dep; do
+		einfo "Making ${dep} available locally"
+		cp "${DISTDIR}/${dep/@/-}.zip" "${DUB_LOCAL_REGISTRY}" || die
+	done
+}
+
+# @FUNCTION: dub_gen_settings
+# @DESCRIPTION:
+# Generate a settings.json file for dub.
+dub_gen_settings() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	mkdir -p "${EDUB_HOME}" || die "Could not create dub home directory"
+	mkdir -p "${DUB_LOCAL_REGISTRY}" || die "Could not create dub registry directory"
+
+	# dub merges the settings from all configuration files so settings
+	# which greatly change the build need to be set to a safe
+	# value. Unfortunately the 'customCachePaths' and 'registryUrls'
+	# settings are cumulative, i.e. they will append to the previous
+	# value, not overwrite it.
+	cat > "${EDUB_HOME}/settings.json" <<-EOF || die "Failed to create dub settings.json file"
+	{
+		"registryUrls": [
+			"file://${DUB_LOCAL_REGISTRY}"
+		],
+		"skipRegistry": "standard",
+
+		"customCachePaths": [],
+		"defaultCompiler": "",
+		"defaultArchitecture": ""
+	}
+	EOF
+
+	export DUB_HOME="${EDUB_HOME}"
+}
+
+# @FUNCTION: dub_src_unpack
+# @DESCRIPTION:
+# Unpack all sources and generate a dub configuration file
+dub_src_unpack() {
+	dub_gen_settings
+
+	# DUB_DEPENDENCIES can contain entries like:
+	# dfmt@0.15.1 which maps to the archive dmft-0.15.1.zip
+	#
+	# There can also be dependencies like:
+	# botan-math@1.0.4 -> botan-math-1.0.4.zip
+	# botan@1.13.6 -> botan-1.13.6.zip
+	#
+	# Because of the ambiguous `-' character create a map
+	# from the archive back to the dependency.
+	local -A dubFiles
+	local dep
+	for dep in "${DUB_DEPENDENCIES[@]}"; do
+		dubFiles["${dep/@/-}.zip"]="${dep}"
+	done
+
+	local dubFetch=(
+		dub
+		--skip-registry=all
+		--registry="file://${DISTDIR}"
+		fetch
+	)
+	local dep file
+	for file in ${A}; do
+		if [[ ${dubFiles[${file}]} ]]; then
+			# file can be 'dfmt-0.15.1.zip'
+			# in which case dubFiles[${file}] wil be 'dfmt@0.15.1'
+			dep="${dubFiles[${file}]}"
+			edo "${dubFetch[@]}" "${dep}"
+
+			# If it's the main package extract it for ${S}.
+			# In case of prereleases:
+			# serve-d-0.8.0_beta17 -> serve-d-0.8.0-beta.17.zip
+			[[ ${file} == ${PN}-$(ver_rs 3 - 4 .)* ]] \
+				&& unpack "${file}"
+		else
+			unpack "${file}"
+		fi
+	done
+}
+
+# @FUNCTION: dub_src_compile
+# @DESCRIPTION:
+# Compile the package using dub
+dub_src_compile() {
+	edub build
+}
+
+# @FUNCTION: dub_src_test
+# @DESCRIPTION:
+# Test the package using dub
+dub_src_test() {
+	edub test
+}
+
+fi
+
+[[ ${DUB_OPTIONAL} ]] \
+	|| EXPORT_FUNCTIONS src_unpack src_compile src_test


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-07-14 19:44 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-07-14 19:44 UTC (permalink / raw
  To: gentoo-commits

commit:     92b008c53f99715797248fdbf68b31873048fe08
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sun Jul 14 10:43:17 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sun Jul 14 10:43:17 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=92b008c5

dlang-compilers-r1.eclass: Correct ldc2:1.39 entry to match ebuild

Correct the keywords list in the eclass by removing the arm64 keyword
which has been dropped with the ldc2:1.39 addition. It should be added
back when tests on arm64 can be performed again.

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

 eclass/dlang-compilers-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/dlang-compilers-r1.eclass b/eclass/dlang-compilers-r1.eclass
index f601e92..b570a64 100644
--- a/eclass/dlang-compilers-r1.eclass
+++ b/eclass/dlang-compilers-r1.eclass
@@ -96,7 +96,7 @@ readonly _DLANG_LDC2_FRONTENDS=(
 	"1.36 2.106 ~amd64 ~arm64 ~x86"
 	"1.37 2.107 ~amd64 ~arm64 ~x86"
 	"1.38 2.108 ~amd64 ~arm64 ~x86"
-	"1.39 2.109 ~amd64 ~arm64 ~x86"
+	"1.39 2.109 ~amd64 ~x86"
 )
 
 # @FUNCTION: _dlang_accumulate_implementations


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-07-12 18:59 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-07-12 18:59 UTC (permalink / raw
  To: gentoo-commits

commit:     86c34c4c6eea78928dd605d83415988620772806
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Jul  6 14:12:26 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Jul  6 14:14:48 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=86c34c4c

dmd-r1.eclass: update LICENSE

List licenses of all files used by the package, not just the main
license governing the project.

This change also stops installing one file with a questionable license.

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

 eclass/dmd-r1.eclass | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/eclass/dmd-r1.eclass b/eclass/dmd-r1.eclass
index e16c056..91ebc2b 100644
--- a/eclass/dmd-r1.eclass
+++ b/eclass/dmd-r1.eclass
@@ -38,6 +38,29 @@ MULTILIB_COMPAT=( abi_x86_{32,64} )
 inherit desktop edos2unix dlang-single multilib-build multiprocessing optfeature
 
 LICENSE=Boost-1.0
+# A couple of files are public domain, e.g. dmd/compiler/src/dmd/backend/bcomplex.d
+LICENSE+=" public-domain"
+# valgrind headers are BSD-like, see: dmd/druntime/src/etc/valgrind/memcheck.h
+LICENSE+=" BZIP2"
+# curl header: phobos/etc/c/curl.d
+LICENSE+=" curl"
+# zlib header: phobos/etc/c/zlib.d
+LICENSE+=" ZLIB"
+# Older versions use md5 for hashing newer ones use blake3
+if ver_test -ge 2.109.0_beta1; then
+	# see: dmd/compiler/src/dmd/common/blake3.d which is based on:
+	# https://github.com/oconnor663/blake3_reference_impl_c
+	LICENSE+=" || ( CC0-1.0 Apache-2.0 )"
+else
+	# see: dmd/compiler/src/dmd/common/md5.d
+	LICENSE+=" RSA"
+fi
+# Some files in dmd/compiler/samples like htmlget.d are public-domain.
+# dmd/compiler/samples/d2html.d has a license which sounds like the colt
+# license which is not free. The file has little value so it won't be
+# installed.
+LICENSE+=" examples? ( public-domain )"
+
 SLOT=$(ver_cut 1-2)
 readonly MAJOR=$(ver_cut 1)
 readonly MINOR=$(ver_cut 2)
@@ -317,6 +340,9 @@ dmd-r1_src_install() {
 	doins dmd/generated/docs/man/man5/dmd.conf.5
 
 	if use examples; then
+		# Problematic license
+		rm dmd/compiler/samples/d2html.d || die
+
 		insinto "${dmd_prefix}"/samples
 		doins -r dmd/compiler/samples/*
 		docompress -x "${dmd_prefix}"/samples


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-07-12 18:59 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-07-12 18:59 UTC (permalink / raw
  To: gentoo-commits

commit:     f72da9c5e7b691f145a65839f3e9b0faf8fc67f6
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Jul  6 15:15:38 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Jul  6 15:43:41 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=f72da9c5

dmd-r1.eclass: clarify dependency on stdlib of host compiler

The previous comment, saying that dmd doesn't link the standard lib of
the host compiler, is plain wrong, it always does. The only
particularity is that dmd doesn't seem to need phobos but it does need
druntime. Regardless, a RDEPEND on the host compiler is needed.

Another comment has been added trying to describe the reason why
DLANG_DEPS should be present in DEPEND. My current understanding is that
since the compiler needs to link libraries from SYSROOT (druntime and
phobos) to produce the CHOST dmd executable then those libraries should
be listed in DEPEND. I'm not 100% sure though.

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

 eclass/dmd-r1.eclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eclass/dmd-r1.eclass b/eclass/dmd-r1.eclass
index e34af81..49ec257 100644
--- a/eclass/dmd-r1.eclass
+++ b/eclass/dmd-r1.eclass
@@ -85,10 +85,10 @@ IDEPEND=">=app-eselect/eselect-dlang-20140709"
 BDEPEND="!selfhost? ( ${DLANG_DEPS} )"
 # We don't need anything in DEPEND, curl is dl-opened
 # so it belongs in RDEPEND.
+#
+# Thinking about this more ${DLANG_DEPS} should probably go in DEPEND. I
+# want, however, to test this before making the fix.
 #DEPEND=
-# Since 2.107.0, dmd links the standard library of the host
-# compiler. Since this eclass is only used by >=dmd-2.107.0-r1 the
-# dependency is added unconditionally.
 RDEPEND="
 	${IDEPEND}
 	net-misc/curl[${MULTILIB_USEDEP}]


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-07-12 18:59 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-07-12 18:59 UTC (permalink / raw
  To: gentoo-commits

commit:     2f6ab5a6f5fad10a3cb53cbf9e4b906ec6fa8bc4
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Jul  6 15:09:18 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Jul  6 15:09:18 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=2f6ab5a6

dmd-r1.eclass: trivial typo fixes in comments

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

 eclass/dmd-r1.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/dmd-r1.eclass b/eclass/dmd-r1.eclass
index 91ebc2b..e34af81 100644
--- a/eclass/dmd-r1.eclass
+++ b/eclass/dmd-r1.eclass
@@ -163,7 +163,7 @@ dmd-r1_src_compile() {
 		"${BUILD_D}"
 		-j$(makeopts_jobs)
 		# A bit overkill to specify the flags here but it does get the
-		# jobs done.
+		# job done.
 		DFLAGS="${DMDW_DCFLAGS} ${DMDW_LDFLAGS}"
 	)
 
@@ -232,7 +232,7 @@ dmd-r1_src_compile() {
 			$(usex static-libs 'lib dll' dll)
 		)
 		# Prefer compiling C files with CC, not with dmd. (USE_IMPORTC=1
-		# adds dependency on libdruntime.a)
+		# adds a dependency on libdruntime.a)
 		ver_test -ge 2.108.0 && phobosMakeArgs+=( "USE_IMPORTC=0" )
 
 		emake -C dmd/druntime "${commonMakeArgs[@]}" "${druntimeMakeArgs[@]}"


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-04-26 20:25 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-04-26 20:25 UTC (permalink / raw
  To: gentoo-commits

commit:     1d835dc4a882768383667cb17d450be48b9a7637
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Fri Apr 26 18:34:24 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Fri Apr 26 18:34:24 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=1d835dc4

dmd-r1.eclass: use dlang_get_abi_bits instead of _get_abi_bits

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

 eclass/dmd-r1.eclass | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/eclass/dmd-r1.eclass b/eclass/dmd-r1.eclass
index 19a6224..e16c056 100644
--- a/eclass/dmd-r1.eclass
+++ b/eclass/dmd-r1.eclass
@@ -97,7 +97,7 @@ dmd-r1_pkg_setup() {
 dmd-r1_src_unpack() {
 	# Here because pkgdev complains about it being in pkg_setup
 	if use selfhost; then
-		export DC=${WORKDIR}/dmd2/linux/bin$(_get_abi_bits)/dmd
+		export DC=${WORKDIR}/dmd2/linux/bin$(dlang_get_abi_bits)/dmd
 		export DMDW=${DC}
 	fi
 
@@ -149,7 +149,7 @@ dmd-r1_src_compile() {
 	"${cmd[@]}" || die "Failed to build dmd"
 
 	# The release here is from ENABLE_RELEASE, keep them in sync.
-	export GENERATED_DMD=${S}/dmd/generated/linux/release/$(_get_abi_bits)/dmd
+	export GENERATED_DMD=${S}/dmd/generated/linux/release/$(dlang_get_abi_bits)/dmd
 
 	compile_libraries() {
 		local commonMakeArgs=(
@@ -229,7 +229,7 @@ dmd-r1_src_compile() {
 		# ${GENERATED_DMD} is not yet fully functional as we didn't
 		# create a good dmd.conf. But instead of doing that we're going
 		# to specify our flags here.
-		DFLAGS="-defaultlib=phobos2 -L-rpath=${S}/phobos/generated/linux/release/$(_get_abi_bits)"
+		DFLAGS="-defaultlib=phobos2 -L-rpath=${S}/phobos/generated/linux/release/$(dlang_get_abi_bits)"
 	)
 	echo "${cmd[@]}"
 	"${cmd[@]}" || die "Could not generate man pages"
@@ -383,20 +383,6 @@ EOF
 	fi
 }
 
-# @FUNCTION: _get_abi_bits
-# @USAGE: [<abi>]
-# @INTERNAL
-# @DESCRIPTION:
-# Echo the bits of abi, 64 for amd64 and 32 for x86. If unspecified, the
-# value is taken from $ABI.
-_get_abi_bits() {
-	case "${1:-${ABI}}" in
-		amd64*) echo 64 ;;
-		x86*) echo 32 ;;
-		*) die "Unknown ABI: ${ABI}." ;;
-	esac
-}
-
 # @FUNCTION: _dmd_foreach_abi
 # @USAGE: <cmd> [<args>...]
 # @INTERNAL
@@ -409,7 +395,7 @@ _dmd_foreach_abi() {
 
 	local ABI
 	for ABI in $(multilib_get_enabled_abis); do
-		local MODEL=$(_get_abi_bits)
+		local MODEL=$(dlang_get_abi_bits)
 		einfo "Executing ${1} in ${MODEL}-bit"
 		"${@}"
 	done


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-04-22 20:03 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-04-22 20:03 UTC (permalink / raw
  To: gentoo-commits

commit:     c1bdf245f2a8f82cd24512f18f72eee1f5052b61
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Apr 20 19:33:27 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Apr 20 19:33:27 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=c1bdf245

dmd-r1.eclass: Fix paths in pkg_postinst elog messages

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

 eclass/dmd-r1.eclass | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/eclass/dmd-r1.eclass b/eclass/dmd-r1.eclass
index 802e820..90459c2 100644
--- a/eclass/dmd-r1.eclass
+++ b/eclass/dmd-r1.eclass
@@ -331,8 +331,9 @@ dmd-r1_src_install() {
 dmd-r1_pkg_postinst() {
 	"${EROOT}"/usr/bin/eselect dlang update dmd
 
-	use examples && elog "Examples can be found in: ${dmd_prefix}/samples"
-	use doc && elog "HTML documentation is in: /usr/share/doc/${PF}/html"
+	use examples &&
+		elog "Examples can be found in: ${EPREFIX}/usr/lib/${PN}/${SLOT}/samples"
+	use doc && elog "HTML documentation is in: ${EPREFIX}/usr/share/doc/${PF}/html"
 
 	optfeature "additional D development tools" "dev-util/dlang-tools"
 }


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-04-13 23:04 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-04-13 23:04 UTC (permalink / raw
  To: gentoo-commits

commit:     e76ec139c6db2b0ab1d83bd61088d6903f2febff
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Mar  2 17:28:49 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Apr 13 22:47:30 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=e76ec139

dlang-single.eclass: new eclass

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

 eclass/dlang-single.eclass | 409 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 409 insertions(+)

diff --git a/eclass/dlang-single.eclass b/eclass/dlang-single.eclass
new file mode 100644
index 0000000..a94bc80
--- /dev/null
+++ b/eclass/dlang-single.eclass
@@ -0,0 +1,409 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: dlang-single.eclass
+# @MAINTAINER:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# @AUTHOR:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# Based on python-utils-r1.eclass by Michał Górny <mgorny@gentoo.org> et al
+# with logic taken from dlang.eclass by Marco Leise <marco.leise@gmx.de>.
+# @BUGREPORTS:
+# Please report bugs via https://github.com/gentoo/dlang/issues
+# @VCSURL: https://github.com/gentoo/dlang
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: dlang-utils
+# @BLURB: An eclass for Dlang packages not installed for multiple implementations.
+# @DESCRIPTION:
+# An extension of the dlang-r1 eclass suite for packages which don't
+# support being installed for multiple Dlang implementations.
+#
+# This eclass sets correct IUSE. It also provides DLANG_DEPS and
+# DLANG_REQUIRED_USE that need to be added to appropriate ebuild
+# metadata variables.
+#
+# The eclass exports DLANG_SINGLE_USEDEP that is suitable for depending
+# on other packages using the eclass.  Dependencies on packages using
+# dlang-r1 should be created via dlang_gen_cond_dep() function, using
+# DLANG_USEDEP placeholder.
+#
+# Please note that packages which support multiple Dlang implementations
+# (using dlang-r1 eclass) can not depend on packages not supporting them
+# (using this eclass).
+#
+# Please note that dlang-single will always inherit dlang-utils as
+# well. Thus, all the functions defined there can be used in the
+# packages using dlang-single, and there is no need ever to inherit
+# both.
+#
+# Same as dlang-r1.eclass, the contents of $KEYWORDS need to be set
+# before the inherit.
+#
+# @EXAMPLE:
+# @CODE
+# EAPI=8
+# DLANG_COMPAT=( dmd-2_{101..106} gdc-12 gdc-13 ldc2-1_{32..36} )
+# KEYWORDS="amd64 x86"
+#
+# inherit dlang-single
+#
+# REQUIRED_USE=${DLANG_REQUIRED_USE}
+# DEPEND="${DLANG_DEPS} $(dlang_gen_cond_dep '
+#     dev-libs/gtkd[${DLANG_USEDEP}]
+# ')"
+# RDEPEND=${DEPEND}
+# BDEPEND=${DLANG_DEPS}
+#
+# src_compile() {
+#     emake DMD="$(dlang_get_dmdw)" DFLAGS="$(dlang_get_dmdw_dcflags)"
+# }
+# @CODE
+
+case ${EAPI} in
+	8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0}  not supported" ;;
+esac
+
+if [[ -z ${_DLANG_SINGLE_ECLASS} ]]; then
+_DLANG_SINGLE_ECLASS=1
+
+if [[ ${_DLANG_R1_ECLASS} ]]; then
+	die 'dlang-single.eclass cannot be used with dlang-r1.eclass.'
+fi
+
+inherit dlang-utils
+
+# @ECLASS_VARIABLE: DLANG_COMPAT
+# @REQUIRED
+# @PRE_INHERIT
+# @DESCRIPTION:
+# This variable contains a list of Dlang implementations the package
+# supports. It must be set before the `inherit' call. It has to be an
+# array.
+#
+# Example:
+# @CODE
+# DLANG_COMPAT=( gdc-12 ldc2-1_36 dmd-2_102 dmd-2_103 )
+# @CODE
+#
+# Please note that you can also use bash brace expansion if you like:
+# @CODE
+# DLANG_COMPAT=( gdc-1{2..3} ldc2-1_{29..36} dmd-2_10{5,6} )
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_COMPAT_OVERRIDE
+# @USER_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# This variable can be used when working with ebuilds to override the
+# in-ebuild DLANG_COMPAT. It is a string naming the implementation which
+# package will be built for. It needs to be specified in the calling
+# environment, and not in ebuilds.
+#
+# It should be noted that in order to preserve metadata immutability,
+# DLANG_COMPAT_OVERRIDE does not affect IUSE nor dependencies. The state
+# of DLANG_TARGETS is ignored, and all the implementations in
+# DLANG_COMPAT_OVERRIDE are built. Dependencies need to be satisfied
+# manually.
+#
+# Example:
+# @CODE
+# DLANG_COMPAT_OVERRIDE='gdc-13' emerge -1v dev-libs/foo
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_REQ_USE
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# An associative array of Dlang implementations and USE-dependencies
+# strings. The keys are implementation names, so: "dmd" "ldc2" or "gdc";
+# and the values are the aforementioned USE-dependency strings.
+#
+# This should be set before calling `inherit'.
+#
+# Example:
+# @CODE
+# declare -A DLANG_REQ_USE=(
+#     [dmd]="static-libs(-)?"
+#     [gdc]="another_flag"
+#     [ldc2]="static-libs(-)?"
+# )
+# @CODE
+#
+# It will cause the Dlang dependencies to look like:
+# @CODE
+# dlang_targets_ldc2-X_Y? ( dev-lang/ldc2:X.Y=[static-libs(-)?] )
+# dlang_targets_gdc-X? ( sys-devel/gcc[d,another_flag]:X dev-util/gdmd:X )
+# dlang_targets_dmd-X_Y? ( dev-lang/dmd:X.Y=[static-libs(-)?] )
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_DEPS
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated Dlang dependency string for all
+# implementations listed in DLANG_COMPAT.
+#
+# Example use:
+# @CODE
+# RDEPEND="${DLANG_DEPS}
+#	dev-foo/mydep"
+# DEPEND=${RDEPEND}
+# @CODE
+#
+# Example value:
+# @CODE
+# dlang_single_target_gdc-12? ( sys-devel/gcc:12[d] dev-util/gdmd:12 )
+# dlang_single_target_ldc2-1_36? ( dev-lang/ldc2:1.36= )
+# dlang_single_target_dmd-2_099? ( dev-lang/dmd:2.099= )
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_SINGLE_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated USE-dependency string which can be used to
+# depend on another dlang-single package being built for the same Dlang
+# implementation.
+#
+# If you need to depend on a multi-impl (dlang-r1) package, use
+# dlang_gen_cond_dep with DLANG_USEDEP placeholder instead.
+#
+# Example use:
+# @CODE
+# RDEPEND="dev-util/foo[${DLANG_SINGLE_USEDEP}]"
+# @CODE
+#
+# Example value:
+# @CODE
+# dlang_single_target_gdc-13(-)?
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is a placeholder variable supported by dlang_gen_cond_dep, in
+# order to depend on dlang-r1 packages built for the same Dlang
+# implementation.
+#
+# Example use:
+# @CODE
+# RDEPEND="$(dlang_gen_cond_dep '
+#     dev-libs/foo[${DLANG_USEDEP}]
+#   ')"
+# @CODE
+#
+# Example value:
+# @CODE
+# dlang_targets_ldc2-1_35(-)
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_REQUIRED_USE
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated required-use expression which ensures that
+# exactly one DLANG_SINGLE_TARGET value has been enabled.
+#
+# This expression should be utilized in an ebuild by including it in
+# REQUIRED_USE, optionally behind a use flag.
+#
+# Example use:
+# @CODE
+# REQUIRED_USE="^^ ( selfhost ${DLANG_REQUIRED_USE} )"
+# @CODE
+#
+# Example value:
+# @CODE
+# ^^ ( dlang_single_target_gdc-11 dlang_single_target_dmd-2_106 dlang_single_target_ldc2-1_34 )
+# @CODE
+
+# @FUNCTION: _dlang_single_set_globals
+# @INTERNAL
+# @DESCRIPTION:
+# Sets all the global output variables provided by this eclass.
+# This function must be called once, in global scope.
+_dlang_single_set_globals() {
+	_dlang_set_impls
+
+	local flags=( "${_DLANG_SUPPORTED_IMPLS[@]/#/dlang_single_target_}" )
+
+	if [[ ${#_DLANG_SUPPORTED_IMPLS[@]} -eq 1 ]]; then
+		# if only one implementation is supported, use IUSE defaults to
+		# avoid requesting the user to enable it
+		IUSE="+${flags[0]}"
+	else
+		IUSE="${flags[*]}"
+	fi
+
+	local stabilization_mock=$(dlang_compilers_stabs_required_use \
+								   dlang_single_target \
+								   "${_DLANG_SUPPORTED_IMPLS[@]}"
+		  )
+	local requse="( ^^ ( ${flags[*]} )${stabilization_mock:+ ${stabilization_mock}} )"
+	local single_flags="${flags[@]/%/(-)?}"
+	local single_usedep=${single_flags// /,}
+
+	local deps= i DLANG_PKG_DEP
+	for i in "${_DLANG_SUPPORTED_IMPLS[@]}"; do
+		_dlang_export "${i}" DLANG_PKG_DEP
+		deps+=$(
+			dlang_compilers_stabs_impl_dep \
+				"${i}" \
+				"dlang_single_target_${i}? (
+					${DLANG_PKG_DEP}
+				) "
+			 )
+	done
+
+	if [[ ${DLANG_DEPS+1} ]]; then
+		if [[ ${DLANG_DEPS} != ${deps} ]]; then
+			eerror "DLANG_DEPS have changed between inherits (DLANG_REQ_USE?)!"
+			eerror "Before: ${DLANG_DEPS}"
+			eerror "Now   : ${deps}"
+			die "DLANG_DEPS integrity check failed"
+		fi
+
+		if [[ ${DLANG_REQUIRED_USE} != ${requse} ]]; then
+			eerror "DLANG_REQUIRED_USE have changed between inherits!"
+			eerror "Before: ${DLANG_REQUIRED_USE}"
+			eerror "Now   : ${requse}"
+			die "DLANG_REQUIRED_USE integrity check failed"
+		fi
+
+		# this one's a formality -- it depends on DLANG_COMPAT only
+		if [[ ${DLANG_SINGLE_USEDEP} != ${single_usedep} ]]; then
+			eerror "DLANG_SINGLE_USEDEP have changed between inherits!"
+			eerror "Before: ${DLANG_SINGLE_USEDEP}"
+			eerror "Now   : ${single_usedep}"
+			die "DLANG_SINGLE_USEDEP integrity check failed"
+		fi
+	else
+		DLANG_DEPS=${deps}
+		DLANG_REQUIRED_USE=${requse}
+		DLANG_USEDEP='%DLANG_USEDEP-NEEDS-TO-BE-USED-IN-DLANG_GEN_COND_DEP%'
+		DLANG_SINGLE_USEDEP=${single_usedep}
+		readonly DLANG_DEPS DLANG_REQUIRED_USE DLANG_SINGLE_USEDEP \
+			DLANG_USEDEP
+	fi
+}
+_dlang_single_set_globals
+unset -f _dlang_single_set_globals
+
+# @FUNCTION: dlang_gen_cond_dep
+# @USAGE: <dependency> [<pattern>...]
+# @DESCRIPTION:
+# Output a list of <dependency>-ies made conditional to USE flags of
+# Dlang implementations which are both in DLANG_COMPAT and match any of
+# the patterns passed as the remaining parameters.
+#
+# For the pattern syntax, please see _dlang_impl_matches
+# in dlang-utils.eclass.
+#
+# In order to enforce USE constraints on the packages, verbatim
+# '${DLANG_SINGLE_USEDEP}' and '${DLANG_USEDEP}' (quoted!) may
+# be placed in the dependency specification. It will get expanded within
+# the function into a proper USE dependency string.
+#
+# Example:
+# @CODE
+# DLANG_COMPAT=( gdc-1{2,3} ldc2-1_36 dmd-2_{101..106} )
+# RDEPEND="$(dlang_gen_cond_dep \
+#   'dev-libs/gtkd[${DLANG_USEDEP}]' 'gdc*')"
+# @CODE
+#
+# It will cause the variable to look like:
+# @CODE
+# RDEPEND="dlang_single_target_gdc-12? (
+#     dev-libs/gtkd[dlang_targets_gdc-12(-),...] )
+#  dlang_single_target_gdc-13? (
+#     dev-libs/gtkd[dlang_targets_gdc-13(-),...] )
+# @CODE
+dlang_gen_cond_dep() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl matches=()
+
+	local dep=${1}
+	shift
+
+	_dlang_verify_patterns "${@}"
+	for impl in "${_DLANG_SUPPORTED_IMPLS[@]}"; do
+		if _dlang_impl_matches "${impl}" "${@}"; then
+			local single_usedep="dlang_single_target_${impl}(-)"
+			local multi_usedep="dlang_targets_${impl}(-)"
+
+			local subdep=${dep//\$\{DLANG_SINGLE_USEDEP\}/${single_usedep}}
+			matches+=( "dlang_single_target_${impl}? (
+				${subdep//\$\{DLANG_USEDEP\}/${multi_usedep}} )" )
+		fi
+	done
+
+	echo "${matches[@]}"
+}
+
+# @FUNCTION: dlang_setup
+# @DESCRIPTION:
+# Determine what the selected Dlang implementation is and set the Dlang
+# build environment up for it.
+dlang_setup() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	unset EDC
+
+	# support developer override
+	if [[ ${DLANG_COMPAT_OVERRIDE} ]]; then
+		local impls=( ${DLANG_COMPAT_OVERRIDE} )
+		[[ ${#impls[@]} -eq 1 ]] || die "DLANG_COMPAT_OVERRIDE must name exactly one implementation for dlang-single"
+
+		ewarn "WARNING: DLANG_COMPAT_OVERRIDE in effect. The following Dlang"
+		ewarn "implementation will be used:"
+		ewarn
+		ewarn "	${DLANG_COMPAT_OVERRIDE}"
+		ewarn
+		ewarn "Dependencies won't be satisfied, and DLANG_SINGLE_TARGET flags will be ignored."
+
+		_dlang_export "${impls[0]}" EDC DC DCFLAGS DLANG_LDFLAGS
+		_dlang_wrapper_setup
+		einfo "Using ${EDC} to build"
+		return
+	fi
+
+	local impl
+	for impl in "${_DLANG_SUPPORTED_IMPLS[@]}"; do
+		if use "dlang_single_target_${impl}"; then
+			if [[ ${EDC} ]]; then
+				eerror "Your DLANG_SINGLE_TARGET setting lists more than a single Dlang"
+				eerror "implementation. Please set it to just one value. If you need"
+				eerror "to override the value for a single package, please use package.use"
+				eerror "or an equivalent solution (man 5 portage)."
+				echo
+				die "More than one implementation in DLANG_SINGLE_TARGET."
+			fi
+
+			_dlang_export "${impl}" EDC DC DCFLAGS DLANG_LDFLAGS
+			_dlang_wrapper_setup
+			einfo "Using ${EDC} to build"
+		fi
+	done
+
+	if [[ ! ${EDC} ]]; then
+		eerror "No Dlang implementation selected for the build. Please set"
+		eerror "the DLANG_SINGLE_TARGET variable in your make.conf to one"
+		eerror "of the following values:"
+		eerror
+		eerror "${_DLANG_SUPPORTED_IMPLS[@]}"
+		echo
+		die "No supported Dlang implementation in DLANG_SINGLE_TARGET."
+	fi
+}
+
+# @FUNCTION: dlang-single_pkg_setup
+# @DESCRIPTION:
+# Runs dlang_setup.
+dlang-single_pkg_setup() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${MERGE_TYPE} != binary ]] && dlang_setup
+}
+
+fi
+
+EXPORT_FUNCTIONS pkg_setup


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-04-13 23:04 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-04-13 23:04 UTC (permalink / raw
  To: gentoo-commits

commit:     88e2ca3511032435742bd8d7d1c01d8a29588ba3
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Mar  2 14:27:21 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Apr 13 22:47:25 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=88e2ca35

dlang-compilers-r1.eclass: new eclass

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

 eclass/dlang-compilers-r1.eclass | 293 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 293 insertions(+)

diff --git a/eclass/dlang-compilers-r1.eclass b/eclass/dlang-compilers-r1.eclass
new file mode 100644
index 0000000..933b05a
--- /dev/null
+++ b/eclass/dlang-compilers-r1.eclass
@@ -0,0 +1,293 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: dlang-compilers-r1.eclass
+# @MAINTAINER:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# @AUTHOR:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# Based on dlang-compilers.eclass by Marco Leise <marco.leise@gmx.de>.
+# @BUGREPORTS:
+# Please report bugs via https://github.com/gentoo/dlang/issues
+# @VCSURL: https://github.com/gentoo/dlang
+# @BLURB: Support data for dlang-utils.eclass
+# @DESCRIPTION:
+# Contains the available D compiler versions with their stable
+# architectures and the language version they support.
+
+if [[ ! ${_DLANG_COMPILERS_R1_ECLASS} ]] ; then
+_DLANG_COMPILERS_R1_ECLASS=1
+
+# @ECLASS_VARIABLE: _DLANG_DMD_FRONTENDS
+# @INTERNAL
+# @DESCRIPTION:
+# A list of dmd implementations with their dlang frontend version (which
+# happens to coincide with the implementation version) and the
+# architectures they support as a list of keywords. Only stable and
+# unstable keywords will appear.
+#
+# The elements are ordered, the higher implementation version has the
+# higher index.
+#
+# Example value for an element:
+# @CODE
+# "2.102 2.102 ~amd64 x86"
+# @CODE
+# Where the first 2.102 represents the implementation version,
+# the second one represents the D language version the implementation
+# supports and, lastly, there are two keywords.
+readonly _DLANG_DMD_FRONTENDS=(
+	"2.101 2.101 ~amd64 ~x86"
+	"2.102 2.102 ~amd64 ~x86"
+	"2.103 2.103 ~amd64 ~x86"
+	"2.104 2.104 ~amd64 ~x86"
+	"2.105 2.105 ~amd64 ~x86"
+	"2.106 2.106 ~amd64 ~x86"
+	"2.107 2.107 ~amd64 ~x86"
+)
+
+# @ECLASS_VARIABLE: _DLANG_GDC_FRONTENDS
+# @INTERNAL
+# @DESCRIPTION:
+# A list of gdc implementations with their dlang frontend version and
+# the architectures they support as a list of keywords. Only stable and
+# unstable keywords will appear.
+#
+# The elements are ordered, the higher implementation version has the
+# higher index.
+#
+# Example value for an element:
+# @CODE
+# "13 2.103 amd64 ~arm64 x86"
+# @CODE
+# Where 13 represents the implementation version, 2.103 represents the D
+# language version the implementation supports and, lastly, there are
+# three keywords.
+readonly _DLANG_GDC_FRONTENDS=(
+	"12 2.100 ~amd64 ~arm64 ~x86"
+	"13 2.103 ~amd64 ~arm64 ~x86"
+)
+
+# @ECLASS_VARIABLE: _DLANG_LDC2_FRONTENDS
+# @INTERNAL
+# @DESCRIPTION:
+# A list of ldc2 implementations with their dlang frontend version and
+# the architectures they support as a list of keywords. Only stable and
+# unstable keywords will appear.
+#
+# The elements are ordered, the higher implementation version has the
+# higher index.
+#
+# Example value for an element:
+# @CODE
+# 1.34 2.104 ~amd64 ~arm64
+# @CODE
+# Where 1.34 represents the implementation version, 2.104 represents the
+# D language version the implementation supports and, lastly, there are
+# two keywords.
+readonly _DLANG_LDC2_FRONTENDS=(
+	"1.32 2.102 ~amd64 ~arm64 ~x86"
+	"1.33 2.103 ~amd64 ~arm64 ~x86"
+	"1.34 2.104 ~amd64 ~arm64 ~x86"
+	"1.35 2.105 ~amd64 ~arm64 ~x86"
+	"1.36 2.106 ~amd64 ~arm64 ~x86"
+)
+
+# @FUNCTION: _dlang_accumulate_implementations
+# @INTERNAL
+# @DESCRIPTION:
+# Set the global variable _DLANG_ALL_IMPLS based on the three arrays:
+# _DLANG_(DMD|LDC2|GDC)_FRONTENDS. This function should be called once,
+# in global scope.
+_dlang_accumulate_implementations() {
+	local line result=()
+	for line in "${_DLANG_DMD_FRONTENDS[@]/#/dmd-}" \
+				"${_DLANG_GDC_FRONTENDS[@]/#/gdc-}" \
+				"${_DLANG_LDC2_FRONTENDS[@]/#/ldc2-}"
+	do
+		line=( ${line} )
+		# We only need the first component (name + version)
+		local impl=${line[0]/\./_}
+		result+=( "${impl}" )
+	done
+
+	if [[ ${_DLANG_ALL_IMPLS+1} ]]; then
+		if [[ ${_DLANG_ALL_IMPLS[@]} != ${result[@]} ]]; then
+			eerror "_DLANG_ALL_IMPLS has changed between inherits!"
+			eerror "Before: ${_DLANG_ALL_IMPLS[*]}"
+			eerror "Now   : ${result[*]}"
+			die "_DLANG_ALL_IMPLS integrity check failed!"
+		fi
+	else
+		_DLANG_ALL_IMPLS=( "${result[@]}" )
+		readonly _DLANG_ALL_IMPLS
+	fi
+}
+_dlang_accumulate_implementations
+unset -f _dlang_accumulate_implementations
+
+# @ECLASS_VARIABLE: _DLANG_ALL_IMPLS
+# @INTERNAL
+# @DESCRIPTION:
+# All supported Dlang implementations, most preferred last.
+
+# @ECLASS_VARIABLE: _DLANG_HISTORICAL_IMPLS
+# @INTERNAL
+# @DESCRIPTION:
+# All historical Dlang implementations that are no longer supported.
+readonly _DLANG_HISTORICAL_IMPLS=(
+	gdc-11
+)
+
+# @FUNCTION: dlang_compilers_stabs_required_use
+# @USAGE: <use_expand_name> [<impls>...]
+# @DESCRIPTION:
+# Generate a required-use expression which ensures that only supported
+# implementations can be selected.
+#
+# Check _dlang_get_bad_arches for a more detailed description of what
+# an implementation being supported means.
+#
+# <use_expand_name> is a string used to transform implementations as
+# they appear in <impls> into USE flags. Possible values are
+# "dlang_targets" and "dlang_single_target".
+#
+# Example: If we had the implementation dmd-2_105 with the keywords,
+# i.e. the keywords in _DLANG_DMD_FRONTENDS, `amd64 ~x86' and $KEYWORDS
+# has the contents `amd64 arm64 x86' the output should be:
+# @CODE
+# "<use_expand_name>_dmd-2_105? ( !x86 ) <use_expand_name>_dmd-2_105? ( !arm64 )"
+# @CODE
+dlang_compilers_stabs_required_use() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local use_expand_name=${1}
+	local impls=( ${@:2} )
+
+	local result=() impl
+	for impl in "${impls[@]}"; do
+		local badArches=( $(_dlang_get_bad_arches "${impl}") )
+		local arch
+		for arch in "${badArches[@]}"; do
+			result+=( "${use_expand_name}_${impl}? ( !${arch} )" )
+		done
+	done
+
+	echo "${result[@]}"
+}
+
+# @FUNCTION: dlang_compilers_stabs_impl_dep
+# @USAGE: <impl> <dep_string>
+# @DESCRIPTION:
+# Print a dependency string based on <dep_string>, USE disabled on
+# architectures found in $KEYWORDS that are not supported by <impl>.
+#
+# To see what it means for an architecture to be unsupported check
+# _dlang_get_bad_arches.
+#
+# Example: If we had the implementation dmd-2_105 with the keywords,
+# i.e. the keywords in _DLANG_DMD_FRONTENDS, `amd64 ~x86' and $KEYWORDS
+# has the contents `amd64 arm64 x86' the output should be:
+# @CODE
+# "!arm64? ( !x86? ( <dep_string> ) ) "
+# @CODE
+# Where <dep_string> looks like `dlang_single_target_dmd-2_105? ( dev-lang/dmd:2.105= ) '
+dlang_compilers_stabs_impl_dep() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl=${1} dep=${2}
+	local badArches=( $(_dlang_get_bad_arches "${impl}") )
+
+	local arch
+	for arch in "${badArches[@]}"; do
+		dep="!${arch}? ( ${dep}) "
+	done
+
+	echo "${dep}"
+}
+
+# @FUNCTION: _dlang_get_bad_arches
+# @USAGE: <impl>
+# @INTERNAL
+# @DESCRIPTION:
+# Output a string of all the arches that are unsupported by <impl> in
+# regards to $KEYWORDS.
+#
+# An architecture is considered unsupported if it:
+#
+# - appears in $KEYWORDS (either as stable or unstable) and it doesn't
+#   appear in the keywords of <impl>, the ones from the
+#   _DLANG_*_FRONTENDS arrays.
+#
+# - appears in $KEYWORDS as stable and it appears in the keywords of
+#   <impl> as unstable.
+#
+# For example, if we had the implementation dmd-2_105 with the keywords,
+# i.e. the keywords in _DLANG_DMD_FRONTENDS, `amd64 ~x86' and $KEYWORDS
+# has the contents `amd64 arm64 x86' the output should be, in no
+# particular order:
+# @CODE
+# x86 arm64
+# @CODE
+_dlang_get_bad_arches() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local details=( $(_dlang_get_impl_details "${1}") )
+	local implKeywords=( ${details[@]:2} )
+
+	local result=() keyword
+	# Meh, $KEYWORDS can contain -* (like for dmd) and that is globing
+	# so bad.
+	local keywords
+	read -ra keywords <<<"${KEYWORDS}"
+	for keyword in "${keywords[@]}"; do
+		[[ ${keyword::1} == - ]] && continue
+
+		local arch=${keyword}
+		[[ ${keyword::1} == "~" ]] && arch=${keyword:1}
+
+		local found=0
+		if [[ ${keyword::1} == "~" ]]; then
+			# An unstable package accepts a stable or an unstable implementation
+			has "${arch}" "${implKeywords[@]}" && found=1
+			has "~${arch}" "${implKeywords[@]}" && found=1
+		else
+			# A stable package accepts only a stable implementation
+			has "${arch}" "${implKeywords[@]}" && found=1
+		fi
+
+		if [[ ${found} == 0 ]]; then
+			result+=( "${arch}" )
+		fi
+	done
+
+	echo "${result[@]}"
+}
+
+# @FUNCTION: _dlang_get_impl_details
+# @USAGE: <impl>
+# @INTERNAL
+# @DESCRIPTION:
+# Print the details of the implementation denoted by <impl>, as they
+# appear in _DLANG_*_FRONTENDS.
+_dlang_get_impl_details() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local impl="${1/_/.}"
+
+	# Yay, optimizations
+	local name=${impl%-*} ver=${impl#*-}
+	local arr=_DLANG_${name^^}_FRONTENDS[@]
+
+	local details
+	for details in "${!arr}"; do
+		if [[ ${details%% *} == ${ver} ]]; then
+			echo "${details}"
+			return
+		fi
+	done
+
+	die "Unknown implementation: ${impl}"
+}
+
+fi


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-04-13 23:04 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-04-13 23:04 UTC (permalink / raw
  To: gentoo-commits

commit:     8c87f32d55db8c0f99374d6e42758f539a49d344
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Mar  2 17:09:48 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Apr 13 22:47:30 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=8c87f32d

dlang-r1.eclass: new eclass

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

 eclass/dlang-r1.eclass | 391 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 391 insertions(+)

diff --git a/eclass/dlang-r1.eclass b/eclass/dlang-r1.eclass
new file mode 100644
index 0000000..3ec24fe
--- /dev/null
+++ b/eclass/dlang-r1.eclass
@@ -0,0 +1,391 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: dlang-r1.eclass
+# @MAINTAINER:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# @AUTHOR:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# Based on python-r1.eclass by Michał Górny <mgorny@gentoo.org> et al
+# with logic taken from dlang.eclass by Marco Leise <marco.leise@gmx.de>.
+# @BUGREPORTS:
+# Please report bugs via https://github.com/gentoo/dlang/issues
+# @VCSURL: https://github.com/gentoo/dlang
+# @SUPPORTED_EAPIS: 8
+# @PROVIDES: dlang-utils
+# @BLURB: A common eclass for Dlang packages.
+# @DESCRIPTION:
+# A common eclass providing helper functions to build and install
+# packages supporting being installed for multiple Dlang implementations.
+#
+# This eclass sets correct IUSE. Modification of REQUIRED_USE has to
+# be done by the author of the ebuild (but DLANG_REQUIRED_USE is
+# provided for convenience, see below). dlang-r1 exports DLANG_DEPS
+# and DLANG_USEDEP so you can create correct dependencies for your
+# package easily. It also provides methods to easily run a command for
+# each enabled Dlang implementation and duplicate the sources for them.
+#
+# Please note that dlang-r1 will always inherit dlang-utils as
+# well. Thus, all the functions defined there can be used
+# in the packages using dlang-r1, and there is no need ever to inherit
+# both.
+#
+# There is one more particularity about the eclass. In order to provide
+# correct DLANG_DEPS and DLANG_REQUIRED_USE the contents of KEYWORDS
+# need to be set before the inherit, see the example below.
+#
+# @EXAMPLE:
+# @CODE
+# EAPI=8
+# DLANG_COMPAT=( dmd-2_{101..106} gdc-12 gdc-13 ldc2-1_{32..36} )
+# KEYWORDS="amd64 x86"
+#
+# inherit dlang-r1
+#
+# REQUIRED_USE=${DLANG_REQUIRED_USE}
+# DEPEND="${DLANG_DEPS} dev-libs/gtkd[${DLANG_USEDEP}]"
+# RDEPEND=${DEPEND}
+# BDEPEND=${DLANG_DEPS}
+#
+# dlang_src_compile() {
+#     emake DC_FLAGS="${DCFLAGS}" LD_FLAGS="${DLANG_LDFLAGS}"
+# }
+#
+# src_compile() {
+#     dlang_foreach_impl dlang_src_compile
+# }
+# @CODE
+
+case ${EAPI} in
+	8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ -z ${_DLANG_R1_ECLASS} ]]; then
+_DLANG_R1_ECLASS=1
+
+if [[ ${_DLANG_SINGLE_ECLASS} ]]; then
+	die 'dlang-r1.eclass cannot be used with dlang-single.eclass.'
+fi
+
+inherit multibuild dlang-utils
+
+# @ECLASS_VARIABLE: DLANG_COMPAT
+# @REQUIRED
+# @PRE_INHERIT
+# @DESCRIPTION:
+# This variable contains a list of Dlang implementations the package
+# supports. It must be set before the `inherit' call. It has to be an
+# array.
+#
+# Example:
+# @CODE
+# DLANG_COMPAT=( gdc-12 ldc2-1_36 dmd-2_102 dmd-2_103 )
+# @CODE
+#
+# Please note that you can also use bash brace expansion if you like:
+# @CODE
+# DLANG_COMPAT=( gdc-1{2..3} ldc2-1_{29..36} dmd-2_10{5,6} )
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_COMPAT_OVERRIDE
+# @USER_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# This variable can be used when working with ebuilds to override the
+# in-ebuild DLANG_COMPAT. It is a string listing all the implementations
+# which package will be built for. It needs to be specified in the
+# calling environment, and not in ebuilds.
+#
+# It should be noted that in order to preserve metadata immutability,
+# DLANG_COMPAT_OVERRIDE does not affect IUSE nor dependencies.
+# The state of DLANG_TARGETS is ignored, and all the implementations
+# in DLANG_COMPAT_OVERRIDE are built. Dependencies need to be satisfied
+# manually.
+#
+# Example:
+# @CODE
+# DLANG_COMPAT_OVERRIDE='gdc-13 dmd-2_106' emerge -1v dev-libs/foo
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_REQ_USE
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# An associative array of Dlang implementations and USE-dependencies
+# strings. The keys are implementation names, so: "dmd" "ldc2" or "gdc";
+# and the values are the aforementioned USE-dependency strings.
+#
+# This should be set before calling `inherit'.
+#
+# Example:
+# @CODE
+# declare -A DLANG_REQ_USE=(
+#     [dmd]="static-libs(-)?"
+#     [gdc]="another_flag"
+#     [ldc2]="static-libs(-)?"
+# )
+# @CODE
+#
+# It will cause the Dlang dependencies to look like:
+# @CODE
+# dlang_targets_ldc2-X_Y? ( dev-lang/ldc2:X.Y=[static-libs(-)?] )
+# dlang_targets_gdc-X? ( sys-devel/gcc[d,another_flag]:X dev-util/gdmd:X )
+# dlang_targets_dmd-X_Y? ( dev-lang/dmd:X.Y=[static-libs(-)?] )
+# @CODE
+
+# @ECLASS_VARIABLE: BUILD_DIR
+# @OUTPUT_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The current build directory. In global scope, it is supposed to
+# contain an initial build directory; if unset, it defaults to ${S}.
+#
+# In functions run by dlang_foreach_impl(), the BUILD_DIR is locally
+# set to an implementation-specific build directory. That path is
+# created through appending a hyphen and the implementation name
+# to the final component of the initial BUILD_DIR.
+#
+# Example value:
+# @CODE
+# ${WORKDIR}/foo-1.3-ldc2-1_35
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_DEPS
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated Dlang dependency string for all
+# implementations listed in DLANG_COMPAT.
+#
+# Example use:
+# @CODE
+# RDEPEND="${DLANG_DEPS}
+#	dev-foo/mydep"
+# DEPEND=${RDEPEND}
+# @CODE
+#
+# Example value:
+# @CODE
+# dlang_targets_gdc-12? ( sys-devel/gcc:12[d] dev-util/gdmd:12 )
+# dlang_targets_ldc2-1_36? ( dev-lang/ldc2:1.36= )
+# dlang_targets_dmd-2_099? ( dev-lang/dmd:2.099= )
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_USEDEP
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated USE-dependency string which can be used to
+# depend on another Dlang package being built for the same Dlang
+# implementations.
+#
+# Example use:
+# @CODE
+# RDEPEND="dev-libs/foo[${DLANG_USEDEP}]"
+# @CODE
+#
+# Example value:
+# @CODE
+# dlang_targets_gdc-11(-)?,dlang_targets_dmd-2_106(-)?,dlang_targets_ldc2-1_34(-)?
+# @CODE
+
+# @ECLASS_VARIABLE: DLANG_REQUIRED_USE
+# @OUTPUT_VARIABLE
+# @DESCRIPTION:
+# This is an eclass-generated required-use expression which ensures that
+# at least one Dlang implementation has been enabled.
+#
+# This expression should be utilized in an ebuild by including it in
+# REQUIRED_USE, optionally behind a use flag.
+#
+# Example use:
+# @CODE
+# REQUIRED_USE="^^ ( selfhost ${DLANG_REQUIRED_USE} )"
+# @CODE
+#
+# Example value:
+# @CODE
+# || ( dlang_targets_gdc-11 dlang_targets_dmd-2_106 dlang_targets_ldc2-1_34 )
+# @CODE
+
+# @FUNCTION: _dlang_set_globals
+# @INTERNAL
+# @DESCRIPTION:
+# Sets all the global output variables provided by this eclass.
+# This function must be called once, in global scope.
+_dlang_set_globals() {
+	local deps i DLANG_PKG_DEP
+
+	_dlang_set_impls
+
+	for i in "${_DLANG_SUPPORTED_IMPLS[@]}"; do
+		_dlang_export "${i}" DLANG_PKG_DEP
+		deps+=$(
+			dlang_compilers_stabs_impl_dep \
+				"${i}" \
+				"dlang_targets_${i}? (
+					${DLANG_PKG_DEP}
+				 ) "
+			 )
+	done
+
+	local flags=( "${_DLANG_SUPPORTED_IMPLS[@]/#/dlang_targets_}" )
+	local optflags=${flags[@]/%/(-)?}
+	local stabilization_mock=$(dlang_compilers_stabs_required_use \
+								   dlang_targets \
+								   "${_DLANG_SUPPORTED_IMPLS[@]}"
+		  )
+	local requse="( || ( ${flags[*]} )${stabilization_mock:+ ${stabilization_mock}} )"
+	local usedep=${optflags// /,}
+
+	if [[ ${DLANG_DEPS+1} ]]; then
+		# IUSE is magical, so we can't really check it
+		# (but we verify DLANG_COMPAT already)
+
+		if [[ ${DLANG_DEPS} != ${deps} ]]; then
+			eerror "DLANG_DEPS have changed between inherits (DLANG_REQ_USE?)!"
+			eerror "Before: ${DLANG_DEPS}"
+			eerror "Now   : ${deps}"
+			die "DLANG_DEPS integrity check failed"
+		fi
+
+		if [[ ${DLANG_REQUIRED_USE} != ${requse} ]]; then
+			eerror "DLANG_REQUIRED_USE have changed between inherits!"
+			eerror "Before: ${DLANG_REQUIRED_USE}"
+			eerror "Now   : ${requse}"
+			die "DLANG_REQUIRED_USE integrity check failed"
+		fi
+
+		# this one's a formality -- it depends on DLANG_COMPAT only
+		if [[ ${DLANG_USEDEP} != ${usedep} ]]; then
+			eerror "DLANG_USEDEP have changed between inherits!"
+			eerror "Before: ${DLANG_USEDEP}"
+			eerror "Now   : ${usedep}"
+			die "DLANG_USEDEP integrity check failed"
+		fi
+	else
+		IUSE=${flags[*]}
+
+		DLANG_DEPS=${deps}
+		DLANG_REQUIRED_USE=${requse}
+		DLANG_USEDEP=${usedep}
+		readonly DLANG_DEPS DLANG_REQUIRED_USE DLANG_USEDEP
+	fi
+}
+_dlang_set_globals
+unset -f _dlang_set_globals
+
+# @FUNCTION: _dlang_validate_useflags
+# @INTERNAL
+# @DESCRIPTION:
+# Enforce the proper setting of DLANG_TARGETS, if DLANG_COMPAT_OVERRIDE
+# is not in effect. If it is, just warn that the flags will be ignored.
+_dlang_validate_useflags() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	if [[ ${DLANG_COMPAT_OVERRIDE} ]]; then
+		if [[ ! ${_DLANG_COMPAT_OVERRIDE_WARNED} ]]; then
+			ewarn "WARNING: DLANG_COMPAT_OVERRIDE in effect. The following Dlang"
+			ewarn "implementations will be enabled:"
+			ewarn
+			ewarn "	${DLANG_COMPAT_OVERRIDE}"
+			ewarn
+			ewarn "Dependencies won't be satisfied, and DLANG_TARGETS will be ignored."
+			_DLANG_COMPAT_OVERRIDE_WARNED=1
+		fi
+		# we do not use flags with DCO
+		return
+	fi
+
+	local i
+	for i in "${_DLANG_SUPPORTED_IMPLS[@]}"; do
+		use "dlang_targets_${i}" && return 0
+	done
+
+	eerror "No Dlang implementation selected for the build. Please add one"
+	eerror "of the following values to your DLANG_TARGETS (in make.conf):"
+	eerror
+	eerror "${DLANG_COMPAT[@]}"
+	echo
+	die "No supported Dlang implementation in DLANG_TARGETS."
+}
+
+# @FUNCTION: dlang_copy_sources
+# @DESCRIPTION:
+# Create a single copy of the package sources for each enabled Dlang
+# implementation.
+#
+# The sources are always copied from initial BUILD_DIR (or S if unset)
+# to implementation-specific build directory matching BUILD_DIR used by
+# dlang_foreach_impl().
+dlang_copy_sources() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local MULTIBUILD_VARIANTS
+	_dlang_obtain_impls
+
+	multibuild_copy_sources
+}
+
+# @FUNCTION: _dlang_obtain_impls
+# @INTERNAL
+# @DESCRIPTION:
+# Set up the enabled implementation list.
+_dlang_obtain_impls() {
+	_dlang_validate_useflags
+
+	if [[ ${DLANG_COMPAT_OVERRIDE} ]]; then
+		MULTIBUILD_VARIANTS=( ${DLANG_COMPAT_OVERRIDE} )
+		return
+	fi
+
+	MULTIBUILD_VARIANTS=()
+
+	local impl
+	for impl in "${_DLANG_SUPPORTED_IMPLS[@]}"; do
+		use "dlang_targets_${impl}" && MULTIBUILD_VARIANTS+=( "${impl}" )
+	done
+}
+
+# @FUNCTION: _dlang_multibuild_wrapper
+# @USAGE: <command> [<args>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Initialize the environment for the Dlang implementation selected for
+# multibuild.
+_dlang_multibuild_wrapper() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local -x EDC DC DCFLAGS DLANG_LDFLAGS
+	local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
+	_dlang_export "${MULTIBUILD_VARIANT}" EDC DC DCFLAGS DLANG_LDFLAGS
+	_dlang_wrapper_setup "${T}/${MULTIBUILD_ID}"
+
+	pushd "${BUILD_DIR}" > /dev/null || die
+	"${@}"
+	popd > /dev/null || die
+}
+
+# @FUNCTION: dlang_foreach_impl
+# @USAGE: <command> [<args>...]
+# @DESCRIPTION:
+# Run the given command for each of the enabled Dlang implementations.
+# If additional parameters are passed, they will be passed through to
+# the command.
+#
+# The function will return 0 status if all invocations succeed.
+# Otherwise, the return code from first failing invocation will be
+# returned.
+#
+# For each command being run, BUILD_DIR, EDC, DC, DCFLAGS and
+# DLANG_LDFLAGS are set locally, and the latter four are exported to the
+# command environment.
+dlang_foreach_impl() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local MULTIBUILD_VARIANTS
+	_dlang_obtain_impls
+
+	multibuild_foreach_variant _dlang_multibuild_wrapper "${@}"
+}
+
+fi


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-04-13 23:04 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-04-13 23:04 UTC (permalink / raw
  To: gentoo-commits

commit:     02e60ee7974e31d94d7210bfc566c1427d4df6df
Author:     Andrei Horodniceanu <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Mar  2 17:56:22 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sat Apr 13 22:47:30 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=02e60ee7

dmd-r1.eclass: new eclass

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

 eclass/dmd-r1.eclass | 414 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 414 insertions(+)

diff --git a/eclass/dmd-r1.eclass b/eclass/dmd-r1.eclass
new file mode 100644
index 0000000..802e820
--- /dev/null
+++ b/eclass/dmd-r1.eclass
@@ -0,0 +1,414 @@
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: dmd-r1.eclass
+# @MAINTAINER:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# @AUTHOR:
+# Andrei Horodniceanu <a.horodniceanu@proton.me>
+# Based on dmd.eclass by Marco Leise <marco.leise@gmx.de>.
+# @BUGREPORTS:
+# Please report bugs via https://github.com/gentoo/dlang/issues
+# @VCSURL: https://github.com/gentoo/dlang
+# @SUPPORTED_EAPIS: 8
+# @BLURB: Captures most of the logic for building and installing DMD
+# @DESCRIPTION:
+# Helps with the maintenance of the various DMD versions by capturing common
+# logic.
+
+if [[ ! ${_ECLASS_ONCE_DMD_R1} ]] ; then
+_ECLASS_ONCE_DMD_R1=1
+
+case ${EAPI:-0} in
+	8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+DESCRIPTION="Reference compiler for the D programming language"
+HOMEPAGE="https://dlang.org/"
+
+# DMD supports amd64/x86 exclusively
+# @ECLASS_VARIABLE: MULTILIB_COMPAT
+# @DESCRIPTION:
+# A list of multilib ABIs supported by $PN. It only supports
+# abi_x86_{32,64}. See the multilib-build.eclass documentation for this
+# variable for more information.
+MULTILIB_COMPAT=( abi_x86_{32,64} )
+
+inherit desktop edos2unix dlang-single multilib-build multiprocessing optfeature
+
+LICENSE=Boost-1.0
+SLOT=$(ver_cut 1-2)
+readonly MAJOR=$(ver_cut 1)
+readonly MINOR=$(ver_cut 2)
+readonly PATCH=$(ver_cut 3)
+readonly VERSION=$(ver_cut 1-3)
+readonly BETA=$(ver_cut 4-)
+
+# For prereleases, 2.097.0_rc1 -> 2.097.0-rc.1
+MY_VER=$(ver_rs 3 - 4 .)
+
+DLANG_ORG=https://downloads.dlang.org/${BETA:+pre-}releases/2.x/${VERSION}
+SRC_URI="
+	https://github.com/dlang/${PN}/archive/refs/tags/v${MY_VER}.tar.gz -> ${PN}-${MY_VER}.tar.gz
+	https://github.com/dlang/phobos/archive/refs/tags/v${MY_VER}.tar.gz -> phobos-${MY_VER}.tar.gz
+	selfhost? ( ${DLANG_ORG}/dmd.${MY_VER}.linux.tar.xz )
+	doc? ( ${DLANG_ORG}/dmd.${MY_VER}.linux.tar.xz )
+"
+
+IUSE="doc examples +selfhost static-libs"
+REQUIRED_USE="^^ ( selfhost ${DLANG_REQUIRED_USE} )"
+IDEPEND=">=app-eselect/eselect-dlang-20140709"
+BDEPEND="!selfhost? ( ${DLANG_DEPS} )"
+# We don't need anything in DEPEND, curl is dl-opened
+# so it belongs in RDEPEND.
+#DEPEND=
+# Since 2.107.0, dmd links the standard library of the host
+# compiler. Since this eclass is only used by >=dmd-2.107.0-r1 the
+# dependency is added unconditionally.
+RDEPEND="
+	${IDEPEND}
+	net-misc/curl[${MULTILIB_USEDEP}]
+	!selfhost? ( ${DLANG_DEPS} )
+"
+
+dmd-r1_pkg_setup() {
+	if use !selfhost; then
+		dlang-single_pkg_setup
+		# set by dlang-single.eclass:
+		# $EDC, $DC, $DLANG_LDFLAGS, $DCFLAGS
+
+		# Now let's build our environment
+		export DMDW=$(dlang_get_dmdw)
+		export DMDW_DCFLAGS=$(dlang_get_dmdw_dcflags)
+		export DMDW_LDFLAGS=$(dlang_get_dmdw_ldflags)
+	else
+		# Setup up similar variables to the above
+		export EDC=dmd-${SLOT}
+		#export DC= # is set inside src_unpack
+		#export DMDW= # is set inside src_unpack
+		export DLANG_LDFLAGS=$(dlang_get_ldflags)
+		# Should we put user DMDFLAGS here?
+		export DMDW_DCFLAGS= DCFLAGS=
+		export DMDW_LDFLAGS=$(dlang_get_dmdw_ldflags)
+	fi
+}
+
+dmd-r1_src_unpack() {
+	# Here because pkgdev complains about it being in pkg_setup
+	if use selfhost; then
+		export DC=${WORKDIR}/dmd2/linux/bin$(_get_abi_bits)/dmd
+		export DMDW=${DC}
+	fi
+
+	default
+
+	# $S may collide with $PN-$MY_VER
+	mv "${PN}-${MY_VER}" tmp || die
+	mkdir "${S}" || die
+	mv -T tmp "${S}/${PN}" || die
+	mv -T "phobos-${MY_VER}" "${S}/phobos" || die
+}
+
+dmd-r1_src_prepare() {
+	einfo "Removing dos-style line endings."
+	local file
+	while read -rd '' file; do
+		edos2unix "${file}"
+	done < <( find "${WORKDIR}" \( -name '*.txt' -o -name '*.html' -o -name '*.d' \
+				   -o -name '*.di' -o -name '*.ddoc' -type f \) \
+				   -print0 )
+
+	default
+}
+
+dmd-r1_src_compile() {
+	einfo "Building dmd build script"
+	dlang_compile_bin dmd/compiler/src/build{,.d}
+	local BUILD_D=${S}/dmd/compiler/src/build
+
+	local cmd=(
+		env
+		VERBOSE=1
+		HOST_DMD="${DMDW}"
+		# Just like old dmd.eclass.
+		#
+		# TODO, this has to be fixed but right now we either do
+		# ENABLE_RELEASE (we add -O -inline -release) or build.d will
+		# add -g.
+		ENABLE_RELEASE=1
+		"${BUILD_D}"
+		-j$(makeopts_jobs)
+		# A bit overkill to specify the flags here but it does get the
+		# jobs done.
+		DFLAGS="${DMDW_DCFLAGS} ${DMDW_LDFLAGS}"
+	)
+
+	einfo "Building dmd"
+	echo "${cmd[@]}"
+	"${cmd[@]}" || die "Failed to build dmd"
+
+	# The release here is from ENABLE_RELEASE, keep them in sync.
+	export GENERATED_DMD=${S}/dmd/generated/linux/release/$(_get_abi_bits)/dmd
+
+	compile_libraries() {
+		local commonMakeArgs=(
+			DMD="${GENERATED_DMD}"
+			MODEL=${MODEL}
+
+			# Just like how multilib_toolchain_setup does it:
+			CC="$(tc-getCC) $(get_abi_CFLAGS)"
+			# The flags are, a little, project dependent
+			#CFLAGS=
+
+			# With DFLAGS we have 2 problems:
+			#
+			# 1. it's pretty hard to specify them for druntime so
+			#    it would need a makefile patch
+			#
+			# 2. we have the same question as in pkg_setup, do we
+			#    respect DMDFLAGS when building with the generated dmd?
+			#
+			#DFLAGS=
+		)
+		local druntimeMakeArgs=(
+			# Calls git in global scope, only used for whitespace checks.
+			MANIFEST=
+
+			# Specifying user flags here discards the, hopefully
+			# relevant, values from the makefile so add them back.
+			CFLAGS="${CFLAGS} -fPIC -DHAVE_UNISTD_H" # -m32/64 is added in $CC.
+
+			# druntime's notion of a shared library is a static archive
+			# that is embedded into the phobos shared library.
+			#
+			# Technically there is the dll_so target which is the proper
+			# so file but who's gonna use it? Perhaps if phobos would
+			# not incorporate druntime we could install them as separate
+			# libraries (like ldc2 and gdc).
+			$(usex static-libs 'lib dll' dll)
+
+			# We also need to copy the headers to the proper location
+			import
+		)
+		local phobosMakeArgs=(
+			# If unspecified, would rebuild druntime.
+			CUSTOM_DRUNTIME=1
+
+			# Like druntime, specifying flags removes the makefile added ones.
+			CFLAGS="${CFLAGS} -fPIC -std=c11 -DHAVE_UNISTD_H" # -m32/64 is added in $CC.
+
+			# Overkill but it does work. Remember that we have to
+			# convert $LDFLAGS to something dmd understands.
+			DFLAGS="$(dlang_get_ldflags ${PN}-${SLOT})"
+
+			# By default builds both static+dynamic libraries.
+			$(usex static-libs 'lib dll' dll)
+		)
+
+		emake -C dmd/druntime "${commonMakeArgs[@]}" "${druntimeMakeArgs[@]}"
+		emake -C phobos "${commonMakeArgs[@]}" "${phobosMakeArgs[@]}"
+	}
+
+	_dmd_foreach_abi compile_libraries
+
+	# Build the man pages
+	local cmd=(
+		env
+		VERBOSE=1
+		HOST_DMD="${GENERATED_DMD}"
+		"${BUILD_D}"
+		-j$(makeopts_jobs)
+		man
+		# ${GENERATED_DMD} is not yet fully functional as we didn't
+		# create a good dmd.conf. But instead of doing that we're going
+		# to specify our flags here.
+		DFLAGS="-defaultlib=phobos2 -L-rpath=${S}/phobos/generated/linux/release/$(_get_abi_bits)"
+	)
+	echo "${cmd[@]}"
+	"${cmd[@]}" || die "Could not generate man pages"
+
+	# Now clean up some artifacts that would make the install phase
+	# harder (we rely on globbing and recursive calls a lot).
+
+	# The object file is useless
+	rm -f phobos/generated/linux/release/*/libphobos2.so.0.${MINOR}.o || die
+	# the zlib folder contains source code which is no longer
+	# needed. Don't touch etc/c/zlib.d however, that's important.
+	rm -rf phobos/etc/c/zlib || die
+}
+
+dmd-r1_src_test() {
+	# As opposed to old dmd.eclass we have access to actual tests. For
+	# porting reasons we're going to keep only the old test,
+	# hello_world.
+
+	test_hello_world() {
+		local phobosDir=${S}/phobos/generated/linux/release/${MODEL}
+		local commandArgs=(
+			# Copied from _gen_dmd.conf
+			-L--export-dynamic
+			-defaultlib=phobos2 # If unspecified, defaults to libphobos2.a
+			-fPIC
+			-L-L"${phobosDir}"
+			-L-rpath="${phobosDir}"
+
+			-conf= # Don't use dmd.conf
+			-m${MODEL}
+			-Iphobos
+			-Idmd/druntime/import
+		)
+
+		"${GENERATED_DMD}" "${commandArgs[@]}" dmd/compiler/samples/hello.d \
+			|| die "Failed to build hello.d (${MODEL}-bit)"
+		./hello ${MODEL}-bit || die "Failed to run test sample (${MODEL}-bit)"
+	}
+
+	_dmd_foreach_abi test_hello_world
+
+}
+
+dmd-r1_src_install() {
+	local EDC=${PN}-${SLOT} # overwrite the one from pkg_setup
+	local dmd_prefix=/usr/lib/${PN}/$(dlang_get_be_version)
+
+	dodir /etc/dmd
+	_gen_dmd.conf > "${ED}"/etc/dmd/${SLOT}.conf || die "Could not generate dmd.conf"
+	# Put a symlink to dmd.conf into the same folder as the dmd
+	# executable so it gets picked up automatically (and instead of
+	# /etc/dmd.conf).
+	dosym -r "/etc/dmd/${SLOT}.conf" "${dmd_prefix}/bin/dmd.conf"
+
+	into "${dmd_prefix}"
+	dobin "${GENERATED_DMD}"
+	dosym -r "${dmd_prefix}/bin/dmd" "/usr/bin/dmd-${SLOT}"
+
+	insinto "${dmd_prefix}"
+	doins -r dmd/druntime/import
+
+	# Old dmd.eclass installed the so to $(get_libdir) and symlinked it
+	# into ${dmd_prefix}. We do it the other way around.
+	install_phobos_2() {
+		local G=phobos/generated/linux/release/${MODEL}
+		into /usr
+
+		dlang_dolib.so "${G}"/libphobos2.so*
+		use static-libs && dlang_dolib.a "${G}"/libphobos2.a
+
+		# The symlinks under $(get_libdir) are only for backwards
+		# compatibility purposes.
+		local filename=libphobos2.so.0.${MINOR}
+		dosym -r "/usr/$(dlang_get_libdir)/${filename}" "/usr/$(get_libdir)/${filename}"
+		dosym -r "/usr/$(dlang_get_libdir)/${filename}.${PATCH}" "/usr/$(get_libdir)/${filename}.${PATCH}"
+	}
+	_dmd_foreach_abi install_phobos_2
+	insinto "${dmd_prefix}"/import
+	doins -r phobos/{etc,std}
+
+	insinto "${dmd_prefix}"/man/man1
+	doins dmd/generated/docs/man/man1/dmd.1
+	insinto "${dmd_prefix}"/man/man5
+	doins dmd/generated/docs/man/man5/dmd.conf.5
+
+	if use examples; then
+		insinto "${dmd_prefix}"/samples
+		doins -r dmd/compiler/samples/*
+		docompress -x "${dmd_prefix}"/samples
+	fi
+
+	if use doc; then
+		HTML_DOCS=( "${WORKDIR}"/dmd2/html/* )
+		einstalldocs
+		insinto "/usr/share/doc/${PF}/html"
+		doins "${FILESDIR}/dmd-doc.png"
+		make_desktop_entry "xdg-open ${EPREFIX}/usr/share/doc/${PF}/html/d/index.html" \
+						   "DMD ${PV}" \
+						   "${EPREFIX}/usr/share/doc/${PF}/html/dmd-doc.png" \
+						   "Development"
+	fi
+}
+
+dmd-r1_pkg_postinst() {
+	"${EROOT}"/usr/bin/eselect dlang update dmd
+
+	use examples && elog "Examples can be found in: ${dmd_prefix}/samples"
+	use doc && elog "HTML documentation is in: /usr/share/doc/${PF}/html"
+
+	optfeature "additional D development tools" "dev-util/dlang-tools"
+}
+
+dmd-r1_pkg_postrm() {
+	"${ERROT}"/usr/bin/eselect dlang update dmd
+}
+
+# @FUNCTION: _gen_dmd.conf
+# @INTERNAL
+# @DESCRIPTION:
+# Print a dmd.conf to be installed on the user system. Needs $EDC to be
+# set up up beforehand.
+_gen_dmd.conf() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	# Note, the logic for which libdir is used is all kept in
+	# dlang-utils.eclass in order not to duplicate code.
+
+	local import_dir=${EPREFIX}/usr/lib/${PN}/$(dlang_get_be_version)/import
+	# Should this, instead, check which ABIs have been enabled?
+	if has_multilib_profile; then
+		local libdir_amd64=${EPREFIX}/usr/$(ABI=amd64 dlang_get_libdir)
+		local libdir_x86=${EPREFIX}/usr/$(ABI=x86 dlang_get_libdir)
+		cat <<EOF
+[Environment]
+DFLAGS=-I${import_dir} -L--export-dynamic -defaultlib=phobos2 -fPIC
+[Environment32]
+DFLAGS=%DFLAGS% -L-L${libdir_x86} -L-rpath=${libdir_x86}
+[Environment64]
+DFLAGS=%DFLAGS% -L-L${libdir_amd64} -L-rpath=${libdir_amd64}
+EOF
+
+	else
+		local libdir=${EPREFIX}/usr/$(dlang_get_libdir)
+		cat <<EOF
+[Environment]
+DFLAGS=-I${import_dir} -L--export-dynamic -defaultlib=phobos2 -fPIC -L-L${libdir} -L-rpath=${libdir}
+EOF
+
+	fi
+}
+
+# @FUNCTION: _get_abi_bits
+# @USAGE: [<abi>]
+# @INTERNAL
+# @DESCRIPTION:
+# Echo the bits of abi, 64 for amd64 and 32 for x86. If unspecified, the
+# value is taken from $ABI.
+_get_abi_bits() {
+	case "${1:-${ABI}}" in
+		amd64*) echo 64 ;;
+		x86*) echo 32 ;;
+		*) die "Unknown ABI: ${ABI}." ;;
+	esac
+}
+
+# @FUNCTION: _dmd_foreach_abi
+# @USAGE: <cmd> [<args>...]
+# @INTERNAL
+# @DESCRIPTION:
+# Run a command for each enabled ABI, similar to multilib_foreach_abi but
+# without setting $BUILD_DIR. Sets up $ABI and $MODEL (bits)
+# appropriately.
+_dmd_foreach_abi() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local ABI
+	for ABI in $(multilib_get_enabled_abis); do
+		local MODEL=$(_get_abi_bits)
+		einfo "Executing ${1} in ${MODEL}-bit"
+		"${@}"
+	done
+}
+
+fi
+
+EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_compile src_test src_install \
+				 pkg_postinst pkg_postrm


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-02-20 17:54 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-02-20 17:54 UTC (permalink / raw
  To: gentoo-commits

commit:     967f6d8dbaf9b73e9e0911b7f6ab397c99dc42b9
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Tue Feb 20 17:32:31 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Tue Feb 20 17:36:15 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=967f6d8d

dmd.eclass: Fix overwriting instead of appending to array.

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

 eclass/dmd.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index fb57d19..9b4554a 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -231,7 +231,7 @@ dmd_src_compile() {
 		# shared+static libraries with !static-libs. Do this only for
 		# >=2.107, if it's useful backport the improvements later.
 		if dmd_ge 2.107; then
-			phobosMakeArgs=( $(usex static-libs 'lib dll' 'dll') )
+			phobosMakeArgs+=( $(usex static-libs 'lib dll' 'dll') )
 			# druntime's notion of a shared library is a static archive
 			# that is embedded into the phobos shared library.
 			#
@@ -239,7 +239,7 @@ dmd_src_compile() {
 			# so file but who's gonna use it? Perhaps if phobos would
 			# not incorporate druntime we could install them as separate
 			# libraries (like ldc2 and gdc).
-			druntimeMakeArgs=( $(usex static-libs 'lib dll' 'dll') )
+			druntimeMakeArgs+=( $(usex static-libs 'lib dll' 'dll') )
 			# Either way, now we no longer build static-libs
 			# indiscriminately.
 		fi


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-02-18 22:49 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-02-18 22:49 UTC (permalink / raw
  To: gentoo-commits

commit:     d5063fd94813514c29539b5bd9baddfa3954b2f6
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sun Feb 18 14:22:48 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sun Feb 18 14:22:48 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=d5063fd9

dmd.eclass: explicitly specify arguments to dmd in tests

Refactor the test code a little for better readability and prevent
linking by default to libphosbos2.a, which happens to work only because
the build wrongfully generates both shared and static libraries
regardless of USE=static-libs.

Pass the same options to dmd as the ones in the installed dmd.conf to
get a closer setup to what the user will have installed on their system.

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

 eclass/dmd.eclass | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 1e49af7..52e4209 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -233,7 +233,22 @@ dmd_src_compile() {
 
 dmd_src_test() {
 	test_hello_world() {
-		"$(dmd_gen_exe_dir)/dmd" -m${MODEL} -fPIC -Iphobos -Idruntime/import -L-Lphobos/generated/linux/release/${MODEL} samples/d/hello.d || die "Failed to build hello.d (${MODEL}-bit)"
+		local phobosDir=phobos/generated/linux/release/"${MODEL}"
+		local commandArgs=(
+			# Copied from below, where dmd.conf is generated
+			-L--export-dynamic
+			-defaultlib=phobos2 # If unspecified, defaults to libphobos2.a
+			-fPIC
+			-L-L"${phobosDir}"
+			-L-rpath="${phobosDir}"
+
+			-conf= # Don't use dmd.conf
+			-m"${MODEL}"
+			-Iphobos
+			-Idruntime/import
+		)
+		"$(dmd_gen_exe_dir)/dmd" "${commandArgs[@]}" samples/d/hello.d \
+			|| die "Failed to build hello.d (${MODEL}-bit)"
 		./hello ${MODEL}-bit || die "Failed to run test sample (${MODEL}-bit)"
 		rm hello.o hello || die "Could not remove temporary files"
 	}


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2024-02-18 22:49 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2024-02-18 22:49 UTC (permalink / raw
  To: gentoo-commits

commit:     47b6ed5f3ffb4aa24afdca634f1b430da78dbfc2
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Thu Jan  4 11:45:41 2024 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sun Feb  4 11:53:33 2024 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=47b6ed5f

dmd.eclass: add optfeature for dev-util/dlang-tools

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

 eclass/dmd.eclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index d19bdd1..1e49af7 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -35,7 +35,7 @@ HTML_DOCS="html/*"
 # DMD supports amd64/x86 exclusively
 MULTILIB_COMPAT=( abi_x86_{32,64} )
 
-inherit desktop edos2unix multilib-build toolchain-funcs
+inherit desktop edos2unix multilib-build optfeature toolchain-funcs
 
 # @FUNCTION: dmd_eq
 # @DESCRIPTION:
@@ -354,6 +354,8 @@ dmd_pkg_postinst() {
 
 	use examples && elog "Examples can be found in: /${PREFIX}/samples"
 	use doc && elog "HTML documentation is in: /usr/share/doc/${PF}/html"
+
+	optfeature "additional D development tools" "dev-util/dlang-tools"
 }
 
 dmd_pkg_postrm() {


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-12-17 11:58 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-12-17 11:58 UTC (permalink / raw
  To: gentoo-commits

commit:     8c977f9dc9d15ebcf73032411eed7acf033782fb
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Thu Nov 30 19:32:20 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> 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 <a.horodniceanu <AT> 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 <backend>
+# @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


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-12-17 11:58 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-12-17 11:58 UTC (permalink / raw
  To: gentoo-commits

commit:     c6ab2690ead707fa368813014edd75509b07727b
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Thu Nov 30 13:34:14 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Sat Dec  9 18:13:15 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=c6ab2690

dlang.eclass: Properly set LIBDIR_$ABI for single type packages

Previously, only packages that set DLANG_PACKAGE_TYPE to multi
received a valid value in LIBDIR_$ABI, the path to the compiler
specific directory for libraries, in order to know where to
install their libraries.

Now, both types of packages will have this value set properly,
alowing single type packages to know the exact path to the
compiler library directory for easy access to auxiliary files
like pkg-config files.

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

 eclass/dlang.eclass | 11 ++++++++---
 eclass/dmd.eclass   | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass
index 385a458..2817779 100644
--- a/eclass/dlang.eclass
+++ b/eclass/dlang.eclass
@@ -584,7 +584,7 @@ _dlang_build_configurations() {
 						variants="${variants} ${abi}-${version_component}"
 					done
 				else
-					variants="default-${version_component}"
+					variants="${DEFAULT_ABI:-default}-${version_component}"
 				fi
 				;;
 			selfhost)
@@ -647,10 +647,15 @@ _dlang_use_build_vars() {
 		# gcc's SLOT is its major version component.
 		export DC="/usr/${CHOST_default}/gcc-bin/${DC_VERSION}/${CHOST_default}-gdc"
 		export DMD="/usr/${CHOST_default}/gcc-bin/${DC_VERSION}/gdmd"
-		if [[ "${DLANG_PACKAGE_TYPE}" == "multi" ]] && multilib_is_native_abi; then
+		if [[ ${DLANG_PACKAGE_TYPE} != multi ]]; then
+			# Both single and dmd enter this branch
 			export LIBDIR_${ABI}="lib/gcc/${CHOST_default}/${DC_VERSION}"
 		else
-			export LIBDIR_${ABI}="lib/gcc/${CHOST_default}/${DC_VERSION}/${MODEL}"
+			if multilib_is_native_abi; then
+				export LIBDIR_${ABI}="lib/gcc/${CHOST_default}/${DC_VERSION}"
+			else
+				export LIBDIR_${ABI}="lib/gcc/${CHOST_default}/${DC_VERSION}/${MODEL}"
+			fi
 		fi
 		export DCFLAGS="${GDCFLAGS} -shared-libphobos"
 		export DLANG_LINKER_FLAG="-Xlinker "

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 7d9e1f5..2292e12 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -295,8 +295,26 @@ EOF
 		fi
 
 		# Install shared lib.
+		# dlang.eclass will set LIBDIR_$ABI to the path of the host compiler
+		# library direcory (if not selfhosting). We don't care about that
+		# location, however, and we instead want to have it point
+		# to the path where this package is supposed to install the libraries
+		# to, i.e. the system library directory. We can use $LIBDIR_HOST
+		# to restore that value to the correct one but only if the ABI
+		# this function is running into is the same as the one set
+		# by dlang.eclass. Since dlang.eclass treats dmd as a 'single'
+		# type package, it will only treat the case where $ABI is the
+		# native one.
+		if ! use selfhost && multilib_is_native_abi; then
+			# We aren't going to use LIBDIR_$ABI for this ABI anymore
+			# so just overwrite it, don't bother saving it.
+			export LIBDIR_${ABI}="${LIBDIR_HOST}"
+		fi
+
+		# We are installing the real file into the system libdir.
 		dolib.so phobos/generated/linux/release/${MODEL}/"${SONAME}"
 		dosym "${SONAME}" /usr/"$(get_libdir)"/"${SONAME_SYM}"
+		# We create an additional symlink in this package's specific libdir.
 		dosym ../../../../../usr/"$(get_libdir)"/"${SONAME}" /usr/"${libdir}"/libphobos2.so
 
 		# Install static lib if requested.


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-12-17 11:58 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-12-17 11:58 UTC (permalink / raw
  To: gentoo-commits

commit:     1bb2eb6ab240eec201a15cb78ed0fed2d7c6f9c3
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Thu Nov 30 19:13:46 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Sun Dec 10 21:53:34 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=1bb2eb6a

dlang.eclass: export PKG_CONFIG_* in phase functions

PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH will now be set to a list of the
the system pkg-config directories and the compiler specific one, allowing
packages that use build systems to easily find both their C and D
dependencies.

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

 eclass/dlang.eclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass
index 2817779..ab41b18 100644
--- a/eclass/dlang.eclass
+++ b/eclass/dlang.eclass
@@ -610,6 +610,17 @@ _dlang_use_build_vars() {
 	# The original value is exported as LIBDIR_HOST.
 	local libdir_var="LIBDIR_${ABI}"
 	export LIBDIR_HOST="${!libdir_var}"
+	# Save the default pkgconfig path
+	if [[ ! -v DLANG_SAVE_PKG_CONFIG_PATH ]]; then
+		# Copy the logic from meson.eclass for setting PKG_CONFIG_PATH
+		export DLANG_SAVE_PKG_CONFIG_PATH="${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}/usr/share/pkgconfig"
+	fi
+	if [[ ! -v DLANG_SAVE_PKG_CONFIG_LIBDIR ]]; then
+		# either save the value or provide a sane default lest other eclasses get confused.
+		# e.g. meson.eclass will set PKG_CONFIG_LIBDIR using $(get_libdir) which won't
+		# work properly since we will overwrite $LIBDIR_$ABI
+		export DLANG_SAVE_PKG_CONFIG_LIBDIR="${PKG_CONFIG_LIBDIR:-/usr/$(get_libdir)/pkgconfig}"
+	fi
 	export ABI="$(echo ${MULTIBUILD_VARIANT} | cut -d- -f1)"
 	export DC="$(echo ${MULTIBUILD_VARIANT} | cut -d- -f2)"
 	export DC_VERSION="$(echo ${MULTIBUILD_VARIANT} | cut -d- -f3)"
@@ -699,6 +710,13 @@ _dlang_use_build_vars() {
 		filter-ldflags -f{no-,}use-linker-plugin -f{no-,}lto -flto=*
 	fi
 	export LDFLAGS=`dlang_convert_ldflags`
+
+	# Add the compiler specific pkgconfig paths.
+	export PKG_CONFIG_PATH="${DLANG_SAVE_PKG_CONFIG_PATH}:/usr/$(get_libdir)/pkgconfig"
+	# Technically, this value will stay the same so it's enough to export it once
+	# but it's cleaner to keep these 2 variables close together.
+	export PKG_CONFIG_LIBDIR="${DLANG_SAVE_PKG_CONFIG_LIBDIR}"
+
 	"${@}"
 }
 


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-11-17 21:44 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2023-11-17 21:44 UTC (permalink / raw
  To: gentoo-commits

commit:     c606e7a45cdf790f9bf3947c97b1d78f545d829d
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Wed Oct 11 11:40:06 2023 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Fri Nov 17 20:54:08 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=c606e7a4

dlang.eclass: explicitly support EAPI 6, 7 and 8

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

 eclass/dlang.eclass | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass
index dc8d56e..385a458 100644
--- a/eclass/dlang.eclass
+++ b/eclass/dlang.eclass
@@ -1,6 +1,7 @@
 # @ECLASS: dlang.eclass
 # @MAINTAINER:
 # Marco Leise <marco.leise@gmx.de>
+# @SUPPORTED_EAPIS: 6 7 8
 # @BLURB: install D libraries in multiple locations for each D version and compiler
 # @DESCRIPTION:
 # The dlang eclass faciliates creating dependiencies on D libraries for use
@@ -32,12 +33,13 @@
 if [[ ${_ECLASS_ONCE_DLANG} != "recur -_+^+_- spank" ]] ; then
 _ECLASS_ONCE_DLANG="recur -_+^+_- spank"
 
-if has ${EAPI:-0} 0 1 2 3 4 5; then
-	die "EAPI must be >= 6 for dlang packages."
-fi
+case ${EAPI:-0} in
+	6) inherit eapi7-ver ;;
+	7|8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
 
 inherit flag-o-matic dlang-compilers
-test ${EAPI:-0} -lt 7 && inherit eapi7-ver
 if [[ "${DLANG_PACKAGE_TYPE}" == "multi" ]]; then
 	# We handle a multi instance package.
 	inherit multilib-minimal


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-11-17 21:44 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2023-11-17 21:44 UTC (permalink / raw
  To: gentoo-commits

commit:     aa4dca9af20224f56c25937f9f979ddba7ca8dac
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Wed Oct 11 10:05:12 2023 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Fri Nov 17 20:54:03 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=aa4dca9a

dmd.eclass: support EAPI 7 and 8

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

 eclass/dmd.eclass | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 0555f47..7d9e1f5 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -1,6 +1,7 @@
 # @ECLASS: dmd.eclass
 # @MAINTAINER:
 # Marco Leise <marco.leise@gmx.de>
+# @SUPPORTED_EAPIS: 6 7 8
 # @BLURB: Captures most of the logic for installing DMD
 # @DESCRIPTION:
 # Helps with the maintenance of the various DMD versions by capturing common
@@ -21,9 +22,11 @@
 if [[ ${_ECLASS_ONCE_DMD} != "recur -_+^+_- spank" ]] ; then
 _ECLASS_ONCE_DMD="recur -_+^+_- spank"
 
-if has ${EAPI:-0} 0 1 2 3 4 5; then
-	die "EAPI must be >= 6 for dmd packages."
-fi
+case ${EAPI:-0} in
+	6) inherit eapi7-ver ;;
+	7|8) ;;
+	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
 
 DESCRIPTION="Reference compiler for the D programming language"
 HOMEPAGE="http://dlang.org/"
@@ -32,7 +35,7 @@ HTML_DOCS="html/*"
 # DMD supports amd64/x86 exclusively
 MULTILIB_COMPAT=( abi_x86_{32,64} )
 
-inherit multilib-build eapi7-ver toolchain-funcs
+inherit desktop edos2unix multilib-build toolchain-funcs
 
 # @FUNCTION: dmd_eq
 # @DESCRIPTION:
@@ -271,7 +274,7 @@ EOF
 	einfo "Installing ${PN}..."
 	# From version 2.066 on, dmd will find dmd.conf in the executable directory, if we
 	# call it through a symlink in /usr/bin
-	dmd_ge 2.066 && dosym "../../${PREFIX}/bin/dmd" "${ROOT}/usr/bin/dmd-${SLOT}"
+	dmd_ge 2.066 && dosym "../../${PREFIX}/bin/dmd" "/usr/bin/dmd-${SLOT}"
 	into ${PREFIX}
 	dobin "$(dmd_gen_exe_dir)/dmd"
 
@@ -319,7 +322,7 @@ EOF
 		einstalldocs
 		insinto "/usr/share/doc/${PF}/html"
 		doins "${FILESDIR}/dmd-doc.png"
-		make_desktop_entry "xdg-open ${ROOT}usr/share/doc/${PF}/html/d/index.html" "DMD ${PV}" "${ROOT}usr/share/doc/${PF}/html/dmd-doc.png" "Development"
+		make_desktop_entry "xdg-open ${EPREFIX}/usr/share/doc/${PF}/html/d/index.html" "DMD ${PV}" "${EPREFIX}/usr/share/doc/${PF}/html/dmd-doc.png" "Development"
 	fi
 	if use examples; then
 		insinto ${PREFIX}/samples
@@ -330,14 +333,14 @@ EOF
 
 dmd_pkg_postinst() {
 	# Update active dmd
-	"${ROOT}"/usr/bin/eselect dlang update dmd
+	"${ROOT%/}"/usr/bin/eselect dlang update dmd
 
 	use examples && elog "Examples can be found in: /${PREFIX}/samples"
 	use doc && elog "HTML documentation is in: /usr/share/doc/${PF}/html"
 }
 
 dmd_pkg_postrm() {
-	"${ROOT}"/usr/bin/eselect dlang update dmd
+	"${ROOT%/}"/usr/bin/eselect dlang update dmd
 }
 
 dmd_foreach_abi() {


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-10-01 14:01 Horodniceanu Andrei
  0 siblings, 0 replies; 30+ messages in thread
From: Horodniceanu Andrei @ 2023-10-01 14:01 UTC (permalink / raw
  To: gentoo-commits

commit:     0ab16629adb5c8c8e4c19ebabcbb6368c78b985a
Author:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
AuthorDate: Sat Sep 30 06:42:31 2023 +0000
Commit:     Horodniceanu Andrei <a.horodniceanu <AT> proton <DOT> me>
CommitDate: Sun Oct  1 09:24:13 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=0ab16629

dmd.eclass: Support >=dmd-2.101

Since dmd-2.101 the dmd and druntime upstream repositories have merged
and paths need to be adjusted.

The download link needs to be changed as well as new releases are no
longer uploaded to aws.

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

 eclass/dmd.eclass | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 0333a2b..0555f47 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -53,7 +53,9 @@ dmd_ge() {
 # Returns the relative directory that the compiler executable will be found in. This directory is used both for
 # installing the binary as well as setting the compiler during compilation of druntime and Phobos.
 dmd_gen_exe_dir() {
-	if dmd_ge 2.074; then
+	if dmd_ge 2.101; then
+		echo generated/linux/release/$(dmd_arch_to_model)
+	elif dmd_ge 2.074; then
 		echo dmd/generated/linux/release/$(dmd_arch_to_model)
 	else
 		echo dmd/src
@@ -95,7 +97,12 @@ if [[ -n "${BETA}" ]]; then
 	# We want to convert a Gentoo version string to an upstream one: 2.097.0_rc1 -> 2.097.0-rc.1
 	SRC_URI="http://downloads.dlang.org/pre-releases/${MAJOR}.x/${VERSION}/${PN}.$(ver_rs 3 "-" 4 ".").${ARCHIVE}"
 else
-	SRC_URI="mirror://aws/${YEAR}/${PN}.${PV}.${ARCHIVE}"
+	# the aws mirrors work for <=dmd-2.100.2
+	if dmd_ge 2.101; then
+		SRC_URI="https://downloads.dlang.org/releases/${YEAR}/${PN}.${PV}.${ARCHIVE}"
+	else
+		SRC_URI="mirror://aws/${YEAR}/${PN}.${PV}.${ARCHIVE}"
+	fi
 fi
 
 COMMON_DEPEND="
@@ -121,6 +128,9 @@ dmd_src_prepare() {
 	mkdir dmd || die "Failed to create directories 'dmd', 'druntime' and 'phobos'"
 	mv src/dmd      dmd/src     || die "Failed to move 'src/dmd' to 'dmd/src'"
 	mv src/VERSION  dmd/VERSION || die "Failed to move 'src/VERSION' to 'dmd/VERSION'"
+	# >=dmd-2.101 expects the version file to be in the same directory as the dmd
+	# folder. i.e. VERSION should be in ${S} not in ${S}/dmd
+	ln -s dmd/VERSION VERSION   || die "Failed to symlink 'src/VERSION' to 'VERSION'"
 	mv src/druntime druntime    || die "Failed to move 'src/druntime' to 'druntime'"
 	mv src/phobos   phobos      || die "Failed to move 'src/phobos' to 'phobos'"
 	# Symlinks used by dmd in the selfhosting case
@@ -203,13 +213,14 @@ dmd_src_compile() {
 			MODEL="${MODEL}"
 			PIC=1
 			CC="$(tc-getCC)"
+			DMD_DIR=../dmd
 		)
 
 		einfo 'Building druntime...'
 		emake -C druntime -f posix.mak "${mymakeargs[@]}" MANIFEST=
 
 		einfo 'Building Phobos 2...'
-		emake -C phobos -f posix.mak "${mymakeargs[@]}" CUSTOM_DRUNTIME=1
+		emake -C phobos -f posix.mak "${mymakeargs[@]}" CUSTOM_DRUNTIME=1 DRUNTIME_PATH=../druntime
 	}
 
 	dmd_foreach_abi compile_libraries


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-09-28  4:56 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-09-28  4:56 UTC (permalink / raw
  To: gentoo-commits

commit:     e003cbcab41e39e82bfcf6bd3bb055c1a2bf2986
Author:     Horodniceanu Andrei <a.horodniceanu <AT> protonmail <DOT> com>
AuthorDate: Mon Sep  4 17:10:24 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Mon Sep  4 17:13:40 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=e003cbca

dmd.eclass: respect CC

Signed-off-by: Horodniceanu Andrei <a.horodniceanu <AT> protonmail.com>

 eclass/dmd.eclass | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index ad99b43..16f926a 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -194,11 +194,18 @@ dmd_src_compile() {
 	fi
 
 	compile_libraries() {
+		local mymakeargs=(
+			DMD="../$(dmd_gen_exe_dir)/dmd"
+			MODEL="${MODEL}"
+			PIC=1
+			CC="$(tc-getCC)"
+		)
+
 		einfo 'Building druntime...'
-		emake -C druntime -f posix.mak DMD="../$(dmd_gen_exe_dir)/dmd" MODEL=${MODEL} PIC=1 MANIFEST=
+		emake -C druntime -f posix.mak "${mymakeargs[@]}" MANIFEST=
 
 		einfo 'Building Phobos 2...'
-		emake -C phobos -f posix.mak DMD="../$(dmd_gen_exe_dir)/dmd" MODEL=${MODEL} PIC=1 CUSTOM_DRUNTIME=1
+		emake -C phobos -f posix.mak "${mymakeargs[@]}" CUSTOM_DRUNTIME=1
 	}
 
 	dmd_foreach_abi compile_libraries


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-09-28  4:56 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-09-28  4:56 UTC (permalink / raw
  To: gentoo-commits

commit:     52fbe825e5cd9252ce80e3297aebc9805ec5f57d
Author:     Horodniceanu Andrei <a.horodniceanu <AT> protonmail <DOT> com>
AuthorDate: Tue Jan 24 13:47:52 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Fri Sep  1 21:12:51 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=52fbe825

dmd.eclass: die if the build script fails

Signed-off-by: Horodniceanu Andrei <a.horodniceanu <AT> protonmail.com>

 eclass/dmd.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 008cbbf..ad99b43 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -181,7 +181,7 @@ dmd_src_compile() {
 		einfo "Building dmd build script..."
 		DC="${DMD}" dlang_compile_bin dmd/generated/build dmd/src/build.d
 		einfo "Building dmd..."
-		env VERBOSE=1 ${HOST_DMD}="${DMD}" CXX="$(tc-getCXX)" ${ENABLE_RELEASE}=1 ${LTO} dmd/generated/build DFLAGS="$(dlang_dmdw_dcflags)" dmd
+		env VERBOSE=1 ${HOST_DMD}="${DMD}" CXX="$(tc-getCXX)" ${ENABLE_RELEASE}=1 ${LTO} dmd/generated/build DFLAGS="$(dlang_dmdw_dcflags)" dmd || die
 	else
 		einfo "Building dmd..."
 		emake -C dmd/src -f posix.mak TARGET_CPU=X86 ${HOST_DMD}="${DMD}" ${HOST_CXX}="$(tc-getCXX)" ${ENABLE_RELEASE}=1 ${LTO}


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-09-28  4:56 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-09-28  4:56 UTC (permalink / raw
  To: gentoo-commits

commit:     c4612259e75b37bc013ce7adba21df5c86516a50
Author:     Horodniceanu Andrei <a.horodniceanu <AT> protonmail <DOT> com>
AuthorDate: Tue Jan 24 13:39:55 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Fri Sep  1 21:12:42 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=c4612259

dmd.eclass: Fix SRC_URI for beta and rc versions

Signed-off-by: Horodniceanu Andrei <a.horodniceanu <AT> protonmail.com>

 eclass/dmd.eclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 47fc51a..008cbbf 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -92,7 +92,8 @@ fi
 EXPORT_FUNCTIONS src_prepare src_compile src_test src_install pkg_postinst pkg_postrm
 
 if [[ -n "${BETA}" ]]; then
-	SRC_URI="http://downloads.dlang.org/pre-releases/${MAJOR}.x/${VERSION}/${PN}.${VERSION}-b${BETA:4}.${ARCHIVE}"
+	# We want to convert a Gentoo version string to an upstream one: 2.097.0_rc1 -> 2.097.0-rc.1
+	SRC_URI="http://downloads.dlang.org/pre-releases/${MAJOR}.x/${VERSION}/${PN}.$(ver_rs 3 "-" 4 ".").${ARCHIVE}"
 else
 	SRC_URI="mirror://aws/${YEAR}/${PN}.${PV}.${ARCHIVE}"
 fi


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-09-04 19:18 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-09-04 19:18 UTC (permalink / raw
  To: gentoo-commits

commit:     a1be7a24454f9e4985157de636f3fe61f29197b6
Author:     Horodniceanu Andrei <a.horodniceanu <AT> protonmail <DOT> com>
AuthorDate: Mon Aug 21 13:33:07 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Thu Aug 31 21:07:01 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=a1be7a24

dmd.eclass: Properly assign DC when not selfhosting

Signed-off-by: Horodniceanu Andrei <a.horodniceanu <AT> protonmail.com>

 eclass/dmd.eclass | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 47fc51a..e5129e8 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -159,7 +159,7 @@ dmd_src_compile() {
 	dmd_ge 2.081 && ENABLE_RELEASE="ENABLE_RELEASE" || ENABLE_RELEASE="RELEASE"
 
 	# Special case for self-hosting (i.e. no compiler USE flag selected).
-	local kernel model
+	local kernel model actual_compiler
 	if [ "${DC_VERSION}" == "selfhost" ]; then
 		case "${KERNEL}" in
 			"linux")   kernel="linux";;
@@ -175,10 +175,14 @@ dmd_src_compile() {
 		if ! dmd_ge 2.094; then
 			export DMD="../../${DMD}"
 		fi
+		actual_compiler="${S}/${DMD}"
+	else
+		# Not selfhosting, leave the compiler variable unchanged
+		actual_compiler="${DC}"
 	fi
 	if dmd_ge 2.094; then
 		einfo "Building dmd build script..."
-		DC="${DMD}" dlang_compile_bin dmd/generated/build dmd/src/build.d
+		DC="${actual_compiler}" dlang_compile_bin dmd/generated/build dmd/src/build.d
 		einfo "Building dmd..."
 		env VERBOSE=1 ${HOST_DMD}="${DMD}" CXX="$(tc-getCXX)" ${ENABLE_RELEASE}=1 ${LTO} dmd/generated/build DFLAGS="$(dlang_dmdw_dcflags)" dmd
 	else


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-08-15  2:32 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-08-15  2:32 UTC (permalink / raw
  To: gentoo-commits

commit:     2adabe76d14583809ed58fceec03bdee9d4a194a
Author:     Horodniceanu Andrei <a.horodniceanu <AT> protonmail <DOT> com>
AuthorDate: Thu Aug 10 06:13:24 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Thu Aug 10 06:16:13 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=2adabe76

dmd.eclass: specify compiler path when selfhosting

Signed-off-by: Horodniceanu Andrei <a.horodniceanu <AT> protonmail.com>

 eclass/dmd.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index f972961..47fc51a 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -178,7 +178,7 @@ dmd_src_compile() {
 	fi
 	if dmd_ge 2.094; then
 		einfo "Building dmd build script..."
-		dlang_compile_bin dmd/generated/build dmd/src/build.d
+		DC="${DMD}" dlang_compile_bin dmd/generated/build dmd/src/build.d
 		einfo "Building dmd..."
 		env VERBOSE=1 ${HOST_DMD}="${DMD}" CXX="$(tc-getCXX)" ${ENABLE_RELEASE}=1 ${LTO} dmd/generated/build DFLAGS="$(dlang_dmdw_dcflags)" dmd
 	else


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-07-22 14:13 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-07-22 14:13 UTC (permalink / raw
  To: gentoo-commits

commit:     1d86b0bbaccf420383f7e38fba23b82bc07334ff
Author:     Marco Leise <marco.leise <AT> gmx <DOT> de>
AuthorDate: Sat Jul 22 12:39:43 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Sat Jul 22 12:47:42 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=1d86b0bb

Fixed pkgcheck EclassReservedName errors, mostly symbols starting with two underscores.

Signed-off-by: Marco Leise <marco.leise <AT> gmx.de>

 eclass/dlang-compilers.eclass |  16 ++---
 eclass/dlang.eclass           | 136 +++++++++++++++++++++---------------------
 eclass/dmd.eclass             |   4 +-
 3 files changed, 78 insertions(+), 78 deletions(-)

diff --git a/eclass/dlang-compilers.eclass b/eclass/dlang-compilers.eclass
index a42496b..5d1c924 100644
--- a/eclass/dlang-compilers.eclass
+++ b/eclass/dlang-compilers.eclass
@@ -5,16 +5,16 @@
 # @DESCRIPTION:
 # Contains the available D compiler versions with their stable archs.
 
-if [[ ${___ECLASS_ONCE_DLANG_COMPILERS} != "recur -_+^+_- spank" ]] ; then
-___ECLASS_ONCE_DLANG_COMPILERS="recur -_+^+_- spank"
+if [[ ${_ECLASS_ONCE_DLANG_COMPILERS} != "recur -_+^+_- spank" ]] ; then
+_ECLASS_ONCE_DLANG_COMPILERS="recur -_+^+_- spank"
 
 dlang-compilers_declare_versions() {
-	declare -gA __dlang_dmd_frontend
-	declare -gA __dlang_gdc_frontend
-	declare -gA __dlang_ldc2_frontend
+	declare -gA _dlang_dmd_frontend
+	declare -gA _dlang_gdc_frontend
+	declare -gA _dlang_ldc2_frontend
 
 	# DMD
-	__dlang_dmd_frontend=(
+	_dlang_dmd_frontend=(
 		["2.064"]="2.064 x86 amd64"
 		["2.065"]="2.065 x86 amd64"
 		["2.066"]="2.066 x86 amd64"
@@ -54,7 +54,7 @@ dlang-compilers_declare_versions() {
 	)
 
 	# GDC (hppa, sparc: masked "d" USE-flag)
-	__dlang_gdc_frontend=(
+	_dlang_gdc_frontend=(
 		["11.3.1_p20221209"]="2.076 ~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
 		["11.3.1_p20230120"]="2.076 ~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
 		["11.3.1_p20230303"]="2.076 ~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
@@ -63,7 +63,7 @@ dlang-compilers_declare_versions() {
 	)
 
 	# LDC
-	__dlang_ldc2_frontend=(
+	_dlang_ldc2_frontend=(
 		["1.29"]="2.099 amd64 ~arm ~arm64 ~ppc64 x86"
 		["1.30"]="2.100 ~amd64 ~arm ~arm64 ~ppc64 ~x86"
 	)

diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass
index f9f8072..751dde4 100644
--- a/eclass/dlang.eclass
+++ b/eclass/dlang.eclass
@@ -20,8 +20,8 @@
 # and RDEPEND for Dlang compilers based on above variables. The ebuild is responsible
 # for providing them as required by the function it uses from this eclass.
 
-if [[ ${___ECLASS_ONCE_DLANG} != "recur -_+^+_- spank" ]] ; then
-___ECLASS_ONCE_DLANG="recur -_+^+_- spank"
+if [[ ${_ECLASS_ONCE_DLANG} != "recur -_+^+_- spank" ]] ; then
+_ECLASS_ONCE_DLANG="recur -_+^+_- spank"
 
 if has ${EAPI:-0} 0 1 2 3 4 5; then
 	die "EAPI must be >= 6 for dlang packages."
@@ -71,7 +71,7 @@ dlang-compilers_declare_versions
 dlang_foreach_config() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local MULTIBUILD_VARIANTS=($(__dlang_build_configurations))
+	local MULTIBUILD_VARIANTS=($(_dlang_build_configurations))
 
 	multibuild_wrapper() {
 		debug-print-function ${FUNCNAME} "${@}"
@@ -79,17 +79,17 @@ dlang_foreach_config() {
 		# We need to reset CC, else when dmd calls it, the result is:
 		# "x86_64-pc-linux-gnu-gcc -m32": No such file or directory
 		if [[ -v CC ]]; then
-			local __ORIGINAL_CC="${CC}"
+			local _ORIGINAL_CC="${CC}"
 		fi
 		multilib_toolchain_setup "${ABI}"
-		if [[ -v __ORIGINAL_CC ]]; then
-			CC="${__ORIGINAL_CC}"
+		if [[ -v _ORIGINAL_CC ]]; then
+			CC="${_ORIGINAL_CC}"
 		else
 			unset CC
 		fi
 		mkdir -p "${BUILD_DIR}" || die
 		pushd "${BUILD_DIR}" >/dev/null || die
-		__dlang_use_build_vars "${@}"
+		_dlang_use_build_vars "${@}"
 		popd >/dev/null || die
 	}
 
@@ -101,9 +101,9 @@ export DLANG_IMPORT_DIR="usr/include/dlang"
 dlang_single_config() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local MULTIBUILD_VARIANT=$(__dlang_build_configurations)
+	local MULTIBUILD_VARIANT=$(_dlang_build_configurations)
 
-	__dlang_use_build_vars "${@}"
+	_dlang_use_build_vars "${@}"
 }
 
 
@@ -116,25 +116,25 @@ dlang_src_prepare() {
 	default_src_prepare
 
 	if [[ "${DLANG_PACKAGE_TYPE}" == "multi" ]]; then
-		local MULTIBUILD_VARIANTS=($(__dlang_build_configurations))
+		local MULTIBUILD_VARIANTS=($(_dlang_build_configurations))
 		multibuild_copy_sources
 	fi
 }
 
 dlang_src_configure() {
-	__dlang_phase_wrapper configure
+	_dlang_phase_wrapper configure
 }
 
 dlang_src_compile() {
-	__dlang_phase_wrapper compile
+	_dlang_phase_wrapper compile
 }
 
 dlang_src_test() {
-	__dlang_phase_wrapper test
+	_dlang_phase_wrapper test
 }
 
 dlang_src_install() {
-	__dlang_phase_wrapper install
+	_dlang_phase_wrapper install
 }
 
 
@@ -164,7 +164,7 @@ dlang_compile_bin() {
 	local binname="${1}"
 	local sources="${@:2}"
 
-	dlang_exec ${DC} ${DCFLAGS} ${sources} $(__dlang_additional_flags) \
+	dlang_exec ${DC} ${DCFLAGS} ${sources} $(_dlang_additional_flags) \
 		${LDFLAGS} ${DLANG_OUTPUT_FLAG}${binname}
 }
 
@@ -183,7 +183,7 @@ dlang_compile_lib_a() {
 	if [[ "${DLANG_PACKAGE_TYPE}" == "multi" ]]; then
 		DCFLAGS="${DCFLAGS} -m${MODEL}"
 	fi
-	dlang_exec ${DC} ${DCFLAGS} ${sources} $(__dlang_additional_flags) \
+	dlang_exec ${DC} ${DCFLAGS} ${sources} $(_dlang_additional_flags) \
 		${LDFLAGS} ${DLANG_A_FLAGS} ${DLANG_OUTPUT_FLAG}${libname}
 }
 
@@ -198,7 +198,7 @@ dlang_compile_lib_so() {
 	local soname="${2}"
 	local sources="${@:3}"
 
-	dlang_exec ${DC} ${DCFLAGS} -m${MODEL} ${sources} $(__dlang_additional_flags) \
+	dlang_exec ${DC} ${DCFLAGS} -m${MODEL} ${sources} $(_dlang_additional_flags) \
 		${LDFLAGS} ${DLANG_SO_FLAGS} ${DLANG_LINKER_FLAG}-soname=${soname} \
 		${DLANG_OUTPUT_FLAG}${libname}
 }
@@ -292,21 +292,21 @@ dlang_system_imports() {
 dlang_phobos_level() {
 	if [ -z "$DLANG_VERSION" ]; then
 		[ "$DLANG_PACKAGE_TYPE" != "multi" ] || die "'dlang_phobos_level' needs 'DLANG_PACKAGE_TYPE != multi' when called outside of compiles."
-		local config=`__dlang_build_configurations`
+		local config=`_dlang_build_configurations`
 		local dc="$(echo ${config} | cut -d- -f2)"
 		local dc_version="$(echo ${config} | cut -d- -f3)"
-		local DLANG_VERSION="$(__dlang_compiler_to_dlang_version ${dc} ${dc_version})"
+		local DLANG_VERSION="$(_dlang_compiler_to_dlang_version ${dc} ${dc_version})"
 	fi
 	ver_test "$DLANG_VERSION" -ge "$1"
 }
 
 ### Non-public helper functions ###
 
-declare -a __dlang_compiler_iuse
-declare -a __dlang_compiler_iuse_mask
-declare -a __dlang_depends
+declare -a _dlang_compiler_iuse
+declare -a _dlang_compiler_iuse_mask
+declare -a _dlang_depends
 
-__dlang_compiler_masked_archs_for_version_range() {
+_dlang_compiler_masked_archs_for_version_range() {
 	# Given a Dlang compiler represented through an IUSE flag (e.g. "ldc2-1_1")
 	# and DEPEND atom (e.g. "dev-lang/ldc2:1.1="), this function tests if the
 	# current ebuild can depend and thus be compiled with that compiler on
@@ -315,12 +315,12 @@ __dlang_compiler_masked_archs_for_version_range() {
 	# architectures, is dropped completely. A compiler that disqualifies
 	# for only some, but not all architectures, on the other hand, is disabled
 	# though REQUIRED_USE (e.g. "!amd64? ( ldc2-1_1? ( dev-lang/ldc2:1.1= ) )").
-	# Available compilers are accumulated in the __dlang_compiler_iuse array,
+	# Available compilers are accumulated in the _dlang_compiler_iuse array,
 	# which is later turned into the IUSE variable.
 	# Partially available compilers are additionally masked out for particular
-	# architectures by adding them to the __dlang_compiler_iuse_mask array,
+	# architectures by adding them to the _dlang_compiler_iuse_mask array,
 	# which is later appended to REQUIRED_USE.
-	# Finally, the __dlang_depends array receives the USE-flag enabled
+	# Finally, the _dlang_depends array receives the USE-flag enabled
 	# dependencies on Dlang compilers, which is later turned into DEPEND and
 	# RDEPEND.
 
@@ -344,16 +344,16 @@ __dlang_compiler_masked_archs_for_version_range() {
 	fi
 
 	# Check the stability requirements
-	local ebuild_stab comp_stab=0 have_one=0
+	local package_stab comp_stab=0 have_one=0
 	for package_keyword in $KEYWORDS; do
 		if [ "${package_keyword:0:1}" == "-" ]; then
 			# Skip "-arch" and "-*"
 			continue
 		elif [ "${package_keyword:0:1}" == "~" ]; then
-			ebuild_stab=1
+			package_stab=1
 			arch=${package_keyword:1}
 		else
-			ebuild_stab=2
+			package_stab=2
 			arch=$package_keyword
 		fi
 
@@ -365,7 +365,7 @@ __dlang_compiler_masked_archs_for_version_range() {
 				comp_stab=2
 			fi
 		done
-		if [ $comp_stab -lt $ebuild_stab ]; then
+		if [ $comp_stab -lt $package_stab ]; then
 			masked_archs+=( $arch )
 		fi
 		if [ $comp_stab -gt 0 ]; then
@@ -374,28 +374,28 @@ __dlang_compiler_masked_archs_for_version_range() {
 	done
 	[ $have_one -eq 0 ] && return 1
 
-	__dlang_compiler_iuse+=( $iuse )
+	_dlang_compiler_iuse+=( $iuse )
 	if [ "${#masked_archs[@]}" -ne 0 ]; then
 		for arch in ${masked_archs[@]}; do
-			__dlang_compiler_iuse_mask+=( "${arch}? ( !${iuse} )" )
+			_dlang_compiler_iuse_mask+=( "${arch}? ( !${iuse} )" )
 			depend="!${arch}? ( ${depend} )"
 		done
 	fi
-	__dlang_depends+=( "$depend" )
+	_dlang_depends+=( "$depend" )
 }
 
-__dlang_filter_compilers() {
+_dlang_filter_compilers() {
 	# Given a range of Dlang front-end version that the current ebuild can be built with,
 	# this function goes through each compatible Dlang compilers as provided by the file
-	# dlang-compilers.eclass and then calls __dlang_compiler_masked_archs_for_version_range
+	# dlang-compilers.eclass and then calls _dlang_compiler_masked_archs_for_version_range
 	# where they will be further scrutinized for architecture stability requirements and
 	# then either dropped as option or partially masked.
 
 	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}]}"
+	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}]"
@@ -403,20 +403,20 @@ __dlang_filter_compilers() {
 			depend=""
 		fi
 		depend="dev-lang/dmd:$dc_version=$depend"
-		__dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2"
+		_dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2"
 	done
 
 	# 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}]}"
+	for dc_version in "${!_dlang_gdc_frontend[@]}"; do
+		mapping="${_dlang_gdc_frontend[${dc_version}]}"
 		iuse=gdc-$(ver_rs 1-2 _ $dc_version)
 		depend="~sys-devel/gcc-$dc_version[d,-d-bootstrap(-)]"
-		__dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2"
+		_dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2"
 	done
 
 	# filter for LDC2
-	for dc_version in "${!__dlang_ldc2_frontend[@]}"; do
-		mapping="${__dlang_ldc2_frontend[${dc_version}]}"
+	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}]"
@@ -424,11 +424,11 @@ __dlang_filter_compilers() {
 			depend=""
 		fi
 		depend="dev-lang/ldc2:$dc_version=$depend"
-		__dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2"
+		_dlang_compiler_masked_archs_for_version_range "$iuse" "$depend" "$mapping" "$1" "$2"
 	done
 }
 
-__dlang_filter_versions() {
+_dlang_filter_versions() {
 	# This function sets up the preliminary REQUIRED_USE, DEPEND and RDEPEND ebuild
 	# variables with compiler requirements for the current ebuild.
 	# If DLANG_VERSION_RANGE is set in the ebuild, this variable will be parsed to
@@ -457,38 +457,38 @@ __dlang_filter_versions() {
 				start="${range}"
 				stop="${range}"
 			fi
-			__dlang_filter_compilers "$start" "$stop"
+			_dlang_filter_compilers "$start" "$stop"
 		done
 	else
-		__dlang_filter_compilers "" ""
+		_dlang_filter_compilers "" ""
 	fi
 
-	[ ${#__dlang_compiler_iuse[@]} -eq 0 ] && die "No Dlang compilers found that satisfy this package's version range: $DLANG_VERSION_RANGE"
+	[ ${#_dlang_compiler_iuse[@]} -eq 0 ] && die "No Dlang compilers found that satisfy this package's version range: $DLANG_VERSION_RANGE"
 
 	if [ "${DLANG_PACKAGE_TYPE}" != "multi" ]; then
 		REQUIRED_USE="^^"
 	else
 		REQUIRED_USE="||"
 	fi
-	DEPEND="${__dlang_depends[@]}"
+	DEPEND="${_dlang_depends[@]}"
 	# DMD, is statically linked and does not have its host compiler as a runtime dependency.
 	if [ "${DLANG_PACKAGE_TYPE}" == "dmd" ]; then
-		IUSE="${__dlang_compiler_iuse[@]} +selfhost"
-		__dlang_compiler_iuse+=( selfhost )
+		IUSE="${_dlang_compiler_iuse[@]} +selfhost"
+		_dlang_compiler_iuse+=( selfhost )
 	else
 		RDEPEND="$DEPEND"
-		IUSE="${__dlang_compiler_iuse[@]}"
+		IUSE="${_dlang_compiler_iuse[@]}"
 	fi
-	REQUIRED_USE="${REQUIRED_USE} ( ${__dlang_compiler_iuse[@]} ) ${__dlang_compiler_iuse_mask[@]}"
+	REQUIRED_USE="${REQUIRED_USE} ( ${_dlang_compiler_iuse[@]} ) ${_dlang_compiler_iuse_mask[@]}"
 
 	local -a compiler
-	for compiler in ${__dlang_compiler_iuse[@]}; do
+	for compiler in ${_dlang_compiler_iuse[@]}; do
 		DLANG_COMPILER_USE="${DLANG_COMPILER_USE}${compiler}?,"
 	done
 	DLANG_COMPILER_USE="${DLANG_COMPILER_USE:0:-1}"
 }
 
-__dlang_phase_wrapper() {
+_dlang_phase_wrapper() {
 	dlang_phase() {
 		if declare -f d_src_${1} >/dev/null ; then
 			d_src_${1}
@@ -508,24 +508,24 @@ __dlang_phase_wrapper() {
 	fi
 }
 
-__dlang_compiler_to_dlang_version() {
+_dlang_compiler_to_dlang_version() {
 	local mapping
 	case "$1" in
 		"dmd")
 			mapping="$2"
 		;;
 		"gdc")
-			mapping=`echo ${__dlang_gdc_frontend[$2]} | cut -f 1 -d " "`
+			mapping=`echo ${_dlang_gdc_frontend[$2]} | cut -f 1 -d " "`
 		;;
 		"ldc2")
-			mapping=`echo ${__dlang_ldc2_frontend[$2]} | cut -f 1 -d " "`
+			mapping=`echo ${_dlang_ldc2_frontend[$2]} | cut -f 1 -d " "`
 		;;
 	esac
 	[ -n "${mapping}" ] || die "Could not retrieve dlang version for '$1-$2'."
 	echo "${mapping}"
 }
 
-__dlang_build_configurations() {
+_dlang_build_configurations() {
 	local variants version_component use_flag use_flags
 
 	if [ -z ${DLANG_USE_COMPILER+x} ]; then
@@ -574,7 +574,7 @@ __dlang_build_configurations() {
 	echo ${variants}
 }
 
-__dlang_use_build_vars() {
+_dlang_use_build_vars() {
 	# Now we define some variables and then call the function.
 	# LIBDIR_${ABI} is used by the dolib.* functions, that's why we override it per compiler.
 	# The original value is exported as LIBDIR_HOST.
@@ -588,7 +588,7 @@ __dlang_use_build_vars() {
 		"gdc") export DLANG_VENDOR="GNU" ;;
 		"ldc") export DLANG_VENDOR="LDC" ;;
 	esac
-	export DLANG_VERSION="$(__dlang_compiler_to_dlang_version ${DC} ${DC_VERSION})"
+	export DLANG_VERSION="$(_dlang_compiler_to_dlang_version ${DC} ${DC_VERSION})"
 	case "${ABI}" in
 		"default") ;;
 		"x86"*)    export MODEL=32 ;;
@@ -667,13 +667,13 @@ __dlang_use_build_vars() {
 	"${@}"
 }
 
-__dlang_prefix_words() {
+_dlang_prefix_words() {
 	for arg in ${*:2}; do
 		echo -n " $1$arg"
 	done
 }
 
-__dlang_additional_flags() {
+_dlang_additional_flags() {
 	# For info on debug use flags see:
 	# https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces#debug_USE_flag
 	case "${DLANG_VENDOR}" in
@@ -694,15 +694,15 @@ __dlang_additional_flags() {
 			;;
 	esac
 	echo $(has debug ${IUSE} && use debug && echo ${debug_flags})\
-		$(__dlang_prefix_words "${DLANG_VERSION_FLAG}=" $versions)\
-		$(__dlang_prefix_words $import_prefix $imports)\
-		$(__dlang_prefix_words $string_import_prefix $string_imports)\
-		$(__dlang_prefix_words "${DLANG_LINKER_FLAG}-l" $libs)
+		$(_dlang_prefix_words "${DLANG_VERSION_FLAG}=" $versions)\
+		$(_dlang_prefix_words $import_prefix $imports)\
+		$(_dlang_prefix_words $string_import_prefix $string_imports)\
+		$(_dlang_prefix_words "${DLANG_LINKER_FLAG}-l" $libs)
 }
 
 # 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
+	set -f; _dlang_filter_versions; set +f
 fi
 
 fi

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index c9b3adf..15770c1 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -6,8 +6,8 @@
 # Helps with the maintenance of the various DMD versions by capturing common
 # logic.
 
-if [[ ${___ECLASS_ONCE_DMD} != "recur -_+^+_- spank" ]] ; then
-___ECLASS_ONCE_DMD="recur -_+^+_- spank"
+if [[ ${_ECLASS_ONCE_DMD} != "recur -_+^+_- spank" ]] ; then
+_ECLASS_ONCE_DMD="recur -_+^+_- spank"
 
 if has ${EAPI:-0} 0 1 2 3 4 5; then
 	die "EAPI must be >= 6 for dmd packages."


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2023-07-22 11:46 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2023-07-22 11:46 UTC (permalink / raw
  To: gentoo-commits

commit:     140bf7a1cb7eae744bc7a12485e89304548b2e00
Author:     Marco Leise <marco.leise <AT> gmx <DOT> de>
AuthorDate: Sat Jul 22 11:35:13 2023 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Sat Jul 22 11:35:13 2023 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=140bf7a1

pkgcheck: Fixed @MAINTAINER paragraphs formatting.

Signed-off-by: Marco Leise <marco.leise <AT> gmx.de>

 eclass/dlang-compilers.eclass | 3 ++-
 eclass/dlang.eclass           | 3 ++-
 eclass/dmd.eclass             | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/eclass/dlang-compilers.eclass b/eclass/dlang-compilers.eclass
index a872872..6882c16 100644
--- a/eclass/dlang-compilers.eclass
+++ b/eclass/dlang-compilers.eclass
@@ -1,5 +1,6 @@
 # @ECLASS: dlang-compilers.eclass
-# @MAINTAINER: marco.leise@gmx.de
+# @MAINTAINER:
+# Marco Leise <marco.leise@gmx.de>
 # @BLURB: Support data for dlang.eclass
 # @DESCRIPTION:
 # Contains the available D compiler versions with their stable archs.

diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass
index 5c86088..0d313db 100644
--- a/eclass/dlang.eclass
+++ b/eclass/dlang.eclass
@@ -1,5 +1,6 @@
 # @ECLASS: dlang.eclass
-# @MAINTAINER: marco.leise@gmx.de
+# @MAINTAINER:
+# Marco Leise <marco.leise@gmx.de>
 # @BLURB: install D libraries in multiple locations for each D version and compiler
 # @DESCRIPTION:
 # The dlang eclass faciliates creating dependiencies on D libraries for use

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 55f62e8..c9b3adf 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -1,5 +1,6 @@
 # @ECLASS: dmd.eclass
-# @MAINTAINER: marco.leise@gmx.de
+# @MAINTAINER:
+# Marco Leise <marco.leise@gmx.de>
 # @BLURB: Captures most of the logic for installing DMD
 # @DESCRIPTION:
 # Helps with the maintenance of the various DMD versions by capturing common


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2022-07-23 12:24 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2022-07-23 12:24 UTC (permalink / raw
  To: gentoo-commits

commit:     675421df42f5689e496af2b54dd2b20c2804af3a
Author:     Horodniceanu Andrei <a.horodniceanu <AT> protonmail <DOT> com>
AuthorDate: Fri Jul 22 11:20:23 2022 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Fri Jul 22 11:20:23 2022 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=675421df

Improve dmd.eclass support for gdc

Signed-off-by: Horodniceanu Andrei <a.horodniceanu <AT> protonmail.com>

 eclass/dlang.eclass | 31 +++++++++++++++++++++++++++++++
 eclass/dmd.eclass   |  6 ++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass
index 80dea3a..5c86088 100644
--- a/eclass/dlang.eclass
+++ b/eclass/dlang.eclass
@@ -234,6 +234,37 @@ dlang_convert_ldflags() {
 	fi
 }
 
+# @FUNCTION: dlang_dmdw_dcflags
+# @DESCRIPTION:
+# Convertes compiler specific $DCFLAGS to something that can be passed to the
+# dmd wrapper of said compiler. Calls `die` if the flags could not be
+# converted.
+dlang_dmdw_dcflags() {
+	if [[ "${DLANG_VENDOR}" == "DigitalMars" ]]; then
+		# There's no translation that needs to be done.
+		echo "${DCFLAGS}"
+	elif [[ "${DLANG_VENDOR}" == "LDC" ]]; then
+		# ldmd2 passes all the arguments that it doesn't understand to ldc2.
+		echo "${DCFLAGS}"
+	elif [[ "${DLANG_VENDOR}" == "GNU" ]]; then
+		# From `gdmd --help`:   -q,arg1,...    pass arg1, arg2, etc. to gdc
+		if [[ "${DCFLAGS}" =~ .*,.* ]]; then
+			eerror "DCFLAGS (${DCFLAGS}) contain a comma and can not be passed to gdmd."
+			eerror "Please remove the comma, use a different compiler, or call gdc directly."
+			die "DCFLAGS contain an unconvertable comma."
+		fi
+
+		local set flags=()
+		for set in ${DCFLAGS}; do
+			flags+=("-q,${set}")
+		done
+		echo "${flags[@]}"
+	else
+		die "Set DLANG_VENDOR to DigitalMars, LDC or GNU prior to calling ${FUNCNAME}()."
+	fi
+}
+
+
 # @FUNCTION: dlang_system_imports
 # @DESCRIPTION:
 # Returns a list of standard system import paths (one per line) for the current

diff --git a/eclass/dmd.eclass b/eclass/dmd.eclass
index 3215f00..55f62e8 100644
--- a/eclass/dmd.eclass
+++ b/eclass/dmd.eclass
@@ -103,6 +103,8 @@ dmd_src_prepare() {
 	ln -s ../druntime src/druntime || die "Failed to symlink 'druntime' to 'src/druntime'"
 	ln -s ../phobos   src/phobos   || die "Failed to symlink 'phobos' to 'src/phobos'"
 
+	mkdir dmd/generated || die "Could not create output directory"
+
 	# Convert line-endings of file-types that start as cr-lf and are installed later on
 	for file in $( find . -name "*.txt" -o -name "*.html" -o -name "*.d" -o -name "*.di" -o -name "*.ddoc" -type f ); do
 		edos2unix $file || die "Failed to convert DOS line-endings to Unix."
@@ -153,9 +155,9 @@ dmd_src_compile() {
 	fi
 	if dmd_ge 2.094; then
 		einfo "Building dmd build script..."
-		DC="${DMD}" dlang_compile_bin dmd/generated/build dmd/src/build.d
+		dlang_compile_bin dmd/generated/build dmd/src/build.d
 		einfo "Building dmd..."
-		env VERBOSE=1 ${HOST_DMD}="${DMD}" CXX="$(tc-getCXX)" ${ENABLE_RELEASE}=1 ${LTO} dmd/generated/build dmd
+		env VERBOSE=1 ${HOST_DMD}="${DMD}" CXX="$(tc-getCXX)" ${ENABLE_RELEASE}=1 ${LTO} dmd/generated/build DFLAGS="$(dlang_dmdw_dcflags)" dmd
 	else
 		einfo "Building dmd..."
 		emake -C dmd/src -f posix.mak TARGET_CPU=X86 ${HOST_DMD}="${DMD}" ${HOST_CXX}="$(tc-getCXX)" ${ENABLE_RELEASE}=1 ${LTO}


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [gentoo-commits] repo/user/dlang:master commit in: eclass/
@ 2020-08-15  1:50 Marco Leise
  0 siblings, 0 replies; 30+ messages in thread
From: Marco Leise @ 2020-08-15  1:50 UTC (permalink / raw
  To: gentoo-commits

commit:     be92bd625289f6c2167917761dd4690cc62986d0
Author:     Marco Leise <marco.leise <AT> gmx <DOT> de>
AuthorDate: Fri Aug 14 19:59:19 2020 +0000
Commit:     Marco Leise <marco.leise <AT> gmx <DOT> de>
CommitDate: Sat Aug 15 01:34:45 2020 +0000
URL:        https://gitweb.gentoo.org/repo/user/dlang.git/commit/?id=be92bd62

Fixed an issue where ldc2 would not build with dmd, because "-Wl,--icf=safe" wasn't correctly filtered out of LDFLAGS if set.

Signed-off-by: Marco Leise <marco.leise <AT> gmx.de>

 eclass/dlang.eclass | 37 ++++++++++++++++++-------------------
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/eclass/dlang.eclass b/eclass/dlang.eclass
index a8a4ace..80dea3a 100644
--- a/eclass/dlang.eclass
+++ b/eclass/dlang.eclass
@@ -207,25 +207,6 @@ dlang_compile_lib_so() {
 # Makes linker flags meant for GCC understandable for the current D compiler.
 # Basically it replaces -L with what the D compiler uses as linker prefix.
 dlang_convert_ldflags() {
-	if [[ "${DLANG_VENDOR}" == "DigitalMars" ]]; then
-		# gc-sections breaks executables for some versions of D
-		# It works with the gold linker on the other hand
-		# See: https://issues.dlang.org/show_bug.cgi?id=879
-		[[ "${DLANG_PACKAGE_TYPE}" == "dmd" ]] && local dlang_version=$SLOT || local dlang_version=$DLANG_VERSION
-		if ver_test $dlang_version -lt 2.072; then
-			if ! ld -v | grep -q "^GNU gold"; then
-				filter-ldflags {-L,-Xlinker,-Wl,}--gc-sections
-			fi
-		fi
-		# Filter ld.gold ICF flag. (https://issues.dlang.org/show_bug.cgi?id=17515)
-		filter-ldflags {-L,-Xlinker,-Wl,}--icf={none,all,safe}
-	fi
-
-	if [[ "${DLANG_VENDOR}" == "DigitalMars" ]] || [[ "${DLANG_VENDOR}" == "GNU" ]]; then
-		# DMD and GDC don't undestand/work with LTO flags
-		filter-ldflags -f{no-,}use-linker-plugin -f{no-,}lto -flto=*
-	fi
-
 	if [[ "${DLANG_VENDOR}" == "DigitalMars" ]] || [[ "${DLANG_VENDOR}" == "LDC" ]]; then
 		local set prefix flags=()
 		if [[ is_dmd ]]; then
@@ -613,6 +594,24 @@ __dlang_use_build_vars() {
 		die "Could not detect D compiler vendor!"
 	fi
 	# We need to convert the LDFLAGS, so they are understood by DMD and LDC.
+	if [[ "${DLANG_VENDOR}" == "DigitalMars" ]]; then
+		# gc-sections breaks executables for some versions of D
+		# It works with the gold linker on the other hand
+		# See: https://issues.dlang.org/show_bug.cgi?id=879
+		[[ "${DLANG_PACKAGE_TYPE}" == "dmd" ]] && local dlang_version=$SLOT || local dlang_version=$DLANG_VERSION
+		if ver_test $dlang_version -lt 2.072; then
+			if ! ld -v | grep -q "^GNU gold"; then
+				filter-flags {-L,-Xlinker,-Wl\,}--gc-sections
+			fi
+		fi
+		# Filter ld.gold ICF flag. (https://issues.dlang.org/show_bug.cgi?id=17515)
+		filter-flags {-L,-Xlinker,-Wl\,}--icf={none,all,safe}
+	fi
+
+	if [[ "${DLANG_VENDOR}" == "DigitalMars" ]] || [[ "${DLANG_VENDOR}" == "GNU" ]]; then
+		# DMD and GDC don't undestand/work with LTO flags
+		filter-ldflags -f{no-,}use-linker-plugin -f{no-,}lto -flto=*
+	fi
 	export LDFLAGS=`dlang_convert_ldflags`
 	"${@}"
 }


^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2024-08-30  7:58 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-22 14:13 [gentoo-commits] repo/user/dlang:master commit in: eclass/ Marco Leise
  -- strict thread matches above, loose matches on Subject: below --
2024-08-30  7:58 Horodniceanu Andrei
2024-07-14 19:44 Horodniceanu Andrei
2024-07-12 18:59 Horodniceanu Andrei
2024-07-12 18:59 Horodniceanu Andrei
2024-07-12 18:59 Horodniceanu Andrei
2024-04-26 20:25 Horodniceanu Andrei
2024-04-22 20:03 Horodniceanu Andrei
2024-04-13 23:04 Horodniceanu Andrei
2024-04-13 23:04 Horodniceanu Andrei
2024-04-13 23:04 Horodniceanu Andrei
2024-04-13 23:04 Horodniceanu Andrei
2024-02-20 17:54 Horodniceanu Andrei
2024-02-18 22:49 Horodniceanu Andrei
2024-02-18 22:49 Horodniceanu Andrei
2023-12-17 11:58 Marco Leise
2023-12-17 11:58 Marco Leise
2023-12-17 11:58 Marco Leise
2023-11-17 21:44 Horodniceanu Andrei
2023-11-17 21:44 Horodniceanu Andrei
2023-10-01 14:01 Horodniceanu Andrei
2023-09-28  4:56 Marco Leise
2023-09-28  4:56 Marco Leise
2023-09-28  4:56 Marco Leise
2023-09-04 19:18 Marco Leise
2023-08-15  2:32 Marco Leise
2023-07-22 14:13 Marco Leise
2023-07-22 11:46 Marco Leise
2022-07-23 12:24 Marco Leise
2020-08-15  1:50 Marco Leise

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox