@@ -33,8 +33,6 @@ P4C_DIR=$(readlink -f ${THIS_DIR}/..)
33
33
: " ${INSTALL_PTF_EBPF_DEPENDENCIES:= OFF} "
34
34
# Whether to build and run GTest unit tests.
35
35
: " ${ENABLE_GTESTS:= ON} "
36
- # Whether to build the P4Tools back end and platform.
37
- : " ${ENABLE_TEST_TOOLS:= OFF} "
38
36
# Whether to treat warnings as errors.
39
37
: " ${ENABLE_WERROR:= ON} "
40
38
# Compile with Clang compiler
@@ -48,14 +46,28 @@ P4C_DIR=$(readlink -f ${THIS_DIR}/..)
48
46
# Build with -ftrivial-auto-var-init=pattern to catch more bugs caused by
49
47
# uninitialized variables.
50
48
: " ${BUILD_AUTO_VAR_INIT_PATTERN:= OFF} "
51
- # Install BMv2 and its dependencies.
52
- : " ${INSTALL_BMV2:= ON} "
53
- # Install eBPF and its dependencies.
54
- : " ${INSTALL_EBPF:= ON} "
55
- # Install DPDK and its dependencies.
56
- : " ${INSTALL_DPDK:= OFF} "
57
- # Install Tofino and its dependencies.
58
- : " ${INSTALL_TOFINO:= ON} "
49
+ # BMv2 is enable by default.
50
+ : " ${ENABLE_BMV2:= ON} "
51
+ # eBPF is enabled by default.
52
+ : " ${ENABLE_EBPF:= ON} "
53
+ # This is the list of back ends that can be enabled.
54
+ # Back ends can be enabled from the command line with "ENABLE_[backend]=TRUE/FALSE"
55
+ ENABLE_BACKENDS=(" TOFINO" " BMV2" " EBPF" " UBPF" " DPDK"
56
+ " P4TC" " P4FMT" " P4TEST" " P4C_GRAPHS"
57
+ " TEST_TOOLS"
58
+ )
59
+ function build_cmake_enabled_backend_string() {
60
+ CMAKE_ENABLE_BACKENDS=" "
61
+ for backend in " ${ENABLE_BACKENDS[@]} " ;
62
+ do
63
+ enable_var=ENABLE_${backend}
64
+ if [ -n " ${! enable_var} " ]; then
65
+ echo " ${enable_var} =${! enable_var} is set."
66
+ CMAKE_ENABLE_BACKENDS+=" -D${enable_var} =${! enable_var} "
67
+ fi
68
+ done
69
+ }
70
+
59
71
60
72
. /etc/lsb-release
61
73
103
115
104
116
# ! ------ END CORE -----------------------------------------------
105
117
118
+ # TODO: Remove this check once 18.04 is deprecated.
119
+ if [[ " ${DISTRIB_RELEASE} " == " 18.04" ]] ; then
120
+ ccache --set-config cache_dir=.ccache
121
+ # For Ubuntu 18.04 install the pypi-supplied version of cmake instead.
122
+ sudo pip3 install cmake==3.16.3
123
+ fi
124
+ ccache --set-config max_size=1G
125
+
106
126
# ! ------ BEGIN BMV2 -----------------------------------------------
107
127
function build_bmv2() {
108
128
# TODO: Remove this check once 18.04 is deprecated.
@@ -136,21 +156,13 @@ function build_bmv2() {
136
156
137
157
sudo apt-get update && sudo apt-get install -y --no-install-recommends ${P4C_RUNTIME_DEPS}
138
158
139
- # TODO: Remove this check once 18.04 is deprecated.
140
- if [[ " ${DISTRIB_RELEASE} " == " 18.04" ]] ; then
141
- ccache --set-config cache_dir=.ccache
142
- # For Ubuntu 18.04 install the pypi-supplied version of cmake instead.
143
- sudo pip3 install cmake==3.16.3
144
- fi
145
- ccache --set-config max_size=1G
146
-
147
159
if [[ " ${DISTRIB_RELEASE} " != " 18.04" ]] ; then
148
160
# To run PTF nanomsg tests. Not available on 18.04.
149
161
sudo pip3 install nnpy
150
162
fi
151
163
}
152
164
153
- if [[ " ${INSTALL_BMV2 } " == " ON" ]] ; then
165
+ if [[ " ${ENABLE_BMV2 } " == " ON" ]] ; then
154
166
build_bmv2
155
167
fi
156
168
# ! ------ END BMV2 -----------------------------------------------
@@ -193,7 +205,7 @@ function install_ptf_ebpf_test_deps() (
193
205
popd
194
206
)
195
207
196
- if [[ " ${INSTALL_EBPF } " == " ON" ]] ; then
208
+ if [[ " ${ENABLE_EBPF } " == " ON" ]] ; then
197
209
build_ebpf
198
210
if [[ " ${INSTALL_PTF_EBPF_DEPENDENCIES} " == " ON" ]] ; then
199
211
install_ptf_ebpf_test_deps
@@ -209,7 +221,7 @@ function build_dpdk() {
209
221
sudo pip3 install protobuf==3.20.3 netaddr==0.9.0
210
222
}
211
223
212
- if [[ " ${INSTALL_DPDK } " == " ON" ]]; then
224
+ if [[ " ${ENABLE_DPDK } " == " ON" ]]; then
213
225
build_dpdk
214
226
fi
215
227
# ! ------ END DPDK -----------------------------------------------
219
231
function build_tofino() {
220
232
P4C_TOFINO_PACKAGES=" rapidjson-dev"
221
233
sudo apt-get install -y --no-install-recommends ${P4C_TOFINO_PACKAGES}
234
+ sudo pip3 install jsl==0.2.4 pyinstaller==6.11.0
222
235
}
223
236
224
- if [[ " ${INSTALL_TOFINO } " == " ON" ]]; then
237
+ if [[ " ${ENABLE_TOFINO } " == " ON" ]]; then
225
238
echo " Installing Tofino dependencies"
226
239
build_tofino
227
240
fi
@@ -258,8 +271,6 @@ CMAKE_FLAGS+="-DSTATIC_BUILD_WITH_DYNAMIC_GLIBC=${STATIC_BUILD_WITH_DYNAMIC_GLIB
258
271
CMAKE_FLAGS+=" -DSTATIC_BUILD_WITH_DYNAMIC_STDLIB=${STATIC_BUILD_WITH_DYNAMIC_STDLIB} "
259
272
# Enable GTest.
260
273
CMAKE_FLAGS+=" -DENABLE_GTESTS=${ENABLE_GTESTS} "
261
- # Toggle the installation of the tools back end.
262
- CMAKE_FLAGS+=" -DENABLE_TEST_TOOLS=${ENABLE_TEST_TOOLS} "
263
274
# RELEASE should be default, but we want to make sure.
264
275
CMAKE_FLAGS+=" -DCMAKE_BUILD_TYPE=Release "
265
276
# Treat warnings as errors.
@@ -268,35 +279,9 @@ CMAKE_FLAGS+="-DENABLE_WERROR=${ENABLE_WERROR} "
268
279
CMAKE_FLAGS+=" -DENABLE_SANITIZERS=${ENABLE_SANITIZERS} "
269
280
# Enable auto var initialization with pattern.
270
281
CMAKE_FLAGS+=" -DBUILD_AUTO_VAR_INIT_PATTERN=${BUILD_AUTO_VAR_INIT_PATTERN} "
271
- # Enable Tofino.
272
- if [ -n " ${ENABLE_TOFINO} " ]; then
273
- CMAKE_FLAGS+=" -DENABLE_TOFINO=${ENABLE_TOFINO} "
274
- fi
275
- if [ -n " ${ENABLE_BMV2} " ]; then
276
- CMAKE_FLAGS+=" -DENABLE_BMV2=${ENABLE_BMV2} "
277
- fi
278
- if [ -n " ${ENABLE_EBPF} " ]; then
279
- CMAKE_FLAGS+=" -DENABLE_EBPF=${ENABLE_EBPF} "
280
- fi
281
- if [ -n " ${ENABLE_UBPF} " ]; then
282
- CMAKE_FLAGS+=" -DENABLE_UBPF=${ENABLE_UBPF} "
283
- fi
284
- if [ -n " ${ENABLE_DPDK} " ]; then
285
- CMAKE_FLAGS+=" -DENABLE_DPDK=${ENABLE_DPDK} "
286
- fi
287
- if [ -n " ${ENABLE_P4TC} " ]; then
288
- CMAKE_FLAGS+=" -DENABLE_P4TC=${ENABLE_P4TC} "
289
- fi
290
- if [ -n " ${ENABLE_P4FMT} " ]; then
291
- CMAKE_FLAGS+=" -DENABLE_P4FMT=${ENABLE_P4FMT} "
292
- fi
293
- if [ -n " ${ENABLE_P4TEST} " ]; then
294
- CMAKE_FLAGS+=" -DENABLE_P4TEST=${ENABLE_P4TEST} "
295
- fi
296
- if [ -n " ${ENABLE_P4C_GRAPHS} " ]; then
297
- CMAKE_FLAGS+=" -DENABLE_P4C_GRAPHS=${ENABLE_P4C_GRAPHS} "
298
- fi
299
-
282
+ # Assemble the enabled back ends as a single CMake variable.
283
+ build_cmake_enabled_backend_string
284
+ CMAKE_FLAGS+=" ${CMAKE_ENABLE_BACKENDS} "
300
285
301
286
if [ " $ENABLE_SANITIZERS " == " ON" ]; then
302
287
CMAKE_FLAGS+=" -DENABLE_GC=OFF"
0 commit comments