diff options
author | Jeremy Bettis <jbettis@google.com> | 2022-12-07 16:17:12 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-10 01:42:36 +0000 |
commit | 15c095a3556cf60fab8e3eda966c3287eea79b36 (patch) | |
tree | f01b20fba422bfa66720e0e0ce03d668c5fc611c | |
parent | 948b29d6dd29039a7aa226a47842574ab15abb21 (diff) | |
download | chrome-ec-15c095a3556cf60fab8e3eda966c3287eea79b36.tar.gz |
cq: Export a few boards in binary_sizes
For some boards that have been added or edited recently, and for just
2 regions, set the track_in_gerrit option on the metric.
Also extract the baseboard from make and use that as the platform
name instead of "ec".
BRANCH=None
BUG=b:261622866
TEST=./firmware_builder.py --metrics /tmp/metrics_build build
Change-Id: Iac325778370e606901d1e372b735e0531c530323
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4086970
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Jeremy Bettis <jbettis@chromium.org>
Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | Makefile.rules | 8 | ||||
-rwxr-xr-x | firmware_builder.py | 49 |
2 files changed, 53 insertions, 4 deletions
diff --git a/Makefile.rules b/Makefile.rules index 8b52882635..9f4538b07c 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -750,6 +750,14 @@ flash_ec: $(out)/ec.bin flash_dfu: $(out)/ec.bin sudo ./$(BDIR)/dfu $(out)/ec.bin +.PHONY: print-all-baseboards +print-all-baseboards: $(foreach b, $(BOARDS), print-baseboard-$(b)) +print-baseboard-%: + @$(MAKE) BOARD=$* V=$(V) print-one-baseboard +.PHONY: print-one-baseboard +print-one-baseboard: + @echo "${BOARD}=${BASEBOARD}" + # Deprecated, use print-make-vars instead .PHONY: print-baseboard print-baseboard: diff --git a/firmware_builder.py b/firmware_builder.py index 06bf9beec6..8e0b8ef749 100755 --- a/firmware_builder.py +++ b/firmware_builder.py @@ -32,6 +32,22 @@ BOARDS_UNIT_TEST = [ "dartmonkey", ] +# Interesting regions to show in gerrit +BINARY_SIZE_REGIONS = ["RW_FLASH", "RW_IRAM"] + +# The most recently edited boards that should show binary size changes in +# gerrit +BINARY_SIZE_BOARDS = [ + "dibbi", + "gaelin", + "gladios", + "lisbon", + "marasov", + "moli", + "prism", + "shotzo", +] + def build(opts): """Builds all EC firmware targets @@ -91,12 +107,29 @@ def build(opts): print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) + cmd = ["make", "print-all-baseboards", f"-j{opts.cpus}"] + print(f"# Running {' '.join(cmd)}.") + baseboards = {} + for line in subprocess.run( + cmd, + cwd=os.path.dirname(__file__), + check=True, + universal_newlines=True, + stdout=subprocess.PIPE, + ).stdout.splitlines(): + parts = line.split("=") + if len(parts) > 1: + baseboards[parts[0]] = parts[1] + ec_dir = os.path.dirname(__file__) build_dir = os.path.join(ec_dir, "build") for build_target in sorted(os.listdir(build_dir)): metric = metric_list.value.add() metric.target_name = build_target - metric.platform_name = "ec" + metric.platform_name = build_target + if build_target in baseboards and baseboards[build_target]: + metric.platform_name = baseboards[build_target] + for variant in ["RO", "RW"]: memsize_file = ( pathlib.Path(build_dir) @@ -105,7 +138,12 @@ def build(opts): / f"ec.{variant}.elf.memsize.txt" ) if memsize_file.exists(): - parse_memsize(memsize_file, metric, variant) + parse_memsize( + memsize_file, + metric, + variant, + build_target in BINARY_SIZE_BOARDS, + ) with open(opts.metrics, "w") as file: file.write(json_format.MessageToJson(metric_list)) @@ -124,7 +162,7 @@ UNITS = { } -def parse_memsize(filename, metric, variant): +def parse_memsize(filename, metric, variant, track_on_gerrit): """Parse the output of the build to extract the image size.""" with open(filename, "r") as infile: # Skip header line @@ -135,7 +173,10 @@ def parse_memsize(filename, metric, variant): fw_section.region = variant + "_" + parts[0][:-1] fw_section.used = int(parts[1]) * UNITS[parts[2]] fw_section.total = int(parts[3]) * UNITS[parts[4]] - fw_section.track_on_gerrit = False + if track_on_gerrit and fw_section.region in BINARY_SIZE_REGIONS: + fw_section.track_on_gerrit = True + else: + fw_section.track_on_gerrit = False def bundle(opts): |