Skip to content

Commit

Permalink
ninja: Update to 1.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandesign committed May 17, 2024
1 parent 55118f8 commit a52dd80
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 11 deletions.
23 changes: 18 additions & 5 deletions devel/ninja/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ PortSystem 1.0
PortGroup github 1.0

epoch 1
github.setup ninja-build ninja 1.12.0 v
github.setup ninja-build ninja 1.12.1 v
revision 0

checksums rmd160 ec9d91ea727da87f1178226ccf42645d10d05d45 \
sha256 8b2c86cd483dc7fcb7975c5ec7329135d210099a89bc7db0590a07b0bbfe49a5 \
size 240291
checksums rmd160 edb99cb67641947a6cdde89300a326de69df77f4 \
sha256 821bdff48a3f683bc4bb3b6f0b5fe7b2d647cf65d52aeb63328c91a6c6df285a \
size 240483

categories devel
maintainers {ryandesign @ryandesign} openmaintainer
Expand All @@ -34,11 +33,24 @@ long_description Ninja is yet another build system. It takes as input \

homepage https://ninja-build.org
github.tarball_from archive
checksums-prepend ${distfiles}
set gtest_version 1.14.0
set gtest_distname googletest-${gtest_version}
set gtest_distfile ${gtest_distname}${extract.suffix}
master_sites ${master_sites}:main \
https://github.com/google/googletest/archive/v${gtest_version}:gtest
distfiles ${distfiles}:main \
${gtest_distfile}:gtest
checksums-append ${gtest_distfile} \
rmd160 54f7bd68b80152528dfc13d9291b247c0353c2a4 \
sha256 8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7 \
size 867764

installs_libs no

patchfiles patch-configure.py-bootstrap-only.diff \
patch-ninja-configure.py-remove-mmd.diff
patchfiles-append tests.patch

depends_build-append \
port:re2c
Expand All @@ -58,6 +70,7 @@ configure.pre_args configure.py
default configure.args \
{--with-python=${configure.python}}
configure.post_args --bootstrap \
--gtest-source-dir=${workpath}/${gtest_distname} \
--verbose
configure.universal_args

Expand Down
6 changes: 3 additions & 3 deletions devel/ninja/files/patch-configure.py-bootstrap-only.diff
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
When running ./configure.py --bootstrap, do not automatically run ./ninja
--- configure.py.orig 2022-05-15 10:08:10.000000000 -0500
+++ configure.py 2022-05-18 04:18:56.000000000 -0500
@@ -693,28 +693,3 @@
--- configure.py.orig 2024-05-11 06:43:36.000000000 -0500
+++ configure.py 2024-05-17 00:15:59.000000000 -0500
@@ -675,28 +675,3 @@
n.close()
print('wrote %s.' % BUILD_FILENAME)

Expand Down
6 changes: 3 additions & 3 deletions devel/ninja/files/patch-ninja-configure.py-remove-mmd.diff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- configure.py.orig 2021-02-13 23:21:58.000000000 -0800
+++ configure.py 2021-02-13 23:22:17.000000000 -0800
@@ -425,7 +425,7 @@
--- configure.py.orig 2024-05-17 00:15:14.000000000 -0500
+++ configure.py 2024-05-17 00:15:14.000000000 -0500
@@ -435,7 +435,7 @@
)
else:
n.rule('cxx',
Expand Down
101 changes: 101 additions & 0 deletions devel/ninja/files/tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
Allow the tests to be run using the Python-based configure.py build system.
https://github.com/ninja-build/ninja/issues/2447
https://github.com/ninja-build/ninja/pull/2448
--- configure.py.orig 2024-05-17 01:04:17.000000000 -0500
+++ configure.py 2024-05-17 01:04:17.000000000 -0500
@@ -213,7 +213,10 @@
parser.add_option('--profile', metavar='TYPE',
choices=profilers,
help='enable profiling (' + '/'.join(profilers) + ')',)
-parser.add_option('--with-gtest', metavar='PATH', help='ignored')
+parser.add_option('--gtest-source-dir', metavar='PATH',
+ help='Path to GoogleTest source directory. If not provided ' +
+ 'GTEST_SOURCE_DIR will be probed in the environment. ' +
+ 'Tests will not be built without a value.')
parser.add_option('--with-python', metavar='EXE',
help='use EXE as the Python interpreter',
default=os.path.basename(sys.executable))
@@ -582,6 +585,83 @@
# build.ninja file.
n = ninja_writer

+# Build the ninja_test executable only if the GTest source directory
+# is provided explicitly. Either from the environment with GTEST_SOURCE_DIR
+# or with the --gtest-source-dir command-line option.
+#
+# Do not try to look for an installed binary version, and link against it
+# because doing so properly is platform-specific (use the CMake build for
+# this).
+if options.gtest_source_dir:
+ gtest_src_dir = options.gtest_source_dir
+else:
+ gtest_src_dir = os.environ.get('GTEST_SOURCE_DIR')
+
+if gtest_src_dir:
+ # Verify GoogleTest source directory, and add its include directory
+ # to the global include search path (even for non-test sources) to
+ # keep the build plan generation simple.
+ gtest_all_cc = os.path.join(gtest_src_dir, 'googletest', 'src', 'gtest-all.cc')
+ if not os.path.exists(gtest_all_cc):
+ print('ERROR: Missing GoogleTest source file: %s' % gtest_all_cc)
+ sys.exit(1)
+
+ n.comment('Tests all build into ninja_test executable.')
+
+ # Test-specific version of cflags, must include the GoogleTest
+ # include directory. Also GoogleTest can only build with a C++14 compiler.
+ test_cflags = [f.replace('std=c++11', 'std=c++14') for f in cflags]
+ test_cflags.append('-I' + os.path.join(gtest_src_dir, 'googletest', 'include'))
+
+ test_variables = [('cflags', test_cflags)]
+ if platform.is_msvc():
+ test_variables += [('pdb', 'ninja_test.pdb')]
+
+ test_names = [
+ 'build_log_test',
+ 'build_test',
+ 'clean_test',
+ 'clparser_test',
+ 'depfile_parser_test',
+ 'deps_log_test',
+ 'disk_interface_test',
+ 'dyndep_parser_test',
+ 'edit_distance_test',
+ 'graph_test',
+ 'json_test',
+ 'lexer_test',
+ 'manifest_parser_test',
+ 'ninja_test',
+ 'state_test',
+ 'string_piece_util_test',
+ 'subprocess_test',
+ 'test',
+ 'util_test',
+ ]
+ if platform.is_windows():
+ test_names += [
+ 'includes_normalize_test',
+ 'msvc_helper_test',
+ ]
+
+ objs = []
+ for name in test_names:
+ objs += cxx(name, variables=test_variables)
+
+ # Build GTest as a monolithic source file.
+ # This requires one extra include search path, so replace the
+ # value of 'cflags' in our list.
+ gtest_all_variables = test_variables[1:] + [
+ ('cflags', test_cflags + ['-I' + os.path.join(gtest_src_dir, 'googletest') ]),
+ ]
+ # Do not use cxx() directly to ensure the object file is under $builddir.
+ objs += n.build(built('gtest_all' + objext), 'cxx', gtest_all_cc, variables=gtest_all_variables)
+
+ ninja_test = n.build(binary('ninja_test'), 'link', objs, implicit=ninja_lib,
+ variables=[('libs', libs)])
+ n.newline()
+ all_targets += ninja_test
+
n.comment('Ancillary executables.')

if platform.is_aix() and '-maix64' not in ldflags:

0 comments on commit a52dd80

Please sign in to comment.