git: 7bb64b89d0e5 - main - framework: add Mk/Uses/pycryptography

From: Tobias C. Berner <tcberner_at_FreeBSD.org>
Date: Sat, 22 Jul 2023 07:48:42 UTC
The branch main has been updated by tcberner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7bb64b89d0e5ec8d77b28f8341269ffbad279ebf

commit 7bb64b89d0e5ec8d77b28f8341269ffbad279ebf
Author:     Tobias C. Berner <tcberner@FreeBSD.org>
AuthorDate: 2023-07-22 06:16:46 +0000
Commit:     Tobias C. Berner <tcberner@FreeBSD.org>
CommitDate: 2023-07-22 07:46:38 +0000

    framework: add Mk/Uses/pycryptography
    
    With the added new DEFAULT_VERSION "PYCRYPTOGRAHY_DEFAULT=rust|legacy"
    it is important to transparently depend on the right one.
    
    This is the job of this new uses.
    
    So instead of manually adding dependency lines like
    
            RUN_DEPENDS=${PYTHON_PKGNAMEPREFIX}cryptography>0:security/py-cryptography@${PY_FLAVOR}
    
    this should now be
    
            USES=pycryptography:run
    
    Supported arguments: <none>,build,run,test
    If no argument is given, it defaults to 'build,run'.
    
    A future commit will update to security/py-cryptography will introduce a
    rust dependency.
    
    PR:             254853
---
 CHANGES                   | 20 ++++++++++++++++++++
 Mk/Uses/pycryptography.mk | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/CHANGES b/CHANGES
index 25c7d5fa12a9..48f0ce9023cd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,26 @@ in the release notes and/or placed into UPDATING.
 
 All ports committers are allowed to commit to this file.
 
+20230722:
+AUTHOR: tcberner@FreeBSD.org
+
+  A new uses 'pycryptography' has been added to transparently depend on the
+  proper variant of 'rust' or 'legacy' depending on the default version set
+  by the user.
+
+  Supported arguments: <none>,build,run
+  Passing no arguments (<none>) is equivalent to passing both build and run.
+
+  Usage:
+	USES=pycryptography:build
+		-> adds a BUILD_DEPENDS only
+	USES=pycryptography:run
+		-> adds a RUN_DEPENDS only
+	USES=pycryptography:test
+		-> adds a TEST_DEPENDS only
+	USES=pycryptography:build,run   or   USES=pycryptography
+		-> adds a BUILD_ and RUN_DEPENDS
+
 20230712:
 AUTHOR: zirias@FreeBSD.org
 
diff --git a/Mk/Uses/pycryptography.mk b/Mk/Uses/pycryptography.mk
new file mode 100644
index 000000000000..78576746e414
--- /dev/null
+++ b/Mk/Uses/pycryptography.mk
@@ -0,0 +1,46 @@
+# Handle dependency on security/py-cryptogrpaphy[-legacy]
+#
+# Feature:	pycrptography
+# Usage:	USES=pycryptography
+# Valid ARGS:	<none>, build, run
+# 		<none>:   default same as build,run
+# 		build:    add BUILD_DEPENDS
+# 		run:      add RUN_DEPENDS
+# 		test:     add TEST_DEPENDS
+#
+# MAINTAINER: portmgr@FreeBSD.org
+#
+
+.if ! defined(_INCLUDE_USES_PYCRYPTOGRAPHY_MK)
+_INCLUDE_USES_PYCRYPTOGRAPHY_MK=	YES
+
+# valid arguments:
+_PYCRYPTOGRAPHY_MK_VALID_MODES=		build run test
+
+# Suffixes
+_PYCRYPTOGRAPHY_MK_SUFFIX_rust=		#
+_PYCRYPTOGRAPHY_MK_SUFFIX_legacy=	-legacy
+
+# Dependency
+_PYCRYPTOGRAPHY_MK_SUFFIX=	${_PYCRYPTOGRAPHY_MK_SUFFIX_${PYCRYPTOGRAPHY_DEFAULT}}
+_PYCRYPTOGRAPHY_MK_PKG=		${PYTHON_PKGNAMEPREFIX}cryptography${_PYCRYPTOGRAPHY_MK_SUFFIX}
+_PYCRYPTOGRAPHY_MK_PORT=	security/py-cryptography${_PYCRYPTOGRAPHY_MK_SUFFIX}
+_PYCRYPTOGRAPHY_MK_DEPENDENCY=	${_PYCRYPTOGRAPHY_MK_PKG}>0:${_PYCRYPTOGRAPHY_MK_PORT}@${PY_FLAVOR}
+
+# === parse version arguments ===
+_PYGRYPTOGRAPHY_MK_MODES=	# empty
+.  for _mode in ${_PYCRYPTOGRAPHY_MK_VALID_MODES}
+.    if ${pycryptography_ARGS:M${_mode}}
+_PYCRYPTOGRAPHY_MK_MODES+=	${_mode}
+.    endif
+.  endfor
+.  if empty(_PYGRYPTOGRAPHY_MK_MODES)
+_PYCRYPTOGRAPHY_MK_MODES=	build run
+.  endif
+
+# == add actual dependencies ===
+.  for _mode in ${_PYCRYPTOGRAPHY_MK_MODES}
+${_mode:tu}_DEPENDS+=	${_PYCRYPTOGRAPHY_MK_DEPENDENCY}
+.  endfor
+
+.endif