public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/4] eclass/dotnet-pkg*: remove unnecessary auto-append of project dir
@ 2023-10-05 19:10 Maciej Barć
  2023-10-05 19:10 ` [gentoo-dev] [PATCH 2/4] eclass/dotnet-pkg-base.eclass: clarify test, quotes in dolauncher Maciej Barć
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Maciej Barć @ 2023-10-05 19:10 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Maciej Barć

Also reorder dotnet-pkg-base_foreach-solution argument positions.

Signed-off-by: Maciej Barć <xgqt@gentoo.org>
---
 eclass/dotnet-pkg-base.eclass | 56 ++++++++++++++---------------------
 eclass/dotnet-pkg.eclass      |  6 ++--
 2 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/eclass/dotnet-pkg-base.eclass b/eclass/dotnet-pkg-base.eclass
index c7f2e031d..e2659a829 100644
--- a/eclass/dotnet-pkg-base.eclass
+++ b/eclass/dotnet-pkg-base.eclass
@@ -305,35 +305,37 @@ dotnet-pkg-base_info() {
 }
 
 # @FUNCTION: dotnet-pkg-base_foreach-solution
-# @USAGE: <function> [directory]
+# @USAGE: <directory> <args> ...
 # @DESCRIPTION:
 # Execute a function for each solution file (.sln) in a specified directory.
 # This function may yield no real results because solutions are discovered
 # automatically.
 #
-# Optional "directory" argument defaults to the current directory path.
-#
-# Used by "dotnet-pkg_src_configure" from the "dotnet-pkg" eclass.
+# Used by "dotnet-pkg_src_configure" and "dotnet-pkg_src_test" from
+# the "dotnet-pkg" eclass.
 dotnet-pkg-base_foreach-solution() {
 	debug-print-function "${FUNCNAME[0]}" "${@}"
 
+	local directory="${1}"
+	shift
+
 	local dotnet_solution
 	local dotnet_solution_name
 	while read -r dotnet_solution ; do
 		dotnet_solution_name="$(basename "${dotnet_solution}")"
 
-		ebegin "Running \"${1}\" for solution: \"${dotnet_solution_name}\""
-		"${1}" "${dotnet_solution}"
+		ebegin "Running \"${@}\" for solution: \"${dotnet_solution_name}\""
+		"${@}" "${dotnet_solution}"
 		eend $? "${FUNCNAME[0]}: failed for solution: \"${dotnet_solution}\"" || die
-	done < <(find "${2:-.}" -maxdepth 1 -type f -name "*.sln")
+	done < <(find "${directory}" -maxdepth 1 -type f -name "*.sln")
 }
 
 # @FUNCTION: dotnet-pkg-base_restore
-# @USAGE: [directory] [args] ...
+# @USAGE: [args] ...
 # @DESCRIPTION:
-# Restore the package using "dotnet restore" in a specified directory.
-#
-# Optional "directory" argument defaults to the current directory path.
+# Restore the package using "dotnet restore".
+# Restore is performed in current directory unless a different directory is
+# passed via "args".
 #
 # Additionally any number of "args" maybe be given, they are appended to
 # the "dotnet" command invocation.
@@ -342,14 +344,6 @@ dotnet-pkg-base_foreach-solution() {
 dotnet-pkg-base_restore() {
 	debug-print-function "${FUNCNAME[0]}" "${@}"
 
-	local directory
-	if [[ "${1}" ]] ; then
-		directory="${1}"
-		shift
-	else
-		directory="$(pwd)"
-	fi
-
 	local -a restore_args=(
 		--runtime "${DOTNET_PKG_RUNTIME}"
 		--source "${NUGET_PACKAGES}"
@@ -357,7 +351,7 @@ dotnet-pkg-base_restore() {
 		"${@}"
 	)
 
-	edotnet restore "${restore_args[@]}" "${directory}"
+	edotnet restore "${restore_args[@]}"
 }
 
 # @FUNCTION: dotnet-pkg-base_restore_tools
@@ -388,11 +382,11 @@ dotnet-pkg-base_restore_tools() {
 }
 
 # @FUNCTION: dotnet-pkg-base_build
-# @USAGE: [directory] [args] ...
+# @USAGE: [args] ...
 # @DESCRIPTION:
 # Build the package using "dotnet build" in a specified directory.
-#
-# Optional "directory" argument defaults to the current directory path.
+# Build is performed in current directory unless a different directory is
+# passed via "args".
 #
 # Additionally any number of "args" maybe be given, they are appended to
 # the "dotnet" command invocation.
@@ -401,14 +395,6 @@ dotnet-pkg-base_restore_tools() {
 dotnet-pkg-base_build() {
 	debug-print-function "${FUNCNAME[0]}" "${@}"
 
-	local directory
-	if [[ "${1}" ]] ; then
-		directory="${1}"
-		shift
-	else
-		directory="$(pwd)"
-	fi
-
 	local -a build_args=(
 		--configuration "${DOTNET_PKG_CONFIGURATION}"
 		--no-restore
@@ -416,7 +402,6 @@ dotnet-pkg-base_build() {
 		--output "${DOTNET_PKG_OUTPUT}"
 		--runtime "${DOTNET_PKG_RUNTIME}"
 		-maxCpuCount:$(makeopts_jobs)
-		"${@}"
 	)
 
 	if ! use debug ; then
@@ -426,7 +411,12 @@ dotnet-pkg-base_build() {
 		)
 	fi
 
-	edotnet build "${build_args[@]}" "${directory}"
+	# And append "args" at the end.
+	build_args+=(
+		"${@}"
+	)
+
+	edotnet build "${build_args[@]}"
 }
 
 # @FUNCTION: dotnet-pkg-base_test
diff --git a/eclass/dotnet-pkg.eclass b/eclass/dotnet-pkg.eclass
index 05886af85..201daf1ec 100644
--- a/eclass/dotnet-pkg.eclass
+++ b/eclass/dotnet-pkg.eclass
@@ -194,7 +194,9 @@ dotnet-pkg_src_configure() {
 	dotnet-pkg_foreach-project \
 		dotnet-pkg-base_restore "${DOTNET_PKG_RESTORE_EXTRA_ARGS[@]}"
 
-	dotnet-pkg-base_foreach-solution dotnet-pkg-base_restore "$(pwd)"
+	dotnet-pkg-base_foreach-solution \
+		"$(pwd)" \
+		dotnet-pkg-base_restore "${DOTNET_PKG_RESTORE_EXTRA_ARGS[@]}"
 }
 
 # @FUNCTION: dotnet-pkg_src_compile
@@ -223,7 +225,7 @@ dotnet-pkg_src_compile() {
 # will execute wrong or incomplete test suite. Maintainers should inspect if
 # any and/or correct tests are ran.
 dotnet-pkg_src_test() {
-	dotnet-pkg-base_foreach-solution dotnet-pkg-base_test "$(pwd)"
+	dotnet-pkg-base_foreach-solution "$(pwd)" dotnet-pkg-base_test
 }
 
 # @FUNCTION: dotnet-pkg_src_install
-- 
2.41.0



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

* [gentoo-dev] [PATCH 2/4] eclass/dotnet-pkg-base.eclass: clarify test, quotes in dolauncher
  2023-10-05 19:10 [gentoo-dev] [PATCH 1/4] eclass/dotnet-pkg*: remove unnecessary auto-append of project dir Maciej Barć
@ 2023-10-05 19:10 ` Maciej Barć
  2023-10-05 19:10 ` [gentoo-dev] [PATCH 3/4] eclass/nuget.eclass: add special NUGET_API case for Gentoo devs' hosting Maciej Barć
  2023-10-05 19:10 ` [gentoo-dev] [PATCH 4/4] eclass/nuget.eclass: partition dotnet-pkg_src_unpack Maciej Barć
  2 siblings, 0 replies; 4+ messages in thread
From: Maciej Barć @ 2023-10-05 19:10 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Maciej Barć

Signed-off-by: Maciej Barć <xgqt@gentoo.org>
---
 eclass/dotnet-pkg-base.eclass | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/eclass/dotnet-pkg-base.eclass b/eclass/dotnet-pkg-base.eclass
index e2659a829..5b2d6e2dd 100644
--- a/eclass/dotnet-pkg-base.eclass
+++ b/eclass/dotnet-pkg-base.eclass
@@ -371,7 +371,7 @@ dotnet-pkg-base_restore_tools() {
 		--add-source "${NUGET_PACKAGES}"
 	)
 
-	if [[ "${1}" ]] ; then
+	if [[ -n "${1}" ]] ; then
 		tool_restore_args+=( --configfile "${1}" )
 		shift
 	fi
@@ -434,7 +434,7 @@ dotnet-pkg-base_test() {
 	debug-print-function "${FUNCNAME[0]}" "${@}"
 
 	local directory
-	if [[ "${1}" ]] ; then
+	if [[ -n "${1}" ]] ; then
 		directory="${1}"
 		shift
 	else
@@ -529,7 +529,7 @@ dotnet-pkg-base_dolauncher() {
 
 	local executable_path executable_name
 
-	if [[ "${1}" ]] ; then
+	if [[ -n "${1}" ]] ; then
 		local executable_path="${1}"
 		shift
 	else
@@ -553,9 +553,9 @@ dotnet-pkg-base_dolauncher() {
 	# compatible with dotnet version ${DOTNET_PKG_COMPAT}.
 
 	for __dotnet_root in \\
-		${EPREFIX}/usr/$(get_libdir)/dotnet-sdk-${DOTNET_PKG_COMPAT} \\
-		${EPREFIX}/opt/dotnet-sdk-bin-${DOTNET_PKG_COMPAT} ; do
-		[ -d \${__dotnet_root} ] && break
+		"${EPREFIX}/usr/$(get_libdir)/dotnet-sdk-${DOTNET_PKG_COMPAT}" \\
+		"${EPREFIX}/opt/dotnet-sdk-bin-${DOTNET_PKG_COMPAT}" ; do
+		[ -d "\${__dotnet_root}" ] && break
 	done
 
 	DOTNET_ROOT="\${__dotnet_root}"
-- 
2.41.0



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

* [gentoo-dev] [PATCH 3/4] eclass/nuget.eclass: add special NUGET_API case for Gentoo devs' hosting
  2023-10-05 19:10 [gentoo-dev] [PATCH 1/4] eclass/dotnet-pkg*: remove unnecessary auto-append of project dir Maciej Barć
  2023-10-05 19:10 ` [gentoo-dev] [PATCH 2/4] eclass/dotnet-pkg-base.eclass: clarify test, quotes in dolauncher Maciej Barć
@ 2023-10-05 19:10 ` Maciej Barć
  2023-10-05 19:10 ` [gentoo-dev] [PATCH 4/4] eclass/nuget.eclass: partition dotnet-pkg_src_unpack Maciej Barć
  2 siblings, 0 replies; 4+ messages in thread
From: Maciej Barć @ 2023-10-05 19:10 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Maciej Barć

Signed-off-by: Maciej Barć <xgqt@gentoo.org>
---
 eclass/nuget.eclass | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/eclass/nuget.eclass b/eclass/nuget.eclass
index 8ac81497f..445dcdccd 100644
--- a/eclass/nuget.eclass
+++ b/eclass/nuget.eclass
@@ -112,6 +112,9 @@ _nuget_set_nuget_uris() {
 
 		for nuget_api in "${NUGET_APIS[@]}" ; do
 			case ${nuget_api%/} in
+				*dev.gentoo.org/~* )
+					url="${nuget_api}/${name}.${version}.nupkg"
+					;;
 				*/v2 )
 					url="${nuget_api}/package/${name}/${version}
 							-> ${name}.${version}.nupkg"
-- 
2.41.0



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

* [gentoo-dev] [PATCH 4/4] eclass/nuget.eclass: partition dotnet-pkg_src_unpack
  2023-10-05 19:10 [gentoo-dev] [PATCH 1/4] eclass/dotnet-pkg*: remove unnecessary auto-append of project dir Maciej Barć
  2023-10-05 19:10 ` [gentoo-dev] [PATCH 2/4] eclass/dotnet-pkg-base.eclass: clarify test, quotes in dolauncher Maciej Barć
  2023-10-05 19:10 ` [gentoo-dev] [PATCH 3/4] eclass/nuget.eclass: add special NUGET_API case for Gentoo devs' hosting Maciej Barć
@ 2023-10-05 19:10 ` Maciej Barć
  2 siblings, 0 replies; 4+ messages in thread
From: Maciej Barć @ 2023-10-05 19:10 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Maciej Barć

This enables easier usage of "nuget_link-nuget-archives"
in some special cases.

Signed-off-by: Maciej Barć <xgqt@gentoo.org>
---
 eclass/dotnet-pkg.eclass | 14 ++-----------
 eclass/nuget.eclass      | 45 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 12 deletions(-)

diff --git a/eclass/dotnet-pkg.eclass b/eclass/dotnet-pkg.eclass
index 201daf1ec..b4f0c053d 100644
--- a/eclass/dotnet-pkg.eclass
+++ b/eclass/dotnet-pkg.eclass
@@ -136,18 +136,8 @@ dotnet-pkg_pkg_setup() {
 # 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
+	nuget_link-nuget-archives
+	nuget_unpack-non-nuget-archives
 }
 
 # @FUNCTION: dotnet-pkg_src_prepare
diff --git a/eclass/nuget.eclass b/eclass/nuget.eclass
index 445dcdccd..669e21300 100644
--- a/eclass/nuget.eclass
+++ b/eclass/nuget.eclass
@@ -181,6 +181,51 @@ nuget_link-system-nugets() {
 	done
 }
 
+# @FUNCTION: nuget_link-nuget-archives
+# @DESCRIPTION:
+# Link NuGet packages from package source files to the "NUGET_PACKAGES"
+# directory.
+#
+# This is a complementary function to "nuget_unpack-non-nuget-archives".
+#
+# This function is used inside "dotnet-pkg_src_unpack"
+# from the "dotnet-pkg" eclass.
+nuget_link-nuget-archives() {
+	local archive
+	for archive in ${A} ; do
+		case "${archive}" in
+			*.nupkg )
+				nuget_link "${DISTDIR}/${archive}"
+				;;
+			* )
+				:
+				;;
+		esac
+	done
+}
+
+# @FUNCTION: nuget_unpack-non-nuget-archives
+# @DESCRIPTION:
+# Unpack all from package source files that are not NuGet packages.
+#
+# This is a complementary function to "nuget_link-nuget-archives".
+#
+# This function is used inside "dotnet-pkg_src_unpack"
+# from the "dotnet-pkg" eclass.
+nuget_unpack-non-nuget-archives() {
+	local archive
+	for archive in ${A} ; do
+		case "${archive}" in
+			*.nupkg )
+				:
+				;;
+			* )
+				unpack "${archive}"
+				;;
+		esac
+	done
+}
+
 # @FUNCTION: nuget_donuget
 # @USAGE: <nuget-path> ...
 # @DESCRIPTION:
-- 
2.41.0



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

end of thread, other threads:[~2023-10-05 19:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-05 19:10 [gentoo-dev] [PATCH 1/4] eclass/dotnet-pkg*: remove unnecessary auto-append of project dir Maciej Barć
2023-10-05 19:10 ` [gentoo-dev] [PATCH 2/4] eclass/dotnet-pkg-base.eclass: clarify test, quotes in dolauncher Maciej Barć
2023-10-05 19:10 ` [gentoo-dev] [PATCH 3/4] eclass/nuget.eclass: add special NUGET_API case for Gentoo devs' hosting Maciej Barć
2023-10-05 19:10 ` [gentoo-dev] [PATCH 4/4] eclass/nuget.eclass: partition dotnet-pkg_src_unpack Maciej Barć

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