1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/usr/bin/env python3
# Copyright 2024 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Runs `bb add`, with additional convenience features."""
import argparse
import logging
import os
import shlex
import sys
from typing import Iterable, List
import cros_cls
import llvm_next
def generate_bb_add_command(
use_llvm_next: bool,
disable_werror: bool,
extra_cls: Iterable[cros_cls.ChangeListURL],
bots: Iterable[str],
) -> List[str]:
cls: List[cros_cls.ChangeListURL] = []
if use_llvm_next:
if not llvm_next.LLVM_NEXT_TESTING_CLS:
raise ValueError(
"llvm-next testing requested, but no llvm-next CLs exist."
)
cls += llvm_next.LLVM_NEXT_TESTING_CLS
if disable_werror:
cls.append(llvm_next.DISABLE_WERROR_CL)
if extra_cls:
cls += extra_cls
cmd = ["bb", "add"]
for cl in cls:
cmd += ("-cl", cl.crrev_url_without_http())
cmd += bots
return cmd
def main(argv: List[str]) -> None:
logging.basicConfig(
format=">> %(asctime)s: %(levelname)s: %(filename)s:%(lineno)d: "
"%(message)s",
level=logging.INFO,
)
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"--llvm-next",
action="store_true",
help="Add the current llvm-next patch set.",
)
parser.add_argument(
"--disable-werror",
action="store_true",
help="Add the 'disable -Werror' patch sets",
)
parser.add_argument(
"--cl",
action="append",
type=cros_cls.ChangeListURL.parse,
help="""
CL to add to the `bb add` run. May be specified multiple times. In the
form crrev.com/c/123456.
""",
)
parser.add_argument("bot", nargs="+", help="Bot(s) to run `bb add` with.")
opts = parser.parse_args(argv)
cmd = generate_bb_add_command(
use_llvm_next=opts.llvm_next,
disable_werror=opts.disable_werror,
extra_cls=opts.cl,
bots=opts.bot,
)
logging.info("Running `bb add` command: %s...", shlex.join(cmd))
# execvp raises if it fails, so no need to check.
os.execvp(cmd[0], cmd)
if __name__ == "__main__":
main(sys.argv[1:])
|