blob: 86c335bbf717beb5af46e2800cce0c0020842e03 [file] [log] [blame]
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -06001#!/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
6set -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 Sotad42948c2019-11-18 13:56:55 -060017echo "\$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.
23readonly DIST_ARTIFACTS=(
24 'sw/device/*.elf'
25 'sw/device/*.bin'
26 'sw/device/*.vmem'
Philipp Wagner972b3c22020-10-30 19:05:10 +000027 'sw/otbn/*.elf'
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -060028 'sw/host/spiflash/spiflash'
Michael Schaffner93fe50c2021-03-31 16:25:42 -070029 'hw/top_earlgrey/Vchip_earlgrey_verilator'
30 'hw/top_earlgrey/lowrisc_systems_chip_earlgrey_nexysvideo_0.1.bit'
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -060031)
32
Miguel Young de la Sotab2ef4832019-11-22 12:55:46 -060033DIST_DIR="$OBJ_DIR/$OT_VERSION"
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -060034mkdir -p "$DIST_DIR"
35
36cp ci/README.snapshot "$DIST_DIR"
37cp LICENSE "$DIST_DIR"
38
39for pat in "${DIST_ARTIFACTS[@]}"; do
40 echo "Searching for $pat." >&2
Miguel Young de la Sotaf208eea2019-11-22 11:18:16 -060041 found_file=false
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -060042 for file in $(find "$BIN_DIR" -type f -path "$BIN_DIR/$pat"); do
Miguel Young de la Sotaf208eea2019-11-22 11:18:16 -060043 found_file=true
Miguel Young de la Sotad42948c2019-11-18 13:56:55 -060044 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 Sotaf208eea2019-11-22 11:18:16 -060051 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 Sotad42948c2019-11-18 13:56:55 -060056done
57
Miguel Young de la Sotab2ef4832019-11-22 12:55:46 -060058cd "$(dirname "$DIST_DIR")"
59tar -cJf "$BIN_DIR/$(basename "$DIST_DIR").tar.xz" \
60 "$(basename "$DIST_DIR")"