-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
101 lines (79 loc) · 2.91 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# SPDX-FileCopyrightText: 2020 Open Networking Foundation <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
UID := $(shell id -u)
main_file := p4src/main.p4
include .env.stable
include .env.latest
default: build check
_docker_pull_all:
docker pull ${P4C_IMAGE}
docker pull ${PTF_IMAGE}
docker pull ${PTF_BMV2_IMAGE}
deps: _docker_pull_all
clean:
-rm -rf p4src/build
-rm -rf ptf/*.log
-rm -rf ptf/*.pcap
-rm -rf .m2
-rm -rf app/target
-rm -rf app/app/target
-rm -rf app/api/target
# Required by sdfabric-onos build scripts - do not remove!
_prepare_app_build:
cd app && make _build_resources
local-app-build:
cd app && make local-build
app-build:
cd app && make build
app-build-ci:
cd app && make build-ci
app-check:
cd app && make check
build: ${main_file}
$(info *** Building P4 program...)
@mkdir -p p4src/build
docker run --rm -v ${CURRENT_DIR}:/workdir -w /workdir ${P4C_IMAGE} \
p4c-bm2-ss ${P4C_FLAGS} --arch v1model -o p4src/build/bmv2.json \
--p4runtime-files p4src/build/p4info.txt,p4src/build/p4info.bin \
--Wdisable=unsupported \
${main_file}
@echo "*** P4 program compiled successfully! Output files are in p4src/build"
graph: ${main_file}
$(info *** Generating P4 program graphs...)
@mkdir -p p4src/build/graphs
docker run --rm -v ${CURRENT_DIR}:/workdir -w /workdir ${P4C_IMAGE} \
p4c-graphs --graphs-dir p4src/build/graphs ${main_file}
for f in p4src/build/graphs/*.dot; do \
docker run --rm -v ${CURRENT_DIR}:/workdir -w /workdir ${P4C_IMAGE} \
dot -Tpdf $${f} > $${f}.pdf; rm -f $${f}; \
done
@echo "*** Done! Graph files are in p4src/build/graphs"
check:
@cd ptf && PTF_IMAGE=$(PTF_IMAGE) PTF_BMV2_IMAGE=$(PTF_BMV2_IMAGE) ./run_tests ${PTF_TEST_PARAMS} $(TEST)
.yapf:
rm -rf ./yapf
git clone --depth 1 https://github.com/google/yapf.git .yapf
rm -rf .yapf/.git
prettify: .yapf
PYTHONPATH=${CURRENT_DIR}/.yapf python3 .yapf/yapf -ir -e .yapf/ .
reuse-lint:
docker run --rm -v ${CURRENT_DIR}:/up4 -w /up4 omecproject/reuse-verify:latest reuse lint
reuse-addheader:
docker run --rm -v ${CURRENT_DIR}:/up4 -w /up4 omecproject/reuse-verify:latest reuse addheader \
--copyright "Open Networking Foundation <[email protected]>" \
--license "Apache-2.0" \
--year "2020-present" $(FILE)
build-ptf:
cd ptf && docker build --build-arg MN_STRATUM_IMAGE=$(MN_STRATUM_IMAGE) \
-t opennetworking/up4-ptf .
push-ptf:
# Remember to update Makefile.vars with the new image sha
docker push opennetworking/up4-ptf
constants:
docker run -v $(CURRENT_DIR):$(CURRENT_DIR) -w $(CURRENT_DIR) --rm --user $(UID)\
--entrypoint python $(PTF_BMV2_IMAGE) ./util/gen-p4-constants.py Up4P4Info \
-o $(CURRENT_DIR)/app/app/src/main/java/org/omecproject/up4/impl/Up4P4InfoConstants.java \
$(CURRENT_DIR)/p4src/build/p4info.txt