From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DC66415800A for ; Sun, 16 Jul 2023 12:58:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8BE9BE08D4; Sun, 16 Jul 2023 12:58:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A51A7E0891 for ; Sun, 16 Jul 2023 12:58:10 +0000 (UTC) References: <20230716123830.78932-1-xgqt@gentoo.org> <20230716123830.78932-3-xgqt@gentoo.org> User-agent: mu4e 1.10.4; emacs 29.0.92 From: Sam James To: gentoo-dev@lists.gentoo.org Cc: Maciej =?utf-8?Q?Bar=C4=87?= Subject: Re: [gentoo-dev] [PATCH 3/7] eclass/dotnet-pkg.eclass: introduce new eclass Date: Sun, 16 Jul 2023 13:56:26 +0100 In-reply-to: <20230716123830.78932-3-xgqt@gentoo.org> Message-ID: <87h6q4rp29.fsf@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Archives-Salt: c24f3501-ef87-4891-8b74-c71ad82ecaaf X-Archives-Hash: 4cde5a63273d61e19e6f3de720f4a26f --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Maciej Bar=C4=87 writes: > Bug: https://bugs.gentoo.org/900597 > Bug: https://github.com/gentoo/gentoo/pull/29309 > Signed-off-by: Maciej Bar=C4=87 > --- > eclass/dotnet-pkg.eclass | 249 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 249 insertions(+) > create mode 100644 eclass/dotnet-pkg.eclass > > diff --git a/eclass/dotnet-pkg.eclass b/eclass/dotnet-pkg.eclass > new file mode 100644 > index 0000000000..2b711467f5 > --- /dev/null > +++ b/eclass/dotnet-pkg.eclass > @@ -0,0 +1,249 @@ > +# Copyright 1999-2023 Gentoo Authors > +# Distributed under the terms of the GNU General Public License v2 > + > +# @ECLASS: dotnet-pkg.eclass > +# @MAINTAINER: > +# Gentoo Dotnet project > +# @AUTHOR: > +# Anna Figueiredo Gomes > +# Maciej Bar=C4=87 > +# @SUPPORTED_EAPIS: 7 8 > +# @PROVIDES: dotnet-pkg-utils nuget > +# @BLURB: common functions and variables for .NET packages > +# @DESCRIPTION: > +# This eclass is designed to help with building and installing packages = that > +# use the .NET SDK. > +# > +# .NET SDK is a open-source framework from Microsoft, it is a cross-plat= form > +# successor to .NET Framework. > +# > +# .NET packages require proper inspection before packaging: > +# - the compatible .NET SDK version has to be declared, > +# this can be done by inspecting the package's "*proj" files, > +# unlike JAVA, .NET packages tend to lock onto one selected .NET SDK > +# version, so building with other .NET versions will be mostly unsuppo= rted, > +# - nugets, which are similar to JAVA's JARs (package .NET dependencies), > +# have to be listed using either the "NUGETS" variable or bundled insi= de > +# a "prebuilt" archive, in second case also the "NUGET_PACKAGES" varia= ble > +# has to be explicitly set. > +# - the main project file (.*proj) that builds the project has to be spe= cified > +# by the "DOTNET_PROJECT" variable. > + > +case "${EAPI}" in > + 7 | 8 ) > + : > + ;; > + * ) > + die "${ECLASS}: EAPI ${EAPI} unsupported." > + ;; > +esac > + > +if [[ -z ${_DOTNET_PKG_ECLASS} ]] ; then > +_DOTNET_PKG_ECLASS=3D1 > + > +inherit dotnet-pkg-utils > + > +# @ECLASS_VARIABLE: DOTNET_PROJECTS > +# @DEFAULT_UNSET > +# @DESCRIPTION: > +# Path to the main .NET project files (".csproj", ".fsproj", ".vbproj") > +# used by default by "dotnet-pkg_src_compile" phase function. > +# > +# In .NET version 6.0 and lower it was possible to build a project solut= ion > +# (".sln") immediately with output to a specified directory ("--output D= IR"), > +# but versions >=3D 7.0 deprecated this behavior. This means that > +# "dotnet-pkg-utils_build" will fail when pointed to a solution or a dir= ectory > +# containing a solution file. > +# > +# It is up to the maintainer if this variable is set before inheriting > +# "dotnet-pkg-utils" eclass, but it is advised that it is set after > +# the variable "${S}" is set, it should also integrate with it > +# (see the example below). > +# > +# Example: > +# @CODE > +# SRC_URI=3D"..." > +# S=3D"${S}"/src > +# > +# LICENSE=3D"MIT" > +# SLOT=3D"0" > +# KEYWORDS=3D"~amd64" > +# > +# DOTNET_PROJECTS=3D( "${S}/DotnetProject" ) > +# > +# src_prepare() { > +# ... > +# @CODE > + > +# @ECLASS_VARIABLE: DOTNET_RESTORE_EXTRA_ARGS > +# @DESCRIPTION: > +# Extra arguments to pass to the package restore, in the "src_configure"= phase. > +# > +# This is passed only when restoring the specified "DOTNET_PROJECT". > +# Other project restorers do not use this variable. > +# > +# It is up to the maintainer if this variable is set before inheriting > +# "dotnet-pkg.eclass", but it is advised that it is set after the variab= le > +# "DOTNET_PROJECT" (from "dotnet-pkg-utils" eclass) is set. > +# > +# Default value is an empty array. > +# > +# For more info see the "DOTNET_PROJECT" variable and "dotnet-pkg_src_co= nfigure". > +DOTNET_RESTORE_EXTRA_ARGS=3D() > + > +# @ECLASS_VARIABLE: DOTNET_BUILD_EXTRA_ARGS > +# @DESCRIPTION: > +# Extra arguments to pass to the package build, in the "src_compile" pha= se. > +# > +# This is passed only when building the specified "DOTNET_PROJECT". > +# Other project builds do not use this variable. > +# > +# It is up to the maintainer if this variable is set before inheriting > +# "dotnet-pkg.eclass", but it is advised that it is set after the variab= le > +# "DOTNET_PROJECT" (from "dotnet-pkg-utils" eclass) is set. > +# > +# Default value is an empty array. > +# > +# Example: > +# @CODE > +# DOTNET_BUILD_EXTRA_ARGS=3D( -p:WarningLevel=3D0 ) > +# @CODE > +# > +# For more info see the "DOTNET_PROJECT" variable and "dotnet-pkg_src_co= mpile". > +DOTNET_BUILD_EXTRA_ARGS=3D() > + > +# @FUNCTION: dotnet-pkg_pkg_setup > +# @DESCRIPTION: > +# Default "pkg_setup" for the "dotnet-pkg" eclass. > +# Pre-build configuration and checks. > +# > +# Calls "dotnet-pkg-utils_pkg_setup". > +dotnet-pkg_pkg_setup() { > + dotnet-pkg-utils_setup > +} > + > +# @FUNCTION: dotnet-pkg_src_unpack > +# @DESCRIPTION: > +# Default "src_unpack" for the "dotnet-pkg" eclass. > +# Unpack the package sources. > +# > +# Includes a special exception for nugets (".nupkg" files) - they are in= stead > +# copied into the "NUGET_PACKAGES" directory. > +dotnet-pkg_src_unpack() { > + nuget_link-system-nugets > + > + local archive > + for archive in ${A} ; do > + case ${archive} in > + *.nupkg ) > + nuget_link "${DISTDIR}"/${archive} > + ;; > + * ) > + unpack ${archive} > + ;; > + esac > + done > +} > + > +# @FUNCTION: dotnet-pkg_src_prepare > +# @DESCRIPTION: > +# Default "src_prepare" for the "dotnet-pkg" eclass. > +# Prepare the package sources. > +# > +# Run "dotnet-pkg-utils_remove-global-json". > +dotnet-pkg_src_prepare() { > + dotnet-pkg-utils_remove-global-json > + > + default > +} > + > +# @FUNCTION: dotnet-pkg_foreach-project > +# @USAGE: ... > +# @DESCRIPTION: > +# Run a specified command for each project listed inside the "DOTNET_PRO= JECTS" > +# variable. > +# > +# Used by "dotnet-pkg_src_configure" and "dotnet-pkg_src_compile". > +dotnet-pkg_foreach-project() { > + debug-print-function ${FUNCNAME} "${@}" > + > + local dotnet_project > + for dotnet_project in "${DOTNET_PROJECTS[@]}" ; do > + einfo "Running \"${@}\" for project: \"$(basename "${dotnet_project}")= \"" > + "${@}" "${dotnet_project}" No die? > + done > +} > + > +# @FUNCTION: dotnet-pkg_src_configure > +# @DESCRIPTION: > +# Default "src_configure" for the "dotnet-pkg" eclass. > +# Configure the package. > +# > +# First show information about current .NET SDK that is being used, > +# then restore the project file specified by "DOTNET_PROJECT", > +# afterwards restore any found solutions. > +dotnet-pkg_src_configure() { > + dotnet-pkg-utils_info > + > + dotnet-pkg_foreach-project \ > + dotnet-pkg-utils_restore "${DOTNET_RESTORE_EXTRA_ARGS[@]}" > + > + dotnet-pkg-utils_foreach-solution dotnet-pkg-utils_restore "$(pwd)" > +} > + > +# @FUNCTION: dotnet-pkg_src_compile > +# @DESCRIPTION: > +# Default "src_compile" for the "dotnet-pkg" eclass. > +# Build the package. > +# > +# Build the package using "dotnet build" in the directory specified by e= ither > +# "DOTNET_PROJECT" or "S" (temporary build directory) variables. > +# > +# For more info see: "DOTNET_PROJECT" variable > +# and "dotnet-pkg-utils_get-project" function. > +dotnet-pkg_src_compile() { > + dotnet-pkg_foreach-project \ > + dotnet-pkg-utils_build "${DOTNET_BUILD_EXTRA_ARGS[@]}" > +} > + > +# @FUNCTION: dotnet-pkg_src_test > +# @DESCRIPTION: > +# Default "src_test" for the "dotnet-pkg" eclass. > +# Test the package. > +# > +# Test the package by testing any found solutions. > +# > +# It is very likely that this function will either not execute any tests= or > +# will execute wrong or incomplete test suite. Maintainers should inspec= t if > +# any and/or correct tests are ran. > +dotnet-pkg_src_test() { > + dotnet-pkg-utils_foreach-solution dotnet-pkg-utils_test "$(pwd)" > +} > + > +# @FUNCTION: dotnet-pkg_src_install > +# @DESCRIPTION: > +# Default "src_install" for the "dotnet-pkg" eclass. > +# Install the package. > +# > +# This is the default package install function for the "dotnet-pkg" ecla= ss. > +# > +# It is very likely that this function is either insufficient or has to = be > +# redefined in a ebuild. > +dotnet-pkg_src_install() { > + # Install the compiled .NET package artifacts, > + # for more info see "dotnet-pkg-utils_install" and "DOTNET_OUTPUT". > + dotnet-pkg-utils_install > + > + # Create launcher from the .NET package directory to "/usr/bin". > + # For example: /usr/bin/Nake -> /usr/share/nake-3.0.0/Nake > + dotnet-pkg-utils_dolauncher /usr/share/${P}/${PN^} > + > + # Create a compatibility symlink and also for ease of use from CLI. > + dosym -r /usr/bin/${PN^} /usr/bin/${PN} > + > + einstalldocs > +} > + > +EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_comp= ile src_test src_install > + > +fi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iOUEARYKAI0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCZLPpXl8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MA8cc2FtQGdlbnRv by5vcmcACgkQc4QJ9SDfkZAmZwEA/stIfb0oJhlz8CbUuDzVLG9uxvGcaFsKvhd4 21PZAn8BAI0CCVQSGsfZ96IHzM/e3pyzajC7OTVgoK663X6LaI8N =lEHx -----END PGP SIGNATURE----- --=-=-=--