xref: /aosp_15_r20/external/angle/build/config/siso/mac_sdk.star (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# -*- bazel-starlark -*-
2# Copyright 2024 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Siso configuration for mac sdk."""
6
7load("@builtin//lib/gn.star", "gn")
8load("@builtin//runtime.star", "runtime")
9load("@builtin//struct.star", "module")
10load("./gn_logs.star", "gn_logs")
11
12def __enabled(ctx):
13    if "args.gn" in ctx.metadata:
14        gn_args = gn.args(ctx)
15        if gn_args.get("target_os") in ('"mac"', '"ios"'):
16            return True
17    return runtime.os == "darwin"
18
19def __filegroups(ctx):
20    sdk_includes = [
21        "*.framework",
22        "*.h",
23        "*.json",
24        "*.modulemap",
25        "Current",
26        "Frameworks",
27        "Headers",
28        "Modules",
29        "crt*.o",
30        "usr/include/c++/v1/*",
31        "usr/include/c++/v1/*/*",
32    ]
33    fg = {
34        "build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk:headers": {
35            "type": "glob",
36            "includes": sdk_includes,
37        },
38    }
39    if gn.args(ctx).get("use_remoteexec") == "true":
40        # precompute subtree for sysroot/frameworks for siso scandeps,
41        # which is not complex enough to handle C preprocessor tricks
42        # and need system include dirs when using deps log of -MMD.
43        # need to add new entries when new version is used.
44        #
45        # if use_remoteexec is not true, these dirs are not under exec root
46        # and failed to create filegroup for such dirs. crbug.com/352216756
47        gn_logs_data = gn_logs.read(ctx)
48        if gn_logs_data.get("mac_sdk_path"):
49            fg[ctx.fs.canonpath("./" + gn_logs_data.get("mac_sdk_path")) + ":headers"] = {
50                "type": "glob",
51                "includes": sdk_includes,
52            }
53            fg[ctx.fs.canonpath("./" + gn_logs_data.get("mac_sdk_path")) + ":link"] = {
54                "type": "glob",
55                "includes": [
56                    "*.framework",
57                    "*.o",
58                    "*.tbd",
59                    "Current",
60                    "Frameworks",
61                ],
62            }
63        if gn_logs_data.get("ios_sdk_path"):
64            fg[ctx.fs.canonpath("./" + gn_logs_data.get("ios_sdk_path")) + ":headers"] = {
65                "type": "glob",
66                "includes": sdk_includes,
67            }
68
69    fg[ctx.fs.canonpath("./sdk/xcode_links/iPhoneSimulator.platform/Developer/Library/Frameworks") + ":headers"] = {
70        "type": "glob",
71        "includes": sdk_includes,
72    }
73    return fg
74
75mac_sdk = module(
76    "mac_sdk",
77    enabled = __enabled,
78    filegroups = __filegroups,
79)
80