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/316267242 - Enable remote links after confirming performance. 24 "remote-library-link", 25 "remote-exec-link", 26] 27 28def __check(ctx): 29 if "config" in ctx.flags: 30 for cfg in ctx.flags["config"].split(","): 31 if cfg not in __KNOWN_CONFIG_OPTIONS: 32 print("unknown config: %s" % cfg) 33 34def __get(ctx, key): 35 disableRemoteOnCog = False 36 if "config" in ctx.flags: 37 for cfg in ctx.flags["config"].split(","): 38 if cfg == key: 39 return True 40 if cfg == "disable-remote-on-cog": 41 disableRemoteOnCog = True 42 if ctx.fs.exists("../.citc"): 43 if disableRemoteOnCog: 44 return False 45 46 # on cog, .citc directory exist in parent directory of exec root. 47 # disable race strategy as "builder". 48 # enable "remote-*" on cog 49 # TODO: b/308405411 - enable "remote-devtools-frontend-typescript" 50 if key in ("builder", "cog", "remote-library-link", "remote-exec-link"): 51 return True 52 return False 53 54config = module( 55 "config", 56 check = __check, 57 get = __get, 58) 59