xref: /aosp_15_r20/external/pigweed/pw_toolchain/host_clang/macos_sysroot.BUILD (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2024 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("@bazel_skylib//rules/directory:directory.bzl", "directory")
16load("@bazel_skylib//rules/directory:subdirectory.bzl", "subdirectory")
17load("@rules_cc//cc/toolchains/args:sysroot.bzl", "cc_sysroot")
18
19package(default_visibility = ["//visibility:public"])
20
21cc_sysroot(
22    name = "sysroot",
23    sysroot = ":root",
24    data = glob([
25        "usr/lib/*.tbd",
26        "System/Library/Frameworks/*/*.tbd",
27    ]),
28    allowlist_include_directories = [
29        ":usr-include",
30        ":CoreFoundation.framework-Headers",
31        ":IOKit.framework-Headers",
32        ":Security.framework-Headers",
33    ],
34)
35
36directory(
37    name = "root",
38    srcs = glob([
39        "usr/include/**/*",
40        "usr/lib/**/*",
41        "System/Library/Frameworks/CoreFoundation.framework/**/*",
42        "System/Library/Frameworks/IOKit.framework/**/*",
43        "System/Library/Frameworks/Security.framework/**/*",
44    ]),
45)
46
47subdirectory(
48    name = "usr-include",
49    parent = ":root",
50    path = "usr/include",
51)
52
53# Eventually, it's probably better to expose frameworks as cc_args with a
54# `-framework CoreFoundation` flag and a single subdirectory in
55# `allowlist_include_directories`. This better isolates usages and ensures
56# things are properly linked.
57subdirectory(
58    name = "CoreFoundation.framework-Headers",
59    parent = ":root",
60    path = "System/Library/Frameworks/CoreFoundation.framework/Headers",
61)
62
63subdirectory(
64    name = "IOKit.framework-Headers",
65    parent = ":root",
66    path = "System/Library/Frameworks/IOKit.framework/Headers",
67)
68
69subdirectory(
70    name = "Security.framework-Headers",
71    parent = ":root",
72    path = "System/Library/Frameworks/Security.framework/Headers",
73)
74