Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Jun 2019 04:30:46 +0000 (UTC)
From:      Jan Beich <jbeich@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r503780 - in head/devel/gn: . files
Message-ID:  <201906090430.x594UkNO083226@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jbeich
Date: Sun Jun  9 04:30:46 2019
New Revision: 503780
URL: https://svnweb.freebsd.org/changeset/ports/503780

Log:
  devel/gn: modernize build
  
  - Unbreak with GCC
  - Unbreak on DragonFly
  - Allow Python 3.x
  - Allow debug builds
  - Convert to HAS_CONFIGURE
  - Convert to do-build from USES=ninja
  - Drop default build dependency in do-test
  - Drop unnecessary glob in CONFLICTS_INSTALL
  
  PR:		238353
  Reviewed by:	cpm
  Approved by:	Oleh Hushchenkov (maintainer)

Added:
  head/devel/gn/files/patch-tools_gn_exec__process__unittest.cc   (contents, props changed)
  head/devel/gn/files/patch-util_exe__path.cc   (contents, props changed)
Modified:
  head/devel/gn/Makefile   (contents, props changed)
  head/devel/gn/files/patch-build_gen.py   (contents, props changed)

Modified: head/devel/gn/Makefile
==============================================================================
--- head/devel/gn/Makefile	Sun Jun  9 04:22:37 2019	(r503779)
+++ head/devel/gn/Makefile	Sun Jun  9 04:30:46 2019	(r503780)
@@ -3,6 +3,7 @@
 PORTNAME=	gn
 DISTVERSIONPREFIX=	v
 DISTVERSION=	1592
+PORTREVISION=	1
 CATEGORIES=	devel
 
 MAINTAINER=	o.hushchenkov@gmail.com
@@ -11,25 +12,29 @@ COMMENT=	Gn meta build framework - standalone version
 LICENSE=	BSD3CLAUSE
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-USES=		compiler:c++14-lang ninja python:2.7,build
+CONFLICTS_INSTALL=	chromium-gn
 
+USES=		alias compiler:c++14-lang ninja python:build shebangfix
 USE_GITHUB=	yes
 GH_ACCOUNT=	cglogic # mirror
+SHEBANG_FILES=	${CONFIGURE_SCRIPT}
+HAS_CONFIGURE=	yes
+CONFIGURE_OUTSOURCE=	yes
+CONFIGURE_SCRIPT=	build/gen.py
+CONFIGURE_WRKSRC=	${WRKSRC}/out # --out-path breaks "make test"
+CONFIGURE_ENV=	GN_VERSION=${PORTVERSION}
+CONFIGURE_ARGS=	--platform freebsd ${WITH_DEBUG:D--debug}
+ALL_TARGET=	# empty
+PLIST_FILES=	bin/${PORTNAME}
 
-CONFLICTS_INSTALL=	chromimum-gn*
+post-patch:
+	@${REINPLACE_CMD} 's/"python"/"${PYTHON_CMD:T}"/' \
+		${WRKSRC}/tools/gn/exec_process_unittest.cc
 
-PLIST_FILES=	bin/gn
-
-do-configure:
-	cd ${WRKSRC} && GN_VERSION=${PORTVERSION} ${PYTHON_CMD} build/gen.py
-
-do-build:
-	cd ${WRKSRC} && ninja -C out
-
 do-install:
-	${INSTALL_PROGRAM} ${WRKSRC}/out/gn ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_PROGRAM} ${INSTALL_WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin
 
-do-test: build
-	cd ${WRKSRC} && ./out/gn_unittests
+do-test:
+	${TEST_WRKSRC}/gn_unittests
 
 .include <bsd.port.mk>

Modified: head/devel/gn/files/patch-build_gen.py
==============================================================================
--- head/devel/gn/files/patch-build_gen.py	Sun Jun  9 04:22:37 2019	(r503779)
+++ head/devel/gn/files/patch-build_gen.py	Sun Jun  9 04:30:46 2019	(r503780)
@@ -1,5 +1,17 @@
+- Unbreak --platform freebsd (required on DragonFly)
+- .git/ is missing in archive, so use version from environment
+
 --- build/gen.py.orig	2019-05-30 09:42:43 UTC
 +++ build/gen.py
+@@ -46,7 +46,7 @@ class Platform(object):
+ 
+   @staticmethod
+   def known_platforms():
+-    return ['linux', 'darwin', 'msvc', 'aix', 'fuchsia', 'openbsd']
++    return ['linux', 'darwin', 'msvc', 'aix', 'fuchsia', 'freebsd', 'openbsd']
+ 
+   def platform(self):
+     return self._platform
 @@ -117,24 +117,15 @@ def main(argv):
  
  

Added: head/devel/gn/files/patch-tools_gn_exec__process__unittest.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gn/files/patch-tools_gn_exec__process__unittest.cc	Sun Jun  9 04:30:46 2019	(r503780)
@@ -0,0 +1,49 @@
+- Convert inline Python to 3.x syntax
+
+--- tools/gn/exec_process_unittest.cc.orig	2019-05-30 00:15:11 UTC
++++ tools/gn/exec_process_unittest.cc
+@@ -70,7 +70,7 @@ TEST(ExecProcessTest, TestLargeOutput) {
+   std::string std_out, std_err;
+   int exit_code;
+ 
+-  ASSERT_TRUE(ExecPython("import sys; print 'o' * 1000000", &std_out, &std_err,
++  ASSERT_TRUE(ExecPython("import sys; print('o' * 1000000)", &std_out, &std_err,
+                          &exit_code));
+   EXPECT_EQ(0, exit_code);
+   EXPECT_EQ(1000001u, std_out.size());
+@@ -81,7 +81,7 @@ TEST(ExecProcessTest, TestStdoutAndStderrOutput) {
+   int exit_code;
+ 
+   ASSERT_TRUE(ExecPython(
+-      "import sys; print 'o' * 10000; print >>sys.stderr, 'e' * 10000",
++      "from __future__ import print_function; import sys; print('o' * 10000); print('e' * 10000, file=sys.stderr)",
+       &std_out, &std_err, &exit_code));
+   EXPECT_EQ(0, exit_code);
+   EXPECT_EQ(10001u, std_out.size());
+@@ -90,7 +90,7 @@ TEST(ExecProcessTest, TestStdoutAndStderrOutput) {
+   std_out.clear();
+   std_err.clear();
+   ASSERT_TRUE(ExecPython(
+-      "import sys; print >>sys.stderr, 'e' * 10000; print 'o' * 10000",
++      "from __future__ import print_function; import sys; print('e' * 10000, file=sys.stderr); print('o' * 10000)",
+       &std_out, &std_err, &exit_code));
+   EXPECT_EQ(0, exit_code);
+   EXPECT_EQ(10001u, std_out.size());
+@@ -101,7 +101,7 @@ TEST(ExecProcessTest, TestOneOutputClosed) {
+   std::string std_out, std_err;
+   int exit_code;
+ 
+-  ASSERT_TRUE(ExecPython("import sys; sys.stderr.close(); print 'o' * 10000",
++  ASSERT_TRUE(ExecPython("import sys; sys.stderr.close(); print('o' * 10000)",
+                          &std_out, &std_err, &exit_code));
+   EXPECT_EQ(0, exit_code);
+   EXPECT_EQ(10001u, std_out.size());
+@@ -110,7 +110,7 @@ TEST(ExecProcessTest, TestOneOutputClosed) {
+   std_out.clear();
+   std_err.clear();
+   ASSERT_TRUE(ExecPython(
+-      "import sys; sys.stdout.close(); print >>sys.stderr, 'e' * 10000",
++      "from __future__ import print_function; import sys; sys.stdout.close(); print('e' * 10000, file=sys.stderr)",
+       &std_out, &std_err, &exit_code));
+   EXPECT_EQ(0, exit_code);
+   EXPECT_EQ(0u, std_out.size());

Added: head/devel/gn/files/patch-util_exe__path.cc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/devel/gn/files/patch-util_exe__path.cc	Sun Jun  9 04:30:46 2019	(r503780)
@@ -0,0 +1,23 @@
+- Unbreak build with GCC:
+
+../util/exe_path.cc: In function 'base::FilePath GetExePath()':
+../util/exe_path.cc:56:12: error: 'PATH_MAX' was not declared in this scope
+   56 |   char buf[PATH_MAX];
+      |            ^~~~~~~~
+../util/exe_path.cc:58:22: error: 'buf' was not declared in this scope
+   58 |   if (sysctl(mib, 4, buf, &buf_size, nullptr, 0) == -1) {
+      |                      ^~~
+../util/exe_path.cc:61:25: error: 'buf' was not declared in this scope
+   61 |   return base::FilePath(buf);
+      |                         ^~~
+
+--- util/exe_path.cc.orig	2019-05-30 00:15:11 UTC
++++ util/exe_path.cc
+@@ -16,6 +16,7 @@
+ #elif defined(OS_FREEBSD)
+ #include <sys/sysctl.h>
+ #include <sys/types.h>
++#include <limits.h> // PATH_MAX
+ #endif
+ 
+ #if defined(OS_MACOSX)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906090430.x594UkNO083226>