Merge "build_with_bazel: Add menuconfig option"
This commit is contained in:
commit
888ef98cc5
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
# Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
# Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
|
||||
import argparse
|
||||
import errno
|
||||
@ -220,6 +220,7 @@ class BazelBuilder:
|
||||
out_subdir="dist",
|
||||
extra_options=None,
|
||||
us_cross_toolchain=None,
|
||||
bazel_target_opts=None,
|
||||
):
|
||||
"""Execute a bazel command"""
|
||||
cmdline = [self.bazel_bin, bazel_subcommand]
|
||||
@ -228,8 +229,8 @@ class BazelBuilder:
|
||||
if us_cross_toolchain:
|
||||
cmdline.extend(self.get_cross_cli_opts(us_cross_toolchain))
|
||||
cmdline.extend(targets)
|
||||
if self.out_dir and bazel_subcommand == "run":
|
||||
cmdline.extend(["--", "--dist_dir", os.path.join(self.out_dir, out_subdir)])
|
||||
if bazel_target_opts is not None:
|
||||
cmdline.extend(["--"] + bazel_target_opts)
|
||||
|
||||
cmdline_str = " ".join(cmdline)
|
||||
try:
|
||||
@ -257,8 +258,17 @@ class BazelBuilder:
|
||||
self, targets, out_subdir="dist", user_opts=None, us_cross_toolchain=None
|
||||
):
|
||||
"""Run "bazel run" on all targets in serial (since bazel run cannot have multiple targets)"""
|
||||
bto = []
|
||||
if self.out_dir:
|
||||
bto.extend(["--dist_dir", os.path.join(self.out_dir, out_subdir)])
|
||||
for target in targets:
|
||||
self.bazel("run", [target], out_subdir, user_opts, us_cross_toolchain)
|
||||
self.bazel("run", [target], out_subdir, user_opts, us_cross_toolchain, bazel_target_opts=bto)
|
||||
|
||||
def run_menuconfig(self):
|
||||
"""Run menuconfig on all target-variant combos class is initialized with"""
|
||||
for t, v in self.target_list:
|
||||
self.bazel("run", ["//{}:{}_{}_config".format(self.kernel_dir, t, v)],
|
||||
out_subdir=None, bazel_target_opts=["menuconfig"])
|
||||
|
||||
def build(self):
|
||||
"""Determine which targets to build, then build them"""
|
||||
@ -341,6 +351,12 @@ def main():
|
||||
choices=["debug", "info", "warning", "error"],
|
||||
help="Log level (debug, info, warning, error)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c",
|
||||
"--menuconfig",
|
||||
action="store_true",
|
||||
help="Run menuconfig for <target>-<variant> and exit without building",
|
||||
)
|
||||
|
||||
args, user_opts = parser.parse_known_args(sys.argv[1:])
|
||||
|
||||
@ -353,7 +369,10 @@ def main():
|
||||
|
||||
builder = BazelBuilder(args.target, args.skip, args.out_dir, user_opts)
|
||||
try:
|
||||
builder.build()
|
||||
if args.menuconfig:
|
||||
builder.run_menuconfig()
|
||||
else:
|
||||
builder.build()
|
||||
except KeyboardInterrupt:
|
||||
logging.info("Received keyboard interrupt... exiting")
|
||||
del builder
|
||||
|
Loading…
Reference in New Issue
Block a user