|
| 1 | +#!/bin/sh |
| 2 | +# SPDX-License-Identifier: BSD-3-Clause |
| 3 | +# shellcheck disable=SC3043 |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +die() |
| 8 | +{ |
| 9 | + # shellcheck disable=SC2059 |
| 10 | + >&2 printf "$@" |
| 11 | + exit 1 |
| 12 | +} |
| 13 | + |
| 14 | +fix_dir() |
| 15 | +{ |
| 16 | + local bd="$1" |
| 17 | + |
| 18 | + test -d "$bd"/build-sof-staging || |
| 19 | + die 'No %s/build-sof-staging directory\n' "$bd" |
| 20 | + |
| 21 | + # config files have absolute paths |
| 22 | + find "$bd" -name 'config.gz' -exec rm '{}' \; |
| 23 | + |
| 24 | + # In case of a compression timestamp. Also gives better messages. |
| 25 | + find "$bd" -name '*.gz' -print0 | xargs -r -0 gunzip |
| 26 | + |
| 27 | + ( set -x |
| 28 | + |
| 29 | + # Native binaries |
| 30 | + rm -f "$bd"/build-sof-staging/tools/sof-logger* |
| 31 | + # Python and other scripts |
| 32 | + dos2unix "$bd"/build-sof-staging/tools/* || true |
| 33 | + |
| 34 | + # signature salt |
| 35 | + find "$bd" -name '*.ri' -exec rm '{}' \; |
| 36 | + |
| 37 | + # debug symbols |
| 38 | + find "$bd" -name main.mod -exec rm '{}' \; |
| 39 | + find "$bd" -name zephyr.elf -exec rm '{}' \; |
| 40 | + |
| 41 | + # Unlike zephyr.lst, zephyr.map includes some debug information which is |
| 42 | + # as usual full of absolute paths, e.g.: |
| 43 | + # /opt/toolchains/zephyr-sdk-0.15.2/xtensa-intel_s1000_..../libgcc.a(_divsf3.o) |
| 44 | + # Delete non-reproducible information inside zephyr.map. |
| 45 | + find "$bd" -name zephyr.map -exec sed -i'' -e \ |
| 46 | + 's#[^[:blank:]]*zephyr-sdk-[^/]*/xtensa#ZSDK/xtensa#; s#\\#/#g; /^ \.debug_/ d' \ |
| 47 | + '{}' \; |
| 48 | + |
| 49 | + # The above search/replace normalizes MOST but unfortunately not |
| 50 | + # all the debug information! So let's delete zephyr.map after all :-( |
| 51 | + # Comparing "almost normalized" zephyr.map files can be very |
| 52 | + # useful to root cause differences: comment out this line in your |
| 53 | + # local workspace. |
| 54 | + find "$bd" -name zephyr.map -exec rm '{}' \; |
| 55 | + |
| 56 | + find "$bd" -name 'compile_commands.json' -exec rm '{}' \; |
| 57 | + ) |
| 58 | + |
| 59 | +} |
| 60 | + |
| 61 | +main() |
| 62 | +{ |
| 63 | + for d in "$@"; do |
| 64 | + fix_dir "$d" |
| 65 | + done |
| 66 | +} |
| 67 | + |
| 68 | + |
| 69 | +main "$@" |
0 commit comments