1 { appleDerivation, xcbuildHook, CoreSymbolication, apple_sdk
2 , xnu, bison, flex, stdenv, fixDarwinDylibNames }:
5 nativeBuildInputs = [ xcbuildHook flex bison fixDarwinDylibNames ];
6 buildInputs = [ CoreSymbolication apple_sdk.frameworks.CoreSymbolication xnu ];
7 # -fcommon: workaround build failure on -fno-common toolchains:
8 # duplicate symbol '_kCSRegionMachHeaderName' in: libproc.o dt_module_apple.o
9 env.NIX_CFLAGS_COMPILE = "-DCTF_OLD_VERSIONS -DPRIVATE -DYYDEBUG=1 -I${xnu}/Library/Frameworks/System.framework/Headers -Wno-error=implicit-function-declaration -fcommon";
10 NIX_LDFLAGS = "-L./Products/Release";
11 xcbuildFlags = [ "-target" "dtrace_frameworks" "-target" "dtrace" ];
14 checkPhase = "xcodebuild -target dtrace_tests";
17 substituteInPlace dtrace.xcodeproj/project.pbxproj \
18 --replace "/usr/sbin" ""
19 substituteInPlace libdtrace/dt_open.c \
20 --replace /usr/bin/clang ${stdenv.cc.cc}/bin/clang \
21 --replace /usr/bin/ld ${stdenv.cc.bintools.bintools}/bin/ld \
22 --replace /usr/lib/dtrace/dt_cpp.h $out/include/dt_cpp.h \
23 --replace /usr/lib/dtrace $out/lib/dtrace
24 substituteInPlace libproc/libproc.c \
25 --replace "#include <sandbox/rootless.h>" ""
28 # hack to handle xcbuild's broken lex handling
35 substituteInPlace dtrace.xcodeproj/project.pbxproj \
36 --replace '6EBC9800099BFBBF0001019C /* dt_grammar.y */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.yacc; name = dt_grammar.y; path = libdtrace/dt_grammar.y; sourceTree = "<group>"; };' '6EBC9800099BFBBF0001019C /* y.tab.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = y.tab.c; path = libdtrace/y.tab.c; sourceTree = "<group>"; };' \
37 --replace '6EBC9808099BFBBF0001019C /* dt_lex.l */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.lex; name = dt_lex.l; path = libdtrace/dt_lex.l; sourceTree = "<group>"; };' '6EBC9808099BFBBF0001019C /* lex.yy.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = lex.yy.c; path = libdtrace/lex.yy.c; sourceTree = "<group>"; };'
40 # xcbuild doesn't support install
44 cp -r Products/Release/usr/include $out/include
45 cp scripts/dt_cpp.h $out/include/dt_cpp.h
48 cp Products/Release/*.dylib $out/lib
51 cp Products/Release/dtrace $out/bin
53 mkdir -p $out/lib/dtrace
55 install_name_tool -change $PWD/Products/Release/libdtrace.dylib $out/lib/libdtrace.dylib $out/bin/dtrace