nixpkgs/pkgs/development/tools/build-managers/bazel/cpp-test.nix
Guillaume Bouchard 67904dccbb bazel: 0.28.1 -> 0.29.0
- Upgraded dependencies
  - dependencies script upgraded to take into account new WORKSPACE
    rules
- Tests now depends on the `distdir`

Runtime bazel now also depends on the `distdir` setting which appears
in the global configuration file. This increases the bazel closure
size by 85 MO for stuffs which can normally be downloaded at runtime
by bazel. However, any invocation of `buildBazelPackage` (such as in
`bazel-watcher`) may fail in nix sandbox if theses files are not
available at runtime.

If this overhead is too important, we may later evolve to a finer
grained solution, where buildBazelPackage declares the list of
necessary dependencies.
2019-09-03 13:12:53 +02:00

52 lines
1 KiB
Nix

{
bazel
, bazelTest
, bazel-examples
, gccStdenv
, lib
, runLocal
, runtimeShell
, writeScript
, writeText
, distDir
}:
let
toolsBazel = writeScript "bazel" ''
#! ${runtimeShell}
export CXX='${gccStdenv.cc}/bin/g++'
export LD='${gccStdenv.cc}/bin/ld'
export CC='${gccStdenv.cc}/bin/gcc'
# XXX: hack for macosX, this flags disable bazel usage of xcode
# See: https://github.com/bazelbuild/bazel/issues/4231
export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
exec "$BAZEL_REAL" "$@"
'';
workspaceDir = runLocal "our_workspace" {} (''
cp -r ${bazel-examples}/cpp-tutorial/stage3 $out
find $out -type d -exec chmod 755 {} \;
''
+ (lib.optionalString gccStdenv.isDarwin ''
mkdir $out/tools
cp ${toolsBazel} $out/tools/bazel
''));
testBazel = bazelTest {
name = "bazel-test-cpp";
inherit workspaceDir;
bazelPkg = bazel;
bazelScript = ''
${bazel}/bin/bazel \
build --verbose_failures \
--distdir=${distDir} \
//...
'';
};
in testBazel