blob: 56807d03b5710e8a1822585df0231e54bfa00cae [file] [log] [blame]
CyberHasH4c527e32019-10-05 02:37:50 +08001#!/usr/bin/env bash
2
3set -e
4
5PROFILE=$1
6OTHER_FLAGS=$2
7
8SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9OUT_DIR=${SRC_DIR}/p4c-out/bmv2
10
11mkdir -p ${OUT_DIR}
12mkdir -p ${OUT_DIR}/graphs
13
14echo
15echo "## Compiling profile ${PROFILE} in ${OUT_DIR}..."
16
17dockerImage=opennetworking/p4c:stable
18dockerRun="docker run --rm -w ${SRC_DIR} -v ${SRC_DIR}:${SRC_DIR} -v ${OUT_DIR}:${OUT_DIR} ${dockerImage}"
19
20# Generate preprocessed P4 source (for debugging).
21(set -x; ${dockerRun} p4c-bm2-ss --arch v1model \
22 ${OTHER_FLAGS} \
23 --pp ${OUT_DIR}/${PROFILE}_pp.p4 ${PROFILE}.p4)
24
25# Generate BMv2 JSON and P4Info.
26(set -x; ${dockerRun} p4c-bm2-ss --arch v1model -o ${OUT_DIR}/${PROFILE}.json \
27 ${OTHER_FLAGS} \
28 --p4runtime-files ${OUT_DIR}/${PROFILE}_p4info.txt ${PROFILE}.p4)