summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Mendes <arthurmco@gmail.com>2021-04-06 12:54:28 -0300
committerGitHub <noreply@github.com>2021-04-06 17:54:28 +0200
commit0fd50f02836e59ad6fbe97ba423fb517fa9348b7 (patch)
tree97a7a488f2b47f391514a22a4103972903790fcf
parent380e688123250c671e1b935490e73090e19e6ec8 (diff)
downloadserenity-0fd50f02836e59ad6fbe97ba423fb517fa9348b7.zip
Ports: Add flatbuffers library (#6050)
The flatbuffers library is a serialization library, created by Google for game development and performance-critical applications. It aims to be fast and efficient. This commit creates a port of it to SerenityOS. The flatbuffers build process generates three things: some header files, a library (libflatbuffers) and a schema compiler (flatc). There are tests, but they are not compiled, because it runs the flatbuffers schema compiler, one of the things we are cross-compiling. The compiler will not run because the target is different from the host
-rw-r--r--Ports/AvailablePorts.md1
-rwxr-xr-xPorts/flatbuffers/package.sh18
-rw-r--r--Ports/flatbuffers/patches/flatbuffers-1.12.0.patch21
3 files changed, 40 insertions, 0 deletions
diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md
index 5ffce3d8d6..c395bdbfcc 100644
--- a/Ports/AvailablePorts.md
+++ b/Ports/AvailablePorts.md
@@ -23,6 +23,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^
| [`dropbear`](dropbear/) | Dropbear SSH | 2019.78 | https://dropbear.nl/mirror/dropbear.html |
| [`ed`](ed/) | GNU ed | 1.15 | https://www.gnu.org/software/ed/ |
| [`figlet`](figlet/) | FIGlet | 2.2.5 | http://www.figlet.org/ |
+| [`flatbuffers`](flatbuffers/) | Flatbuffers | 1.12.0 | https://github.com/google/flatbuffers |
| [`flex`](flex/) | flex | 2.6.4 | https://github.com/westes/flex |
| [`freetype`](freetype/) | FreeType | 2.10.4 | https://www.freetype.org/ |
| [`frotz`](frotz/) | Frotz | | https://gitlab.com/DavidGriffith/frotz |
diff --git a/Ports/flatbuffers/package.sh b/Ports/flatbuffers/package.sh
new file mode 100755
index 0000000000..ac104cd5eb
--- /dev/null
+++ b/Ports/flatbuffers/package.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env -S bash ../.port_include.sh
+
+port="flatbuffers"
+version="1.12.0"
+auth_type=sha256
+files="https://github.com/google/flatbuffers/archive/refs/tags/v${version}.tar.gz v${version}.tar.gz 62f2223fb9181d1d6338451375628975775f7522185266cd5296571ac152bc45"
+useconfigure=true
+# Since we are cross-compiling, we cannot build the tests, because we need
+# the flatbuffers compiler to build them
+configopts="-DCMAKE_TOOLCHAIN_FILE=$SERENITY_ROOT/Toolchain/CMakeToolchain.txt -DFLATBUFFERS_BUILD_TESTS=off"
+
+configure() {
+ run cmake $configopts
+}
+
+install() {
+ run make install
+}
diff --git a/Ports/flatbuffers/patches/flatbuffers-1.12.0.patch b/Ports/flatbuffers/patches/flatbuffers-1.12.0.patch
new file mode 100644
index 0000000000..0169fd1975
--- /dev/null
+++ b/Ports/flatbuffers/patches/flatbuffers-1.12.0.patch
@@ -0,0 +1,21 @@
+diff -ruN flatbuffers-1.12.0/src/code_generators.cpp flatbuffers-1.12.0-serenity/src/code_generators.cpp
+--- flatbuffers-1.12.0/src/code_generators.cpp 2020-03-12 19:33:39.000000000 -0300
++++ flatbuffers-1.12.0-serenity/src/code_generators.cpp 2021-03-31 20:39:12.000000000 -0300
+@@ -23,6 +23,17 @@
+ #include "flatbuffers/base.h"
+ #include "flatbuffers/util.h"
+
++#if defined(__serenity__)
++ // We do not have those functions inside std namespace...
++
++namespace std {
++ auto isnan(double x) { return ::isnan(x); }
++ auto isinf(double x) { return ::isinf(x); }
++}
++
++#endif
++
++
+ #if defined(_MSC_VER)
+ # pragma warning(push)
+ # pragma warning(disable : 4127) // C4127: conditional expression is constant