public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Maciej Barć" <xgqt@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Maciej Barć" <xgqt@gentoo.org>
Subject: [gentoo-dev] [PATCH 1/4] eclass/dotnet-pkg*: remove unnecessary auto-append of project dir
Date: Thu,  5 Oct 2023 21:10:15 +0200	[thread overview]
Message-ID: <20231005191025.12504-1-xgqt@gentoo.org> (raw)

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



             reply	other threads:[~2023-10-05 19:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05 19:10 Maciej Barć [this message]
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ć

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231005191025.12504-1-xgqt@gentoo.org \
    --to=xgqt@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox