aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan R Abrahams-Whitehead <ajordanr@google.com>2024-02-23 22:02:13 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-02-23 22:14:52 +0000
commitc75f0ff3942b3fd2feb8bb4bcc64d3e47149ece8 (patch)
treecacf92d054fb7547cd88eeb58a02b16051081ea4
parente632e6f8dab213a3d351adfad8d35b8a91de51bb (diff)
downloadtoolchain-utils-c75f0ff3942b3fd2feb8bb4bcc64d3e47149ece8.tar.gz
llvm_tools: Fix cros workon invocation
At present, we invoke `cros workon` using the `cros-workon` style syntax. This unfortunately: 1. Is going to be deprecated. 2. Doesn't work outside of the chroot. 3. Assumes you're working on the --host, when in fact you may not want to workon the host, you may want to workon a board. This CL changes this behaviour, by not enabling cros workon by default (warning the user it's not workon-ed), and using the more modern cros workon syntax. BUG=None TEST=llvm_tools/setup_for_workon.py \ --workon-board volteer-scudo \ --package sys-libs/scudo TEST=llvm_tools/setup_for_workon.py \ --package sys-libs/scudo Change-Id: I4f65c73ef12e64da973a14ec1ea9b9ea7b70b35f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5321923 Reviewed-by: George Burgess <gbiv@chromium.org> Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com> Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
-rwxr-xr-xllvm_tools/setup_for_workon.py40
1 files changed, 30 insertions, 10 deletions
diff --git a/llvm_tools/setup_for_workon.py b/llvm_tools/setup_for_workon.py
index db290d81..41f3d45c 100755
--- a/llvm_tools/setup_for_workon.py
+++ b/llvm_tools/setup_for_workon.py
@@ -3,13 +3,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Sets up src/third_party/llvm-project for cros-workon from an LLVM ebuild."""
+"""Sets up src/third_party/llvm-project for cros workon from an LLVM ebuild."""
import argparse
import dataclasses
import logging
from pathlib import Path
import re
+import shlex
import subprocess
import sys
from typing import List, Union
@@ -167,10 +168,12 @@ def main(argv: List[str]) -> None:
help="Don't create a commit with all changes applied.",
)
parser.add_argument(
- "--no-ensure-workon",
- dest="ensure_workon",
- action="store_false",
- help="Don't call cros-workon on the project after applying changes.",
+ "--workon-board",
+ dest="workon_board",
+ help="""
+ Ensure cros workon for the given board after applying changes.
+ Set to 'host' for working on the host system, and not a board.
+ """,
)
opts = parser.parse_args(argv)
@@ -254,12 +257,29 @@ def main(argv: List[str]) -> None:
stdin=subprocess.DEVNULL,
)
- if opts.ensure_workon:
- subprocess.run(
- ["cros-workon", "--host", "start", package_name],
- check=True,
- stdin=subprocess.DEVNULL,
+ if not opts.workon_board:
+ logging.warning(
+ "Didn't ensure 'workon' for any board or host."
+ " Make sure you've called 'cros workon [...] start %s'"
+ " before building!",
+ package_name,
)
+ return
+
+ if opts.workon_board == "host":
+ cmd = ["cros", "workon", "--host", "start", package_name]
+ else:
+ cmd = [
+ "cros",
+ "workon",
+ f"-b={opts.workon_board}",
+ "start",
+ package_name,
+ ]
+ subprocess.run(cmd, check=True, stdin=subprocess.DEVNULL)
+ logging.info(
+ "Successfully workon-ed: %s", shlex.join([str(c) for c in cmd])
+ )
if __name__ == "__main__":