Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports: Add flatbuffers library #6050

Merged
merged 2 commits into from
Apr 6, 2021

Conversation

arthurmco
Copy link
Contributor

@arthurmco arthurmco commented Apr 1, 2021

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.
Although this library is not much popular among the bigger opensource projects, there are some uses of it here on Github. If someone happens to port any small game that uses flatbuffers, it would be one less dependency for the person to port

The flatbuffers build process generates three things: some header files, a library (libflatbuffers) and a schema compiler (flatc).


A small caveat of this port: the library comes with a test suite, but we cannot run it, because it attempts to run the flatc executable we are compiling to SerenityOS in the host system. The host system does not recognize the file format, so it fails.
Nevertheless, the port compiles and runs: the schema compiler runs and the library links successfully

Comment on lines 29 to 31
+ #ifdef __serenity__
+ #define PATH_MAX 4096
+ #endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct way (according to Dr. POSIX) to get PATH_MAX is to make sure <limits.h> is included.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, I forgot about <limits.h>...

But a weird thing: the file I patched already includes this header

#ifdef _WIN32
#  ifndef WIN32_LEAN_AND_MEAN
#    define WIN32_LEAN_AND_MEAN
#  endif
#  ifndef NOMINMAX
#    define NOMINMAX
#  endif
#  ifdef _MSC_VER
#    include <crtdbg.h>
#  endif
#  include <windows.h> 
#  include <direct.h>
#  include <winbase.h>
#  undef interface 
#else
#  define _XOPEN_SOURCE 600  
#  include <limits.h>  // <----------
#endif
// clang-format on

(the complete file is here )


I will try to compile a test program to investigate

Copy link
Contributor Author

@arthurmco arthurmco Apr 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I investigated. It was something with my toolchain
I recompiled it and it worked

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
PATH_MAX was already defined in <limits.h>, a file that already
has been included in the file we were patching

So, no need to patch that file at all
@awesomekling awesomekling merged commit 0fd50f0 into SerenityOS:master Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants