1{ lib
2, stdenv
3, fetchFromGitHub
4, pkg-config
5, capstone
6, freetype
7, glfw
8, dbus
9, hicolor-icon-theme
10, tbb
11, darwin
12}:
13
14let
15 disableLTO = stdenv.cc.isClang && stdenv.isDarwin; # workaround issue #19098
16in
17stdenv.mkDerivation rec {
18 pname = "tracy";
19 version = "0.9.1";
20
21 src = fetchFromGitHub {
22 owner = "wolfpld";
23 repo = "tracy";
24 rev = "v${version}";
25 sha256 = "sha256-K1lQNRS8+ju9HyKNVXtHqslrPWcPgazzTitvwkIO3P4";
26 };
27
28 patches = lib.optionals (stdenv.isDarwin && !(lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11")) [
29 ./0001-remove-unifiedtypeidentifiers-framework
30 ];
31
32 nativeBuildInputs = [ pkg-config ];
33
34 buildInputs = [
35 capstone
36 freetype
37 glfw
38 ] ++ lib.optionals stdenv.isLinux [
39 dbus
40 hicolor-icon-theme
41 tbb
42 ] ++ lib.optionals stdenv.isDarwin [
43 darwin.apple_sdk.frameworks.AppKit
44 darwin.apple_sdk.frameworks.Carbon
45 ] ++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") [
46 darwin.apple_sdk.frameworks.UniformTypeIdentifiers
47 ];
48
49 env.NIX_CFLAGS_COMPILE = toString ([ ]
50 # Apple's compiler finds a format string security error on
51 # ../../../server/TracyView.cpp:649:34, preventing building.
52 ++ lib.optional stdenv.isDarwin "-Wno-format-security"
53 ++ lib.optional stdenv.isLinux "-ltbb"
54 ++ lib.optional stdenv.cc.isClang "-faligned-allocation"
55 ++ lib.optional disableLTO "-fno-lto");
56
57 buildPhase = ''
58 runHook preBuild
59
60 make -j $NIX_BUILD_CORES -C profiler/build/unix release LEGACY=1
61 make -j $NIX_BUILD_CORES -C import-chrome/build/unix/ release
62 make -j $NIX_BUILD_CORES -C capture/build/unix/ release
63 make -j $NIX_BUILD_CORES -C update/build/unix/ release
64
65 runHook postBuild
66 '';
67
68 installPhase = ''
69 runHook preInstall
70
71 install -D ./profiler/build/unix/Tracy-release $out/bin/Tracy
72 install -D ./import-chrome/build/unix/import-chrome-release $out/bin/import-chrome
73 install -D ./capture/build/unix/capture-release $out/bin/capture
74 install -D ./update/build/unix/update-release $out/bin/update
75
76 runHook postInstall
77 '';
78
79 postFixup = lib.optionalString stdenv.isDarwin ''
80 install_name_tool -change libcapstone.4.dylib ${capstone}/lib/libcapstone.4.dylib $out/bin/Tracy
81 '';
82
83 meta = with lib; {
84 description = "A real time, nanosecond resolution, remote telemetry frame profiler for games and other applications";
85 homepage = "https://github.com/wolfpld/tracy";
86 platforms = platforms.linux ++ platforms.darwin;
87 license = licenses.bsd3;
88 maintainers = with maintainers; [ mpickering nagisa ];
89 };
90}