summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2021-08-09 14:33:38 -0700
committerCommit Bot <commit-bot@chromium.org>2021-08-10 21:09:15 +0000
commitd89284053e21cd21ebd5f5853d0de81709c72f08 (patch)
tree8ab2d88565903d7646bc726792ace37de1284c82
parent6d68e9a1a9ac642465416cdf7074b9f8469e9ca0 (diff)
downloadchrome-ec-d89284053e21cd21ebd5f5853d0de81709c72f08.tar.gz
firmware_builder: Make cros lint happy
BRANCH=none BUG=none TEST=cros lint ./firmware_builder.py TEST=./firmware_builder.py --help TEST=./firmware_builder.py --metrics $(mktemp /tmp/fwbld.XXX) test TEST=./firmware_builder.py --metrics $(mktemp /tmp/fwbld.XXX) build Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I0c2b03d3197fc021e93ce8a0029cdd465b9eb457 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3082336 Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
-rwxr-xr-xfirmware_builder.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/firmware_builder.py b/firmware_builder.py
index 0b586076a6..d5a7e6ac8d 100755
--- a/firmware_builder.py
+++ b/firmware_builder.py
@@ -15,10 +15,11 @@ import os
import subprocess
import sys
+# pylint: disable=import-error
+from google.protobuf import json_format
# TODO(crbug/1181505): Code outside of chromite should not be importing from
# chromite.api.gen. Import json_format after that so we get the matching one.
from chromite.api.gen.chromite.api import firmware_pb2
-from google.protobuf import json_format
DEFAULT_BUNDLE_DIRECTORY = '/tmp/artifact_bundles'
@@ -50,7 +51,7 @@ def build(opts):
if opts.code_coverage:
print("When --code-coverage is selected, 'build' is a no-op. "
- "Run 'test' with --code-coverage instead.")
+ "Run 'test' with --code-coverage instead.")
return
cmd = ['make', 'buildall_only', '-j{}'.format(opts.cpus)]
@@ -70,8 +71,10 @@ def bundle(opts):
def get_bundle_dir(opts):
"""Get the directory for the bundle from opts or use the default.
- Also create the directory if it doesn't exist."""
- bundle_dir = opts.output_dir if opts.output_dir else DEFAULT_BUNDLE_DIRECTORY
+ Also create the directory if it doesn't exist.
+ """
+ bundle_dir = opts.output_dir if opts.output_dir else \
+ DEFAULT_BUNDLE_DIRECTORY
if not os.path.isdir(bundle_dir):
os.mkdir(bundle_dir)
return bundle_dir
@@ -79,7 +82,8 @@ def get_bundle_dir(opts):
def write_metadata(opts, info):
"""Write the metadata about the bundle."""
- bundle_metadata_file = opts.metadata if opts.metadata else DEFAULT_BUNDLE_METADATA_FILE
+ bundle_metadata_file = opts.metadata if opts.metadata else \
+ DEFAULT_BUNDLE_METADATA_FILE
with open(bundle_metadata_file, 'w') as f:
f.write(json_format.MessageToJson(info))
@@ -96,7 +100,8 @@ def bundle_coverage(opts):
subprocess.run(cmd, cwd=os.path.join(ec_dir, 'build/coverage'), check=True)
meta = info.objects.add()
meta.file_name = tarball_name
- meta.lcov_info.type = firmware_pb2.FirmwareArtifactInfo.LcovTarballInfo.LcovType.LCOV
+ meta.lcov_info.type = (
+ firmware_pb2.FirmwareArtifactInfo.LcovTarballInfo.LcovType.LCOV)
write_metadata(opts, info)
@@ -117,9 +122,10 @@ def bundle_firmware(opts):
cmd, cwd=os.path.join(ec_dir, 'build', build_target), check=True)
meta = info.objects.add()
meta.file_name = tarball_name
- meta.tarball_info.type = firmware_pb2.FirmwareArtifactInfo.TarballInfo.FirmwareType.EC
- # TODO(kmshelton): Populate the rest of metadata contents as it gets defined in
- # infra/proto/src/chromite/api/firmware.proto.
+ meta.tarball_info.type = (
+ firmware_pb2.FirmwareArtifactInfo.TarballInfo.FirmwareType.EC)
+ # TODO(kmshelton): Populate the rest of metadata contents as it gets
+ # defined in infra/proto/src/chromite/api/firmware.proto.
write_metadata(opts, info)
@@ -157,11 +163,14 @@ def test(opts):
def main(args):
- """Builds, bundles, or tests all of the EC targets and reports build metrics."""
+ """Builds, bundles, or tests all of the EC targets.
+
+ Additionally, the tool reports build metrics.
+ """
opts = parse_args(args)
if not hasattr(opts, 'func'):
- print("Must select a valid sub command!")
+ print('Must select a valid sub command!')
return -1
# Run selected sub command function
@@ -192,15 +201,15 @@ def parse_args(args):
parser.add_argument(
'--metadata',
required=False,
- help=
- 'Full pathname for the file in which to write build artifact metadata.',
+ help='Full pathname for the file in which to write build artifact '
+ 'metadata.',
)
parser.add_argument(
'--output-dir',
required=False,
- help=
- 'Full pathanme for the directory in which to bundle build artifacts.',
+ help='Full pathanme for the directory in which to bundle build '
+ 'artifacts.',
)
parser.add_argument(