NetBSD Problem Report #55027

From www@netbsd.org  Thu Feb 27 20:04:52 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 683761A9213
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 27 Feb 2020 20:04:52 +0000 (UTC)
Message-Id: <20200227200451.4E5A81A9217@mollari.NetBSD.org>
Date: Thu, 27 Feb 2020 20:04:51 +0000 (UTC)
From: nykula@ukr.net
Reply-To: nykula@ukr.net
To: gnats-bugs@NetBSD.org
Subject: Samurai as ninja-build alternative system-wide
X-Send-Pr-Version: www-1.0

>Number:         55027
>Category:       pkg
>Synopsis:       Samurai as ninja-build alternative system-wide
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 27 20:05:00 +0000 2020
>Last-Modified:  Fri Feb 28 23:45:01 +0000 2020
>Originator:     Denys Nykula
>Release:        current
>Organization:
>Environment:
Linux e11 5.5.0-rc3 #1 SMP Thu Dec 26 01:45:51 UTC 2019 x86_64
>Description:

>How-To-Repeat:

>Fix:
From 193a530962afa6b072486ee6cd8d6d1f090c772a Mon Sep 17 00:00:00 2001
From: Denys Nykula <nykula@ukr.net>
Date: Wed, 26 Feb 2020 23:47:42 +0200
Subject: [PATCH] Samurai as ninja-build alternative system-wide

Samurai implements ninja language without depending on either cmake or
python, or other packages such as re2c. It's 4k lines of C and Makefile,
as opposed to 18k lines of C++ and Python according to codetabs, so
builds slightly faster. When you have samurai you don't require to have
ninja-build installed, and vice versa. User should be able to choose
samu as the global ninja implementation while bootstrapping pkgsrc, by
mentioning NINJA_BUILD=samu in their mk.conf fragment.
---
diff --git a/devel/meson/Makefile b/devel/meson/Makefile
index 336572a..f572d68 100644
--- a/devel/meson/Makefile
+++ b/devel/meson/Makefile
@@ -12,7 +12,7 @@ LICENSE=	apache-2.0
 CONFLICTS=	${PYPKGPREFIX}-meson-[0-9]*
 SUPERSEDES=	${PYPKGPREFIX}-meson-[0-9]*

-DEPENDS+=	ninja-build-[0-9]*:../../devel/ninja-build
+.include "../../devel/ninja-build/depends.mk"

 PYTHON_VERSIONS_INCOMPATIBLE=	27

diff --git a/devel/ninja-build/build.mk b/devel/ninja-build/build.mk
new file mode 100644
index 0000000..ce5179d
--- /dev/null
+++ b/devel/ninja-build/build.mk
@@ -0,0 +1,26 @@
+# $NetBSD$
+#
+# This mk fragment can be included by all packages that need ninja as a build
+# dependency (e.g. for gnuradio).
+#
+# User-settable variables:
+#
+# NINJA_BUILD
+#	Type of used ninja-build implementation.
+#
+#	Possible values: ninja samu
+#	Default: ninja
+#
+
+.if !defined(NINJA_BUILD_MK)
+NINJA_BUILD_MK=	defined
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${NINJA_BUILD} == "samu"
+BUILD_DEPENDS+=	samurai-[0-9]*:../../devel/samurai
+.else
+BUILD_DEPENDS+=	ninja-build-[0-9]*:../../devel/ninja-build
+.endif
+
+.endif # NINJA_BUILD_MK
diff --git a/devel/ninja-build/depends.mk b/devel/ninja-build/depends.mk
new file mode 100644
index 0000000..5cc5e7d
--- /dev/null
+++ b/devel/ninja-build/depends.mk
@@ -0,0 +1,26 @@
+# $NetBSD$
+#
+# This mk fragment can be included by all packages that need ninja as a
+# dependency (e.g. for meson).
+#
+# User-settable variables:
+#
+# NINJA_BUILD
+#	Type of used ninja-build implementation.
+#
+#	Possible values: ninja samu
+#	Default: ninja
+#
+
+.if !defined(NINJA_DEPENDS_MK)
+NINJA_DEPENDS_MK=	defined
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${NINJA_BUILD} == "samu"
+DEPENDS+=	samurai-[0-9]*:../../devel/samurai
+.else
+DEPENDS+=	ninja-build-[0-9]*:../../devel/ninja-build
+.endif
+
+.endif # NINJA_DEPENDS_MK
diff --git a/devel/samurai/Makefile b/devel/samurai/Makefile
index e01301f..e879b7c 100644
--- a/devel/samurai/Makefile
+++ b/devel/samurai/Makefile
@@ -14,4 +14,12 @@ BUILD_TARGET=	samu
 MAKE_FLAGS+=	PREFIX=${PREFIX}
 MAKE_FLAGS+=	MANDIR=${PREFIX}/${PKGMANDIR}

+PLIST_VARS+=	ninja
+.include "../../mk/bsd.prefs.mk"
+.if ${NINJA_BUILD} == "samu"
+PLIST.ninja=	yes
+post-install:
+	${LN} -s samu ${DESTDIR}${PREFIX}/bin/ninja
+.endif
+
 .include "../../mk/bsd.pkg.mk"
diff --git a/devel/samurai/PLIST b/devel/samurai/PLIST
index 9ee7f36..cdbd25c 100644
--- a/devel/samurai/PLIST
+++ b/devel/samurai/PLIST
@@ -1,3 +1,4 @@
 @comment $NetBSD: PLIST,v 1.1 2019/12/11 23:36:29 ng0 Exp $
+${PLIST.ninja}bin/ninja
 bin/samu
 man/man1/samu.1
diff --git a/finance/gnucash/Makefile b/finance/gnucash/Makefile
index 3c7db7a..98bd39e 100644
--- a/finance/gnucash/Makefile
+++ b/finance/gnucash/Makefile
@@ -44,7 +44,7 @@ CMAKE_ARGS+=		-DWITH_AQBANKING=OFF
 CMAKE_ARGS+=		-DPERL_EXECUTABLE=${PERL5}
 CMAKE_ARGS+=		-DCOMPILE_GSCHEMAS=OFF
 #CMAKE_ARGS+=		-GNinja
-#BUILD_DEPENDS+=	ninja-build-[0-9]*:../../devel/ninja-build
+#.include "../../devel/ninja-build/build.mk"

 #do-build:
 #	cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ninja
diff --git a/ham/gnuradio-core/options.mk b/ham/gnuradio-core/options.mk
index 0237c34..83b424e 100644
--- a/ham/gnuradio-core/options.mk
+++ b/ham/gnuradio-core/options.mk
@@ -16,7 +16,7 @@ PKG_SUGGESTED_OPTIONS=	filter-design

 .if !empty(PKG_OPTIONS:Mninja-build)
 CMAKE_ARGS+=	-GNinja
-BUILD_DEPENDS+=	ninja-build-[0-9]*:../../devel/ninja-build
+.include "../../devel/ninja-build/build.mk"

 do-build:
 	(cd ${WRKSRC}/build; ninja)
diff --git a/mk/defaults/mk.conf b/mk/defaults/mk.conf
index 78807fe..c73beb1 100644
--- a/mk/defaults/mk.conf
+++ b/mk/defaults/mk.conf
@@ -1470,6 +1470,12 @@ NBPAX_PROGRAM_PREFIX?=  nb
 # Possible: any string, leave it empty for no prefix at all
 # Default: nb

+NINJA_BUILD?=	ninja
+# devel/samurai implements most features of devel/ninja-build
+# without depending on either c++ or python, and is smaller.
+# Possible: ninja or samu.
+# Default: ninja
+
 NMH_EDITOR?= vi
 # default editor for use in nmh.
 # Possible: any editor.

>Audit-Trail:
From: Michael Forney <mforney@mforney.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/55027 (Samurai as ninja-build alternative system-wide)
Date: Thu, 27 Feb 2020 13:08:41 -0800

 I'm quite happy to see samurai become an alternative for ninja for pkgsrc.

 I've been using the following patch to make the ninja command
 selectable via TOOLS_PLATFORM.ninja, so I can use my system version of
 samu:
 https://github.com/oasislinux/pkgsrc/commit/7627f6ef0760d04efde48930981f67c86caba1f2.patch

 Is it possible to integrate your patch with the TOOLS framework
 somehow, so that it can use the system version of ninja or samurai (if
 they are available)?

From: Denys Nykula <nykula@ukr.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/55027 (Samurai as ninja-build alternative system-wide)
Date: Sat, 29 Feb 2020 00:43:30 +0200

 On Thu, 27 Feb 2020 13:08:41 -0800, Michael Forney wrote:
 > I've been using the following patch to make the ninja command
 > selectable via TOOLS_PLATFORM.ninja, so I can use my system version of
 > samu:
 > https://github.com/oasislinux/pkgsrc/commit/7627f6ef0760d04efde48930981f67c86caba1f2.patch
 > 
 > Is it possible to integrate your patch with the TOOLS framework
 > somehow, so that it can use the system version of ninja or samurai (if
 > they are available)?

 Please review if the following patch v2 works for your system.
 ---
 From d65d1e395af4983ee237be6aeddceb4e18bfad73 Mon Sep 17 00:00:00 2001
 From: Denys Nykula <nykula@ukr.net>
 Date: Sat, 29 Feb 2020 00:09:46 +0200
 Subject: [PATCH v2] samurai: ninja-build alternative system-wide

 Samurai implements ninja language without depending on either cmake or
 python, or other packages such as re2c. It's 4k lines of C and Makefile,
 as opposed to 18k lines of C++ and Python according to codetabs, so
 builds slightly faster. When you have samurai you don't require to have
 ninja-build installed, and vice versa. User should be able to choose
 samu as the global ninja implementation while bootstrapping pkgsrc, by
 mentioning NINJA_BUILD=samu in their mk.conf fragment.

 Following Michael Forney's suggestion, switched to the TOOLS framework,
 which removes the need for build.mk and depends.mk and also lets you opt
 out of building either samurai or ninja-build in favor of the host ninja
 implementation, using a TOOLS_PLATFORM.ninja=/usr/bin/ninja setting.
 ---
 diff --git a/devel/meson/Makefile b/devel/meson/Makefile
 index 336572a9d..0d661e633 100644
 --- a/devel/meson/Makefile
 +++ b/devel/meson/Makefile
 @@ -12,7 +12,7 @@ LICENSE=	apache-2.0
  CONFLICTS=	${PYPKGPREFIX}-meson-[0-9]*
  SUPERSEDES=	${PYPKGPREFIX}-meson-[0-9]*

 -DEPENDS+=	ninja-build-[0-9]*:../../devel/ninja-build
 +USE_TOOLS+=	ninja:run

  PYTHON_VERSIONS_INCOMPATIBLE=	27

 diff --git a/devel/meson/build.mk b/devel/meson/build.mk
 index f50a38830..4e0b19b7c 100644
 --- a/devel/meson/build.mk
 +++ b/devel/meson/build.mk
 @@ -1,6 +1,7 @@
  # $NetBSD: build.mk,v 1.5 2020/02/25 04:54:35 rillig Exp $

  BUILD_DEPENDS+=        meson-[0-9]*:../../devel/meson
 +USE_TOOLS+=    ninja

  CONFIGURE_DIRS?=       .
  BUILD_DIRS?=           ${CONFIGURE_DIRS}
 diff --git a/devel/samurai/Makefile b/devel/samurai/Makefile
 index e01301fe9..37c50bf24 100644
 --- a/devel/samurai/Makefile
 +++ b/devel/samurai/Makefile
 @@ -14,4 +14,12 @@ BUILD_TARGET=	samu
  MAKE_FLAGS+=	PREFIX=${PREFIX}
  MAKE_FLAGS+=	MANDIR=${PREFIX}/${PKGMANDIR}

 +PLIST_VARS+=	ninja
 +.include "../../mk/bsd.prefs.mk"
 +.if ${NINJA_BUILD} == "samu"
 +PLIST.ninja=	yes
 +post-install:
 +	${LN} -s samu ${DESTDIR}${PREFIX}/bin/ninja
 +.endif
 +
  .include "../../mk/bsd.pkg.mk"
 diff --git a/devel/samurai/PLIST b/devel/samurai/PLIST
 index 9ee7f3604..cdbd25cd2 100644
 --- a/devel/samurai/PLIST
 +++ b/devel/samurai/PLIST
 @@ -1,3 +1,4 @@
  @comment $NetBSD: PLIST,v 1.1 2019/12/11 23:36:29 ng0 Exp $
 +${PLIST.ninja}bin/ninja
  bin/samu
  man/man1/samu.1
 diff --git a/finance/gnucash/Makefile b/finance/gnucash/Makefile
 index 3c7db7a29..30a173bbf 100644
 --- a/finance/gnucash/Makefile
 +++ b/finance/gnucash/Makefile
 @@ -44,7 +44,7 @@ CMAKE_ARGS+=		-DWITH_AQBANKING=OFF
  CMAKE_ARGS+=		-DPERL_EXECUTABLE=${PERL5}
  CMAKE_ARGS+=		-DCOMPILE_GSCHEMAS=OFF
  #CMAKE_ARGS+=		-GNinja
 -#BUILD_DEPENDS+=	ninja-build-[0-9]*:../../devel/ninja-build
 +#USE_TOOLS+=		ninja

  #do-build:
  #	cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ninja
 diff --git a/ham/gnuradio-core/options.mk b/ham/gnuradio-core/options.mk
 index 0237c3418..3758d3fa0 100644
 --- a/ham/gnuradio-core/options.mk
 +++ b/ham/gnuradio-core/options.mk
 @@ -16,7 +16,7 @@ PKG_SUGGESTED_OPTIONS=	filter-design

  .if !empty(PKG_OPTIONS:Mninja-build)
  CMAKE_ARGS+=	-GNinja
 -BUILD_DEPENDS+=	ninja-build-[0-9]*:../../devel/ninja-build
 +USE_TOOLS+=	ninja

  do-build:
  	(cd ${WRKSRC}/build; ninja)
 diff --git a/mk/defaults/mk.conf b/mk/defaults/mk.conf
 index 78807fe0f..e32866e62 100644
 --- a/mk/defaults/mk.conf
 +++ b/mk/defaults/mk.conf
 @@ -1470,6 +1470,12 @@ NBPAX_PROGRAM_PREFIX?=  nb
  # Possible: any string, leave it empty for no prefix at all
  # Default: nb

 +NINJA_BUILD?=	ninja
 +# devel/samurai implements most features of devel/ninja-build
 +# without depending on either cmake or python.
 +# Possible: ninja or samu.
 +# Default: ninja
 +
  NMH_EDITOR?= vi
  # default editor for use in nmh.
  # Possible: any editor.
 diff --git a/mk/tools/replace.mk b/mk/tools/replace.mk
 index 8d1986ec4..98f0d9b6c 100644
 --- a/mk/tools/replace.mk
 +++ b/mk/tools/replace.mk
 @@ -619,6 +619,20 @@ TOOLS_PATH.mtree=		${LOCALBASE}/bin/mtree
  .  endif
  .endif

 +.if !defined(TOOLS_IGNORE.ninja) && !empty(_USE_TOOLS:Mninja)
 +.  if !empty(PKGPATH:Mdevel/ninja-build)
 +MAKEFLAGS+=			TOOLS_IGNORE.ninja=
 +.  elif !empty(_TOOLS_USE_PKGSRC.ninja:M[yY][eE][sS])
 +TOOLS_CREATE+=			ninja
 +TOOLS_PATH.ninja=		${LOCALBASE}/bin/ninja
 +.    if !empty(NINJA_BUILD:Msamu)
 +TOOLS_DEPENDS.ninja?=		samurai-[0-9]*:../../devel/samurai
 +.    else
 +TOOLS_DEPENDS.ninja?=		ninja-build-[0-9]*:../../devel/ninja-build
 +.    endif
 +.  endif
 +.endif
 +
  .if !defined(TOOLS_IGNORE.openssl) && !empty(_USE_TOOLS:Mopenssl)
  #
  # Ensure we use pkgsrc openssl if we're not using builtin.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.