blob: d9ea01874ea539f7637c1ce5195150fe4745882d [file] [log] [blame]
Carmelo Cascone228092b2018-06-15 20:41:10 +02001#!/usr/bin/env bash
2
Carmelo Casconeb5324e72018-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 Casconeb5324e72018-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} \
Carmelo Casconea4dc3c12019-02-12 17:30:00 -080021 --p4runtime-files ${OUT_DIR}/p4info.txt \
Carmelo Casconeb5324e72018-11-25 02:26:32 -080022 fabric.p4)
23(set -x; p4c-graphs ${BMV2_PP_FLAGS} ${OTHER_PP_FLAGS} --graphs-dir ${OUT_DIR}/graphs fabric.p4)
24for f in ${OUT_DIR}/graphs/*.dot; do
25 (set -x; dot -Tpdf ${f} > ${f}.pdf)
26 rm -f ${f}
27done
Carmelo Cascone6880ba62018-09-06 00:04:34 -070028
Carmelo Casconeb5324e72018-11-25 02:26:32 -080029(set -x; echo ${BMV2_CPU_PORT} > ${OUT_DIR}/cpu_port.txt)