c49b7f64d1
On Darwin, the last argument to GCC is coming up as an empty string. This is breaking the build of proto_library targets. However, I was not able to reproduce with the example cpp project[0]. This commit patches the cc_wrapper of Bazel that gets installed on Darwin to remove the last argument if it's an empty string. This is not a probem on Linux. [0]: https://github.com/bazelbuild/examples/tree/master/cpp-tutorial/stage3
50 lines
1000 B
Nix
50 lines
1000 B
Nix
{
|
|
bazel
|
|
, bazelTest
|
|
, bazel-examples
|
|
, gccStdenv
|
|
, lib
|
|
, runLocal
|
|
, runtimeShell
|
|
, writeScript
|
|
, writeText
|
|
}:
|
|
|
|
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 \
|
|
//...
|
|
'';
|
|
};
|
|
|
|
in testBazel
|