summary refs log tree commit diff
path: root/pkgs/development/tools/xcbuild/default.nix
blob: d38c85a5d838808fa161b1e4ca73aae7db1ad75e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ stdenv, cmake, fetchFromGitHub, zlib, libxml2, libpng, CoreServices, CoreGraphics, ImageIO, ninja }:

let
  googletest = fetchFromGitHub {
    owner  = "google";
    repo   = "googletest";
    rev    = "43359642a1c16ad3f4fc575c7edd0cb935810815";
    sha256 = "0y4xaah62fjr3isaryc3vfz3mn9xflr00vchdimj8785milxga4q";
  };

  linenoise = fetchFromGitHub {
    owner  = "antirez";
    repo   = "linenoise";
    rev    = "c894b9e59f02203dbe4e2be657572cf88c4230c3";
    sha256 = "0wasql7ph5g473zxhc2z47z3pjp42q0dsn4gpijwzbxawid71b4w";
  };
in stdenv.mkDerivation rec {
  name    = "xcbuild-${version}";
  version = "0.1.1";

  src = fetchFromGitHub {
    owner  = "facebook";
    repo   = "xcbuild";
    rev    = version;
    sha256 = "0i98c6lii8r3bgs5gj7div12pxyzjvm4qqzmmzgr7dyhj00qa8r5";
  };

  prePatch = ''
    rmdir ThirdParty/*
    cp -r --no-preserve=all ${googletest} ThirdParty/googletest
    cp -r --no-preserve=all ${linenoise} ThirdParty/linenoise
  '';

  # See https://github.com/facebook/xcbuild/issues/238 and remove once that's in
  patches = [ ./return-false.patch ];

  # Avoid a glibc >= 2.25 deprecation warning that gets fatal via -Werror.
  postPatch = stdenv.lib.optionalString (!stdenv.isDarwin) ''
    sed 1i'#include <sys/sysmacros.h>' \
      -i Libraries/xcassets/Headers/xcassets/Slot/SystemVersion.h
  '';

  enableParallelBuilding = true;

  # TODO: instruct cmake not to put it in /usr, rather than cleaning up
  postInstall = ''
    mv $out/usr/* $out
    rmdir $out/usr
  '';

  NIX_CFLAGS_COMPILE = "-Wno-error=strict-aliasing";

  cmakeFlags = [ "-GNinja" ];

  buildInputs = [ cmake zlib libxml2 libpng ninja ]
    ++ stdenv.lib.optionals stdenv.isDarwin [ CoreServices CoreGraphics ImageIO ];

  meta = with stdenv.lib; {
    description = "Xcode-compatible build tool";
    homepage = https://github.com/facebook/xcbuild;
    platforms = platforms.unix;
    maintainers = with maintainers; [ copumpkin matthewbauer ];
  };
}