@ -1,10 +1,11 @@
{ stdenv , callPackage , lib , fetchurl , fetchpatch , runCommand , makeWrapper
, jdk , zip , unzip , bash , writeCBin , coreutils
, zip , unzip , bash , writeCBin , coreutils
, which , python , perl , gawk , gnused , gnutar , gnugrep , gzip , findutils
# Apple dependencies
, cctools , clang , libcxx , CoreFoundation , CoreServices , Foundation
# Allow to independently override the jdks used to build and run respectively
, buildJdk ? jdk , runJdk ? jdk
, buildJdk , runJdk
, buildJdkName
# Always assume all markers valid (don't redownload dependencies).
# Also, don't clean up environment variables.
, enableNixHacks ? false
@ -53,6 +54,9 @@ let
#
[ bash coreutils findutils gawk gnugrep gnutar gnused gzip which unzip ] ;
# Java toolchain used for the build and tests
javaToolchain = " @ b a z e l _ t o o l s / / t o o l s / j d k : t o o l c h a i n _ h o s t ${ buildJdkName } " ;
in
stdenv . mkDerivation rec {
@ -177,11 +181,6 @@ stdenv.mkDerivation rec {
substituteInPlace scripts/bootstrap/compile.sh \
- - replace /bin/sh $ { customBash } /bin/bash
# We only build with JDK8 for now, since JDK11 does not compile bazel
substituteInPlace tools/jdk/default_java_toolchain.bzl \
- - replace ' " j v m _ o p t s " : JDK9_JVM_OPTS' \
' " j v m _ o p t s " : JDK8_JVM_OPTS'
# add nix environment vars to .bazelrc
cat > > . bazelrc < < EOF
build - - experimental_distdir = $ { distDir }
@ -191,6 +190,7 @@ stdenv.mkDerivation rec {
build - - linkopt = " - W l , $ ( e c h o $ N I X _ L D F L A G S | s e d - e ' s / / " - - linkopt = " - W l , / g ' ) "
build - - host_linkopt = " - W l , $ ( e c h o $ N I X _ L D F L A G S | s e d - e ' s / / " - - host_linkopt = " - W l , / g ' ) "
build - - host_javabase = ' @ local_jdk // : jdk'
build - - host_java_toolchain = ' $ { javaToolchain } '
EOF
# add the same environment vars to compile.sh
@ -199,6 +199,7 @@ stdenv.mkDerivation rec {
- e " / \$ c o m m a n d \\ \\ $ / a - - l i n k o p t = \" - W l , $ ( e c h o $ N I X _ L D F L A G S | s e d - e ' s / / " - - linkopt = \ " - W l , / g ' ) \" \\ \\ " \
- e " / \$ c o m m a n d \\ \\ $ / a - - h o s t _ l i n k o p t = \" - W l , $ ( e c h o $ N I X _ L D F L A G S | s e d - e ' s / / " - - host_linkopt = \ " - W l , / g ' ) \" \\ \\ " \
- e " / \$ c o m m a n d \\ \\ $ / a - - h o s t _ j a v a b a s e = ' @ l o c a l _ j d k / / : j d k ' \\ \\ " \
- e " / \$ c o m m a n d \\ \\ $ / a - - h o s t _ j a v a _ t o o l c h a i n = ' ${ javaToolchain } ' \\ \\ " \
- i scripts/bootstrap/compile.sh
# --experimental_strict_action_env (which will soon become the
@ -268,7 +269,9 @@ stdenv.mkDerivation rec {
export TEST_TMPDIR = $ ( pwd )
hello_test ( ) {
$ out/bin/bazel test - - test_output = errors \
$ out/bin/bazel test \
- - test_output = errors \
- - java_toolchain = ' $ { javaToolchain } ' \
examples/cpp : hello-success_test \
examples/java-native/src/test/java/com/example/myproject : hello
}