examples: skip example when missing dependencies
PATCH 1/1 examples: skip example when missing dependencies
Trying to disable the vhost library, meson will complain it can't build the vhost* and vdpa examples when passing -Dexamples=all.
-Dexamples=all skips examples if the example itself announces it can't be built (for external dependencies, internal dependencies and other reasons).
Since examples/meson.build will evaluate the internal dependencies in any case, let's move the check there and resolve the issue for optional internal libraries.
--- examples/distributor/meson.build | 6 ----- examples/kni/meson.build | 6 ----- examples/l3fwd-power/meson.build | 5 ---- examples/meson.build | 24 ++++++++++++------- examples/vhost_crypto/meson.build | 5 ---- .../vm_power_manager/guest_cli/meson.build | 5 ---- examples/vm_power_manager/meson.build | 5 ---- 7 files changed, 16 insertions(+), 40 deletions(-)
examples/distributor/meson.build +0 -6
@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -# require the power library -build = dpdk_conf.has('RTE_LIB_POWER') -if not build - subdir_done() -endif - allow_experimental_apis = true deps += ['distributor', 'power'] sources = files(
examples/kni/meson.build +0 -6
@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -# this app can be built if-and-only-if KNI library is buildable -build = dpdk_conf.has('RTE_LIB_KNI') -if not build - subdir_done() -endif - deps += ['kni', 'bus_pci'] sources = files( 'main.c',
examples/l3fwd-power/meson.build +0 -5
@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if not dpdk_conf.has('RTE_LIB_POWER') - build = false - subdir_done() -endif - allow_experimental_apis = true deps += ['power', 'timer', 'lpm', 'hash', 'metrics', 'telemetry'] sources = files(
examples/meson.build +16 -8
@@ -104,6 +104,22 @@ foreach example: examples deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] subdir(example) + if build + dep_objs = ext_deps + foreach d:deps + if not build + break + endif + var_name = get_option('default_library') + '_rte_' + d + if not is_variable(var_name) + build = false + message('Missing dependency "@0@" for example "@1@"'.format(d, name)) + else + dep_objs += [get_variable(var_name)] + endif + endforeach + endif + if not build if not allow_skips error('Cannot build requested example "' + name + '"')
@@ -112,14 +128,6 @@ foreach example: examples continue endif - dep_objs = ext_deps - foreach d:deps - var_name = get_option('default_library') + '_rte_' + d - if not is_variable(var_name) - error('Missing dependency "@0@" for example "@1@"'.format(d, name)) - endif - dep_objs += [get_variable(var_name)] - endforeach if allow_experimental_apis cflags += '-DALLOW_EXPERIMENTAL_API' endif
examples/vhost_crypto/meson.build +0 -5
@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -build = dpdk_conf.has('RTE_LIB_VHOST') -if not build - subdir_done() -endif - allow_experimental_apis = true deps += ['vhost', 'cryptodev'] sources = files(
examples/vm_power_manager/guest_cli/meson.build +0 -5
@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if not dpdk_conf.has('RTE_LIB_POWER') - build = false - subdir_done() -endif - deps += ['power'] sources = files(
examples/vm_power_manager/meson.build +0 -5
@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if not dpdk_conf.has('RTE_LIB_POWER') - build = false - subdir_done() -endif - deps += ['power'] if dpdk_conf.has('RTE_NET_BNXT')
Signature · 1 line
2.23.0
Quoted 10 lines · David Marchand
Trying to disable the vhost library, meson will complain it can't build the vhost* and vdpa examples when passing -Dexamples=all.
-Dexamples=all skips examples if the example itself announces it can't be built (for external dependencies, internal dependencies and other reasons).
Since examples/meson.build will evaluate the internal dependencies in any case, let's move the check there and resolve the issue for optional internal libraries.
Quoted 3 lines
Fixes 0bf583222297 ("lib: allow disabling optional libraries")Signed-off-by David Marchand <[email protected]>
One comment inline below, otherwise looks a good change.
Quoted 65 lines
--- examples/distributor/meson.build | 6 ----- examples/kni/meson.build | 6 ----- examples/l3fwd-power/meson.build | 5 ---- examples/meson.build | 24 ++++++++++++------- examples/vhost_crypto/meson.build | 5 ---- .../vm_power_manager/guest_cli/meson.build | 5 ---- examples/vm_power_manager/meson.build | 5 ---- 7 files changed, 16 insertions(+), 40 deletions(-)examples/distributor/meson.build +0
-6@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -# require the power library -build = dpdk_conf.has('RTE_LIB_POWER') -if not build - subdir_done() -endif - allow_experimental_apis = true deps += ['distributor', 'power'] sources = files(examples/kni/meson.build +0
-6@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -# this app can be built if-and-only-if KNI library is buildable -build = dpdk_conf.has('RTE_LIB_KNI') -if not build - subdir_done() -endif - deps += ['kni', 'bus_pci'] sources = files( 'main.c',examples/l3fwd-power/meson.build +0
-5@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if not dpdk_conf.has('RTE_LIB_POWER') - build = false - subdir_done() -endif - allow_experimental_apis = true deps += ['power', 'timer', 'lpm', 'hash', 'metrics', 'telemetry'] sources = files(examples/meson.build +0
-0
examples/meson.build foreach example: examples · line 112
Quoted 9 lines
examples/meson.build +6
-0@@ -104,6 +104,22 @@ foreach example: examples deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] subdir(example) + if build + dep_objs = ext_deps + foreach d:deps + if not build + break + endif
I believe this check can be removed by just putting "break" after the "message()" call below.
Quoted 10 lines
examples/meson.build +10
-0+ var_name = get_option('default_library') + '_rte_' + d + if not is_variable(var_name) + build = false + message('Missing dependency "@0@" for example "@1@"'.format(d, name)) + else + dep_objs += [get_variable(var_name)] + endif + endforeach + endif +
Quoted 4 lines · Bruce Richardson
Quoted 4 lines
examples/meson.build +0
-0@@ -104,6 +104,22 @@ foreach example: examples deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] subdir(example)
Quoted 9 lines
examples/meson.build foreach example: examples · line 112
Quoted 6 lines
examples/meson.build +6
-0+ if build + dep_objs = ext_deps + foreach d:deps + if not build + break + endifI believe this check can be removed by just putting "break" after the "
message()" call below.
I took the inspiration from drivers/meson.build (where I suppose, the if not build in the loop is to catch a build = false set by the subdir meson.build).
It's more readable with a break where expected.
v2 incoming.
Quoted 12 lines
examples/meson.build foreach example: examples · line 122
Quoted 11 lines
examples/meson.build +10
-0+ var_name = get_option('default_library') + '_rte_' + d + if not is_variable(var_name) + build = false + message('Missing dependency "@0@" for example "@1@"'.format(d, name)) + else + dep_objs += [get_variable(var_name)] + endif + endforeach + endif +
Thanks.
Signature · 1 line
David Marchand
PATCH v2 1/1 examples: skip example when missing dependencies
In reply to David MarchandTrying to disable the vhost library, meson will complain it can't build the vhost* and vdpa examples when passing -Dexamples=all.
-Dexamples=all skips examples if the example itself announces it can't be built (for external dependencies, internal dependencies and other reasons).
Since examples/meson.build will evaluate the internal dependencies in any case, let's move the check there and resolve the issue for optional internal libraries.
---
Changes since v1:
- changed to a more explicit way to break from the foreach deps loop,
--- examples/distributor/meson.build | 6 ------ examples/kni/meson.build | 6 ------ examples/l3fwd-power/meson.build | 5 ----- examples/meson.build | 21 ++++++++++++------- examples/vhost_crypto/meson.build | 5 ----- .../vm_power_manager/guest_cli/meson.build | 5 ----- examples/vm_power_manager/meson.build | 5 ----- 7 files changed, 13 insertions(+), 40 deletions(-)
examples/distributor/meson.build +0 -6
@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -# require the power library -build = dpdk_conf.has('RTE_LIB_POWER') -if not build - subdir_done() -endif - allow_experimental_apis = true deps += ['distributor', 'power'] sources = files(
examples/kni/meson.build +0 -6
@@ -6,12 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -# this app can be built if-and-only-if KNI library is buildable -build = dpdk_conf.has('RTE_LIB_KNI') -if not build - subdir_done() -endif - deps += ['kni', 'bus_pci'] sources = files( 'main.c',
examples/l3fwd-power/meson.build +0 -5
@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if not dpdk_conf.has('RTE_LIB_POWER') - build = false - subdir_done() -endif - allow_experimental_apis = true deps += ['power', 'timer', 'lpm', 'hash', 'metrics', 'telemetry'] sources = files(
examples/meson.build +13 -8
@@ -104,6 +104,19 @@ foreach example: examples deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline'] subdir(example) + if build + dep_objs = ext_deps + foreach d:deps + var_name = get_option('default_library') + '_rte_' + d + if not is_variable(var_name) + build = false + message('Missing dependency "@0@" for example "@1@"'.format(d, name)) + break + endif + dep_objs += [get_variable(var_name)] + endforeach + endif + if not build if not allow_skips error('Cannot build requested example "' + name + '"')
@@ -112,14 +125,6 @@ foreach example: examples continue endif - dep_objs = ext_deps - foreach d:deps - var_name = get_option('default_library') + '_rte_' + d - if not is_variable(var_name) - error('Missing dependency "@0@" for example "@1@"'.format(d, name)) - endif - dep_objs += [get_variable(var_name)] - endforeach if allow_experimental_apis cflags += '-DALLOW_EXPERIMENTAL_API' endif
examples/vhost_crypto/meson.build +0 -5
@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -build = dpdk_conf.has('RTE_LIB_VHOST') -if not build - subdir_done() -endif - allow_experimental_apis = true deps += ['vhost', 'cryptodev'] sources = files(
examples/vm_power_manager/guest_cli/meson.build +0 -5
@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if not dpdk_conf.has('RTE_LIB_POWER') - build = false - subdir_done() -endif - deps += ['power'] sources = files(
examples/vm_power_manager/meson.build +0 -5
@@ -6,11 +6,6 @@ # To build this example as a standalone application with an already-installed # DPDK instance, use 'make' -if not dpdk_conf.has('RTE_LIB_POWER') - build = false - subdir_done() -endif - deps += ['power'] if dpdk_conf.has('RTE_NET_BNXT')
Signature · 1 line
2.23.0
David Marchand
AppliedQuoted 11 lines · David Marchand
Trying to disable the vhost library, meson will complain it can't build the vhost* and vdpa examples when passing -Dexamples=all.
-Dexamples=all skips examples if the example itself announces it can't be built (for external dependencies, internal dependencies and other reasons).
Since examples/meson.build will evaluate the internal dependencies in any case, let's move the check there and resolve the issue for optional internal libraries.
Quoted 4 lines
Fixes 0bf583222297 ("lib: allow disabling optional libraries")Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand