summary refs log tree commit diff
path: root/pkgs/development/tools/build-managers
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@google.com>2016-10-08 20:54:12 -0700
committerIrene Knapp <ireneista@google.com>2016-10-08 20:54:12 -0700
commit81c82bb5d6ffbc0d484badb791f2c15294260b40 (patch)
treee5bde337f1aa6ab8de7ebc55848cd789ef1db26d /pkgs/development/tools/build-managers
parentadfcc2d9531e78bf6a9e3b56e2f4fc873cb3d87b (diff)
downloadnixlib-81c82bb5d6ffbc0d484badb791f2c15294260b40.tar
nixlib-81c82bb5d6ffbc0d484badb791f2c15294260b40.tar.gz
nixlib-81c82bb5d6ffbc0d484badb791f2c15294260b40.tar.bz2
nixlib-81c82bb5d6ffbc0d484badb791f2c15294260b40.tar.lz
nixlib-81c82bb5d6ffbc0d484badb791f2c15294260b40.tar.xz
nixlib-81c82bb5d6ffbc0d484badb791f2c15294260b40.tar.zst
nixlib-81c82bb5d6ffbc0d484badb791f2c15294260b40.zip
Update the packaged Bazel to 0.3.2, and also make it actually work.
Diffstat (limited to 'pkgs/development/tools/build-managers')
-rw-r--r--pkgs/development/tools/build-managers/bazel/default.nix91
-rw-r--r--pkgs/development/tools/build-managers/bazel/java_stub_template.patch16
2 files changed, 79 insertions, 28 deletions
diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix
index 002d3bde201e..10b2feeb9d91 100644
--- a/pkgs/development/tools/build-managers/bazel/default.nix
+++ b/pkgs/development/tools/build-managers/bazel/default.nix
@@ -1,35 +1,70 @@
-{ stdenv, fetchFromGitHub, jdk, zip, zlib, protobuf3_0, pkgconfig, libarchive, unzip, which, makeWrapper }:
-stdenv.mkDerivation rec {
-  version = "0.3.1";
-  name = "bazel-${version}";
-
-  src = fetchFromGitHub {
-    owner = "google";
-    repo = "bazel";
-    rev = version;
-    sha256 = "1cm8zjxf8y3ai6h9wndxvflfsijjqhg87fll9ar7ff0hbbbdf6l5";
+{ stdenv, fetchFromGitHub, buildFHSUserEnv, writeScript, jdk, zip, unzip,
+  which, makeWrapper, binutils }:
+
+let
+
+  version = "0.3.2";
+
+  meta = with stdenv.lib; {
+    homepage = http://github.com/bazelbuild/bazel/;
+    description = "Build tool that builds code quickly and reliably";
+    license = licenses.asl20;
+    maintainers = [ maintainers.philandstuff ];
+    platforms = [ "x86_64-linux" ];
+  };
+
+  bootstrapEnv = buildFHSUserEnv {
+    name = "bazel-bootstrap-env";
+
+    targetPkgs = pkgs: [ ];
+
+    inherit meta;
   };
 
-  buildInputs = [ pkgconfig protobuf3_0 zlib zip libarchive unzip which makeWrapper jdk ];
+  bazelBinary = stdenv.mkDerivation rec {
+    name = "bazel-${version}";
+  
+    src = fetchFromGitHub {
+      owner = "bazelbuild";
+      repo = "bazel";
+      rev = version;
+      sha256 = "085cjz0qhm4a12jmhkjd9w3ic4a67035j01q111h387iklvgn6xg";
+    };
+    patches = [ ./java_stub_template.patch ];
 
-  buildPhase = ''
-    export LD_LIBRARY_PATH="${stdenv.lib.makeLibraryPath [ stdenv.cc.cc.lib ]}"
+    packagesNotFromEnv = [
+        stdenv.cc stdenv.cc.cc.lib jdk which zip unzip binutils ];
+    buildInputs = packagesNotFromEnv ++ [ bootstrapEnv makeWrapper ];
 
-    bash compile.sh
-  '';
+    buildTimeBinPath = stdenv.lib.makeBinPath packagesNotFromEnv;
+    buildTimeLibPath = stdenv.lib.makeLibraryPath packagesNotFromEnv;
 
-  installPhase = ''
-    mkdir -p $out/bin $out/share
-    cp -R output $out/share/bazel
-    ln -s $out/share/bazel/bazel $out/bin/bazel
-    wrapProgram $out/bin/bazel --set JAVA_HOME "${jdk.home}"
-  '';
+    runTimeBinPath = stdenv.lib.makeBinPath [ jdk stdenv.cc.cc ];
+    runTimeLibPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc.lib ];
 
-  meta = {
-    homepage = http://github.com/google/bazel/;
-    description = "Build tool that builds code quickly and reliably";
-    license = stdenv.lib.licenses.asl20;
-    maintainers = [ stdenv.lib.maintainers.philandstuff ];
-    platforms = [ "x86_64-linux" ];
+    buildWrapper = writeScript "build-wrapper.sh" ''
+      #! ${stdenv.shell} -e
+      export PATH="${buildTimeBinPath}:$PATH"
+      export LD_LIBRARY_PATH="${buildTimeLibPath}:$LD_LIBRARY_PATH"
+      ./compile.sh
+    '';
+  
+    buildPhase = ''
+      bazel-bootstrap-env ${buildWrapper}
+    '';
+  
+    installPhase = ''
+      mkdir -p $out/bin
+      cp output/bazel $out/bin/
+      wrapProgram $out/bin/bazel \
+          --suffix PATH ":" "${runTimeBinPath}" \
+          --suffix LD_LIBRARY_PATH ":" "${runTimeLibPath}"
+    '';
+  
+    dontStrip = true;
+    dontPatchELF = true;
+  
+    inherit meta;
   };
-}
+
+in bazelBinary
diff --git a/pkgs/development/tools/build-managers/bazel/java_stub_template.patch b/pkgs/development/tools/build-managers/bazel/java_stub_template.patch
new file mode 100644
index 000000000000..4e456a78d800
--- /dev/null
+++ b/pkgs/development/tools/build-managers/bazel/java_stub_template.patch
@@ -0,0 +1,16 @@
+commit 5525326e3287243e0e7417de96bf7d58d04b4c8b
+Author: Irene Knapp <ireneista@google.com>
+Date:   Sat Oct 8 19:36:12 2016 -0700
+
+    Change #!/bin/bash to #!/usr/bin/env bash.
+
+diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
+index f77051f..fbf367a 100644
+--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
++++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt
+@@ -1,4 +1,4 @@
+-#!/bin/bash --posix
++#!/usr/bin/env bash
+ # Copyright 2014 The Bazel Authors. All rights reserved.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");