public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] eclass/cargo.eclass: add CARGO_OPTIONAL condition
@ 2020-11-11  0:21 Georgy Yakovlev
  0 siblings, 0 replies; only message in thread
From: Georgy Yakovlev @ 2020-11-11  0:21 UTC (permalink / raw
  To: gentoo-dev; +Cc: Georgy Yakovlev

Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
---
 eclass/cargo.eclass | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index e6fec844d274..03dfbfebd1d7 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -15,20 +15,40 @@ _CARGO_ECLASS=1
 # we need this for 'cargo vendor' subcommand and net.offline config knob
 RUST_DEPEND=">=virtual/rust-1.37.0"
 
-case ${EAPI} in
-	7) BDEPEND="${RUST_DEPEND}";;
-	*) die "EAPI=${EAPI:-0} is not supported" ;;
+case "${EAPI:-0}" in
+	0|1|2|3|4|5|6)
+		die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
+	7)
+		;;
+	*)
+		die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
+		;;
 esac
 
 inherit multiprocessing toolchain-funcs
 
-EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install src_test
+if [[ ! ${CARGO_OPTIONAL} ]]; then
+	BDEPEND="${RUST_DEPEND}"
+	EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install src_test
+fi
 
 IUSE="${IUSE} debug"
 
 ECARGO_HOME="${WORKDIR}/cargo_home"
 ECARGO_VENDOR="${ECARGO_HOME}/gentoo"
 
+# @ECLASS-VARIABLE: CARGO_OPTIONAL
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# If set to a non-null value, before inherit cargo part of the ebuild will
+# be considered optional. No dependencies will be added and no phase
+# functions will be exported.
+#
+# If you enable CARGO_OPTIONAL, you have to set BDEPEND on virtual/rust
+# for your package and call at least cargo_gen_config manually before using
+# other src_ functions of this eclass.
+
 # @VARIABLE: myfeatures
 # @DEFAULT_UNSET
 # @DESCRIPTION:
-- 
2.29.2



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-11  0:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-11  0:21 [gentoo-dev] [PATCH] eclass/cargo.eclass: add CARGO_OPTIONAL condition Georgy Yakovlev

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