dev-build/ninja: Sync with Gentoo

It's from Gentoo commit 2d25fad95cbaa525c8945d8e582c749d49524f49.

Signed-off-by: Flatcar Buildbot <buildbot@flatcar-linux.org>
This commit is contained in:
Flatcar Buildbot 2026-01-12 07:11:05 +00:00 committed by Krzesimir Nowak
parent 17218dd96b
commit 575ccf6ae8
8 changed files with 99 additions and 269 deletions

View File

@ -1,6 +1,3 @@
DIST gtest-1.14.0.tar.gz 867764 BLAKE2B c457f55ac572b9fb1553eee3df7eeeaf1e7dd2c3d747dd5e90dd279038fa5c71bb7b7d9ba1cf7e6143898b2a1d24d100584bd2a48ded41a426870c4825eec1b2 SHA512 765c326ccc1b87a01027385e69238266e356361cd4ee3e18e3c9d137a5d11fa5d657c164d02dd1be8fe693c8e10f2b580588dbfa57d27f070e2750f50d3e662c
DIST gtest-1.16.0.tar.gz 876245 BLAKE2B e5f301987fd4b73cfc8e900ac476b38444994c63bd2f334fdc58704f9e6e966cc03a2dba7ddc033624e89853a15b2592530a1180c3e56be7a28928ed370a9e27 SHA512 bec8dad2a5abbea8e9e5f0ceedd8c9dbdb8939e9f74785476b0948f21f5db5901018157e78387e106c6717326558d6642fc0e39379c62af57bf1205a9df8a18b
DIST ninja-1.11.1.tar.gz 229479 BLAKE2B c96cf7c319b7abd65f644465688d256f8b3a576c4616d0c63852e25dd0dc5f63c66708d429d8dddb6228502eb147211a86a5dd369b80ec2228902b370d2343e5 SHA512 1bca38877c70ee6613f347ffccef5adc02ba0a3947c62ae004ea97f918442b5a3de92378e4f820ae2a7676bc7609d25fbc7d41f6cfb3a61e5e4b26ec3639e403
DIST ninja-1.12.1.tar.gz 240483 BLAKE2B 915545888cbd7d9e6e7e4fb0bad42f6c36ecef2de93356966541de0f8f4315e59e47cf20f189de5de11ba2a038488c7964ec709bad8868488cc03524a88483f4 SHA512 d6e6f0e89a4844a69069ff0c7cefc07704a41c7b0c062a57534de87decdde63e27928147b321111b806aa7efa1061f031a1319b074391db61b0cbdccf096954c
DIST ninja-1.13.0.tar.gz 291328 BLAKE2B 263da5b3991a7569012a46f2311b50fafc32838aebca79772fdebade4c87d1b01286ba24b4055d19b372cd3829a22f04892518227ce976e24a55777d9b9c762f SHA512 e03f721a34c19e47160eae2daa56299f4d030df646f63a277b8089b37ed8922e0cc944c421d257a33ee05b177a61ed15d8eb0e8584c3196da3137677b7b41db6
DIST ninja-1.13.1.tar.gz 292098 BLAKE2B 610faa82e23ad23ec949f8a75cb4d8533c654bbfea63f2105e214d49cbf739af29d3ceebb4ead52693c7d925220817970073cd14ac8e948c5130b9ecfbac26ba SHA512 ec94d42967b962d66ab0747fcb9d095510117159de0473ec08df47a657895aa2523f920798e4608d0c6cf0e2e382512c14aec8a54ea58b6cd4b01edd3a7c8e62
DIST ninja-1.13.2.tar.gz 292385 BLAKE2B 3418c756386a277f2a280b39f378e1bb944c4f9664254c69066de0d73a274b7faa9b688c475337b28ef24e279b5533ed990479c0cc900dcf38b0562acbdaa322 SHA512 c0b401b4db91a2eea01a474ee979b2c6f1daa97b4c8d1f856871ce5f6d567c4b26d6246bc57e2a5f914329302abcd9c00ab0d4394a25f2ad502b6b00a07903d2

View File

@ -1,135 +0,0 @@
https://bugs.gentoo.org/929221
https://github.com/ninja-build/ninja/issues/2447
https://github.com/ninja-build/ninja/commit/afcd4a146fb82843f6ff695f89504ce4ca65ddfd
From afcd4a146fb82843f6ff695f89504ce4ca65ddfd Mon Sep 17 00:00:00 2001
From: David 'Digit' Turner <digit+github@google.com>
Date: Sun, 12 May 2024 23:45:28 +0200
Subject: [PATCH] configure.py: Support --gtest-source-dir to build tests.
Allow the Ninja build plan generated by configure.py to
build `ninja_test` by compiling GoogleTest from source if
the path to the library if passed through the new option
`--gtest-source-dir` or the GTEST_SOURCE_DIR environment
variable.
For simplicity, probing for an installed version of the
library, and linking to it, is not supported (use the
CMake build for this).
This also removes the obsolete `--gtest-dir` option.
Fixes #2447
---
configure.py | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/configure.py b/configure.py
index f9e49f9cdf..2b16618c43 100755
--- a/configure.py
+++ b/configure.py
@@ -223,7 +223,10 @@ def _run_command(self, cmdline: str) -> None:
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))
@@ -435,6 +438,7 @@ def shell_escape(str: str) -> str:
if 'LDFLAGS' in configure_env:
ldflags.append(configure_env['LDFLAGS'])
n.variable('ldflags', ' '.join(shell_escape(flag) for flag in ldflags))
+
n.newline()
if platform.is_msvc():
@@ -592,6 +596,83 @@ def has_re2c() -> bool:
# 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:

View File

@ -0,0 +1,88 @@
https://github.com/ninja-build/ninja/pull/2692
From 9f1f01d7d03b84342dda511aad0ef3e3fcf4ea7c Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Sat, 22 Nov 2025 12:49:35 +0000
Subject: [PATCH] Don't require a FIFO to be identifiable as such
The jobserver specification [0] currently suggests that the FIFO must be a
genuine FIFO.
For some work we're doing [1][2], we're emulating a FIFO using CUSE/FUSE to allow
tracking when consumers disappear to avoid lost tokens. nixos had a similar
idea in the past too [3].
There doesn't seem to be a good reason to check that any FIFO passed by
the user is actually identifiable as such by `stat()`, so drop the check.
make already does not perform such a check, just the specification isn't
clear about it, so we've asked them to clarify it [4].
[0] https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html
[1] https://codeberg.org/amonakov/guildmaster
[2] https://gitweb.gentoo.org/proj/steve.git/
[3] https://github.com/NixOS/nixpkgs/pull/314888
[4] https://savannah.gnu.org/bugs/index.php?67726
---
src/jobserver-posix.cc | 12 ------------
src/jobserver_test.cc | 10 +---------
2 files changed, 1 insertion(+), 21 deletions(-)
diff --git a/src/jobserver-posix.cc b/src/jobserver-posix.cc
index 0e3c7e250c..95208c09b6 100644
--- a/src/jobserver-posix.cc
+++ b/src/jobserver-posix.cc
@@ -26,13 +26,6 @@
namespace {
-// Return true if |fd| is a fifo or pipe descriptor.
-bool IsFifoDescriptor(int fd) {
- struct stat info;
- int ret = ::fstat(fd, &info);
- return (ret == 0) && ((info.st_mode & S_IFMT) == S_IFIFO);
-}
-
// Implementation of Jobserver::Client for Posix systems
class PosixJobserverClient : public Jobserver::Client {
public:
@@ -89,11 +82,6 @@ class PosixJobserverClient : public Jobserver::Client {
std::string("Error opening fifo for reading: ") + strerror(errno);
return false;
}
- if (!IsFifoDescriptor(read_fd_)) {
- *error = "Not a fifo path: " + fifo_path;
- // Let destructor close read_fd_.
- return false;
- }
write_fd_ = ::open(fifo_path.c_str(), O_WRONLY | O_NONBLOCK | O_CLOEXEC);
if (write_fd_ < 0) {
*error =
diff --git a/src/jobserver_test.cc b/src/jobserver_test.cc
index 850a8b13fd..9e180e6e39 100644
--- a/src/jobserver_test.cc
+++ b/src/jobserver_test.cc
@@ -379,21 +379,13 @@ TEST(Jobserver, PosixFifoClientWithWrongPath) {
ASSERT_GE(fd, 0) << "Could not create file: " << strerror(errno);
::close(fd);
- // Create new client instance, passing the file path for the fifo.
+ // Create new client instance, with an empty file path.
Jobserver::Config config;
config.mode = Jobserver::Config::kModePosixFifo;
- config.path = file_path;
-
std::string error;
std::unique_ptr<Jobserver::Client> client =
Jobserver::Client::Create(config, &error);
- EXPECT_FALSE(client.get());
- EXPECT_FALSE(error.empty());
- EXPECT_EQ("Not a fifo path: " + file_path, error);
- // Do the same with an empty file path.
- error.clear();
- config.path.clear();
client = Jobserver::Client::Create(config, &error);
EXPECT_FALSE(client.get());
EXPECT_FALSE(error.empty());

View File

@ -1,117 +0,0 @@
# Copyright 2012-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{10..12} )
inherit edo bash-completion-r1 python-any-r1 toolchain-funcs
if [[ ${PV} == 9999 ]]; then
EGIT_REPO_URI="https://github.com/ninja-build/ninja.git"
inherit git-r3
else
SRC_URI="https://github.com/ninja-build/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
fi
DESCRIPTION="A small build system similar to make"
HOMEPAGE="https://ninja-build.org/"
LICENSE="Apache-2.0"
SLOT="0"
IUSE="doc test"
RESTRICT="!test? ( test )"
BDEPEND="
${PYTHON_DEPS}
dev-util/re2c
doc? (
app-text/asciidoc
app-text/doxygen
dev-libs/libxslt
media-gfx/graphviz
)
test? ( dev-cpp/gtest )
"
PDEPEND="
app-alternatives/ninja
"
PATCHES=(
"${FILESDIR}"/ninja-cflags.patch
)
run_for_build() {
if tc-is-cross-compiler; then
local -x AR=$(tc-getBUILD_AR)
local -x CXX=$(tc-getBUILD_CXX)
local -x CFLAGS=
local -x CXXFLAGS="${BUILD_CXXFLAGS} -D_FILE_OFFSET_BITS=64"
local -x LDFLAGS=${BUILD_LDFLAGS}
fi
echo "$@" >&2
"$@"
}
src_compile() {
tc-export AR CXX
# configure.py appends CFLAGS to CXXFLAGS
unset CFLAGS
local -x CXXFLAGS="${CXXFLAGS} -D_FILE_OFFSET_BITS=64"
run_for_build ${EPYTHON} configure.py --bootstrap --verbose || die
if tc-is-cross-compiler; then
mv ninja ninja-build || die
${EPYTHON} configure.py || die
./ninja-build -v ninja || die
else
ln ninja ninja-build || die
fi
if use doc; then
./ninja-build -v doxygen manual || die
fi
}
src_test() {
if ! tc-is-cross-compiler; then
# Bug 485772
ulimit -n 2048
edo ./ninja -v ninja_test
edo ./ninja_test
fi
}
src_install() {
dodoc README.md CONTRIBUTING.md
if use doc; then
docinto html
dodoc -r doc/doxygen/html/.
dodoc doc/manual.html
fi
newbin ninja ninja-reference
newbashcomp misc/bash-completion ${PN}
insinto /usr/share/vim/vimfiles/syntax/
doins misc/ninja.vim
echo 'au BufNewFile,BufRead *.ninja set ft=ninja' > "${T}"/ninja.vim || die
insinto /usr/share/vim/vimfiles/ftdetect
doins "${T}"/ninja.vim
insinto /usr/share/zsh/site-functions
newins misc/zsh-completion _ninja
}
pkg_postinst() {
if ! [[ -e "${EROOT}/usr/bin/ninja" ]]; then
ln -s ninja-reference "${EROOT}/usr/bin/ninja" || die
fi
}

View File

@ -15,7 +15,7 @@ if [[ ${PV} == 9999 ]]; then
inherit git-r3
else
SRC_URI="https://github.com/ninja-build/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86 ~arm64-macos ~x64-macos ~x64-solaris"
fi
GTEST_VER=1.16.0

View File

@ -15,10 +15,10 @@ if [[ ${PV} == 9999 ]]; then
inherit git-r3
else
SRC_URI="https://github.com/ninja-build/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ~ppc ppc64 ~riscv ~s390 ~sparc x86 ~arm64-macos ~x64-macos ~x64-solaris"
fi
GTEST_VER=1.14.0
GTEST_VER=1.16.0
SRC_URI+=" test? ( https://github.com/google/googletest/archive/refs/tags/v${GTEST_VER}.tar.gz -> gtest-${GTEST_VER}.tar.gz )"
LICENSE="Apache-2.0"
@ -42,7 +42,7 @@ PDEPEND="
PATCHES=(
"${FILESDIR}"/ninja-cflags.patch
"${FILESDIR}"/${P}-restore-tests-bootstrap.patch
"${FILESDIR}"/${PN}-1.13.2-allow-psuedo-fifo.patch
)
pkg_setup() {
@ -66,17 +66,14 @@ bootstrap() {
local -x LDFLAGS=${BUILD_LDFLAGS}
fi
local args=(
local bootstrap_args=(
--with-python=python
--bootstrap
--verbose
$(usev test --gtest-source-dir="${WORKDIR}"/googletest-${GTEST_VER})
)
if use test; then
args+=( --gtest-source-dir="${WORKDIR}"/googletest-${GTEST_VER} )
fi
edo ${EPYTHON} configure.py "${args[@]}"
edo ${EPYTHON} configure.py "${bootstrap_args[@]}"
}
src_compile() {

View File

@ -15,10 +15,10 @@ if [[ ${PV} == 9999 ]]; then
inherit git-r3
else
SRC_URI="https://github.com/ninja-build/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos ~x64-macos ~x64-solaris"
fi
GTEST_VER=1.14.0
GTEST_VER=1.16.0
SRC_URI+=" test? ( https://github.com/google/googletest/archive/refs/tags/v${GTEST_VER}.tar.gz -> gtest-${GTEST_VER}.tar.gz )"
LICENSE="Apache-2.0"

View File

@ -15,7 +15,7 @@ if [[ ${PV} == 9999 ]]; then
inherit git-r3
else
SRC_URI="https://github.com/ninja-build/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos ~x64-macos ~x64-solaris"
fi
GTEST_VER=1.16.0