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
This commit is contained in:
Arthur Mendes 2021-04-06 12:54:28 -03:00 committed by GitHub
parent 380e688123
commit 0fd50f0283
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 0 deletions

View file

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

18
Ports/flatbuffers/package.sh Executable file
View file

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

View file

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