#!/bin/bash

# Assume vivado 2018.2

# usage: ./ci-scripts/rebuild_RFNCO.sh

set -e

# clone
mkdir update-RFNCO
cd update-RFNCO
git clone https://gitlab.cern.ch/BE-RF-PLDesign/Libraries/xilinx/RFNCO.git

cd RFNCO
sed -i -e "s|https://:@gitlab.cern.ch:8443/|https://gitlab.cern.ch/|" .gitmodules

git submodule update --init

cd Vivado/

#rm -rf Work

# Adjust part_name
#sed -i -e 's/set part_name xc.*/set part_name xc7k160tfbg676-2/' Options/build.tcl

vivado -mode tcl -source ../../../ci-scripts/rebuild_RFNCO.tcl

# TODO: copy result (synth verilog file and vhdl wrapper)
# rename the wrapper module in the verilog file
