From 5bbe01147841f2916658851ede28018952d93a18 Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Fri, 4 Jun 2021 09:37:37 -0400 Subject: [PATCH] flatbuffers: 1.12.0 -> 2.0.0 --- .../libraries/flatbuffers/1.12.nix | 26 +++++++++ .../development/libraries/flatbuffers/2.0.nix | 6 ++ .../libraries/flatbuffers/default.nix | 55 ------------------- .../libraries/flatbuffers/generic.nix | 46 ++++++++++++++++ pkgs/top-level/all-packages.nix | 4 +- 5 files changed, 81 insertions(+), 56 deletions(-) create mode 100644 pkgs/development/libraries/flatbuffers/1.12.nix create mode 100644 pkgs/development/libraries/flatbuffers/2.0.nix delete mode 100644 pkgs/development/libraries/flatbuffers/default.nix create mode 100644 pkgs/development/libraries/flatbuffers/generic.nix diff --git a/pkgs/development/libraries/flatbuffers/1.12.nix b/pkgs/development/libraries/flatbuffers/1.12.nix new file mode 100644 index 00000000000..df2980ba204 --- /dev/null +++ b/pkgs/development/libraries/flatbuffers/1.12.nix @@ -0,0 +1,26 @@ +{ callPackage, fetchpatch, lib, stdenv }: + +callPackage ./generic.nix { + version = "1.12.0"; + sha256 = "0f7xd66vc1lzjbn7jzd5kyqrgxpsfxi4zc7iymhb5xrwyxipjl1g"; + + patches = [ + (fetchpatch { + # Fixed a compilation error with GCC 10.0 to 11.0. June 1, 2020. + # Should be included in the next release after 1.12.0 + url = "https://github.com/google/flatbuffers/commit/988164f6e1675bbea9c852e2d6001baf4d1fcf59.patch"; + sha256 = "0d8c2bywqmkhdi0a41cry85wy4j58pl0vd6h5xpfqm3fr8w0mi9s"; + excludes = [ "src/idl_gen_cpp.cpp" ]; + }) + (fetchpatch { + # Fixed a compilation error with GCC 10.0 to 11.0. July 6, 2020. + # Should be included in the next release after 1.12.0 + url = "https://github.com/google/flatbuffers/pull/6020/commits/44c7a4cf439b0a298720b5a448bcc243a882b0c9.patch"; + sha256 = "126xwkvnlc4ignjhxv9jygfd9j6kr1jx39hyk0ddpcmvzfqsccf4"; + }) + ]; + + preConfigure = lib.optional stdenv.buildPlatform.isDarwin '' + rm BUILD + ''; +} diff --git a/pkgs/development/libraries/flatbuffers/2.0.nix b/pkgs/development/libraries/flatbuffers/2.0.nix new file mode 100644 index 00000000000..2b907e77c49 --- /dev/null +++ b/pkgs/development/libraries/flatbuffers/2.0.nix @@ -0,0 +1,6 @@ +{ callPackage }: + +callPackage ./generic.nix { + version = "2.0.0"; + sha256 = "1zbf6bdpps8369r1ql00irxrp58jnalycc8jcapb8iqg654vlfz8"; +} diff --git a/pkgs/development/libraries/flatbuffers/default.nix b/pkgs/development/libraries/flatbuffers/default.nix deleted file mode 100644 index 374203556a6..00000000000 --- a/pkgs/development/libraries/flatbuffers/default.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake }: - -stdenv.mkDerivation rec { - pname = "flatbuffers"; - version = "1.12.0"; - - src = fetchFromGitHub { - owner = "google"; - repo = "flatbuffers"; - rev = "v${version}"; - sha256 = "0f7xd66vc1lzjbn7jzd5kyqrgxpsfxi4zc7iymhb5xrwyxipjl1g"; - }; - patches = [ - (fetchpatch { - # Fixed a compilation error with GCC 10.0 to 11.0. June 1, 2020. - # Should be included in the next release after 1.12.0 - url = "https://github.com/google/flatbuffers/commit/988164f6e1675bbea9c852e2d6001baf4d1fcf59.patch"; - sha256 = "0d8c2bywqmkhdi0a41cry85wy4j58pl0vd6h5xpfqm3fr8w0mi9s"; - excludes = [ "src/idl_gen_cpp.cpp" ]; - }) - (fetchpatch { - # Fixed a compilation error with GCC 10.0 to 11.0. July 6, 2020. - # Should be included in the next release after 1.12.0 - url = "https://github.com/google/flatbuffers/pull/6020/commits/44c7a4cf439b0a298720b5a448bcc243a882b0c9.patch"; - sha256 = "126xwkvnlc4ignjhxv9jygfd9j6kr1jx39hyk0ddpcmvzfqsccf4"; - }) - ]; - - preConfigure = lib.optional stdenv.buildPlatform.isDarwin '' - rm BUILD - ''; - - nativeBuildInputs = [ cmake ]; - - cmakeFlags = [ "-DFLATBUFFERS_BUILD_TESTS=${if doCheck then "ON" else "OFF"}" ]; - - # tests fail to compile - doCheck = false; - # doCheck = stdenv.hostPlatform == stdenv.buildPlatform; - checkTarget = "test"; - - meta = with lib; { - description = "Memory Efficient Serialization Library"; - longDescription = '' - FlatBuffers is an efficient cross platform serialization library for - games and other memory constrained apps. It allows you to directly - access serialized data without unpacking/parsing it first, while still - having great forwards/backwards compatibility. - ''; - maintainers = [ maintainers.teh ]; - license = licenses.asl20; - platforms = platforms.unix; - homepage = "https://google.github.io/flatbuffers/"; - }; -} diff --git a/pkgs/development/libraries/flatbuffers/generic.nix b/pkgs/development/libraries/flatbuffers/generic.nix new file mode 100644 index 00000000000..1cdfb4b9c87 --- /dev/null +++ b/pkgs/development/libraries/flatbuffers/generic.nix @@ -0,0 +1,46 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, version +, sha256 +, patches ? [ ] +, preConfigure ? null +}: + +stdenv.mkDerivation rec { + pname = "flatbuffers"; + inherit version; + + src = fetchFromGitHub { + owner = "google"; + repo = "flatbuffers"; + rev = "v${version}"; + inherit sha256; + }; + + inherit patches preConfigure; + + nativeBuildInputs = [ cmake ]; + + cmakeFlags = [ + "-DFLATBUFFERS_BUILD_TESTS=${if doCheck then "ON" else "OFF"}" + ]; + + doCheck = stdenv.hostPlatform == stdenv.buildPlatform; + checkTarget = "test"; + + meta = with lib; { + description = "Memory Efficient Serialization Library"; + longDescription = '' + FlatBuffers is an efficient cross platform serialization library for + games and other memory constrained apps. It allows you to directly + access serialized data without unpacking/parsing it first, while still + having great forwards/backwards compatibility. + ''; + maintainers = [ maintainers.teh ]; + license = licenses.asl20; + platforms = platforms.unix; + homepage = "https://google.github.io/flatbuffers/"; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8f19cd1a679..657ae9468a3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17614,7 +17614,9 @@ in protozero = callPackage ../development/libraries/protozero { }; - flatbuffers = callPackage ../development/libraries/flatbuffers { }; + flatbuffers = flatbuffers_2_0; + flatbuffers_2_0 = callPackage ../development/libraries/flatbuffers/2.0.nix { }; + flatbuffers_1_12 = callPackage ../development/libraries/flatbuffers/1.12.nix { }; nanopb = callPackage ../development/libraries/nanopb { };