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)
This commit is contained in:
Jan Beich 2019-06-09 04:30:46 +00:00
parent 9e7fd269f9
commit 6a7017e296
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=503780
4 changed files with 102 additions and 13 deletions

View file

@ -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*
PLIST_FILES= bin/gn
do-configure:
cd ${WRKSRC} && GN_VERSION=${PORTVERSION} ${PYTHON_CMD} build/gen.py
do-build:
cd ${WRKSRC} && ninja -C out
post-patch:
@${REINPLACE_CMD} 's/"python"/"${PYTHON_CMD:T}"/' \
${WRKSRC}/tools/gn/exec_process_unittest.cc
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>

View file

@ -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):

View file

@ -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());

View file

@ -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)