1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79

build / config / siso / mac_sdk.star [blame]

# -*- bazel-starlark -*-
# Copyright 2024 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Siso configuration for mac sdk."""

load("@builtin//lib/gn.star", "gn")
load("@builtin//runtime.star", "runtime")
load("@builtin//struct.star", "module")
load("./gn_logs.star", "gn_logs")

def __enabled(ctx):
    if "args.gn" in ctx.metadata:
        gn_args = gn.args(ctx)
        if gn_args.get("target_os") in ('"mac"', '"ios"'):
            return True
    return runtime.os == "darwin"

def __filegroups(ctx):
    sdk_includes = [
        "*.framework",
        "*.h",
        "*.json",
        "*.modulemap",
        "Current",
        "Frameworks",
        "Headers",
        "Modules",
        "crt*.o",
        "usr/include/c++/v1/*",
        "usr/include/c++/v1/*/*",
    ]
    fg = {
        "build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk:headers": {
            "type": "glob",
            "includes": sdk_includes,
        },
    }
    if gn.args(ctx).get("use_remoteexec") == "true":
        # precompute subtree for sysroot/frameworks for siso scandeps,
        # which is not complex enough to handle C preprocessor tricks
        # and need system include dirs when using deps log of -MMD.
        # need to add new entries when new version is used.
        #
        # if use_remoteexec is not true, these dirs are not under exec root
        # and failed to create filegroup for such dirs. crbug.com/352216756
        gn_logs_data = gn_logs.read(ctx)
        if gn_logs_data.get("mac_sdk_path"):
            fg[ctx.fs.canonpath("./" + gn_logs_data.get("mac_sdk_path")) + ":headers"] = {
                "type": "glob",
                "includes": sdk_includes,
            }
            fg[ctx.fs.canonpath("./" + gn_logs_data.get("mac_sdk_path")) + ":link"] = {
                "type": "glob",
                "includes": [
                    "*.framework",
                    "*.o",
                    "*.tbd",
                    "Current",
                    "Frameworks",
                ],
            }
        if gn_logs_data.get("ios_sdk_path"):
            fg[ctx.fs.canonpath("./" + gn_logs_data.get("ios_sdk_path")) + ":headers"] = {
                "type": "glob",
                "includes": sdk_includes,
            }

    fg[ctx.fs.canonpath("./sdk/xcode_links/iPhoneSimulator.platform/Developer/Library/Frameworks") + ":headers"] = {
        "type": "glob",
        "includes": sdk_includes,
    }
    return fg

mac_sdk = module(
    "mac_sdk",
    enabled = __enabled,
    filegroups = __filegroups,
)