Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright lowRISC contributors. |
| 3 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | # make_distribution.sh takes distribution artifacts in $BIN_DIR and packs them |
| 9 | # into a compressed TAR archive, which is deposited into $BIN_DIR. In |
| 10 | # particular, this script should be run after make_build_bin.sh. |
| 11 | # |
| 12 | # The actual artifacts exported are described by the $DIST_ARTIFACTS variable |
| 13 | # below. |
| 14 | |
| 15 | . util/build_consts.sh |
| 16 | |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 17 | echo "\$OT_VERSION = $OT_VERSION" >&2 |
| 18 | |
| 19 | # $DIST_ARTIFACTS is a list of |find| globs to be copied out of |
| 20 | # $BIN_DIR and into the OpenTitan distribution archive. |
| 21 | # |
| 22 | # These globs are relative to $BIN_DIR. |
| 23 | readonly DIST_ARTIFACTS=( |
| 24 | 'sw/device/*.elf' |
| 25 | 'sw/device/*.bin' |
| 26 | 'sw/device/*.vmem' |
Philipp Wagner | 972b3c2 | 2020-10-30 19:05:10 +0000 | [diff] [blame] | 27 | 'sw/otbn/*.elf' |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 28 | 'sw/host/spiflash/spiflash' |
Michael Schaffner | 93fe50c | 2021-03-31 16:25:42 -0700 | [diff] [blame] | 29 | 'hw/top_earlgrey/Vchip_earlgrey_verilator' |
| 30 | 'hw/top_earlgrey/lowrisc_systems_chip_earlgrey_nexysvideo_0.1.bit' |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 31 | ) |
| 32 | |
Miguel Young de la Sota | b2ef483 | 2019-11-22 12:55:46 -0600 | [diff] [blame] | 33 | DIST_DIR="$OBJ_DIR/$OT_VERSION" |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 34 | mkdir -p "$DIST_DIR" |
| 35 | |
| 36 | cp ci/README.snapshot "$DIST_DIR" |
| 37 | cp LICENSE "$DIST_DIR" |
| 38 | |
| 39 | for pat in "${DIST_ARTIFACTS[@]}"; do |
| 40 | echo "Searching for $pat." >&2 |
Miguel Young de la Sota | f208eea | 2019-11-22 11:18:16 -0600 | [diff] [blame] | 41 | found_file=false |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 42 | for file in $(find "$BIN_DIR" -type f -path "$BIN_DIR/$pat"); do |
Miguel Young de la Sota | f208eea | 2019-11-22 11:18:16 -0600 | [diff] [blame] | 43 | found_file=true |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 44 | relative_file="${file#"$BIN_DIR/"}" |
| 45 | echo "Copying \$BIN_DIR/$relative_file." >&2 |
| 46 | |
| 47 | destination="$DIST_DIR/$(dirname "$relative_file")" |
| 48 | mkdir -p "$destination" |
| 49 | mv "$file" "$destination" |
| 50 | done |
Miguel Young de la Sota | f208eea | 2019-11-22 11:18:16 -0600 | [diff] [blame] | 51 | if [[ "$found_file" == "false" ]]; then |
| 52 | echo "Did not find any files matching $pat." >&2 |
| 53 | echo "If this is intentional, delete that pattern." >&2 |
| 54 | exit 1 |
| 55 | fi |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 56 | done |
| 57 | |
Miguel Young de la Sota | b2ef483 | 2019-11-22 12:55:46 -0600 | [diff] [blame] | 58 | cd "$(dirname "$DIST_DIR")" |
| 59 | tar -cJf "$BIN_DIR/$(basename "$DIST_DIR").tar.xz" \ |
| 60 | "$(basename "$DIST_DIR")" |