aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Smiley <keithbsmiley@gmail.com>2022-11-01 10:09:19 -0700
committerKeith Smiley <keithbsmiley@gmail.com>2023-01-10 08:43:45 -0800
commit52f5feaf1d35083d08593c908bb43cd0b50fe22d (patch)
tree5572ea14702fd20767a9082e3a185bbe1b059acf
parent06112c7d9edff04edf6f95a51e850870347f203e (diff)
downloadbazelbuild-rules_cc-52f5feaf1d35083d08593c908bb43cd0b50fe22d.tar.gz
Move Apple toolchain setup to apple_support
Mirrors https://github.com/bazelbuild/bazel/pull/16619
-rw-r--r--cc/private/toolchain/cc_configure.bzl51
1 files changed, 10 insertions, 41 deletions
diff --git a/cc/private/toolchain/cc_configure.bzl b/cc/private/toolchain/cc_configure.bzl
index c281198..4f9d137 100644
--- a/cc/private/toolchain/cc_configure.bzl
+++ b/cc/private/toolchain/cc_configure.bzl
@@ -13,7 +13,6 @@
# limitations under the License.
"""Rules for configuring the C++ toolchain (experimental)."""
-load("@bazel_tools//tools/osx:xcode_configure.bzl", "run_xcode_locator")
load(
":lib_cc_configure.bzl",
"get_cpu_value",
@@ -23,58 +22,28 @@ load(":osx_cc_configure.bzl", "configure_osx_toolchain")
load(":unix_cc_configure.bzl", "configure_unix_toolchain")
load(":windows_cc_configure.bzl", "configure_windows_toolchain")
-def _generate_cpp_only_build_file(repository_ctx, cpu_value, paths):
- repository_ctx.template(
- "BUILD",
- paths["@rules_cc//cc/private/toolchain:BUILD.toolchains.tpl"],
- {"%{name}": cpu_value},
- )
-
def cc_autoconf_toolchains_impl(repository_ctx):
"""Generate BUILD file with 'toolchain' targets for the local host C++ toolchain.
Args:
repository_ctx: repository context
"""
- paths = resolve_labels(repository_ctx, [
- "@rules_cc//cc/private/toolchain:BUILD.toolchains.tpl",
- "@bazel_tools//tools/osx/crosstool:BUILD.toolchains",
- "@bazel_tools//tools/osx/crosstool:osx_archs.bzl",
- "@bazel_tools//tools/osx:xcode_locator.m",
- ])
env = repository_ctx.os.environ
- cpu_value = get_cpu_value(repository_ctx)
# Should we try to find C++ toolchain at all? If not, we don't have to generate toolchains for C++ at all.
should_detect_cpp_toolchain = "BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN" not in env or env["BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN"] != "1"
- # Should we unconditionally *not* use xcode? If so, we don't have to run Xcode locator ever.
- should_use_cpp_only_toolchain = "BAZEL_USE_CPP_ONLY_TOOLCHAIN" in env and env["BAZEL_USE_CPP_ONLY_TOOLCHAIN"] == "1"
-
- # Should we unconditionally use xcode? If so, we don't have to run Xcode locator now.
- should_use_xcode = "BAZEL_USE_XCODE_TOOLCHAIN" in env and env["BAZEL_USE_XCODE_TOOLCHAIN"] == "1"
-
- if not should_detect_cpp_toolchain:
- repository_ctx.file("BUILD", "# C++ toolchain autoconfiguration was disabled by BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN env variable.")
- elif cpu_value == "darwin" and not should_use_cpp_only_toolchain:
- xcode_toolchains = []
-
- # Only detect xcode if the user didn't tell us it will be there.
- if not should_use_xcode:
- # TODO(#6926): Unify C++ and ObjC toolchains so we don't have to run xcode locator to generate toolchain targets.
- # And also so we don't have to keep this code in sync with @rules_cc//cc/private/toolchain:osx_cc_configure.bzl.
- (xcode_toolchains, _xcodeloc_err) = run_xcode_locator(
- repository_ctx,
- paths["@bazel_tools//tools/osx:xcode_locator.m"],
- )
-
- if should_use_xcode or xcode_toolchains:
- repository_ctx.symlink(paths["@bazel_tools//tools/osx/crosstool:BUILD.toolchains"], "BUILD")
- repository_ctx.symlink(paths["@bazel_tools//tools/osx/crosstool:osx_archs.bzl"], "osx_archs.bzl")
- else:
- _generate_cpp_only_build_file(repository_ctx, cpu_value, paths)
+ if should_detect_cpp_toolchain:
+ paths = resolve_labels(repository_ctx, [
+ "@rules_cc//cc/private/toolchain:BUILD.toolchains.tpl",
+ ])
+ repository_ctx.template(
+ "BUILD",
+ paths["@rules_cc//cc/private/toolchain:BUILD.toolchains.tpl"],
+ {"%{name}": get_cpu_value(repository_ctx)},
+ )
else:
- _generate_cpp_only_build_file(repository_ctx, cpu_value, paths)
+ repository_ctx.file("BUILD", "# C++ toolchain autoconfiguration was disabled by BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN env variable.")
cc_autoconf_toolchains = repository_rule(
environ = [