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