nixpkgs/pkgs/development/tools/build-managers/gn/default.nix

63 lines
1.5 KiB
Nix
Raw Normal View History

{ stdenv, lib, fetchgit, fetchzip, fetchpatch, darwin, writeText
, git, ninja, python }:
2017-07-08 20:12:33 +01:00
let
rev = "106b823805adcc043b2bfe5bc21d58f160a28a7b";
sha256 = "1a5s6i07s8l4f1bakh3fyaym00xz7zgd49sp6awm10xb7yjh95ba";
shortRev = builtins.substring 0 7 rev;
lastCommitPosition = writeText "last_commit_position.h" ''
#ifndef OUT_LAST_COMMIT_POSITION_H_
#define OUT_LAST_COMMIT_POSITION_H_
#define LAST_COMMIT_POSITION "(${shortRev})"
#endif // OUT_LAST_COMMIT_POSITION_H_
'';
in
stdenv.mkDerivation rec {
name = "gn-${version}";
version = "20180830";
src = fetchgit {
url = "https://gn.googlesource.com/gn";
inherit rev sha256;
};
2018-04-25 02:54:36 +01:00
postPatch = ''
# FIXME Needed with old Apple SDKs
substituteInPlace base/mac/foundation_util.mm \
--replace "NSArray<NSString*>*" "NSArray*"
'';
nativeBuildInputs = [ ninja python git ];
buildInputs = lib.optionals stdenv.isDarwin (with darwin; with apple_sdk.frameworks; [
2018-04-25 02:54:36 +01:00
libobjc
cctools
# frameworks
ApplicationServices
Foundation
AppKit
]);
buildPhase = ''
python build/gen.py --no-sysroot --no-last-commit-position
ln -s ${lastCommitPosition} out/last_commit_position.h
ninja -j $NIX_BUILD_CORES -C out gn
2018-04-25 02:54:36 +01:00
'';
installPhase = ''
install -vD out/gn "$out/bin/gn"
2018-04-25 02:54:36 +01:00
'';
meta = with lib; {
description = "A meta-build system that generates NinjaBuild files";
homepage = https://gn.googlesource.com/gn;
2018-04-25 02:54:36 +01:00
license = licenses.bsd3;
platforms = platforms.unix;
maintainers = with maintainers; [ stesie matthewbauer ];
};
}