1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 nix-update-script,
6 cmake,
7 python3,
8 gtest,
9 withAnimation ? true,
10 withTranscoder ? true,
11 eigen,
12 ghc_filesystem,
13 tinygltf,
14}:
15
16let
17 cmakeBool = b: if b then "ON" else "OFF";
18in
19stdenv.mkDerivation (finalAttrs: {
20 version = "1.5.7";
21 pname = "draco";
22
23 src = fetchFromGitHub {
24 owner = "google";
25 repo = "draco";
26 rev = finalAttrs.version;
27 hash = "sha256-p0Mn4kGeBBKL7Hoz4IBgb6Go6MdkgE7WZgxAnt1tE/0=";
28 fetchSubmodules = true;
29 };
30
31 # ld: unknown option: --start-group
32 postPatch = ''
33 substituteInPlace cmake/draco_targets.cmake \
34 --replace "^Clang" "^AppleClang"
35 '';
36
37 buildInputs = [
38 gtest
39 ]
40 ++ lib.optionals withTranscoder [
41 eigen
42 ghc_filesystem
43 tinygltf
44 ];
45
46 nativeBuildInputs = [
47 cmake
48 python3
49 ];
50
51 cmakeFlags = [
52 "-DDRACO_ANIMATION_ENCODING=${cmakeBool withAnimation}"
53 "-DDRACO_GOOGLETEST_PATH=${gtest}"
54 "-DBUILD_SHARED_LIBS=${cmakeBool true}"
55 "-DDRACO_TRANSCODER_SUPPORTED=${cmakeBool withTranscoder}"
56 ]
57 ++ lib.optionals withTranscoder [
58 "-DDRACO_EIGEN_PATH=${eigen}/include/eigen3"
59 "-DDRACO_FILESYSTEM_PATH=${ghc_filesystem}"
60 "-DDRACO_TINYGLTF_PATH=${tinygltf}"
61 ];
62
63 CXXFLAGS = [
64 # error: expected ')' before 'value' in 'explicit GltfValue(uint8_t value)'
65 "-include cstdint"
66 ];
67
68 passthru.updateScript = nix-update-script { };
69
70 meta = with lib; {
71 description = "Library for compressing and decompressing 3D geometric meshes and point clouds";
72 homepage = "https://google.github.io/draco/";
73 changelog = "https://github.com/google/draco/releases/tag/${finalAttrs.version}";
74 license = licenses.asl20;
75 maintainers = with maintainers; [ jansol ];
76 platforms = platforms.all;
77 };
78})