From bdabc9e38c5487d0652057cc8147f6da2461b3e5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 24 Feb 2021 11:38:39 +0100 Subject: [PATCH] build/meson: cleanup build for c-util and nettools helper libraries We have a number of static helper libraries. When a user is using such a library, they need to set the include search paths (-I) and link with the static library at the right place. The first part, the include search path, is now trivial. We no longer add the individual search paths but everybody uses "-I. -Isrc/". The second part means that when we build a shared library or an executable that uses symbols from the static library, we need to link it. But only then, and not earlier so that not multiple intermediate build products (static libraries too) contain the same code. Note that for libnm-device-plugin-*.so and other core plugins it's even that those shared modules should not themselves link with the static helpers. Instead, the need to use the symbols from NetworkManager. Easy enough. Previously, we would sometimes define dependencies in meson. But as it's really simple, I think that those dependencies obfuscate more than help. Instead drop them, and only explicitly link where we need it. The exception is libNetworkManagerTest_dep, which is still a dependency. Maybe that dependency is fine, as it is much later in the process. Or maybe that will also be replaced in the future. --- src/core/meson.build | 19 ++++++++++++++++--- src/meson.build | 31 ++++++------------------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/core/meson.build b/src/core/meson.build index 6a9ff34fa6..6296e38e00 100644 --- a/src/core/meson.build +++ b/src/core/meson.build @@ -76,7 +76,6 @@ libNetworkManagerBase = static_library( ) + platform_wifi_wext_source, dependencies: [ core_default_dep, - libn_dhcp4_dep, libnm_core_impl_dep, libnm_systemd_shared_dep, libnm_udev_aux_dep, @@ -90,7 +89,6 @@ nm_deps = [ libnm_core_impl_dep, core_default_dep, dl_dep, - libn_acd_dep, libndp_dep, libudev_dep, logind_dep, @@ -210,7 +208,6 @@ executable( dl_dep, libndp_dep, libudev_dep, - libn_acd_dep, libnm_glib_aux_dep_link, libnm_core_impl_dep_link, ], @@ -220,6 +217,10 @@ executable( libnm_systemd_shared, libnm_base, libnm_glib_aux, + libn_acd, + libn_dhcp4, + libc_rbtree, + libc_siphash, ], link_args: ldflags_linker_script_binary, link_depends: linker_script_binary, @@ -251,6 +252,10 @@ if enable_tests libNetworkManagerTest, libnm_base, libnm_core_impl, + libn_acd, + libn_dhcp4, + libc_siphash, + libc_rbtree, ], ) @@ -288,6 +293,10 @@ NetworkManager_all_sym = executable( libNetworkManagerBase, libnm_core_impl, libnm_base, + libn_acd, + libn_dhcp4, + libc_rbtree, + libc_siphash, ], ) @@ -314,6 +323,10 @@ NetworkManager = executable( libNetworkManagerBase, libnm_core_impl, libnm_base, + libn_acd, + libn_dhcp4, + libc_rbtree, + libc_siphash, ], link_args: [ '-rdynamic', diff --git a/src/meson.build b/src/meson.build index e560053e41..870e0b1855 100644 --- a/src/meson.build +++ b/src/meson.build @@ -18,19 +18,13 @@ libc_rbtree = static_library( c_args: '-std=c11', ) -if enable_ebpf - n_acd_bpf_source = 'n-acd/src/n-acd-bpf.c' -else - n_acd_bpf_source = 'n-acd/src/n-acd-bpf-fallback.c' -endif - libn_acd = static_library( 'n-acd', sources: files( 'n-acd/src/n-acd.c', 'n-acd/src/n-acd-probe.c', 'n-acd/src/util/timer.c', - n_acd_bpf_source, + enable_ebpf ? 'n-acd/src/n-acd-bpf.c' : 'n-acd/src/n-acd-bpf-fallback.c', ), include_directories: include_directories( 'c-list/src', @@ -45,14 +39,6 @@ libn_acd = static_library( '-Wno-pointer-arith', '-Wno-vla', ], - link_with: [ - libc_rbtree, - libc_siphash, - ], -) - -libn_acd_dep = declare_dependency( - link_with: libn_acd, ) libn_dhcp4 = static_library( @@ -68,22 +54,17 @@ libn_dhcp4 = static_library( 'n-dhcp4/src/util/packet.c', 'n-dhcp4/src/util/socket.c', ), + include_directories: include_directories( + 'c-list/src', + 'c-siphash/src', + 'c-stdaux/src', + ), c_args: [ '-std=c11', '-D_GNU_SOURCE', '-Wno-declaration-after-statement', '-Wno-pointer-arith', ], - include_directories: include_directories( - 'c-list/src', - 'c-siphash/src', - 'c-stdaux/src', - ), - link_with: libc_siphash, -) - -libn_dhcp4_dep = declare_dependency( - link_with: libn_dhcp4, ) ###############################################################################