git: 9843444ea96e - main - Mk/Uses/ninja.mk: Add samurai as option for ARGS

From: Daniel Engberg <diizzy_at_FreeBSD.org>
Date: Mon, 20 May 2024 21:53:57 UTC
The branch main has been updated by diizzy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9843444ea96e25eb7c782a3bf24eb67d4b934cd1

commit 9843444ea96e25eb7c782a3bf24eb67d4b934cd1
Author:     Daniel Engberg <diizzy@FreeBSD.org>
AuthorDate: 2024-05-20 21:11:12 +0000
Commit:     Daniel Engberg <diizzy@FreeBSD.org>
CommitDate: 2024-05-20 21:53:50 +0000

    Mk/Uses/ninja.mk: Add samurai as option for ARGS
    
    This adds the ability for ports to override NINJA_DEFAULT by defining
    USES= ninja:samurai and use devel/samurai as backend instead of
    devel/ninja (default).
    
    Reviewed by:    arrowd, mat and tobik (previous iterations)
    Differential Revision:  https://reviews.freebsd.org/D45165
---
 Mk/Uses/ninja.mk | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/Mk/Uses/ninja.mk b/Mk/Uses/ninja.mk
index 5c78cf152d07..b9a8548fb16c 100644
--- a/Mk/Uses/ninja.mk
+++ b/Mk/Uses/ninja.mk
@@ -2,18 +2,19 @@
 #
 # Feature:		ninja
 # Usage:		USES=ninja
-# Valid ARGS:		build, make (default), run
+# Valid ARGS:		build, make (default), run, samurai
 #
 # build			add a build dependency on ninja
 # make			use ninja for the build instead of make, implies "build"
 # run			add a run dependency on ninja
+# samurai		use samurai irregardless of NINJA_DEFAULT (implies make)
 #
 # MAINTAINER: ports@FreeBSD.org
 
 .if !defined(_INCLUDE_USES_NINJA_MK)
 _INCLUDE_USES_NINJA_MK=	yes
 
-_valid_ARGS=	build make run
+_valid_ARGS=	build make run samurai
 
 .  for _arg in ${ninja_ARGS}
 .    if empty(_valid_ARGS:M${_arg})
@@ -23,16 +24,19 @@ IGNORE=	'USES+= ninja:${ninja_ARGS}' usage: argument [${_arg}] is not recognized
 
 .  if empty(ninja_ARGS)
 ninja_ARGS+=	make
+.  elif !empty(ninja_ARGS:Msamurai)
+_SAMURAI_FROM_ARGS=     yes
+ninja_ARGS+=	make
 .  endif
 
 .  if ${ninja_ARGS:Mmake}
 ninja_ARGS+=	build
 .  endif
 
-.  if ${NINJA_DEFAULT} == ninja
+.  if ${NINJA_DEFAULT} == ninja && !defined(_SAMURAI_FROM_ARGS)
 NINJA_CMD=	ninja
 _NINJA_PORT=	devel/ninja
-.  elif ${NINJA_DEFAULT} == samurai
+.  elif ${NINJA_DEFAULT} == samurai || defined(_SAMURAI_FROM_ARGS)
 NINJA_CMD=	samu
 _NINJA_PORT=	devel/samurai
 MAKE_ENV+=	SAMUFLAGS="-v -j${MAKE_JOBS_NUMBER}"
@@ -56,7 +60,7 @@ MAKE_ENV+=	NINJA_STATUS="[%p %s/%t] "
 .  endif
 
 .  if ${ninja_ARGS:Mmake}
-.    if ${NINJA_DEFAULT} == ninja
+.    if ${NINJA_DEFAULT} == ninja && !defined(_SAMURAI_FROM_ARGS)
 # samu does not support GNU-style args, so we cannot just append
 # -v last.  samu gets this via SAMUFLAGS above but ninja does not
 # support an equivalent environment variable.