2019-06-29 20:07:21 +02:00
|
|
|
{
|
|
|
|
bazel
|
|
|
|
, bazelTest
|
|
|
|
, bazel-examples
|
|
|
|
, gccStdenv
|
|
|
|
, lib
|
|
|
|
, runLocal
|
|
|
|
, runtimeShell
|
|
|
|
, writeScript
|
|
|
|
, writeText
|
2019-08-30 17:05:26 +02:00
|
|
|
, distDir
|
2019-06-29 20:07:21 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
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 \
|
2019-08-30 17:05:26 +02:00
|
|
|
--distdir=${distDir} \
|
2019-06-29 20:07:21 +02:00
|
|
|
//...
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in testBazel
|