Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 1 | PROFILES ?= all |
| 2 | ONOS_HOST ?= localhost |
| 3 | |
| 4 | mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) |
| 5 | curr_dir := $(patsubst %/,%,$(dir $(mkfile_path))) |
| 6 | curr_dir_sha := $(shell echo -n "$(curr_dir)" | shasum | cut -c1-7) |
| 7 | |
| 8 | mvn_image := maven:3.6.1-jdk-11-slim |
| 9 | mvn_container := mvn-build-${curr_dir_sha} |
| 10 | |
| 11 | onos_url := http://${ONOS_HOST}:8181/onos |
| 12 | onos_curl := curl --fail -sSL --user onos:rocks --noproxy localhost |
| 13 | |
| 14 | pipeconf_app_name := org.opencord.fabric-tofino |
Yi Tseng | c3e2d4b | 2020-01-31 16:19:52 -0800 | [diff] [blame] | 15 | pipeconf_oar_file := $(shell ls -1 ${curr_dir}/target/fabric-tofino-*.oar) |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 16 | |
Carmelo Cascone | 91d92fb | 2019-12-16 18:34:26 -0800 | [diff] [blame] | 17 | p4-build := ./src/main/p4/build.sh |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 18 | |
| 19 | .PHONY: pipeconf |
| 20 | |
Carmelo Cascone | 21e72a2 | 2019-12-18 10:01:08 -0800 | [diff] [blame] | 21 | build: clean $(PROFILES) pipeconf p4-changelog |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 22 | |
| 23 | all: fabric fabric-bng fabric-spgw fabric-int fabric-spgw-int |
| 24 | |
| 25 | fabric: |
Carmelo Cascone | 91d92fb | 2019-12-16 18:34:26 -0800 | [diff] [blame] | 26 | @${p4-build} fabric "" |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 27 | |
| 28 | fabric-simple: |
Carmelo Cascone | 91d92fb | 2019-12-16 18:34:26 -0800 | [diff] [blame] | 29 | @${p4-build} fabric-simple "-DWITH_SIMPLE_NEXT" |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 30 | |
| 31 | fabric-bng: |
Daniele Moro | 8de7a8d | 2020-01-30 17:05:37 -0800 | [diff] [blame] | 32 | @${p4-build} fabric-bng "-DWITH_BNG -DWITHOUT_XCONNECT" |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 33 | |
| 34 | fabric-int: |
Carmelo Cascone | 91d92fb | 2019-12-16 18:34:26 -0800 | [diff] [blame] | 35 | @${p4-build} fabric-int "-DWITH_INT_SOURCE -DWITH_INT_TRANSIT" |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 36 | |
| 37 | fabric-spgw: |
Carmelo Cascone | 91d92fb | 2019-12-16 18:34:26 -0800 | [diff] [blame] | 38 | @${p4-build} fabric-spgw "-DWITH_SPGW" |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 39 | |
| 40 | fabric-spgw-int: |
Carmelo Cascone | 91d92fb | 2019-12-16 18:34:26 -0800 | [diff] [blame] | 41 | @${p4-build} fabric-spgw-int "-DWITH_SPGW -DWITH_INT_SOURCE -DWITH_INT_TRANSIT" |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 42 | |
Carmelo Cascone | 21e72a2 | 2019-12-18 10:01:08 -0800 | [diff] [blame] | 43 | p4-changelog: |
| 44 | ./src/main/p4/gen_changelog.sh > P4_CHANGELOG |
| 45 | |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 46 | # Reuse the same container to persist mvn repo cache. |
| 47 | _create_mvn_container: |
| 48 | @if ! docker container ls -a --format '{{.Names}}' | grep -q ${mvn_container} ; then \ |
| 49 | docker create -v ${curr_dir}:/mvn-src -w /mvn-src --name ${mvn_container} ${mvn_image} mvn clean package verify; \ |
| 50 | fi |
| 51 | |
| 52 | _mvn_package: |
| 53 | $(info *** Building ONOS app...) |
| 54 | @mkdir -p target |
| 55 | @docker start -a -i ${mvn_container} |
| 56 | |
| 57 | pipeconf: _create_mvn_container _mvn_package |
| 58 | $(info *** ONOS pipeconf .oar package created succesfully) |
| 59 | @ls -1 ${curr_dir}/target/*.oar |
| 60 | |
| 61 | pipeconf-install: |
| 62 | $(info *** Installing and activating pipeconf app in ONOS at ${ONOS_HOST}...) |
| 63 | ${onos_curl} -X POST -HContent-Type:application/octet-stream \ |
| 64 | '${onos_url}/v1/applications?activate=true' \ |
Yi Tseng | c3e2d4b | 2020-01-31 16:19:52 -0800 | [diff] [blame] | 65 | --data-binary @${pipeconf_oar_file} |
Carmelo Cascone | 97efefb | 2019-12-05 16:40:45 -0800 | [diff] [blame] | 66 | @echo |
| 67 | |
| 68 | pipeconf-uninstall: |
| 69 | $(info *** Uninstalling pipeconf app from ONOS (if present) at ${ONOS_HOST}...) |
| 70 | -${onos_curl} -X DELETE ${onos_url}/v1/applications/${pipeconf_app_name} |
| 71 | @echo |
| 72 | |
| 73 | netcfg: |
| 74 | $(info *** Pushing tofino-netcfg.json to ONOS at ${ONOS_HOST}...) |
| 75 | ${onos_curl} -X POST -H 'Content-Type:application/json' \ |
| 76 | ${onos_url}/v1/network/configuration -d@./tofino-netcfg.json |
| 77 | @echo |
| 78 | |
| 79 | clean: |
| 80 | -rm -rf src/main/resources/p4c-out |
| 81 | |
| 82 | deep-clean: clean |
| 83 | -rm -rf target |
| 84 | -rm -rf p4c-out |
| 85 | -docker rm ${mvn_container} > /dev/null 2>&1 |