2020-04-24 23:36:52 +00:00
|
|
|
{
|
|
|
|
bazel
|
|
|
|
, bazelTest
|
|
|
|
, bazel-examples
|
2022-09-09 14:08:57 +00:00
|
|
|
, stdenv
|
|
|
|
, darwin
|
2020-04-24 23:36:52 +00:00
|
|
|
, lib
|
|
|
|
, runLocal
|
|
|
|
, runtimeShell
|
|
|
|
, writeScript
|
|
|
|
, writeText
|
|
|
|
, distDir
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
toolsBazel = writeScript "bazel" ''
|
|
|
|
#! ${runtimeShell}
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
export CXX='${stdenv.cc}/bin/clang++'
|
|
|
|
export LD='${darwin.cctools}/bin/ld'
|
|
|
|
export LIBTOOL='${darwin.cctools}/bin/libtool'
|
|
|
|
export CC='${stdenv.cc}/bin/clang'
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# 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 {} \;
|
|
|
|
''
|
2022-09-09 14:08:57 +00:00
|
|
|
+ (lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
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} \
|
2021-12-21 02:18:32 +00:00
|
|
|
--curses=no \
|
|
|
|
--sandbox_debug \
|
2022-09-09 14:08:57 +00:00
|
|
|
//... \
|
|
|
|
'' + lib.optionalString (stdenv.isDarwin) ''
|
|
|
|
--cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \
|
|
|
|
--linkopt=-stdlib=libc++ --host_linkopt=-stdlib=libc++ \
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in testBazel
|