git: 74eb1a46d69b - main - Mk/Uses: Validate arguments of USES=llvm:...; Improve format of error messages

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Tue, 20 Aug 2024 02:48:58 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=74eb1a46d69bac3c2ca2e5f51aa214a9375546a8

commit 74eb1a46d69bac3c2ca2e5f51aa214a9375546a8
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-08-20 02:47:37 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-08-20 02:47:37 +0000

    Mk/Uses: Validate arguments of USES=llvm:...; Improve format of error messages
---
 Mk/Uses/llvm.mk | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/Mk/Uses/llvm.mk b/Mk/Uses/llvm.mk
index 9b22482ea914..978784f11541 100644
--- a/Mk/Uses/llvm.mk
+++ b/Mk/Uses/llvm.mk
@@ -42,6 +42,16 @@ _LLVM_MK_VALID_CONSTRAINTS=	min max
 _LLVM_MK_VALID_MODES=		build run lib
 _LLVM_MK_VALID_EXPORTS=		export noexport
 
+# === verify that there are no invalid arguments ===
+.  for _arg in ${llvm_ARGS}
+.    if !${_LLVM_MK_VALID_VERSIONS:M${_arg}} && \
+        !${_LLVM_MK_VALID_MODES:M${_arg}} && \
+        ${_arg:C/^(${_LLVM_MK_VALID_CONSTRAINTS:tW:S/ /|/g})=(${_LLVM_MK_VALID_VERSIONS:tW:S/ /|/g})$//} != "" && \
+        !${_LLVM_MK_VALID_EXPORTS:M${_arg}}
+BROKEN=		USES=llvm:${llvm_ARGS:tW:S/ /,/g} contains an invalid argument: "${_arg}"
+.    endif
+.  endfor
+
 # === parse mode arguments ===
 _LLVM_MK_MODES=	# empty
 .  for _mode in ${_LLVM_MK_VALID_MODES}
@@ -58,7 +68,7 @@ _LLVM_MK_VERSION=	# empty
 .  for _ver in ${_LLVM_MK_VALID_VERSIONS}
 .    if ${llvm_ARGS:M${_ver}}
 .      if !empty(_LLVM_MK_VERSION)
-BROKEN=		USES=llvm:${llvm_ARGS} contains multiple version definitions
+BROKEN=		USES=llvm:${llvm_ARGS:tW:S/ /,/g} contains multiple version definitions
 .      else
 _LLVM_MK_VERSION=	${_ver}
 .      endif
@@ -77,7 +87,7 @@ _LLVM_MK_EXPORT=	# empty
 .  for _export in ${_LLVM_MK_VALID_EXPORTS}
 .    if ${llvm_ARGS:M${_export}}
 .      if !empty(_LLVM_MK_EXPORT)
-BROKEN=		USES=llvm:${llvm_ARGS} contains multiple export definitions
+BROKEN=		USES=llvm:${llvm_ARGS:tW:S/ /,/g} contains multiple export definitions
 .      else
 _LLVM_MK_EXPORT=	${_export}
 .      endif