bazel: fix the compilation of .proto on Darwin (#63879)
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
This commit is contained in:
49
pkgs/development/tools/build-managers/bazel/cpp-test.nix
Normal file
49
pkgs/development/tools/build-managers/bazel/cpp-test.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
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
|
||||
Reference in New Issue
Block a user