| 1 |
#!/bin/bash |
| 2 |
# Copyright 2022 Google LLC |
| 3 |
# |
| 4 |
# Use of this source code is governed by a BSD-style license that can be |
| 5 |
# found in the LICENSE file. |
| 6 |
|
| 7 |
set -euo pipefail |
| 8 |
|
| 9 |
# This script is invoked from two different paths depending on if we are directly compiling |
| 10 |
# C++ code (something like /path/to/bazel_cache/sandbox/darwin-sandbox/511/execroot/_main) |
| 11 |
# or if the rust compiler is shelling out to the C++ compiler (something like |
| 12 |
# /path/to/bazel_cache/sandbox/darwin-sandbox/511/execroot/_main/bazel-out/ |
| 13 |
# darwin_arm64-dbg/bin/external/rules_rust++crate+crates__link-cplusplus-1.0.10/ |
| 14 |
# _bs.cargo_runfiles/rules_rust++crate+crates__link-cplusplus-1.0.10 |
| 15 |
# ). We need to invoke clang via a relative path, otherwise the Bazel #include checks get angry |
| 16 |
# about an "absolute include filepath" that was not marked as a system include. Thus, we check |
| 17 |
# which of the cases we are in to find the clang binary before running it. |
| 18 |
if [ -f external/*clang_mac/bin/clang ]; then |
| 19 |
external/*clang_mac/bin/clang $@ |
| 20 |
elif [ -f ../../../../../../../external/*clang_mac/bin/clang ]; then |
| 21 |
../../../../../../../external/*clang_mac/bin/clang $@ |
| 22 |
fi |