blob: a249aa00c14d8c25063d000ffebbc7aadee2137b [file] [log] [blame]
Carmelo Cascone228092b2018-06-15 20:41:10 +02001#!/usr/bin/env bash
2
Carmelo Cascone4d5757d2018-11-25 02:26:32 -08003set -e
Carmelo Cascone228092b2018-06-15 20:41:10 +02004
5BMV2_CPU_PORT="255"
Carmelo Cascone0c8d73e2018-09-07 16:31:06 -07006BMV2_PP_FLAGS="-DTARGET_BMV2 -DCPU_PORT=${BMV2_CPU_PORT} -DWITH_PORT_COUNTER"
Carmelo Cascone228092b2018-06-15 20:41:10 +02007
8PROFILE=$1
9OTHER_PP_FLAGS=$2
Carmelo Cascone228092b2018-06-15 20:41:10 +020010OUT_DIR=./p4c-out/${PROFILE}/bmv2/default
11
Carmelo Cascone228092b2018-06-15 20:41:10 +020012
Carmelo Cascone4d5757d2018-11-25 02:26:32 -080013mkdir -p ${OUT_DIR}
14mkdir -p ${OUT_DIR}/graphs
15
16echo
17echo "## Compiling profile ${PROFILE} in ${OUT_DIR}..."
18(set -x; p4c-bm2-ss --arch v1model \
Carmelo Cascone228092b2018-06-15 20:41:10 +020019 -o ${OUT_DIR}/bmv2.json \
20 ${BMV2_PP_FLAGS} ${OTHER_PP_FLAGS} \
21 --p4runtime-file ${OUT_DIR}/p4info.txt \
22 --p4runtime-format text \
Carmelo Cascone4d5757d2018-11-25 02:26:32 -080023 fabric.p4)
24(set -x; p4c-graphs ${BMV2_PP_FLAGS} ${OTHER_PP_FLAGS} --graphs-dir ${OUT_DIR}/graphs fabric.p4)
25for f in ${OUT_DIR}/graphs/*.dot; do
26 (set -x; dot -Tpdf ${f} > ${f}.pdf)
27 rm -f ${f}
28done
Carmelo Cascone6880ba62018-09-06 00:04:34 -070029
Carmelo Cascone4d5757d2018-11-25 02:26:32 -080030(set -x; echo ${BMV2_CPU_PORT} > ${OUT_DIR}/cpu_port.txt)