Skip to content

Commit 6cb0fb6

Browse files
rzhwcopybara-github
authored andcommitted
siso: add rewrapper_to_reproxy config for linux
Bug: b/273407069 Change-Id: Iadbac08d0aa1ca3b48d72858f7d6f5920d2fcb05 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4569976 Reviewed-by: Junji Watanabe <[email protected]> Commit-Queue: Richard Wang <[email protected]> Cr-Commit-Position: refs/heads/main@{#1150405} NOKEYCHECK=True GitOrigin-RevId: 730d7693d7c054f1d788ac5265e2ee5a983b12d2
1 parent ecd888f commit 6cb0fb6

File tree

5 files changed

+88
-2
lines changed

5 files changed

+88
-2
lines changed

config/siso/config.star

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
load("@builtin//struct.star", "module")
88

9-
__KNOWN_CONFIG_OPTIONS = []
9+
__KNOWN_CONFIG_OPTIONS = [
10+
"rewrapper_to_reproxy",
11+
]
1012

1113
def __check(ctx):
1214
if "config" in ctx.flags:

config/siso/linux.star

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ load("./config.star", "config")
1010
load("./mojo.star", "mojo")
1111
load("./nacl_linux.star", "nacl")
1212
load("./remote_exec_wrapper.star", "remote_exec_wrapper")
13+
load("./rewrapper_to_reproxy.star", "rewrapper_to_reproxy")
1314

1415
__filegroups = {}
1516
__filegroups.update(clang.filegroups)
@@ -20,6 +21,8 @@ __handlers = {}
2021
__handlers.update(clang.handlers)
2122
__handlers.update(mojo.handlers)
2223
__handlers.update(nacl.handlers)
24+
__handlers.update(remote_exec_wrapper.handlers)
25+
__handlers.update(rewrapper_to_reproxy.handlers)
2326

2427
def __step_config(ctx, step_config):
2528
config.check(ctx)
@@ -29,7 +32,10 @@ def __step_config(ctx, step_config):
2932
"container-image": "docker://gcr.io/chops-private-images-prod/rbe/siso-chromium/linux@sha256:d4fcda628ebcdb3dd79b166619c56da08d5d7bd43d1a7b1f69734904cc7a1bb2",
3033
},
3134
}
32-
if remote_exec_wrapper.enabled(ctx):
35+
# rewrapper_to_reproxy takes precedence over remote exec wrapper handler if enabled.
36+
if rewrapper_to_reproxy.enabled(ctx):
37+
step_config = rewrapper_to_reproxy.step_config(ctx, step_config)
38+
elif remote_exec_wrapper.enabled(ctx):
3339
step_config = remote_exec_wrapper.step_config(ctx, step_config)
3440
else:
3541
step_config = clang.step_config(ctx, step_config)

config/siso/mac.star

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ __filegroups = {}
1111
__handlers = {}
1212

1313
def __step_config(ctx, step_config):
14+
# TODO(b/273407069): Handle reproxy mode.
1415
config.check(ctx)
1516
if remote_exec_wrapper.enabled(ctx):
1617
step_config = remote_exec_wrapper.step_config(ctx, step_config)

config/siso/rewrapper_to_reproxy.star

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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 for rewriting remote exec wrapper calls into reproxy config."""
6+
7+
load("@builtin//lib/gn.star", "gn")
8+
load("@builtin//struct.star", "module")
9+
load("./config.star", "config")
10+
11+
__filegroups = {}
12+
13+
def __remove_rewrapper(ctx, cmd):
14+
# Slice from the first non-arg passed to rewrapper.
15+
# (Whilst rewrapper usage is `rewrapper [-flags] -- command ...` we don't pass -- to rewrapper.)
16+
non_flag_start = -1
17+
for i, arg in enumerate(cmd.args):
18+
if i == 0:
19+
continue
20+
if not arg.startswith('-'):
21+
non_flag_start = i
22+
break
23+
if non_flag_start < 1:
24+
fail("couldn't find first non-arg passed to rewrapper")
25+
ctx.actions.fix(
26+
args = cmd.args[non_flag_start:],
27+
)
28+
29+
__handlers = {
30+
"remove_rewrapper": __remove_rewrapper,
31+
}
32+
33+
def __enabled(ctx):
34+
if config.get(ctx, "rewrapper_to_reproxy") and "args.gn" in ctx.metadata:
35+
gn_args = gn.parse_args(ctx.metadata["args.gn"])
36+
if gn_args.get("use_remoteexec") == "true":
37+
return True
38+
return False
39+
40+
def __step_config(ctx, step_config):
41+
# TODO(b/273407069): Read reproxy config from config files.
42+
step_config["rules"].extend([
43+
{
44+
"name": "clang/cxx",
45+
"action": "(.*_)?cxx",
46+
"handler": "remove_rewrapper",
47+
"reproxy_config": {"labels": {"type": "compile", "compiler": "clang", "lang": "cpp"}},
48+
},
49+
{
50+
"name": "clang/cc",
51+
"action": "(.*_)?cc",
52+
"handler": "remove_rewrapper",
53+
"reproxy_config": {"labels": {"type": "compile", "compiler": "clang", "lang": "cpp"}},
54+
},
55+
{
56+
"name": "clang/objcxx",
57+
"action": "(.*_)?objcxx",
58+
"handler": "remove_rewrapper",
59+
"reproxy_config": {"labels": {"type": "compile", "compiler": "clang", "lang": "cpp"}},
60+
},
61+
{
62+
"name": "clang/objc",
63+
"action": "(.*_)?objc",
64+
"handler": "remove_rewrapper",
65+
"reproxy_config": {"labels": {"type": "compile", "compiler": "clang", "lang": "cpp"}},
66+
},
67+
])
68+
return step_config
69+
70+
rewrapper_to_reproxy = module(
71+
"rewrapper_to_reproxy",
72+
enabled = __enabled,
73+
step_config = __step_config,
74+
filegroups = __filegroups,
75+
handlers = __handlers,
76+
)

config/siso/windows.star

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ __filegroups = {}
1111
__handlers = {}
1212

1313
def __step_config(ctx, step_config):
14+
# TODO(b/273407069): Handle reproxy mode.
1415
config.check(ctx)
1516
if remote_exec_wrapper.enabled(ctx):
1617
step_config = remote_exec_wrapper.step_config(ctx, step_config)

0 commit comments

Comments
 (0)