CyberHasH | 4c527e3 | 2019-10-05 02:37:50 +0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | PROFILE=$1 |
| 6 | OTHER_FLAGS=$2 |
| 7 | |
| 8 | SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 9 | OUT_DIR=${SRC_DIR}/p4c-out/bmv2 |
| 10 | |
| 11 | mkdir -p ${OUT_DIR} |
| 12 | mkdir -p ${OUT_DIR}/graphs |
| 13 | |
| 14 | echo |
| 15 | echo "## Compiling profile ${PROFILE} in ${OUT_DIR}..." |
| 16 | |
| 17 | dockerImage=opennetworking/p4c:stable |
| 18 | dockerRun="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) |