1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, python3
6}:
7
8stdenv.mkDerivation rec {
9 pname = "flatbuffers";
10 version = "23.3.3";
11
12 src = fetchFromGitHub {
13 owner = "google";
14 repo = "flatbuffers";
15 rev = "v${version}";
16 sha256 = "sha256-h0lF7jf1cDVVyqhUCi7D0NoZ3b4X/vWXsFplND80lGs=";
17 };
18
19 nativeBuildInputs = [ cmake python3 ];
20
21 postPatch = ''
22 # Fix default value of "test_data_path" to make tests work
23 substituteInPlace tests/test.cpp --replace '"tests/";' '"../tests/";'
24 '';
25
26 cmakeFlags = [
27 "-DFLATBUFFERS_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
28 "-DFLATBUFFERS_OSX_BUILD_UNIVERSAL=OFF"
29 ];
30
31 doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
32 checkTarget = "test";
33
34 meta = with lib; {
35 description = "Memory Efficient Serialization Library";
36 longDescription = ''
37 FlatBuffers is an efficient cross platform serialization library for
38 games and other memory constrained apps. It allows you to directly
39 access serialized data without unpacking/parsing it first, while still
40 having great forwards/backwards compatibility.
41 '';
42 homepage = "https://google.github.io/flatbuffers/";
43 license = licenses.asl20;
44 maintainers = [ maintainers.teh ];
45 mainProgram = "flatc";
46 platforms = platforms.unix;
47 };
48}