-
Notifications
You must be signed in to change notification settings - Fork 0
/
snap_package.sh
executable file
·90 lines (77 loc) · 2.98 KB
/
snap_package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
ROOT_DIR=$(dirname $(readlink -f "$BASH_SOURCE"))
set -e
## project, compile_path, action
package(){
ACTION_ROOT=`pwd`/$3
PACKAGE_ROOT=`pwd`/${3}_pkg
COMPILE_PATH=`realpath $2`
IP_PATH=$COMPILE_PATH/$1/automated_tests/impl/ip/hdl/vhdl
FLETCHER_HARDWARE_PATH=$FLETCHER_DIR/hardware
rm -f package.tar.gz 2>/dev/null # remove tar if there
rm -rf $PACKAGE_ROOT
mkdir -p $PACKAGE_ROOT/hw/deps
mkdir -p $PACKAGE_ROOT/data
mkdir -p $PACKAGE_ROOT/src
cp $COMPILE_PATH/*.rb $PACKAGE_ROOT/data
cp $COMPILE_PATH/*.fbs $PACKAGE_ROOT/data
cp $COMPILE_PATH/*.cpp $PACKAGE_ROOT/src
cp $COMPILE_PATH/*.h $PACKAGE_ROOT/src
cp $COMPILE_PATH/*.tcl $PACKAGE_ROOT/src
cp $COMPILE_PATH/CMakeLists.txt $PACKAGE_ROOT/src
cp -R $ACTION_ROOT/* $PACKAGE_ROOT
cp $ROOT_DIR/snap_script.sh $PACKAGE_ROOT
find $PACKAGE_ROOT -type l -delete;
FILES=`vhdeps -i $FLETCHER_HARDWARE_PATH -i $IP_PATH -i $PACKAGE_ROOT/hw dump SimTop_tc | awk '{print $NF}'`
PREFIX=`printf "%s\n" "${FILES[@]}" | sed -e 'N;s/^\(.*\).*\n\1.*$/\1\n\1/;D'`
echo "Longest common prefix $PREFIX"
for file in ${FILES}; do
if [ "${file##${ACTION_ROOT}}" == "${file}" ]; then
if [ "${file##${COMPILE_PATH}}" != "${file}" ]; then
DEST=ip/$(dirname ${file##${COMPILE_PATH}})
elif [ "${file##${FLETCHER_HARDWARE_PATH}}" != "${file}" ]; then
DEST=fletcher/$(dirname ${file##${FLETCHER_HARDWARE_PATH}})
else
DEST=$(dirname ${file##${PREFIX}})
fi
echo "Collecting ${file} to deps $(dirname ${file##${PREFIX}}) directory."
mkdir -p $PACKAGE_ROOT/hw/deps/$DEST
cp $file $PACKAGE_ROOT/hw/deps/$DEST
fi
done
echo "Creating $1_pkg.tar.gz"
tar -chzvaf $1_pkg.tar.gz ${3} ${3}_pkg -C `pwd`
#rm -rf $PACKAGE_ROOT
}
usage()
{
echo "usage: $(basename $BASH_SOURCE) -p project -o ../fletcherfiltering_test_workspace/<project> -a projectSnapAction | [-h]]"
}
action=SimpleSnapAction
project=Simple
action=${project}SnapAction
compile_path=../fletcherfiltering_test_workspace/$project
while [ "$1" != "" ]; do
case $1 in
-a | --action ) shift
action=$1
;;
-p | --project ) shift
project=$1
;;
-o | --compile_path ) shift
compile_path=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
# Test code to verify command line processing
echo "Project: $project"
echo "Compile Path: $compile_path"
echo "Fletcher Path: $FLETCHER_DIR/hardware"
package $project $compile_path $action