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(
'utils.c'
)
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep,
libnmc_dep,
libnmc_base_dep,
libnmc_dep,
nm_core_dep,
readline_dep
]
cflags = clients_cflags + [
'-DG_LOG_DOMAIN="nmcli"',
'-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir),
'-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir)
]
ldflags = []
......@@ -48,8 +42,7 @@ endif
executable(
'nmcli',
sources + [libnm_core_enum[1]],
include_directories: incs,
sources,
dependencies: deps,
c_args: cflags,
link_args: ldflags,
......
......@@ -2,15 +2,9 @@ common_inc = include_directories('.')
nm_polkit_listener = files('nm-polkit-listener.c')
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep
libnm_dep,
nm_core_dep
]
cflags = clients_cflags + [
......@@ -25,15 +19,14 @@ sources = shared_utils + files(
libnmc_base = static_library(
'nmc-base',
sources: sources + [libnm_core_enum[1]],
include_directories: incs,
sources: sources,
dependencies: deps,
c_args: cflags,
c_args: cflags
)
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(
......@@ -71,8 +64,7 @@ sources += settings_docs_source
libnmc = static_library(
'nmc',
sources: sources + [libnm_core_enum[1]],
include_directories: incs,
sources: sources,
dependencies: deps,
c_args: cflags,
link_with: libnmc_base,
......@@ -80,8 +72,8 @@ libnmc = static_library(
)
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
......
test_unit = 'test-general'
deps += [
deps = [
libnm_dep,
libnmc_dep,
libnmc_base_dep
libnmc_base_dep,
nm_core_dep
]
exe = executable(
'clients-' + test_unit,
test_unit + '.c',
include_directories: incs,
dependencies: deps,
c_args: clients_cflags + [
'-DNETWORKMANAGER_COMPILATION_TEST',
......
name = 'nm-online'
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep
libnm_dep,
nm_core_dep
]
clients_cflags = [
......@@ -27,8 +21,7 @@ endif
executable(
name,
[name + '.c', libnm_core_enum[1]],
include_directories: incs,
name + '.c',
dependencies: deps,
c_args: cflags,
link_args: ldflags,
......
incs = [
top_inc,
shared_inc,
libnm_core_inc,
libnm_inc,
]
deps = [
glib_dep,
newt_dep
newt_dep,
nm_core_dep
]
cflags = clients_cflags + [
'-DG_LOG_DOMAIN="nmtui"',
'-DLOCALEDIR="@0@"'.format(nm_localedir),
'-DLOCALEDIR="@0@"'.format(nm_localedir)
]
subdir('newt')
......@@ -73,8 +66,7 @@ endif
executable(
'nmtui',
sources + [libnm_core_enum[1]],
include_directories: incs,
sources,
dependencies: deps,
c_args: cflags,
link_args: ldflags,
......
......@@ -23,13 +23,13 @@ sources = files(
libnmt_newt = static_library(
'nmt-newt',
sources: sources + [libnm_core_enum[1]],
include_directories: incs,
sources: sources + [libnm_enum[1]],
include_directories: libnm_inc,
dependencies: deps,
c_args: cflags
)
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(
sources = files('nm-dispatcher-utils.c')
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep
libnm_dep,
nm_core_dep
]
cflags = [
......@@ -47,7 +41,6 @@ cflags = [
libnm_dispatcher_core = static_library(
name + '-core',
sources: sources,
include_directories: incs,
dependencies: deps,
c_args: cflags
)
......@@ -69,7 +62,6 @@ endif
executable(
name,
sources,
include_directories: incs,
dependencies: deps,
c_args: cflags,
link_with: libnm_dispatcher_core,
......
test_unit = 'test-dispatcher-envp'
incs = [
top_inc,
shared_inc,
libnm_core_inc,
libnm_inc,
dispatcher_inc
dispatcher_inc,
libnm_inc
]
cflags = [
......@@ -16,9 +13,9 @@ cflags = [
exe = executable(
test_unit,
[test_unit + '.c', libnm_core_enum[1]],
test_unit + '.c',
include_directories: incs,
dependencies: glib_dep,
dependencies: nm_core_dep,
c_args: cflags,
link_with: libnm_dispatcher_core
)
......
examples = [
['add-connection-gdbus', [uuid_dep], [libnm_core_enum[1], libnm_enum[1]]],
['add-connection-libnm', [libnm_dep], []],
['get-active-connections-gdbus', [], [libnm_core_enum[1], libnm_enum[1]]],
['get-ap-info-libnm', [libnm_dep], []],
['list-connections-gdbus', [], []],
['list-connections-libnm', [libnm_dep], []],
['monitor-nm-running-gdbus', [], []],
['monitor-nm-state-gdbus', [], []]
]
incs = [
top_inc,
shared_inc,
libnm_core_inc,
libnm_inc
['add-connection-gdbus', [libnm_enum[1]], [libnm_inc], [uuid_dep]],
['add-connection-libnm', [], [], [libnm_dep]],
['get-active-connections-gdbus', [libnm_enum[1]], [libnm_inc], []],
['get-ap-info-libnm', [], [], [libnm_dep]],
['list-connections-gdbus', [], [], []],
['list-connections-libnm', [], [], [libnm_dep]],
['monitor-nm-running-gdbus', [], [], []],
['monitor-nm-state-gdbus', [], [], []]
]
foreach example: examples
executable(
example[0],
[example[0] + '.c'] + example[2],
include_directories: incs,
dependencies: [glib_dep] + example[1],
[example[0] + '.c'] + example[1],
include_directories: example[2],
dependencies: [nm_core_dep] + example[3],
c_args: '-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE'
)
endforeach
......@@ -93,6 +93,9 @@ libnmdbus = static_library(
)
libnmdbus_dep = declare_dependency(
link_with: libnmdbus,
include_directories: include_directories('.')
# FIXME: only headers should be added here to resolve dependencies on
# libNetworkManagerBase and libNetworkManager
#sources: sources,
include_directories: include_directories('.'),
link_with: libnmdbus
)
......@@ -127,16 +127,11 @@ libnm_core_enum = gnome.mkenums(
install_dir: libnm_pkgincludedir
)
incs = [
top_inc,
shared_inc
]
deps = [
crypto_dep,
dl_dep,
glib_dep,
libudev_dep,
shared_dep,
uuid_dep
]
......@@ -158,11 +153,16 @@ endif
libnm_core = static_library(
'nm-core',
sources: libnm_core_sources + libnm_core_enum + shared_sources + [version_header],
include_directories: incs,
dependencies: deps,
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')
docbooks = [
......
......@@ -27,12 +27,6 @@ test_units = [
'test-settings-defaults'
]
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
test_cert_dir = join_paths(meson.current_source_dir(), 'certs')
cflags = [
......@@ -45,8 +39,7 @@ foreach test_unit: test_units
exe = executable(
'libnm-core-' + test_unit,
[test_unit + '.c'] + enum,
include_directories: incs,
dependencies: glib_dep,
dependencies: nm_core_dep,
c_args: cflags,
link_with: libnm_core
)
......
dbus_binding_tool = find_program('dbus-binding-tool')
libnm_glib_inc = include_directories('.')
common_incs = [
top_inc,
shared_inc
]
dbus_binding_tool = find_program('dbus-binding-tool')
common_deps = [
dbus_dep,
dbus_glib_dep,
glib_dep
shared_dep
]
common_cflags = [
......@@ -16,11 +13,9 @@ common_cflags = [
]
cflags = common_cflags + [
'-DG_LOG_DOMAIN="libnm-glib"',
'-DG_LOG_DOMAIN="libnm-glib"'
]
libnm_glib_inc = include_directories('.')
vpn_headers = files(
'nm-vpn-plugin.h',
'nm-vpn-plugin-ui-interface.h',
......@@ -65,12 +60,10 @@ install_headers(
subdir: 'libnm-glib'
)
incs = common_incs + [libnm_util_inc]
libdeprecated_nm_glib = static_library(
'deprecated-nm-glib',
sources: 'libnm_glib.c',
include_directories: incs,
include_directories: libnm_util_inc,
dependencies: common_deps,
c_args: cflags + [
'-Wno-deprecated-declarations',
......@@ -116,9 +109,8 @@ endif
libnm_glib_vpn = shared_library(
'nm-glib-vpn',
sources: sources + libnm_glib_vpn_enum + [libnm_utils_enum[1]],
sources: sources + libnm_glib_vpn_enum,
version: libnm_glib_vpn_version,
include_directories: common_incs,
dependencies: deps,
c_args: cflags,
link_args: ldflags,
......@@ -127,8 +119,8 @@ libnm_glib_vpn = shared_library(
)
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(
......@@ -197,8 +189,8 @@ libnm_glib_enum = gnome.mkenums(
)
deps = common_deps + [
libudev_dep,
libnm_util_dep
libnm_util_dep,
libudev_dep
]
symbol_map = join_paths(meson.current_source_dir(), 'libnm-glib.ver')
......@@ -210,9 +202,8 @@ endif
libnm_glib = shared_library(
'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,
include_directories: common_incs,
dependencies: deps,
c_args: cflags + [
'-DNMRUNDIR="@0@"'.format(nm_pkgrundir),
......@@ -224,8 +215,8 @@ libnm_glib = shared_library(
)
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(
......@@ -276,8 +267,7 @@ deps = common_deps + [libnm_util_dep]
executable(
name,
[name + '.c', libnm_utils_enum[1]],
include_directories: common_incs,
name + '.c',
dependencies: deps,
c_args: cflags,
link_with: libnm_glib
......
incs = [
top_inc,
shared_inc
]
deps = [
dbus_dep,
dbus_glib_dep,
glib_dep,
libnm_glib_dep,
libnm_util_dep
libnm_util_dep,
shared_dep
]
test_units = [
......@@ -19,8 +14,7 @@ test_units = [
foreach test_unit: test_units
exe = executable(
test_unit,
[test_unit + '.c', libnm_utils_enum[1]] + shared_test_utils,
include_directories: incs,
[test_unit + '.c'] + shared_test_utils,
dependencies: deps,
c_args: common_cflags + [
'-DNETWORKMANAGER_COMPILATION_TEST',
......
......@@ -91,16 +91,11 @@ sources = shared_utils + files(
'nm-value-transforms.c'
)
incs = [
top_inc,
shared_inc
]
deps = [
crypto_dep,
dbus_dep,
dbus_glib_dep,
glib_dep,
shared_dep,
uuid_dep
]
......@@ -110,7 +105,7 @@ 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')
......@@ -124,7 +119,6 @@ libnm_util = shared_library(
'nm-util',
sources: sources + libnm_utils_enum,
version: libnm_util_version,
include_directories: incs,
dependencies: deps,
c_args: cflags,
link_args: ldflags,
......@@ -133,8 +127,9 @@ libnm_util = shared_library(
)
libnm_util_dep = declare_dependency(
link_with: libnm_util,
include_directories: libnm_util_inc
sources: libnm_utils_enum[1],
include_directories: libnm_util_inc,
link_with: libnm_util
)
pkg.generate(
......@@ -169,8 +164,8 @@ if enable_introspection
)
libnm_util_gir_dep = declare_dependency(
link_with: libnm_util,
sources: libnm_util_gir
sources: libnm_util_gir,
link_with: libnm_util
)
endif
......@@ -187,13 +182,12 @@ sources = files(
deps = [
crypto_dep,
glib_dep
shared_dep
]
libtest_crypto = static_library(
'test-crypto',
sources: sources,
include_directories: incs,
dependencies: deps,
c_args: cflags
)
......
incs = [
top_inc,
shared_inc
]
deps = [
dbus_dep,
dbus_glib_dep,
glib_dep,
libnm_util_dep
libnm_util_dep,
shared_dep
]
cflags = common_cflags + [
......@@ -20,8 +15,7 @@ test = 'test-libnm-linking'
test_libnm_linking = executable(
test,
[test + '.c', libnm_utils_enum[1]],
include_directories: incs,
test + '.c',
dependencies: deps + [libnm_dep],
c_args: cflags
)
......@@ -38,8 +32,7 @@ test_units = [
foreach test_unit: test_units
exe = executable(
'libnm-util-' + test_unit[0],
[test_unit[0] + '.c', libnm_utils_enum[1]],
include_directories: incs,
test_unit[0] + '.c',
dependencies: deps,
c_args: cflags,
link_with: test_unit[1],
......
......@@ -6,17 +6,11 @@ if have_fake_typelibs
subdir('fake-typelib')
endif
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
# FIXME: this makes GIR mandatory?
gir_dep,
glib_dep,
libnmdbus_dep
libnmdbus_dep,
shared_dep
]
cflags = [
......@@ -28,7 +22,7 @@ cflags = [
libnm_utils = static_library(
'nm-utils',
sources: sources,
include_directories: incs,
include_directories: libnm_core_inc,
dependencies: deps,
c_args: cflags
)
......@@ -145,8 +139,8 @@ libnm_sources = files(
deps = [
dl_dep,
glib_dep,
libudev_dep,
shared_dep,
uuid_dep
]
......@@ -161,7 +155,7 @@ libnm = shared_library(
'nm',
sources: libnm_sources + libnm_enum,
version: libnm_version,
include_directories: incs + [libnm_core_inc],
include_directories: libnm_core_inc,
dependencies: deps,
c_args: cflags,
link_with: libnm_utils,
......@@ -172,8 +166,9 @@ libnm = shared_library(
)
libnm_dep = declare_dependency(
link_with: libnm,
include_directories: libnm_inc
sources: libnm_enum[1],
include_directories: libnm_inc,
link_with: libnm
)
pkg.generate(
......
......@@ -6,15 +6,9 @@ test_units = [
#['test-secret-agent', shared_test_utils, []]
]
incs = [
top_inc,
shared_inc,
libnm_core_inc
]
deps = [
glib_dep,
libnm_dep
libnm_dep,
nm_core_dep
]
cflags = [
......@@ -27,7 +21,6 @@ foreach test_unit: test_units
exe = executable(
'libnm-' + test_unit[0],
[test_unit[0] + '.c'] + test_unit[1],
include_directories: incs,
dependencies: deps,
c_args: cflags,
link_with: test_unit[2]
......@@ -36,18 +29,11 @@ foreach test_unit: test_units
test(test_unit[0], exe)
endforeach
incs = [
top_inc,
shared_inc,
libnm_core_inc,
libnm_inc
]
# just test, that we can build "nm-vpn-plugin-utils.c"
libnm_vpn_plugin_utils_test = static_library(
'nm-vpn-plugin-utils-test',
sources: shared_vpn_plugin_utils + [libnm_enum[1]],
include_directories: incs,
dependencies: glib_dep,
c_args: cflags,
include_directories: libnm_inc,
dependencies: nm_core_dep,
c_args: cflags
)
shared_inc = include_directories(
'.',
'nm-utils'
)
shared_inc = include_directories('.')
version_conf = configuration_data()
version_conf.set('NM_MAJOR_VERSION', nm_major_version)
......@@ -37,3 +34,12 @@ shared_sources = shared_utils + shared_meta_setting + shared_udev_utils + files(
'nm-utils/c-list-util.c',
'nm-utils/nm-dedup-multi.c'
)
shared_dep = declare_dependency(
include_directories: [
top_inc,
shared_inc,
include_directories('nm-utils')
],
dependencies: glib_dep
)
......@@ -4,9 +4,9 @@ sources = files(
)
deps = [
core_dep,
libnmdbus_dep,
libudev_dep
libudev_dep,
nm_dep
]
ldflags = []
......
......@@ -9,9 +9,9 @@ sources = files(
)
deps = [
core_dep,
libnmdbus_dep,
libnm_wwan_dep,
libnmdbus_dep
nm_dep
]
ldflags = []
......
......@@ -7,13 +7,11 @@ sources = files(
)
deps = [
core_dep,
jansson_dep,
libnmdbus_dep
libnmdbus_dep,
nm_dep
]
cflags = '-DRUNSTATEDIR="@0@"'.format(nm_runstatedir)
ldflags = []
if have_version_script
ldflags += '-Wl,--version-script,@0@'.format(linker_script_devices)
......@@ -23,7 +21,7 @@ libnm_device_plugin_ovs = shared_module(
'nm-device-plugin-ovs',
sources: sources,
dependencies: deps,
c_args: cflags,
c_args: '-DRUNSTATEDIR="@0@"'.format(nm_runstatedir),
link_args: ldflags,
link_depends: linker_script_devices,
install: true,
......
......@@ -4,10 +4,10 @@ sources = files(
)
deps = [
core_dep,
jansson_dep,
libnmdbus_dep,