|
| 1 | +#!/usr/bin/env python3 |
| 2 | +"""Build the library for Cortex-M55 using the toolchain file in |
| 3 | +framework/platform and measure and print the code size using the |
| 4 | +existing scripts. |
| 5 | +""" |
| 6 | + |
| 7 | +# Copyright The Mbed TLS Contributors |
| 8 | +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 9 | + |
| 10 | +import json |
| 11 | +import os |
| 12 | +import subprocess |
| 13 | + |
| 14 | +def build_library(build_dir, toolchain_file): |
| 15 | + subprocess.check_call(['cmake', '.', '-B' + build_dir, |
| 16 | + '-DCMAKE_TOOLCHAIN_FILE=framework/platform/' + toolchain_file, |
| 17 | + '-DENABLE_PROGRAMS=NO']) |
| 18 | + subprocess.check_call(['cmake', '--build', build_dir, '-j' + str(os.cpu_count())]) |
| 19 | + |
| 20 | +def generate_sizes(build_dir): |
| 21 | + subprocess.check_call(['framework/scripts/generate_code_size_report.py', |
| 22 | + '--output-file', build_dir + '/code_size.json', |
| 23 | + '--library-file', build_dir + '/core/libtfpsacrypto.a', |
| 24 | + '--size-cmd', 'arm-none-eabi-size']) |
| 25 | + |
| 26 | +def display_sizes(build_dir): |
| 27 | + subprocess.check_call(['framework/scripts/show_code_size.py', |
| 28 | + build_dir + '/code_size.json']) |
| 29 | + |
| 30 | +if __name__ == '__main__': |
| 31 | + BUILD_DIR = 'build-code-size-m55' |
| 32 | + |
| 33 | + build_library(BUILD_DIR, 'arm-gcc-m55.cmake') |
| 34 | + generate_sizes(BUILD_DIR) |
| 35 | + display_sizes(BUILD_DIR) |
0 commit comments