manta/examples/common/build_vivado.sh

36 lines
896 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Generate Verilog source for Manta
python3 -m manta gen manta.yaml manta.v
# Determine where Vivado is located - exactly one of PATH or $VIVADO must be available
vivado_on_path=false
vivado_env_set=false
if command -v vivado &> /dev/null; then
vivado_on_path=true
fi
if [[ -v VIVADO ]]; then
vivado_env_set=true
fi
if $vivado_on_path && $vivado_env_set; then
echo "Error: Both \$VIVADO is set and 'vivado' is on PATH. Please use only one." >&2
exit 1
elif $vivado_on_path; then
VIVADO_CMD="vivado"
elif $vivado_env_set; then
VIVADO_CMD="$VIVADO"
else
echo "Error: Vivado not found. Either set \$VIVADO environment variable or add 'vivado' to PATH." >&2
exit 1
fi
# Clean build/ directory, and run Vivado from within it
rm -rf build/
mkdir -p build/
cd build
$VIVADO_CMD -mode batch -source ../../../../common/build.tcl