|
| 1 | +load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library") |
| 2 | +load("//:tools/collect_headers.bzl", "cc_headers_only", "include_dir") |
| 3 | + |
| 4 | +package(default_visibility = ["//visibility:public"]) |
| 5 | + |
| 6 | +#### Compile gRPC from scratch #### |
| 7 | + |
| 8 | +cc_static_library( |
| 9 | + name = "grpc_fat", |
| 10 | + deps = [ |
| 11 | + "@com_github_grpc_grpc//:grpc", |
| 12 | + ], |
| 13 | +) |
| 14 | + |
| 15 | +include_dir( |
| 16 | + name = "grpc_include_dir", |
| 17 | + target = "@com_github_grpc_grpc//:grpc", |
| 18 | +) |
| 19 | + |
| 20 | +#### Targets for pre-built dependency #### |
| 21 | + |
| 22 | +# extract only the header files from grpc without compiling it |
| 23 | +cc_headers_only( |
| 24 | + name = "grpc_hdrs_ccinfo", |
| 25 | + dep = "@com_github_grpc_grpc//:grpc", |
| 26 | +) |
| 27 | + |
| 28 | +cc_library( |
| 29 | + name = "grpc_core_prebuilt", |
| 30 | + visibility = ["//visibility:public"], |
| 31 | + deps = [":grpc_hdrs_ccinfo"] + |
| 32 | + # pick the right prebuilt .a: |
| 33 | + select({ |
| 34 | + ":ios_device_arm64": [":grpc_core_ios_arm64"], |
| 35 | + ":ios_simulator_arm64": [":grpc_core_ios_sim_arm64"], |
| 36 | + ":ios_simulator_x64": [":grpc_core_ios_x64"], |
| 37 | + ":macos_arm64": [":grpc_core_macos_arm64"], |
| 38 | + "//conditions:default": [], |
| 39 | + }), |
| 40 | +) |
| 41 | + |
| 42 | +config_setting( |
| 43 | + name = "ios_device_arm64", |
| 44 | + constraint_values = [ |
| 45 | + "@platforms//os:ios", |
| 46 | + "@platforms//cpu:arm64", |
| 47 | + "@build_bazel_apple_support//constraints:device", |
| 48 | + ], |
| 49 | +) |
| 50 | + |
| 51 | +config_setting( |
| 52 | + name = "ios_simulator_arm64", |
| 53 | + constraint_values = [ |
| 54 | + "@platforms//os:ios", |
| 55 | + "@platforms//cpu:arm64", |
| 56 | + "@build_bazel_apple_support//constraints:simulator", |
| 57 | + ], |
| 58 | +) |
| 59 | + |
| 60 | +config_setting( |
| 61 | + name = "ios_simulator_x64", |
| 62 | + constraint_values = [ |
| 63 | + "@platforms//os:ios", |
| 64 | + "@platforms//cpu:x86_64", |
| 65 | + "@build_bazel_apple_support//constraints:simulator", |
| 66 | + ], |
| 67 | +) |
| 68 | + |
| 69 | +config_setting( |
| 70 | + name = "macos_arm64", |
| 71 | + constraint_values = [ |
| 72 | + "@platforms//os:macos", |
| 73 | + "@platforms//cpu:arm64", |
| 74 | + ], |
| 75 | +) |
| 76 | + |
| 77 | +cc_import( |
| 78 | + name = "grpc_core_ios_arm64", |
| 79 | + static_library = ":libgrpc_fat.ios_arm64.a", |
| 80 | + visibility = ["//visibility:public"], |
| 81 | +) |
| 82 | + |
| 83 | +cc_import( |
| 84 | + name = "grpc_core_ios_sim_arm64", |
| 85 | + static_library = ":libgrpc_fat.ios_simulator_arm64.a", |
| 86 | + visibility = ["//visibility:public"], |
| 87 | +) |
| 88 | + |
| 89 | +cc_import( |
| 90 | + name = "grpc_core_ios_x64", |
| 91 | + static_library = ":libgrpc_fat.ios_x64.a", |
| 92 | + visibility = ["//visibility:public"], |
| 93 | +) |
| 94 | + |
| 95 | +cc_import( |
| 96 | + name = "grpc_core_macos_arm64", |
| 97 | + static_library = ":libgrpc_fat.macos_arm64.a", |
| 98 | + visibility = ["//visibility:public"], |
| 99 | +) |
0 commit comments