• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- bazel-starlark -*-
2# Copyright 2023 The Chromium Authors. All rights reserved.
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 main entry."""
6
7load("@builtin//encoding.star", "json")
8load("@builtin//runtime.star", "runtime")
9load("@builtin//struct.star", "module")
10load("./linux.star", chromium_linux = "chromium")
11load("./mac.star", chromium_mac = "chromium")
12load("./simple.star", "simple")
13load("./windows.star", chromium_windows = "chromium")
14
15def init(ctx):
16    print("runtime: os:%s arch:%s run:%d" % (
17        runtime.os,
18        runtime.arch,
19        runtime.num_cpu,
20    ))
21    host = {
22        "linux": chromium_linux,
23        "darwin": chromium_mac,
24        "windows": chromium_windows,
25    }[runtime.os]
26    step_config = {
27        "platforms": {},
28        "input_deps": {},
29        "rules": [],
30    }
31    step_config = host.step_config(ctx, step_config)
32    step_config = simple.step_config(ctx, step_config)
33
34    #  Python actions may use an absolute path at the first argument.
35    #  e.g. C:/src/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe
36    #  It needs to set `pyhton3` or `python3.exe` be replaced with `python3.exe` for remote execution.
37    for rule in step_config["rules"]:
38        if rule["name"].startswith("clang-coverage"):
39            # clang_code_coverage_wrapper.run() strips the python wrapper.
40            # So it shouldn't set `remote_command: python3`.
41            continue
42        arg0 = rule.get("command_prefix", "").split(" ")[0].strip("\"")
43        if arg0 in ["python3", "python3.exe"]:
44            rule["remote_command"] = arg0
45
46    filegroups = {}
47    filegroups.update(host.filegroups)
48    filegroups.update(simple.filegroups)
49
50    handlers = {}
51    handlers.update(host.handlers)
52    handlers.update(simple.handlers)
53
54    return module(
55        "config",
56        step_config = json.encode(step_config),
57        filegroups = filegroups,
58        handlers = handlers,
59    )
60