Files
scripts/pixel/all.sh
Chirayu Desai ee4afeb5d3 pixel/all: Print parallel output, prefix with device name
* It's a bit spammy but better to see it do something
  then have to just sit by.
* Can always pipe it somewhere and grep for device to get
  logs for just that

Change-Id: I855d067794016515e4bc2453b30edd6afc0b3b4f
2023-06-20 16:32:19 +02:00

77 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# SPDX-FileCopyrightText: 2022 The Calyx Institute
#
# SPDX-License-Identifier: Apache-2.0
#
# all:
#
# Do it all!
#
#
##############################################################################
### SET ###
# use bash strict mode
set -euo pipefail
### TRAPS ###
# trap signals for clean exit
trap 'exit $?' EXIT
trap 'error_m interrupted!' SIGINT
### CONSTANTS ###
readonly script_path="$(cd "$(dirname "$0")";pwd -P)"
readonly vars_path="${script_path}/../../../vendor/lineage/vars"
readonly top="${script_path}/../../.."
readonly work_dir="${WORK_DIR:-/tmp/pixel}"
source "${vars_path}/pixels"
## HELP MESSAGE (USAGE INFO)
# TODO
### FUNCTIONS ###
device() {
local device="${1}"
local script_path="${2}"
"${script_path}/device.sh" "${device}"
}
export -f device
# error message
# ARG1: error message for STDERR
# ARG2: error status
error_m() {
echo "ERROR: ${1:-'failed.'}" 1>&2
return "${2:-1}"
}
# print help message.
help_message() {
echo "${help_message:-'No help available.'}"
}
main() {
if [[ $# -ne 0 ]] ; then
parallel --line-buffer --tag device ::: "${@}" ::: "${script_path}"
else
parallel --line-buffer --tag device ::: ${devices[@]} ::: "${script_path}"
fi
}
### RUN PROGRAM ###
main "${@}"
##