-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
103 lines (86 loc) · 3.06 KB
/
build.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
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
# A build script customized for my needs
# Expects the following environment:
# $TARGET contains the ssh destination host (usually user@host)
# It also expects this repo on a client machine under $CLIENT_PATH
# The same folder mounted on the Tofino server under $SERVER_PATH
# You can mount from the client side using sshfs and this command, i.e. the files
# are on the local machine and are sshfs mounted on the server, but reverse to usual sshfs,
# because the connection is initiated from the client
#
# Script parameters: see --help
set -e
while [[ $# -gt 0 ]]; do
key="$1"
case ${key} in
--nobuild)
NO_BUILD=$1
shift
;;
--no-warning)
NO_WARNING=$1
shift
;;
--forward)
BUILD_FORWARD=$1
shift
;;
--test)
BUILD_TEST=$1
shift
;;
*) # unknown option
HELP=y
shift
;;
esac
done
if [[ ${HELP} ]]; then
echo "Usage"
echo "--nobuild : Do not rebuild P4 Part"
echo "--test : Build test script"
echo "--forward : Build forward script"
exit 0
fi
TARGET="INSERT_SERVER_SSH_NAME_HERE"
SERVER_PATH=~/INSERT_SERVER_MOUNTED_FOLDER_NAME/
CLIENT_PATH=~/INSERT_DEV_MACHINE_FOLDER_PATH(P4_Controller)/
if [[ ${SDE} ]]; then
TOFINO_HEADER_SRC=${SDE}/install/include/
TOFINO_HEADER_TARGET=${SERVER_PATH}/controller/tofino_include/
BUILD_PATH=${SDE}/build/p4-build/marina_data_plane/tofino/marina_data_plane/
if [[ "${BUILD_TEST}" ]]; then
echo "Compiling P4 test script"
${SDE}/p4_build_ab_840.sh -p ${SERVER_PATH}/p4/test.p4
exit 0
fi
if [[ "${BUILD_FORWARD}" ]]; then
echo "Compiling P4 forward script"
${SDE}/p4_build_ab_840.sh -p ${SERVER_PATH}/p4/just_forward.p4
exit 0
fi
if [[ -z "${NO_BUILD}" ]]; then
echo "Compiling P4 program"
P4FLAGS=--parser-timing-reports ${SDE}/p4_build_ab_840.sh -p ${SERVER_PATH}/p4/marina_data_plane.p4
fi
if [[ -z "${NO_WARNING}" ]]; then
echo "WARNING: Could not rebuild thrift api, please do this on the dev machine"
fi
else
SDE="/home/USERNAME_HERE/sde"
TOFINO_HEADER_SRC=${SDE}/install/include/
TOFINO_HEADER_TARGET=${CLIENT_PATH}/controller/tofino_include/
BUILD_PATH=${SDE}/build/p4-build/marina_data_plane/tofino/marina_data_plane/
echo "Calling server"
ssh ${TARGET} "bash -l ${SERVER_PATH}/build.sh --no-warning ${NO_BUILD} ${BUILD_TEST} ${BUILD_FORWARD}"
if [[ "${BUILD_TEST}" || "${BUILD_FORWARD}" ]]; then
exit 0
fi
echo "Syncing other files"
rsync -arv --delete ${TARGET}:${BUILD_PATH}/{visualization,graphs,logs,context} ${CLIENT_PATH}/p4c-out/
rsync -arv ${TARGET}:${TOFINO_HEADER_SRC}/ ${TOFINO_HEADER_TARGET}/
echo "Extracting context from context.json"
python3 scripts/extract_context.py ${CLIENT_PATH}/p4c-out/context/ ${CLIENT_PATH}/controller/autogenerated/
echo "Generating graphs"
find ${CLIENT_PATH}/p4c-out/graphs -type f -name '*.dot' -print -exec dot -Tpng {} -o {}.png \;
fi