make bazel build on macOS work again (#5237)
* make bazel build on macOS work again
* run yapf
diff --git a/configure_bazel.py b/configure_bazel.py
index 77d7855..88f4208 100644
--- a/configure_bazel.py
+++ b/configure_bazel.py
@@ -27,34 +27,37 @@
# All I want to do is set a couple of project specific warning options!
if platform.system() == "Darwin":
- print(f"build --config=generic_clang", file=bazelrc)
- print(f"build:release --config=generic_clang_release", file=bazelrc)
-
- # If the user specified a CXX environment var, bazel will later respect that,
- # so we just see if it says "clang".
- cxx = os.environ.get("CXX")
- cc = os.environ.get("CC")
- if (cxx is not None and cc is None) or (cxx is None and cc is not None):
- print("WARNING: Only one of CXX or CC is set, which can confuse bazel. "
- "Recommend: set both appropriately (or none)")
- if cc is not None and cxx is not None:
- # Persist the variables.
- print(f"build --action_env CC=\"{cc}\"", file=bazelrc)
- print(f"build --action_env CXX=\"{cxx}\"", file=bazelrc)
+ print(f"build --config=macos_clang", file=bazelrc)
+ print(f"build:release --config=macos_clang_release", file=bazelrc)
else:
- print(
- "WARNING: CC and CXX are not set, which can cause mismatches between "
- "flag configurations and compiler. Recommend setting them explicitly.")
- if cxx is not None and "clang" in cxx:
- print(f"Choosing generic_clang config because CXX is set to clang ({cxx})")
- print(f"build --config=generic_clang", file=bazelrc)
- print(f"build:release --config=generic_clang_release", file=bazelrc)
- else:
- print(f"Choosing generic_gcc config by default because no CXX set or "
- f"not recognized as clang ({cxx})")
- print(f"build --config=generic_gcc", file=bazelrc)
- print(f"build:release --config=generic_gcc_release", file=bazelrc)
+ # If the user specified a CXX environment var, bazel will later respect that,
+ # so we just see if it says "clang".
+ cxx = os.environ.get("CXX")
+ cc = os.environ.get("CC")
+ if (cxx is not None and cc is None) or (cxx is None and cc is not None):
+ print("WARNING: Only one of CXX or CC is set, which can confuse bazel. "
+ "Recommend: set both appropriately (or none)")
+ if cc is not None and cxx is not None:
+ # Persist the variables.
+ print(f"build --action_env CC=\"{cc}\"", file=bazelrc)
+ print(f"build --action_env CXX=\"{cxx}\"", file=bazelrc)
+ else:
+ print(
+ "WARNING: CC and CXX are not set, which can cause mismatches between "
+ "flag configurations and compiler. Recommend setting them explicitly."
+ )
+
+ if cxx is not None and "clang" in cxx:
+ print(
+ f"Choosing generic_clang config because CXX is set to clang ({cxx})")
+ print(f"build --config=generic_clang", file=bazelrc)
+ print(f"build:release --config=generic_clang_release", file=bazelrc)
+ else:
+ print(f"Choosing generic_gcc config by default because no CXX set or "
+ f"not recognized as clang ({cxx})")
+ print(f"build --config=generic_gcc", file=bazelrc)
+ print(f"build:release --config=generic_gcc_release", file=bazelrc)
def write_platform(bazelrc):