Commit 5e16bcf2 authored by Inigo Martínez's avatar Inigo Martínez Committed by Thomas Haller

meson: Improve dependency system

Some targets are missing dependencies on some generated sources in
the meson port. These makes the build to fail due to missing source
files on a highly parallelized build.

These dependencies have been resolved by taking advantage of meson's
internal dependencies which can be used to pass source files,
include directories, libraries and compiler flags.

One of such internal dependencies called `core_dep` was already in
use. However, in order to avoid any confusion with another new
internal dependency called `nm_core_dep`, which is used to include
directories and source files from the `libnm-core` directory, the
`core_dep` dependency has been renamed to `nm_dep`.

These changes have allowed minimizing the build details which are
inherited by using those dependencies. The parallelized build has
also been improved.
parent 96658d2f
...@@ -16,23 +16,17 @@ sources = files( ...@@ -16,23 +16,17 @@ sources = files(
'utils.c' 'utils.c'
) )
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [ deps = [
glib_dep,
libnm_dep, libnm_dep,
libnmc_dep,
libnmc_base_dep, libnmc_base_dep,
libnmc_dep,
nm_core_dep,
readline_dep readline_dep
] ]
cflags = clients_cflags + [ cflags = clients_cflags + [
'-DG_LOG_DOMAIN="nmcli"', '-DG_LOG_DOMAIN="nmcli"',
'-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir), '-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir)
] ]
ldflags = [] ldflags = []
...@@ -48,8 +42,7 @@ endif ...@@ -48,8 +42,7 @@ endif
executable( executable(
'nmcli', 'nmcli',
sources + [libnm_core_enum[1]], sources,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_args: ldflags, link_args: ldflags,
......
...@@ -2,15 +2,9 @@ common_inc = include_directories('.') ...@@ -2,15 +2,9 @@ common_inc = include_directories('.')
nm_polkit_listener = files('nm-polkit-listener.c') nm_polkit_listener = files('nm-polkit-listener.c')
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [ deps = [
glib_dep, libnm_dep,
libnm_dep nm_core_dep
] ]
cflags = clients_cflags + [ cflags = clients_cflags + [
...@@ -25,15 +19,14 @@ sources = shared_utils + files( ...@@ -25,15 +19,14 @@ sources = shared_utils + files(
libnmc_base = static_library( libnmc_base = static_library(
'nmc-base', 'nmc-base',
sources: sources + [libnm_core_enum[1]], sources: sources,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags
) )
libnmc_base_dep = declare_dependency( libnmc_base_dep = declare_dependency(
link_with: libnmc_base, include_directories: common_inc,
include_directories: common_inc link_with: libnmc_base
) )
sources = shared_meta_setting + files( sources = shared_meta_setting + files(
...@@ -71,8 +64,7 @@ sources += settings_docs_source ...@@ -71,8 +64,7 @@ sources += settings_docs_source
libnmc = static_library( libnmc = static_library(
'nmc', 'nmc',
sources: sources + [libnm_core_enum[1]], sources: sources,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_with: libnmc_base, link_with: libnmc_base,
...@@ -80,8 +72,8 @@ libnmc = static_library( ...@@ -80,8 +72,8 @@ libnmc = static_library(
) )
libnmc_dep = declare_dependency( libnmc_dep = declare_dependency(
link_with: libnmc, include_directories: common_inc,
include_directories: common_inc link_with: libnmc
) )
if (enable_introspection or enable_nmtui) and enable_tests if (enable_introspection or enable_nmtui) and enable_tests
......
test_unit = 'test-general' test_unit = 'test-general'
deps += [ deps = [
libnm_dep,
libnmc_dep, libnmc_dep,
libnmc_base_dep libnmc_base_dep,
nm_core_dep
] ]
exe = executable( exe = executable(
'clients-' + test_unit, 'clients-' + test_unit,
test_unit + '.c', test_unit + '.c',
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: clients_cflags + [ c_args: clients_cflags + [
'-DNETWORKMANAGER_COMPILATION_TEST', '-DNETWORKMANAGER_COMPILATION_TEST',
......
name = 'nm-online' name = 'nm-online'
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [ deps = [
glib_dep, libnm_dep,
libnm_dep nm_core_dep
] ]
clients_cflags = [ clients_cflags = [
...@@ -27,8 +21,7 @@ endif ...@@ -27,8 +21,7 @@ endif
executable( executable(
name, name,
[name + '.c', libnm_core_enum[1]], name + '.c',
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_args: ldflags, link_args: ldflags,
......
incs = [
top_inc,
shared_inc,
libnm_core_inc,
libnm_inc,
]
deps = [ deps = [
glib_dep, newt_dep,
newt_dep nm_core_dep
] ]
cflags = clients_cflags + [ cflags = clients_cflags + [
'-DG_LOG_DOMAIN="nmtui"', '-DG_LOG_DOMAIN="nmtui"',
'-DLOCALEDIR="@0@"'.format(nm_localedir), '-DLOCALEDIR="@0@"'.format(nm_localedir)
] ]
subdir('newt') subdir('newt')
...@@ -73,8 +66,7 @@ endif ...@@ -73,8 +66,7 @@ endif
executable( executable(
'nmtui', 'nmtui',
sources + [libnm_core_enum[1]], sources,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_args: ldflags, link_args: ldflags,
......
...@@ -23,13 +23,13 @@ sources = files( ...@@ -23,13 +23,13 @@ sources = files(
libnmt_newt = static_library( libnmt_newt = static_library(
'nmt-newt', 'nmt-newt',
sources: sources + [libnm_core_enum[1]], sources: sources + [libnm_enum[1]],
include_directories: incs, include_directories: libnm_inc,
dependencies: deps, dependencies: deps,
c_args: cflags c_args: cflags
) )
libnmt_newt_dep = declare_dependency( libnmt_newt_dep = declare_dependency(
link_with: libnmt_newt, include_directories: include_directories('.'),
include_directories: include_directories('.') link_with: libnmt_newt
) )
...@@ -25,15 +25,9 @@ install_data( ...@@ -25,15 +25,9 @@ install_data(
sources = files('nm-dispatcher-utils.c') sources = files('nm-dispatcher-utils.c')
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [ deps = [
glib_dep, libnm_dep,
libnm_dep nm_core_dep
] ]
cflags = [ cflags = [
...@@ -47,7 +41,6 @@ cflags = [ ...@@ -47,7 +41,6 @@ cflags = [
libnm_dispatcher_core = static_library( libnm_dispatcher_core = static_library(
name + '-core', name + '-core',
sources: sources, sources: sources,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags c_args: cflags
) )
...@@ -69,7 +62,6 @@ endif ...@@ -69,7 +62,6 @@ endif
executable( executable(
name, name,
sources, sources,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_with: libnm_dispatcher_core, link_with: libnm_dispatcher_core,
......
test_unit = 'test-dispatcher-envp' test_unit = 'test-dispatcher-envp'
incs = [ incs = [
top_inc, dispatcher_inc,
shared_inc, libnm_inc
libnm_core_inc,
libnm_inc,
dispatcher_inc
] ]
cflags = [ cflags = [
...@@ -16,9 +13,9 @@ cflags = [ ...@@ -16,9 +13,9 @@ cflags = [
exe = executable( exe = executable(
test_unit, test_unit,
[test_unit + '.c', libnm_core_enum[1]], test_unit + '.c',
include_directories: incs, include_directories: incs,
dependencies: glib_dep, dependencies: nm_core_dep,
c_args: cflags, c_args: cflags,
link_with: libnm_dispatcher_core link_with: libnm_dispatcher_core
) )
......
examples = [ examples = [
['add-connection-gdbus', [uuid_dep], [libnm_core_enum[1], libnm_enum[1]]], ['add-connection-gdbus', [libnm_enum[1]], [libnm_inc], [uuid_dep]],
['add-connection-libnm', [libnm_dep], []], ['add-connection-libnm', [], [], [libnm_dep]],
['get-active-connections-gdbus', [], [libnm_core_enum[1], libnm_enum[1]]], ['get-active-connections-gdbus', [libnm_enum[1]], [libnm_inc], []],
['get-ap-info-libnm', [libnm_dep], []], ['get-ap-info-libnm', [], [], [libnm_dep]],
['list-connections-gdbus', [], []], ['list-connections-gdbus', [], [], []],
['list-connections-libnm', [libnm_dep], []], ['list-connections-libnm', [], [], [libnm_dep]],
['monitor-nm-running-gdbus', [], []], ['monitor-nm-running-gdbus', [], [], []],
['monitor-nm-state-gdbus', [], []] ['monitor-nm-state-gdbus', [], [], []]
]
incs = [
top_inc,
shared_inc,
libnm_core_inc,
libnm_inc
] ]
foreach example: examples foreach example: examples
executable( executable(
example[0], example[0],
[example[0] + '.c'] + example[2], [example[0] + '.c'] + example[1],
include_directories: incs, include_directories: example[2],
dependencies: [glib_dep] + example[1], dependencies: [nm_core_dep] + example[3],
c_args: '-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE' c_args: '-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE'
) )
endforeach endforeach
...@@ -93,6 +93,9 @@ libnmdbus = static_library( ...@@ -93,6 +93,9 @@ libnmdbus = static_library(
) )
libnmdbus_dep = declare_dependency( libnmdbus_dep = declare_dependency(
link_with: libnmdbus, # FIXME: only headers should be added here to resolve dependencies on
include_directories: include_directories('.') # libNetworkManagerBase and libNetworkManager
#sources: sources,
include_directories: include_directories('.'),
link_with: libnmdbus
) )
...@@ -127,16 +127,11 @@ libnm_core_enum = gnome.mkenums( ...@@ -127,16 +127,11 @@ libnm_core_enum = gnome.mkenums(
install_dir: libnm_pkgincludedir install_dir: libnm_pkgincludedir
) )
incs = [
top_inc,
shared_inc
]
deps = [ deps = [
crypto_dep, crypto_dep,
dl_dep, dl_dep,
glib_dep,
libudev_dep, libudev_dep,
shared_dep,
uuid_dep uuid_dep
] ]
...@@ -158,11 +153,16 @@ endif ...@@ -158,11 +153,16 @@ endif
libnm_core = static_library( libnm_core = static_library(
'nm-core', 'nm-core',
sources: libnm_core_sources + libnm_core_enum + shared_sources + [version_header], sources: libnm_core_sources + libnm_core_enum + shared_sources + [version_header],
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags c_args: cflags
) )
nm_core_dep = declare_dependency(
sources: libnm_core_enum[1],
include_directories: libnm_core_inc,
dependencies: shared_dep
)
enums_to_docbook = join_paths(meson.source_root(), 'tools', 'enums-to-docbook.pl') enums_to_docbook = join_paths(meson.source_root(), 'tools', 'enums-to-docbook.pl')
docbooks = [ docbooks = [
......
...@@ -27,12 +27,6 @@ test_units = [ ...@@ -27,12 +27,6 @@ test_units = [
'test-settings-defaults' 'test-settings-defaults'
] ]
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
test_cert_dir = join_paths(meson.current_source_dir(), 'certs') test_cert_dir = join_paths(meson.current_source_dir(), 'certs')
cflags = [ cflags = [
...@@ -45,8 +39,7 @@ foreach test_unit: test_units ...@@ -45,8 +39,7 @@ foreach test_unit: test_units
exe = executable( exe = executable(
'libnm-core-' + test_unit, 'libnm-core-' + test_unit,
[test_unit + '.c'] + enum, [test_unit + '.c'] + enum,
include_directories: incs, dependencies: nm_core_dep,
dependencies: glib_dep,
c_args: cflags, c_args: cflags,
link_with: libnm_core link_with: libnm_core
) )
......
dbus_binding_tool = find_program('dbus-binding-tool') libnm_glib_inc = include_directories('.')
common_incs = [ dbus_binding_tool = find_program('dbus-binding-tool')
top_inc,
shared_inc
]
common_deps = [ common_deps = [
dbus_dep, dbus_dep,
dbus_glib_dep, dbus_glib_dep,
glib_dep shared_dep
] ]
common_cflags = [ common_cflags = [
...@@ -16,11 +13,9 @@ common_cflags = [ ...@@ -16,11 +13,9 @@ common_cflags = [
] ]
cflags = common_cflags + [ cflags = common_cflags + [
'-DG_LOG_DOMAIN="libnm-glib"', '-DG_LOG_DOMAIN="libnm-glib"'
] ]
libnm_glib_inc = include_directories('.')
vpn_headers = files( vpn_headers = files(
'nm-vpn-plugin.h', 'nm-vpn-plugin.h',
'nm-vpn-plugin-ui-interface.h', 'nm-vpn-plugin-ui-interface.h',
...@@ -65,12 +60,10 @@ install_headers( ...@@ -65,12 +60,10 @@ install_headers(
subdir: 'libnm-glib' subdir: 'libnm-glib'
) )
incs = common_incs + [libnm_util_inc]
libdeprecated_nm_glib = static_library( libdeprecated_nm_glib = static_library(
'deprecated-nm-glib', 'deprecated-nm-glib',
sources: 'libnm_glib.c', sources: 'libnm_glib.c',
include_directories: incs, include_directories: libnm_util_inc,
dependencies: common_deps, dependencies: common_deps,
c_args: cflags + [ c_args: cflags + [
'-Wno-deprecated-declarations', '-Wno-deprecated-declarations',
...@@ -116,9 +109,8 @@ endif ...@@ -116,9 +109,8 @@ endif
libnm_glib_vpn = shared_library( libnm_glib_vpn = shared_library(
'nm-glib-vpn', 'nm-glib-vpn',
sources: sources + libnm_glib_vpn_enum + [libnm_utils_enum[1]], sources: sources + libnm_glib_vpn_enum,
version: libnm_glib_vpn_version, version: libnm_glib_vpn_version,
include_directories: common_incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_args: ldflags, link_args: ldflags,
...@@ -127,8 +119,8 @@ libnm_glib_vpn = shared_library( ...@@ -127,8 +119,8 @@ libnm_glib_vpn = shared_library(
) )
libnm_glib_vpn_dep = declare_dependency( libnm_glib_vpn_dep = declare_dependency(
link_with: libnm_glib_vpn, include_directories: libnm_glib_inc,
include_directories: libnm_glib_inc link_with: libnm_glib_vpn
) )
pkg.generate( pkg.generate(
...@@ -197,8 +189,8 @@ libnm_glib_enum = gnome.mkenums( ...@@ -197,8 +189,8 @@ libnm_glib_enum = gnome.mkenums(
) )
deps = common_deps + [ deps = common_deps + [
libudev_dep, libnm_util_dep,
libnm_util_dep libudev_dep
] ]
symbol_map = join_paths(meson.current_source_dir(), 'libnm-glib.ver') symbol_map = join_paths(meson.current_source_dir(), 'libnm-glib.ver')
...@@ -210,9 +202,8 @@ endif ...@@ -210,9 +202,8 @@ endif
libnm_glib = shared_library( libnm_glib = shared_library(
'nm-glib', 'nm-glib',
sources: sources + libnm_glib_enum + [nm_secret_agent_glue, libnm_utils_enum[1]], sources: sources + libnm_glib_enum + [nm_secret_agent_glue],
version: libnm_glib_version, version: libnm_glib_version,
include_directories: common_incs,
dependencies: deps, dependencies: deps,
c_args: cflags + [ c_args: cflags + [
'-DNMRUNDIR="@0@"'.format(nm_pkgrundir), '-DNMRUNDIR="@0@"'.format(nm_pkgrundir),
...@@ -224,8 +215,8 @@ libnm_glib = shared_library( ...@@ -224,8 +215,8 @@ libnm_glib = shared_library(
) )
libnm_glib_dep = declare_dependency( libnm_glib_dep = declare_dependency(
link_with: libnm_glib, include_directories: libnm_glib_inc,
include_directories: libnm_glib_inc link_with: libnm_glib
) )
pkg.generate( pkg.generate(
...@@ -276,8 +267,7 @@ deps = common_deps + [libnm_util_dep] ...@@ -276,8 +267,7 @@ deps = common_deps + [libnm_util_dep]
executable( executable(
name, name,
[name + '.c', libnm_utils_enum[1]], name + '.c',
include_directories: common_incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_with: libnm_glib link_with: libnm_glib
......
incs = [
top_inc,
shared_inc
]
deps = [ deps = [
dbus_dep, dbus_dep,
dbus_glib_dep, dbus_glib_dep,
glib_dep,
libnm_glib_dep, libnm_glib_dep,
libnm_util_dep libnm_util_dep,
shared_dep
] ]
test_units = [ test_units = [
...@@ -19,8 +14,7 @@ test_units = [ ...@@ -19,8 +14,7 @@ test_units = [
foreach test_unit: test_units foreach test_unit: test_units
exe = executable( exe = executable(
test_unit, test_unit,
[test_unit + '.c', libnm_utils_enum[1]] + shared_test_utils, [test_unit + '.c'] + shared_test_utils,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: common_cflags + [ c_args: common_cflags + [
'-DNETWORKMANAGER_COMPILATION_TEST', '-DNETWORKMANAGER_COMPILATION_TEST',
......
...@@ -91,16 +91,11 @@ sources = shared_utils + files( ...@@ -91,16 +91,11 @@ sources = shared_utils + files(
'nm-value-transforms.c' 'nm-value-transforms.c'
) )
incs = [
top_inc,
shared_inc
]
deps = [ deps = [
crypto_dep, crypto_dep,
dbus_dep, dbus_dep,
dbus_glib_dep, dbus_glib_dep,
glib_dep, shared_dep,
uuid_dep uuid_dep
] ]
...@@ -110,7 +105,7 @@ common_cflags = [ ...@@ -110,7 +105,7 @@ common_cflags = [
] ]
cflags = common_cflags + [ cflags = common_cflags + [
'-DG_LOG_DOMAIN="libnm-util"', '-DG_LOG_DOMAIN="libnm-util"'
] ]
symbol_map = join_paths(meson.current_source_dir(), 'libnm-util.ver') symbol_map = join_paths(meson.current_source_dir(), 'libnm-util.ver')
...@@ -124,7 +119,6 @@ libnm_util = shared_library( ...@@ -124,7 +119,6 @@ libnm_util = shared_library(
'nm-util', 'nm-util',
sources: sources + libnm_utils_enum, sources: sources + libnm_utils_enum,
version: libnm_util_version, version: libnm_util_version,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
link_args: ldflags, link_args: ldflags,
...@@ -133,8 +127,9 @@ libnm_util = shared_library( ...@@ -133,8 +127,9 @@ libnm_util = shared_library(
) )
libnm_util_dep = declare_dependency( libnm_util_dep = declare_dependency(
link_with: libnm_util, sources: libnm_utils_enum[1],
include_directories: libnm_util_inc include_directories: libnm_util_inc,
link_with: libnm_util
) )
pkg.generate( pkg.generate(
...@@ -169,8 +164,8 @@ if enable_introspection ...@@ -169,8 +164,8 @@ if enable_introspection
) )
libnm_util_gir_dep = declare_dependency( libnm_util_gir_dep = declare_dependency(
link_with: libnm_util, sources: libnm_util_gir,
sources: libnm_util_gir link_with: libnm_util
) )
endif endif
...@@ -187,13 +182,12 @@ sources = files( ...@@ -187,13 +182,12 @@ sources = files(
deps = [ deps = [
crypto_dep, crypto_dep,
glib_dep shared_dep
] ]
libtest_crypto = static_library( libtest_crypto = static_library(
'test-crypto', 'test-crypto',
sources: sources, sources: sources,
include_directories: incs,
dependencies: deps, dependencies: deps,
c_args: cflags c_args: cflags
) )
......