Carmelo Cascone | 228092b | 2018-06-15 20:41:10 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Carmelo Cascone | 4d5757d | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 3 | set -e |
Carmelo Cascone | 228092b | 2018-06-15 20:41:10 +0200 | [diff] [blame] | 4 | |
| 5 | BMV2_CPU_PORT="255" |
Carmelo Cascone | 0c8d73e | 2018-09-07 16:31:06 -0700 | [diff] [blame] | 6 | BMV2_PP_FLAGS="-DTARGET_BMV2 -DCPU_PORT=${BMV2_CPU_PORT} -DWITH_PORT_COUNTER" |
Carmelo Cascone | 228092b | 2018-06-15 20:41:10 +0200 | [diff] [blame] | 7 | |
| 8 | PROFILE=$1 |
| 9 | OTHER_PP_FLAGS=$2 |
Carmelo Cascone | 228092b | 2018-06-15 20:41:10 +0200 | [diff] [blame] | 10 | OUT_DIR=./p4c-out/${PROFILE}/bmv2/default |
| 11 | |
Carmelo Cascone | 228092b | 2018-06-15 20:41:10 +0200 | [diff] [blame] | 12 | |
Carmelo Cascone | 4d5757d | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 13 | mkdir -p ${OUT_DIR} |
| 14 | mkdir -p ${OUT_DIR}/graphs |
| 15 | |
| 16 | echo |
| 17 | echo "## Compiling profile ${PROFILE} in ${OUT_DIR}..." |
| 18 | (set -x; p4c-bm2-ss --arch v1model \ |
Carmelo Cascone | 228092b | 2018-06-15 20:41:10 +0200 | [diff] [blame] | 19 | -o ${OUT_DIR}/bmv2.json \ |
| 20 | ${BMV2_PP_FLAGS} ${OTHER_PP_FLAGS} \ |
| 21 | --p4runtime-file ${OUT_DIR}/p4info.txt \ |
| 22 | --p4runtime-format text \ |
Carmelo Cascone | 4d5757d | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 23 | fabric.p4) |
| 24 | (set -x; p4c-graphs ${BMV2_PP_FLAGS} ${OTHER_PP_FLAGS} --graphs-dir ${OUT_DIR}/graphs fabric.p4) |
| 25 | for f in ${OUT_DIR}/graphs/*.dot; do |
| 26 | (set -x; dot -Tpdf ${f} > ${f}.pdf) |
| 27 | rm -f ${f} |
| 28 | done |
Carmelo Cascone | 6880ba6 | 2018-09-06 00:04:34 -0700 | [diff] [blame] | 29 | |
Carmelo Cascone | 4d5757d | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 30 | (set -x; echo ${BMV2_CPU_PORT} > ${OUT_DIR}/cpu_port.txt) |