diff options
author | Tobias Kortkamp <tobik@FreeBSD.org> | 2021-04-06 15:23:13 +0800 |
---|---|---|
committer | Tobias Kortkamp <tobik@FreeBSD.org> | 2021-04-20 14:57:34 +0800 |
commit | a91d65363fe8aa72bdf427bb639b0fe258ee7c01 (patch) | |
tree | bff05a5e79d56100a683a17dd262f3cdbf38cf36 /Mk/Uses | |
parent | 18f78deb5310e3dc0c3283cc5893339da900640c (diff) | |
download | freebsd-ports-gnome-a91d65363fe8aa72bdf427bb639b0fe258ee7c01.tar.gz freebsd-ports-gnome-a91d65363fe8aa72bdf427bb639b0fe258ee7c01.tar.zst freebsd-ports-gnome-a91d65363fe8aa72bdf427bb639b0fe258ee7c01.zip |
Mk/Uses/ninja.mk: Add support for devel/samurai (D29353)
Samurai is a Ninja-compatible build tool with fewer dependencies
than Ninja. Hook it to the framework via a new NINJA_DEFAULT.
This also adds %p to NINJA_STATUS to make Ninja or Samurai print
the percentage of completed jobs to make it easier to eyeball how
much of the build is done.
PR: 254678
Exp-run by: antoine
Diffstat (limited to 'Mk/Uses')
-rw-r--r-- | Mk/Uses/ninja.mk | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/Mk/Uses/ninja.mk b/Mk/Uses/ninja.mk index e67d6e488841..6f71484f1ec4 100644 --- a/Mk/Uses/ninja.mk +++ b/Mk/Uses/ninja.mk @@ -2,26 +2,77 @@ # # Feature: ninja # Usage: USES=ninja +# Valid ARGS: build, make (default), run +# +# 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 # # MAINTAINER: portmgr@FreeBSD.org .if !defined(_INCLUDE_USES_NINJA_MK) _INCLUDE_USES_NINJA_MK= yes -.if !empty(ninja_ARGS) -IGNORE= Incorrect 'USES+= ninja:${ninja_ARGS}' ninja takes no arguments +_valid_ARGS= build make run + +.for _arg in ${ninja_ARGS} +. if empty(_valid_ARGS:M${_arg}) +IGNORE= 'USES+= ninja:${ninja_ARGS}' usage: argument [${_arg}] is not recognized +. endif +.endfor + +.if empty(ninja_ARGS) +ninja_ARGS+= make .endif -MAKE_ARGS+= -v +.if ${ninja_ARGS:Mmake} +ninja_ARGS+= build +.endif + +.if ${NINJA_DEFAULT} == ninja +NINJA_CMD= ninja +_NINJA_PORT= devel/ninja +.elif ${NINJA_DEFAULT} == samurai +NINJA_CMD= samu +_NINJA_PORT= devel/samurai +MAKE_ENV+= SAMUFLAGS="-v -j${MAKE_JOBS_NUMBER}" +. if ${ninja_ARGS:Mbuild} && !${BINARY_ALIAS:U:Mninja=*} +# Cmake and Meson have native support for Samurai and detect and +# use it when Ninja is not available in the build environment. The +# alias is needed for other ports which call Ninja directly and do +# not fall back to Samurai. There should be no harm in providing it +# generally. +BINARY_ALIAS+= ninja=samu +. endif +.else +IGNORE= invalid DEFAULT_VERSIONS+=ninja=${NINJA_DEFAULT} +.endif -BUILD_DEPENDS+= ninja:devel/ninja +.if ${ninja_ARGS:Mbuild} +BUILD_DEPENDS+= ${NINJA_CMD}:${_NINJA_PORT} +# Humanize build log and include percentage of completed jobs %p in it. +# See samu(1) or the Ninja manual. +MAKE_ENV+= NINJA_STATUS="[%p %s/%t] " +.endif +.if ${ninja_ARGS:Mmake} +. if ${NINJA_DEFAULT} == ninja +# 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. +MAKE_ARGS+= -v +. endif CMAKE_ARGS+= -GNinja MAKEFILE= -MAKE_CMD= ninja +MAKE_CMD= ${NINJA_CMD} MAKE_FLAGS= # Set a minimal job of 1 _MAKE_JOBS= -j${MAKE_JOBS_NUMBER} _DESTDIR_VIA_ENV= yes +.endif + +.if ${ninja_ARGS:Mrun} +RUN_DEPENDS+= ${NINJA_CMD}:${_NINJA_PORT} +.endif .endif |