From 7f73f0300c16f9769590b1eef14c5e6c4918ace8 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 21 Jun 2020 18:41:01 -0400 Subject: [PATCH] Ports: Add ninja - 1.8.2 for now, newer versions need high-res timestamp file APIs which serenity doesn't have yet - pselect() instead of ppoll() for now, same reason (depends on #2609) - no good default for -j yet (see nproc.patch) - `-l` probably doesn't work yet (see loadavg.patch), but I've never used that anyways - some minor include patches that I've also sent upstream Other than that, this seems to work reasonably well. It currently produces some spam on stdout from probably the shell. --- Ports/ninja/package.sh | 17 +++++++++++++ Ports/ninja/patches/crossbuild.patch | 13 ++++++++++ Ports/ninja/patches/loadavg.patch | 19 +++++++++++++++ Ports/ninja/patches/nproc.patch | 13 ++++++++++ .../patches/sys-select-for-pselect.patch | 24 +++++++++++++++++++ Ports/ninja/patches/unistd-for-stat.patch | 12 ++++++++++ 6 files changed, 98 insertions(+) create mode 100755 Ports/ninja/package.sh create mode 100644 Ports/ninja/patches/crossbuild.patch create mode 100644 Ports/ninja/patches/loadavg.patch create mode 100644 Ports/ninja/patches/nproc.patch create mode 100644 Ports/ninja/patches/sys-select-for-pselect.patch create mode 100644 Ports/ninja/patches/unistd-for-stat.patch diff --git a/Ports/ninja/package.sh b/Ports/ninja/package.sh new file mode 100755 index 00000000000000..069838aba76306 --- /dev/null +++ b/Ports/ninja/package.sh @@ -0,0 +1,17 @@ +#!/bin/bash ../.port_include.sh +port=ninja +version=1.8.2 +workdir=ninja-1.8.2 +files="https://github.com/ninja-build/ninja/archive/v1.8.2.tar.gz ninja-v1.8.2.tar.gz" + +build() { + CXX=i686-pc-serenity-g++ CXXFLAGS="--sysroot=${SERENITY_ROOT}/Build/Root" \ + LDFLAGS="--sysroot=${SERENITY_ROOT}/Build/Root" \ + # platform=linux is close enough. + run ./configure.py --bootstrap --platform=linux --force-pselect + strip "${workdir}/ninja" +} + +install() { + cp "${workdir}/ninja" "${SERENITY_ROOT}/Build/Root/usr/local/bin/ninja" +} diff --git a/Ports/ninja/patches/crossbuild.patch b/Ports/ninja/patches/crossbuild.patch new file mode 100644 index 00000000000000..7efd5865c81144 --- /dev/null +++ b/Ports/ninja/patches/crossbuild.patch @@ -0,0 +1,13 @@ +diff --git a/configure.py b/configure.py +index a443748..064e9df 100755 +--- a/configure.py ++++ b/configure.py +@@ -657,7 +657,7 @@ n.build('all', 'phony', all_targets) + n.close() + print('wrote %s.' % BUILD_FILENAME) + +-if options.bootstrap: ++if options.bootstrap and False: + print('bootstrap complete. rebuilding...') + + rebuild_args = [] diff --git a/Ports/ninja/patches/loadavg.patch b/Ports/ninja/patches/loadavg.patch new file mode 100644 index 00000000000000..cdecfc8a7c1d17 --- /dev/null +++ b/Ports/ninja/patches/loadavg.patch @@ -0,0 +1,19 @@ +diff --git a/src/util.cc b/src/util.cc +index ae94d34..72cf501 100644 +--- a/src/util.cc ++++ b/src/util.cc +@@ -566,11 +566,14 @@ double GetLoadAverage() { + #else + double GetLoadAverage() { + double loadavg[3] = { 0.0f, 0.0f, 0.0f }; ++ /* ++ * FIXME: serenity way of getting loadavg + if (getloadavg(loadavg, 3) < 0) { + // Maybe we should return an error here or the availability of + // getloadavg(3) should be checked when ninja is configured. + return -0.0f; + } ++ */ + return loadavg[0]; + } + #endif // _WIN32 diff --git a/Ports/ninja/patches/nproc.patch b/Ports/ninja/patches/nproc.patch new file mode 100644 index 00000000000000..0e383c0ef2ae0b --- /dev/null +++ b/Ports/ninja/patches/nproc.patch @@ -0,0 +1,13 @@ +diff --git a/src/util.cc b/src/util.cc +index ae94d34..72cf501 100644 +--- a/src/util.cc ++++ b/src/util.cc +@@ -476,7 +476,7 @@ int GetProcessorCount() { + GetNativeSystemInfo(&info); + return info.dwNumberOfProcessors; + #else +- return sysconf(_SC_NPROCESSORS_ONLN); ++ return 1; // FIXME: serenity way of saying sysconf(_SC_NPROCESSORS_ONLN); + #endif + } + diff --git a/Ports/ninja/patches/sys-select-for-pselect.patch b/Ports/ninja/patches/sys-select-for-pselect.patch new file mode 100644 index 00000000000000..1e4212503995c5 --- /dev/null +++ b/Ports/ninja/patches/sys-select-for-pselect.patch @@ -0,0 +1,24 @@ +diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc +index 1de22c3..02b1b7e 100644 +--- a/src/subprocess-posix.cc ++++ b/src/subprocess-posix.cc +@@ -17,13 +17,18 @@ + #include + #include + #include +-#include + #include + #include + #include + #include + #include + ++#if defined(USE_PPOLL) ++#include ++#else ++#include ++#endif ++ + extern char** environ; + + #include "util.h" diff --git a/Ports/ninja/patches/unistd-for-stat.patch b/Ports/ninja/patches/unistd-for-stat.patch new file mode 100644 index 00000000000000..6616b989ccf329 --- /dev/null +++ b/Ports/ninja/patches/unistd-for-stat.patch @@ -0,0 +1,12 @@ +diff --git a/src/disk_interface.cc b/src/disk_interface.cc +index 28530b1..4da9a38 100644 +--- a/src/disk_interface.cc ++++ b/src/disk_interface.cc +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #ifdef _WIN32 + #include