From e0590b50e460739fc2c865c35791a0e20dae318e Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Sat, 16 Apr 2022 09:19:01 -0700 Subject: [PATCH] Set CMAKE_OSX_ARCHITECTURES to target architecture (#891) --- examples/third_party/WORKSPACE.bazel | 36 ------------------- examples/third_party/cares/BUILD.bazel | 15 +++++--- .../private/built_tools_framework.bzl | 1 + foreign_cc/private/framework.bzl | 2 ++ 4 files changed, 14 insertions(+), 40 deletions(-) diff --git a/examples/third_party/WORKSPACE.bazel b/examples/third_party/WORKSPACE.bazel index 77bf146f..a8f975bc 100644 --- a/examples/third_party/WORKSPACE.bazel +++ b/examples/third_party/WORKSPACE.bazel @@ -17,39 +17,3 @@ local_repository( load("//:repositories.bzl", "repositories") repositories() - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "build_bazel_rules_apple", - sha256 = "0052d452af7742c8f3a4e0929763388a66403de363775db7e90adecb2ba4944b", - url = "https://github.com/bazelbuild/rules_apple/releases/download/0.31.3/rules_apple.0.31.3.tar.gz", -) - -load( - "@build_bazel_rules_apple//apple:repositories.bzl", - "apple_rules_dependencies", -) - -apple_rules_dependencies() - -load( - "@build_bazel_rules_swift//swift:repositories.bzl", - "swift_rules_dependencies", -) - -swift_rules_dependencies() - -load( - "@build_bazel_rules_swift//swift:extras.bzl", - "swift_rules_extra_dependencies", -) - -swift_rules_extra_dependencies() - -load( - "@build_bazel_apple_support//lib:repositories.bzl", - "apple_support_dependencies", -) - -apple_support_dependencies() diff --git a/examples/third_party/cares/BUILD.bazel b/examples/third_party/cares/BUILD.bazel index 9fc4ed40..28c2aed1 100644 --- a/examples/third_party/cares/BUILD.bazel +++ b/examples/third_party/cares/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_apple//apple:ios.bzl", "ios_build_test") +load("@bazel_skylib//rules:build_test.bzl", "build_test") load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") cc_test( @@ -15,10 +15,17 @@ cc_library( deps = ["@cares"], ) -ios_build_test( - name = "test_c_ares_ios", +apple_binary( + name = "ios_binary", minimum_os_version = "12.0", + platform_type = "ios", + deps = [":ios_lib"], +) + +build_test( + name = "test_c_ares_ios", tags = ["manual"], - targets = ["ios_lib"], + target_compatible_with = ["@platforms//os:macos"], + targets = ["ios_binary"], visibility = ["//:__pkg__"], ) diff --git a/foreign_cc/built_tools/private/built_tools_framework.bzl b/foreign_cc/built_tools/private/built_tools_framework.bzl index a00d031c..a6fbeb14 100644 --- a/foreign_cc/built_tools/private/built_tools_framework.bzl +++ b/foreign_cc/built_tools/private/built_tools_framework.bzl @@ -27,6 +27,7 @@ FOREIGN_CC_BUILT_TOOLS_ATTRS = { # Common fragments for all built_tool rules FOREIGN_CC_BUILT_TOOLS_FRAGMENTS = [ + "apple", "cpp", ] diff --git a/foreign_cc/private/framework.bzl b/foreign_cc/private/framework.bzl index d0c07a0d..04adb086 100644 --- a/foreign_cc/private/framework.bzl +++ b/foreign_cc/private/framework.bzl @@ -217,6 +217,7 @@ CC_EXTERNAL_RULE_ATTRIBUTES = { # A list of common fragments required by rules using this framework CC_EXTERNAL_RULE_FRAGMENTS = [ + "apple", "cpp", ] @@ -306,6 +307,7 @@ def get_env_prelude(ctx, lib_name, data_dependencies, target_root): "export DEVELOPER_DIR=\"$developer_dir_tmp\"", "sdkroot_tmp=\"$(xcrun --sdk {} --show-sdk-path)\"".format(sdk), "export SDKROOT=\"$sdkroot_tmp\"", + "export CMAKE_OSX_ARCHITECTURES={}".format(ctx.fragments.apple.single_arch_cpu), ]) cc_toolchain = find_cpp_toolchain(ctx)