1{
2 bazel
3, bazelTest
4, bazel-examples
5, gccStdenv
6, lib
7, openjdk8
8, runLocal
9, runtimeShell
10, writeScript
11, writeText
12, distDir
13}:
14
15let
16
17 toolsBazel = writeScript "bazel" ''
18 #! ${runtimeShell}
19
20 export CXX='${gccStdenv.cc}/bin/g++'
21 export LD='${gccStdenv.cc}/bin/ld'
22 export CC='${gccStdenv.cc}/bin/gcc'
23
24 # XXX: hack for macosX, this flags disable bazel usage of xcode
25 # See: https://github.com/bazelbuild/bazel/issues/4231
26 export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
27
28 exec "$BAZEL_REAL" "$@"
29 '';
30
31 workspaceDir = runLocal "our_workspace" {} (''
32 cp -r ${bazel-examples}/java-tutorial $out
33 find $out -type d -exec chmod 755 {} \;
34 ''
35 + (lib.optionalString gccStdenv.isDarwin ''
36 mkdir $out/tools
37 cp ${toolsBazel} $out/tools/bazel
38 ''));
39
40 testBazel = bazelTest {
41 name = "bazel-test-java";
42 inherit workspaceDir;
43 bazelPkg = bazel;
44 buildInputs = [ openjdk8 ];
45 bazelScript = ''
46 ${bazel}/bin/bazel \
47 run \
48 --distdir=${distDir} \
49 --host_javabase='@local_jdk//:jdk' \
50 --java_toolchain='@bazel_tools//tools/jdk:toolchain_hostjdk8' \
51 --javabase='@local_jdk//:jdk' \
52 --verbose_failures \
53 //:ProjectRunner
54 '';
55 };
56
57in testBazel
58