quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

footprint.sh (2804B)


      1 #!/bin/sh
      2 #
      3 # Copyright The Mbed TLS Contributors
      4 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
      5 #
      6 # Purpose
      7 #
      8 # This script determines ROM size (or code size) for the standard Mbed TLS
      9 # configurations, when built for a Cortex M3/M4 target.
     10 #
     11 # Configurations included:
     12 #   default    include/mbedtls/mbedtls_config.h
     13 #   thread     configs/config-thread.h
     14 #   suite-b    configs/config-suite-b.h
     15 #   psk        configs/config-ccm-psk-tls1_2.h
     16 #
     17 # Usage: footprint.sh
     18 #
     19 set -eu
     20 
     21 CONFIG_H='include/mbedtls/mbedtls_config.h'
     22 
     23 if [ -r $CONFIG_H ]; then :; else
     24     echo "$CONFIG_H not found" >&2
     25     echo "This script needs to be run from the root of" >&2
     26     echo "a git checkout or uncompressed tarball" >&2
     27     exit 1
     28 fi
     29 
     30 if grep -i cmake Makefile >/dev/null; then
     31     echo "Not compatible with CMake" >&2
     32     exit 1
     33 fi
     34 
     35 if which arm-none-eabi-gcc >/dev/null 2>&1; then :; else
     36     echo "You need the ARM-GCC toolchain in your path" >&2
     37     echo "See https://launchpad.net/gcc-arm-embedded/" >&2
     38     exit 1
     39 fi
     40 
     41 ARMGCC_FLAGS='-Os -march=armv7-m -mthumb'
     42 OUTFILE='00-footprint-summary.txt'
     43 
     44 log()
     45 {
     46     echo "$@"
     47     echo "$@" >> "$OUTFILE"
     48 }
     49 
     50 doit()
     51 {
     52     NAME="$1"
     53     FILE="$2"
     54 
     55     log ""
     56     log "$NAME ($FILE):"
     57 
     58     cp $CONFIG_H ${CONFIG_H}.bak
     59     if [ "$FILE" != $CONFIG_H ]; then
     60         cp "$FILE"  $CONFIG_H
     61     fi
     62 
     63     {
     64         scripts/config.py unset MBEDTLS_NET_C || true
     65         scripts/config.py unset MBEDTLS_TIMING_C || true
     66         scripts/config.py unset MBEDTLS_FS_IO || true
     67         scripts/config.py --force set MBEDTLS_NO_PLATFORM_ENTROPY || true
     68     } >/dev/null 2>&1
     69 
     70     make clean >/dev/null
     71     CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld \
     72         CFLAGS="$ARMGCC_FLAGS" make lib >/dev/null
     73 
     74     OUT="size-${NAME}.txt"
     75     arm-none-eabi-size -t library/libmbed*.a > "$OUT"
     76     log "$( head -n1 "$OUT" )"
     77     log "$( tail -n1 "$OUT" )"
     78 
     79     cp ${CONFIG_H}.bak $CONFIG_H
     80 }
     81 
     82 # truncate the file just this time
     83 echo "(generated by $0)" > "$OUTFILE"
     84 echo "" >> "$OUTFILE"
     85 
     86 log "Footprint of standard configurations (minus net_sockets.c, timing.c, fs_io)"
     87 log "for bare-metal ARM Cortex-M3/M4 microcontrollers."
     88 
     89 VERSION_H="include/mbedtls/version.h"
     90 MBEDTLS_VERSION=$( sed -n 's/.*VERSION_STRING *"\(.*\)"/\1/p' $VERSION_H )
     91 if git rev-parse HEAD >/dev/null; then
     92     GIT_HEAD=$( git rev-parse HEAD | head -c 10 )
     93     GIT_VERSION=" (git head: $GIT_HEAD)"
     94 else
     95     GIT_VERSION=""
     96 fi
     97 
     98 log ""
     99 log "Mbed TLS $MBEDTLS_VERSION$GIT_VERSION"
    100 log "$( arm-none-eabi-gcc --version | head -n1 )"
    101 log "CFLAGS=$ARMGCC_FLAGS"
    102 
    103 doit default    include/mbedtls/mbedtls_config.h
    104 doit thread     configs/config-thread.h
    105 doit suite-b    configs/config-suite-b.h
    106 doit psk        configs/config-ccm-psk-tls1_2.h
    107 
    108 zip mbedtls-footprint.zip "$OUTFILE" size-*.txt >/dev/null