xref: /aosp_15_r20/external/angle/build/config/siso/config.star (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker# -*- bazel-starlark -*-
2*8975f5c5SAndroid Build Coastguard Worker# Copyright 2023 The Chromium Authors
3*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker"""Config module for checking siso -config flags."""
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Workerload("@builtin//struct.star", "module")
8*8975f5c5SAndroid Build Coastguard Worker
9*8975f5c5SAndroid Build Coastguard Worker__KNOWN_CONFIG_OPTIONS = [
10*8975f5c5SAndroid Build Coastguard Worker    # Indicates that the build runs on a builder.
11*8975f5c5SAndroid Build Coastguard Worker    "builder",
12*8975f5c5SAndroid Build Coastguard Worker
13*8975f5c5SAndroid Build Coastguard Worker    # Indicate that it runs on Cog (automatically set on Cog).
14*8975f5c5SAndroid Build Coastguard Worker    "cog",
15*8975f5c5SAndroid Build Coastguard Worker
16*8975f5c5SAndroid Build Coastguard Worker    # Force disable additional remote on cog.
17*8975f5c5SAndroid Build Coastguard Worker    # TODO: b/333033551 - check performance with/without remote on cog.
18*8975f5c5SAndroid Build Coastguard Worker    "disable-remote-on-cog",
19*8975f5c5SAndroid Build Coastguard Worker
20*8975f5c5SAndroid Build Coastguard Worker    # TODO: b/308405411 - Enable this config for all builders.
21*8975f5c5SAndroid Build Coastguard Worker    "remote-devtools-frontend-typescript",
22*8975f5c5SAndroid Build Coastguard Worker
23*8975f5c5SAndroid Build Coastguard Worker    # TODO: b/370860664 - Enable remote link by default after supporting
24*8975f5c5SAndroid Build Coastguard Worker    # all platforms and target OSes.
25*8975f5c5SAndroid Build Coastguard Worker    # For developers, we can't simply enable remote link without bytes
26*8975f5c5SAndroid Build Coastguard Worker    # because developers need objects and tests locally for debugging
27*8975f5c5SAndroid Build Coastguard Worker    # and testing.
28*8975f5c5SAndroid Build Coastguard Worker    "remote-link",
29*8975f5c5SAndroid Build Coastguard Worker]
30*8975f5c5SAndroid Build Coastguard Worker
31*8975f5c5SAndroid Build Coastguard Workerdef __check(ctx):
32*8975f5c5SAndroid Build Coastguard Worker    if "config" in ctx.flags:
33*8975f5c5SAndroid Build Coastguard Worker        for cfg in ctx.flags["config"].split(","):
34*8975f5c5SAndroid Build Coastguard Worker            if cfg not in __KNOWN_CONFIG_OPTIONS:
35*8975f5c5SAndroid Build Coastguard Worker                print("unknown config: %s" % cfg)
36*8975f5c5SAndroid Build Coastguard Worker
37*8975f5c5SAndroid Build Coastguard Workerdef __get(ctx, key):
38*8975f5c5SAndroid Build Coastguard Worker    onCog = ctx.fs.exists("../.citc")
39*8975f5c5SAndroid Build Coastguard Worker    disableRemoteOnCog = False
40*8975f5c5SAndroid Build Coastguard Worker    if "config" in ctx.flags:
41*8975f5c5SAndroid Build Coastguard Worker        for cfg in ctx.flags["config"].split(","):
42*8975f5c5SAndroid Build Coastguard Worker            if cfg == key:
43*8975f5c5SAndroid Build Coastguard Worker                return True
44*8975f5c5SAndroid Build Coastguard Worker            if cfg == "disable-remote-on-cog":
45*8975f5c5SAndroid Build Coastguard Worker                disableRemoteOnCog = True
46*8975f5c5SAndroid Build Coastguard Worker            if cfg == "cog":
47*8975f5c5SAndroid Build Coastguard Worker                onCog = True
48*8975f5c5SAndroid Build Coastguard Worker    if onCog:
49*8975f5c5SAndroid Build Coastguard Worker        if disableRemoteOnCog:
50*8975f5c5SAndroid Build Coastguard Worker            return False
51*8975f5c5SAndroid Build Coastguard Worker
52*8975f5c5SAndroid Build Coastguard Worker        # on cog, .citc directory exist in parent directory of exec root.
53*8975f5c5SAndroid Build Coastguard Worker        # disable race strategy as "builder".
54*8975f5c5SAndroid Build Coastguard Worker        # enable "remote-*" on cog
55*8975f5c5SAndroid Build Coastguard Worker        # TODO: b/308405411 - enable "remote-devtools-frontend-typescript"
56*8975f5c5SAndroid Build Coastguard Worker        if key in ("builder", "cog", "remote-link"):
57*8975f5c5SAndroid Build Coastguard Worker            return True
58*8975f5c5SAndroid Build Coastguard Worker    return False
59*8975f5c5SAndroid Build Coastguard Worker
60*8975f5c5SAndroid Build Coastguard Workerconfig = module(
61*8975f5c5SAndroid Build Coastguard Worker    "config",
62*8975f5c5SAndroid Build Coastguard Worker    check = __check,
63*8975f5c5SAndroid Build Coastguard Worker    get = __get,
64*8975f5c5SAndroid Build Coastguard Worker)
65