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