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' |
| 27 | 'sw/host/spiflash/spiflash' |
| 28 | 'hw/top_earlgrey/Vtop_earlgrey_verilator' |
| 29 | 'hw/top_earlgrey/lowrisc_systems_top_earlgrey_nexysvideo_0.1.bit' |
| 30 | ) |
| 31 | |
Miguel Young de la Sota | b2ef483 | 2019-11-22 12:55:46 -0600 | [diff] [blame] | 32 | DIST_DIR="$OBJ_DIR/$OT_VERSION" |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 33 | mkdir -p "$DIST_DIR" |
| 34 | |
| 35 | cp ci/README.snapshot "$DIST_DIR" |
| 36 | cp LICENSE "$DIST_DIR" |
| 37 | |
| 38 | for pat in "${DIST_ARTIFACTS[@]}"; do |
| 39 | echo "Searching for $pat." >&2 |
Miguel Young de la Sota | f208eea | 2019-11-22 11:18:16 -0600 | [diff] [blame] | 40 | found_file=false |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 41 | 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] | 42 | found_file=true |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 43 | relative_file="${file#"$BIN_DIR/"}" |
| 44 | echo "Copying \$BIN_DIR/$relative_file." >&2 |
| 45 | |
| 46 | destination="$DIST_DIR/$(dirname "$relative_file")" |
| 47 | mkdir -p "$destination" |
| 48 | mv "$file" "$destination" |
| 49 | done |
Miguel Young de la Sota | f208eea | 2019-11-22 11:18:16 -0600 | [diff] [blame] | 50 | if [[ "$found_file" == "false" ]]; then |
| 51 | echo "Did not find any files matching $pat." >&2 |
| 52 | echo "If this is intentional, delete that pattern." >&2 |
| 53 | exit 1 |
| 54 | fi |
Miguel Young de la Sota | d42948c | 2019-11-18 13:56:55 -0600 | [diff] [blame] | 55 | done |
| 56 | |
Miguel Young de la Sota | b2ef483 | 2019-11-22 12:55:46 -0600 | [diff] [blame] | 57 | cd "$(dirname "$DIST_DIR")" |
| 58 | tar -cJf "$BIN_DIR/$(basename "$DIST_DIR").tar.xz" \ |
| 59 | "$(basename "$DIST_DIR")" |