meson: Use string variables extensively

The strings holding the names used for libraries have also been
moved to different variables. This way they would be less error
as these variables can be reused easily and any typing error
would be quickly detected.
This commit is contained in:
Iñigo Martínez
2018-01-09 08:05:15 +01:00
committed by Thomas Haller
parent 5e16bcf268
commit 50930ed19a
14 changed files with 54 additions and 43 deletions

View File

@@ -1,3 +1,5 @@
name = 'nmcli'
# FIXME: nmcli-completion should be renamed to nmcli # FIXME: nmcli-completion should be renamed to nmcli
install_data( install_data(
'nmcli-completion', 'nmcli-completion',
@@ -25,7 +27,7 @@ deps = [
] ]
cflags = clients_cflags + [ cflags = clients_cflags + [
'-DG_LOG_DOMAIN="nmcli"', '-DG_LOG_DOMAIN="@0@"'.format(name),
'-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir) '-DNMCLI_LOCALEDIR="@0@"'.format(nm_localedir)
] ]
@@ -41,7 +43,7 @@ if enable_polkit_agent
endif endif
executable( executable(
'nmcli', name,
sources, sources,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,

View File

@@ -1,10 +1,12 @@
name = 'nmtui'
deps = [ deps = [
newt_dep, newt_dep,
nm_core_dep nm_core_dep
] ]
cflags = clients_cflags + [ cflags = clients_cflags + [
'-DG_LOG_DOMAIN="nmtui"', '-DG_LOG_DOMAIN="@0@"'.format(name),
'-DLOCALEDIR="@0@"'.format(nm_localedir) '-DLOCALEDIR="@0@"'.format(nm_localedir)
] ]
@@ -65,7 +67,7 @@ if have_version_script
endif endif
executable( executable(
'nmtui', name,
sources, sources,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,

View File

@@ -1,4 +1,4 @@
doc_module = 'NetworkManager' doc_module = nm_name
settings = 'settings-spec' settings = 'settings-spec'
output = settings + '.xml' output = settings + '.xml'

View File

@@ -1,4 +1,4 @@
doc_module = 'libnm-glib' doc_module = libnm_glib_name
private_headers = [ private_headers = [
'common.h', 'common.h',

View File

@@ -1,4 +1,4 @@
doc_module = 'libnm-util' doc_module = libnm_util_name
private_headers = [ private_headers = [
'crypto.h', 'crypto.h',

View File

@@ -1,4 +1,4 @@
doc_module = 'libnm' doc_module = libnm_name
private_headers = [ private_headers = [
'common.h', 'common.h',

View File

@@ -136,7 +136,7 @@ deps = [
] ]
cflags = [ cflags = [
'-DG_LOG_DOMAIN="libnm"', '-DG_LOG_DOMAIN="@0@"'.format(libnm_name),
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE',
'-DLIBEXECDIR="@0@"'.format(nm_libexecdir), '-DLIBEXECDIR="@0@"'.format(nm_libexecdir),
'-DLOCALEDIR="@0@"'.format(nm_localedir), '-DLOCALEDIR="@0@"'.format(nm_localedir),

View File

@@ -13,7 +13,7 @@ common_cflags = [
] ]
cflags = common_cflags + [ cflags = common_cflags + [
'-DG_LOG_DOMAIN="libnm-glib"' '-DG_LOG_DOMAIN="@0@"'.format(libnm_glib_name)
] ]
vpn_headers = files( vpn_headers = files(
@@ -57,7 +57,7 @@ deprecated_headers = files('libnm_glib.h')
install_headers( install_headers(
headers + vpn_headers + deprecated_headers, headers + vpn_headers + deprecated_headers,
subdir: 'libnm-glib' subdir: libnm_glib_name
) )
libdeprecated_nm_glib = static_library( libdeprecated_nm_glib = static_library(
@@ -126,10 +126,10 @@ libnm_glib_vpn_dep = declare_dependency(
pkg.generate( pkg.generate(
libraries: libnm_glib_vpn, libraries: libnm_glib_vpn,
version: nm_version, version: nm_version,
name: 'libnm-glib-vpn', name: libnm_glib_vpn_name,
description: 'Convenience library for NetworkManager VPN plugins', description: 'Convenience library for NetworkManager VPN plugins',
filebase: 'libnm-glib-vpn', filebase: libnm_glib_vpn_name,
subdirs: 'libnm-glib', subdirs: libnm_glib_name,
requires: 'NetworkManager >= ' + nm_version + ' glib-2.0 dbus-glib-1', requires: 'NetworkManager >= ' + nm_version + ' glib-2.0 dbus-glib-1',
variables: 'exec_prefix=${prefix}' variables: 'exec_prefix=${prefix}'
) )
@@ -222,10 +222,10 @@ libnm_glib_dep = declare_dependency(
pkg.generate( pkg.generate(
libraries: libnm_glib, libraries: libnm_glib,
version: nm_version, version: nm_version,
name: 'libnm-glib', name: libnm_glib_name,
description: 'Convenience library for clients of NetworkManager', description: 'Convenience library for clients of NetworkManager',
filebase: 'libnm-glib', filebase: libnm_glib_name,
subdirs: 'libnm-glib', subdirs: libnm_glib_name,
requires: 'libnm-util >= ' + nm_version + ' NetworkManager >= ' + nm_version + ' gobject-2.0 dbus-glib-1', requires: 'libnm-util >= ' + nm_version + ' NetworkManager >= ' + nm_version + ' gobject-2.0 dbus-glib-1',
variables: 'exec_prefix=${prefix}' variables: 'exec_prefix=${prefix}'
) )
@@ -252,7 +252,7 @@ if enable_introspection
namespace: 'NMClient', namespace: 'NMClient',
identifier_prefix: nm_id_prefix, identifier_prefix: nm_id_prefix,
symbol_prefix: nm_id_prefix.to_lower(), symbol_prefix: nm_id_prefix.to_lower(),
export_packages: ['libnm-glib', 'libnm-glib-vpn'], export_packages: [libnm_glib_name, libnm_glib_vpn_name],
includes: gir_includes, includes: gir_includes,
extra_args: cflags + [ extra_args: cflags + [
'--include-uninstalled=' + libnm_util_gir[0].full_path(), '--include-uninstalled=' + libnm_util_gir[0].full_path(),
@@ -261,7 +261,7 @@ if enable_introspection
) )
endif endif
name = 'libnm-glib-test' name = libnm_glib_name + '-test'
deps = common_deps + [libnm_util_dep] deps = common_deps + [libnm_util_dep]
@@ -274,7 +274,7 @@ executable(
) )
run_target( run_target(
'check-local-exports-libnm-glib', 'check-local-exports-' + libnm_glib_name,
command: [check_exports, libnm_glib.full_path(), symbol_map], command: [check_exports, libnm_glib.full_path(), symbol_map],
depends: libnm_glib depends: libnm_glib
) )

View File

@@ -105,7 +105,7 @@ common_cflags = [
] ]
cflags = common_cflags + [ cflags = common_cflags + [
'-DG_LOG_DOMAIN="libnm-util"' '-DG_LOG_DOMAIN="@0@"'.format(libnm_util_name)
] ]
symbol_map = join_paths(meson.current_source_dir(), 'libnm-util.ver') symbol_map = join_paths(meson.current_source_dir(), 'libnm-util.ver')
@@ -135,9 +135,9 @@ libnm_util_dep = declare_dependency(
pkg.generate( pkg.generate(
libraries: libnm_util, libraries: libnm_util,
version: nm_version, version: nm_version,
name: 'libnm-util', name: libnm_util_name,
description: 'Convenience library for clients of NetworkManager', description: 'Convenience library for clients of NetworkManager',
filebase: 'libnm-util', filebase: libnm_util_name,
subdirs: nm_name, subdirs: nm_name,
requires: 'NetworkManager >= ' + nm_version + ' glib-2.0 dbus-glib-1', requires: 'NetworkManager >= ' + nm_version + ' glib-2.0 dbus-glib-1',
variables: 'exec_prefix=${prefix}' variables: 'exec_prefix=${prefix}'
@@ -158,7 +158,7 @@ if enable_introspection
namespace: nm_name, namespace: nm_name,
identifier_prefix: nm_id_prefix, identifier_prefix: nm_id_prefix,
symbol_prefix: nm_id_prefix.to_lower(), symbol_prefix: nm_id_prefix.to_lower(),
export_packages: 'libnm-util', export_packages: libnm_util_name,
includes: gir_includes, includes: gir_includes,
install: true install: true
) )
@@ -170,7 +170,7 @@ if enable_introspection
endif endif
run_target( run_target(
'check-local-exports-libnm-util', 'check-local-exports-' + libnm_util_name,
command: [check_exports, libnm_util.full_path(), symbol_map], command: [check_exports, libnm_util.full_path(), symbol_map],
depends: libnm_util depends: libnm_util
) )

View File

@@ -14,7 +14,7 @@ deps = [
] ]
cflags = [ cflags = [
'-DG_LOG_DOMAIN="libnm"', '-DG_LOG_DOMAIN="@0@"'.format(libnm_name),
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM', '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM',
'-DNMRUNDIR="@0@"'.format(nm_pkgrundir) '-DNMRUNDIR="@0@"'.format(nm_pkgrundir)
] ]
@@ -72,7 +72,7 @@ libnm_headers = files(
install_headers( install_headers(
libnm_core_headers + libnm_headers + [version_header], libnm_core_headers + libnm_headers + [version_header],
subdir: 'libnm' subdir: libnm_name
) )
enum_headers = libnm_headers + [version_header] enum_headers = libnm_headers + [version_header]
@@ -174,10 +174,10 @@ libnm_dep = declare_dependency(
pkg.generate( pkg.generate(
libraries: libnm, libraries: libnm,
version: nm_version, version: nm_version,
name: 'libnm', name: libnm_name,
description: 'Convenience library for clients of NetworkManager', description: 'Convenience library for clients of NetworkManager',
filebase: 'libnm', filebase: libnm_name,
subdirs: 'libnm', subdirs: libnm_name,
requires: 'gio-2.0', requires: 'gio-2.0',
variables: [ variables: [
'exec_prefix=${prefix}', 'exec_prefix=${prefix}',
@@ -186,7 +186,7 @@ pkg.generate(
) )
run_target( run_target(
'check-local-exports-libnm', 'check-local-exports-' + libnm_name,
command: [check_exports, libnm.full_path(), symbol_map], command: [check_exports, libnm.full_path(), symbol_map],
depends: libnm depends: libnm
) )
@@ -201,7 +201,7 @@ if enable_introspection
namespace: 'NM', namespace: 'NM',
identifier_prefix: nm_id_prefix, identifier_prefix: nm_id_prefix,
symbol_prefix: nm_id_prefix.to_lower(), symbol_prefix: nm_id_prefix.to_lower(),
export_packages: 'libnm', export_packages: libnm_name,
includes: 'Gio-2.0', includes: 'Gio-2.0',
extra_args: cflags, extra_args: cflags,
install: true install: true

View File

@@ -42,24 +42,31 @@ nm_pkglibdir = join_paths(nm_libdir, nm_name)
nm_pkgrundir = join_paths(nm_runstatedir, nm_name) nm_pkgrundir = join_paths(nm_runstatedir, nm_name)
nm_pkgstatedir = join_paths(nm_localstatedir, nm_name) nm_pkgstatedir = join_paths(nm_localstatedir, nm_name)
libnm_name = 'libnm'
current = 1 current = 1
revision = 0 revision = 0
age = 1 age = 1
libnm_version = '@0@.@1@.@2@'.format(current - age, age, revision) libnm_version = '@0@.@1@.@2@'.format(current - age, age, revision)
libnm_pkgincludedir = join_paths(nm_includedir, 'libnm') libnm_pkgincludedir = join_paths(nm_includedir, libnm_name)
libnm_util_name = 'libnm-util'
current = 9 current = 9
revision = 0 revision = 0
age = 7 age = 7
libnm_util_version = '@0@.@1@.@2@'.format(current - age, age, revision) libnm_util_version = '@0@.@1@.@2@'.format(current - age, age, revision)
libnm_glib_name = 'libnm-glib'
libnm_glib_vpn_name = libnm_glib_name + '-vpn'
current = 13 current = 13
revision = 0 revision = 0
age = 9 age = 9
libnm_glib_version = '@0@.@1@.@2@'.format(current - age, age, revision) libnm_glib_version = '@0@.@1@.@2@'.format(current - age, age, revision)
libnm_glib_pkgincludedir = join_paths(nm_includedir, 'libnm-glib') libnm_glib_pkgincludedir = join_paths(nm_includedir, libnm_glib_name)
current = 3 current = 3
revision = 0 revision = 0

View File

@@ -83,7 +83,7 @@ if enable_wext
endif endif
libnetwork_manager_base = static_library( libnetwork_manager_base = static_library(
'NetworkManagerBase', nm_name + 'Base',
sources: sources, sources: sources,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
@@ -200,7 +200,7 @@ if enable_session_tracking
endif endif
libnetwork_manager = static_library( libnetwork_manager = static_library(
'NetworkManager', nm_name,
sources: sources, sources: sources,
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
@@ -238,7 +238,7 @@ endif
''' '''
network_manager = executable( network_manager = executable(
meson.project_name(), nm_name,
'main.c', 'main.c',
dependencies: deps, dependencies: deps,
c_args: cflags, c_args: cflags,
@@ -298,7 +298,7 @@ if enable_tests
test_cflags_platform = '-DSETUP=nm_' + platform + '_platform_setup' test_cflags_platform = '-DSETUP=nm_' + platform + '_platform_setup'
libnetwork_manager_test = static_library( libnetwork_manager_test = static_library(
'NetworkManagerTest', nm_name + 'Test',
sources: sources, sources: sources,
dependencies: deps, dependencies: deps,
c_args: cflags + test_cflags, c_args: cflags + test_cflags,

View File

@@ -12,7 +12,7 @@ nm_pppd_plugin = shared_module(
include_directories: src_inc, include_directories: src_inc,
dependencies: deps, dependencies: deps,
c_args: [ c_args: [
'-DG_LOG_DOMAIN="nm-pppd-plugin"', '-DG_LOG_DOMAIN="@0@"'.format(name),
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_GLIB', '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_GLIB',
], ],
install: true, install: true,
@@ -26,7 +26,7 @@ deps = [
nm_dep nm_dep
] ]
symbol_map = join_paths(meson.current_source_dir(), name + '.ver') symbol_map = join_paths(meson.current_source_dir(), 'nm-ppp-plugin.ver')
ldflags = [] ldflags = []
if have_version_script if have_version_script

View File

@@ -1,5 +1,5 @@
gnome.generate_vapi( gnome.generate_vapi(
'libnm', libnm_name,
sources: libnm_gir[0], sources: libnm_gir[0],
packages: 'gio-2.0', packages: 'gio-2.0',
install: true install: true
@@ -12,7 +12,7 @@ if enable_libnm_glib
] ]
libnm_util_vapi = gnome.generate_vapi( libnm_util_vapi = gnome.generate_vapi(
'libnm-util', libnm_util_name,
sources: libnm_util_gir[0], sources: libnm_util_gir[0],
packages: packages, packages: packages,
install: true install: true
@@ -21,7 +21,7 @@ if enable_libnm_glib
packages += libnm_util_vapi packages += libnm_util_vapi
gnome.generate_vapi( gnome.generate_vapi(
'libnm-glib', libnm_glib_name,
sources: libnm_glib_gir[0], sources: libnm_glib_gir[0],
packages: packages, packages: packages,
install: true install: true