1{
2 bazel
3, bazelTest
4, bazel-examples
5, stdenv
6, darwin
7, lib
8, runLocal
9, runtimeShell
10, writeScript
11, writeText
12, distDir
13}:
14
15let
16
17 toolsBazel = writeScript "bazel" ''
18 #! ${runtimeShell}
19
20 export CXX='${stdenv.cc}/bin/clang++'
21 export LD='${darwin.cctools}/bin/ld'
22 export LIBTOOL='${darwin.cctools}/bin/libtool'
23 export CC='${stdenv.cc}/bin/clang'
24
25 # XXX: hack for macosX, this flags disable bazel usage of xcode
26 # See: https://github.com/bazelbuild/bazel/issues/4231
27 export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
28
29 exec "$BAZEL_REAL" "$@"
30 '';
31
32 workspaceDir = runLocal "our_workspace" {} (''
33 cp -r ${bazel-examples}/cpp-tutorial/stage3 $out
34 find $out -type d -exec chmod 755 {} \;
35 ''
36 + (lib.optionalString stdenv.isDarwin ''
37 mkdir $out/tools
38 cp ${toolsBazel} $out/tools/bazel
39 ''));
40
41 testBazel = bazelTest {
42 name = "bazel-test-cpp";
43 inherit workspaceDir;
44 bazelPkg = bazel;
45 bazelScript = ''
46 ${bazel}/bin/bazel \
47 build --verbose_failures \
48 --distdir=${distDir} \
49 --curses=no \
50 --sandbox_debug \
51 //... \
52 '' + lib.optionalString (stdenv.isDarwin) ''
53 --cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \
54 --linkopt=-stdlib=libc++ --host_linkopt=-stdlib=libc++ \
55 '';
56 };
57
58in testBazel