| #!/bin/bash |
| |
| # Copyright 2021 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Builds code and prints binary sizes. For now, this only reports sizes of MCU |
| # binaries as that is by far the most space-constrained. |
| |
| PROJECT_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..) |
| |
| source "${PROJECT_ROOT}/environment" |
| |
| set -e |
| STAGE0="${PROJECT_ROOT}/rust/mcu/target/thumbv6m-none-eabi/release/stage0.bin" |
| APPLICATION="${PROJECT_ROOT}/rust/mcu/target/thumbv6m-none-eabi/release/stage1_app.bin" |
| ( |
| cd "${PROJECT_ROOT}/rust/mcu" |
| cargo build -p stage0 --release |
| arm-none-eabi-objcopy \ |
| -O binary \ |
| target/thumbv6m-none-eabi/release/stage0 \ |
| "${STAGE0}" |
| ) |
| ( |
| cd "${PROJECT_ROOT}/rust/mcu" |
| cargo build -p stage1_app --release |
| arm-none-eabi-objcopy \ |
| -O binary \ |
| target/thumbv6m-none-eabi/release/stage1_app \ |
| "${APPLICATION}" |
| ) |
| echo |
| STAGE0_SIZE=$(stat --printf='%s' "${STAGE0}") |
| APPLICATION_SIZE=$(stat --printf='%s' "${APPLICATION}") |
| echo "Stage0: ${STAGE0_SIZE} bytes" |
| echo "Application: ${APPLICATION_SIZE} bytes" |