diff options
author | Thomas Haller <thaller@redhat.com> | 2018-12-28 21:30:03 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-01-02 11:55:46 +0100 |
commit | d6738c387b4d82c4a0c6f6fb1a46fbbbdac9aa3c (patch) | |
tree | 6a4db31c56a7c74a922054c860025475b4d1b89f | |
parent | 488e3541778f7997e4dd7f80518a21b22c97d144 (diff) | |
download | NetworkManager-th/shared-systemd.tar.gz |
libnm: use "libnm-systemd-shared.a" in "libnm-core.la" (and "libnm.so")th/shared-systemd
It's not yet used, but it will be. We will need nm_sd_utils_unbase64mem()
to validate WireGuard settings, which contain keys in base64 encoding.
Note that we also need a stub implementation for logging. This just
does nothing for all logging from "libnm-systemd-shared.a". This makes
sense because "libnm.so" as a library should not log directly. Also,
"libnm.so" will only use a small portion of "libnm-systemd-shared.a" which
does not log. Thus this code is anyway unused and dropped by the linker
with "--gc-sections".
-rw-r--r-- | Makefile.am | 23 | ||||
-rw-r--r-- | libnm-core/meson.build | 1 | ||||
-rw-r--r-- | libnm-core/tests/meson.build | 5 | ||||
-rw-r--r-- | libnm/meson.build | 1 | ||||
-rw-r--r-- | libnm/tests/meson.build | 1 | ||||
-rw-r--r-- | shared/meson.build | 25 | ||||
-rw-r--r-- | shared/systemd/nm-logging-stub.c | 45 | ||||
-rw-r--r-- | src/systemd/meson.build | 1 |
8 files changed, 100 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index 4685fbda24..c8a5ed0617 100644 --- a/Makefile.am +++ b/Makefile.am @@ -940,6 +940,8 @@ nodist_libnm_core_tests_test_general_SOURCES = \ libnm_core_tests_ldadd = \ libnm-core/libnm-core.la \ + shared/systemd/libnm-systemd-shared.la \ + shared/systemd/libnm-systemd-logging-stub.la \ shared/nm-utils/libnm-utils-base.la \ $(libnm_crypto_lib) \ $(GLIB_LIBS) @@ -1191,6 +1193,8 @@ EXTRA_libnm_libnm_la_DEPENDENCIES = \ libnm_libnm_la_LIBADD = \ libnm/libnm-utils.la \ + shared/systemd/libnm-systemd-shared.la \ + shared/systemd/libnm-systemd-logging-stub.la \ shared/nm-utils/libnm-utils-udev.la \ $(DL_LIBS) \ $(GLIB_LIBS) \ @@ -1357,6 +1361,8 @@ libnm_tests_cppflags = \ libnm_tests_ldadd = \ libnm/libnm.la \ + shared/systemd/libnm-systemd-shared.la \ + shared/systemd/libnm-systemd-logging-stub.la \ $(GLIB_LIBS) libnm_tests_ldflags = \ @@ -1517,6 +1523,22 @@ libsystemd_libadd = \ $(CODE_COVERAGE_LDFLAGS) \ $(NULL) +noinst_LTLIBRARIES += shared/systemd/libnm-systemd-logging-stub.la + +shared_systemd_libnm_systemd_logging_stub_la_CPPFLAGS = \ + $(libsystemd_cppflags) \ + -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD_SHARED \ + -DG_LOG_DOMAIN=\""libnm"\" \ + $(NULL) + +shared_systemd_libnm_systemd_logging_stub_la_SOURCES = \ + shared/systemd/nm-logging-stub.c \ + $(NULL) + +shared_systemd_libnm_systemd_logging_stub_la_LIBADD = \ + $(libsystemd_libadd) \ + $(NULL) + noinst_LTLIBRARIES += shared/systemd/libnm-systemd-shared.la shared_systemd_libnm_systemd_shared_la_CPPFLAGS = \ @@ -2105,6 +2127,7 @@ src_initrd_nm_initrd_generator_LDADD = \ libnm-core/libnm-core.la \ src/initrd/libnmi-core.la \ src/libNetworkManagerBase.la \ + shared/systemd/libnm-systemd-shared.la \ shared/nm-utils/libnm-utils-base.la \ $(GLIB_LIBS) \ $(NULL) diff --git a/libnm-core/meson.build b/libnm-core/meson.build index 84f72cbe83..812f12bbcc 100644 --- a/libnm-core/meson.build +++ b/libnm-core/meson.build @@ -200,6 +200,7 @@ nm_core_dep = declare_dependency( dependencies: [ shared_dep, shared_c_siphash_dep, + libnm_systemd_shared_dep, ], ) diff --git a/libnm-core/tests/meson.build b/libnm-core/tests/meson.build index 265200a696..b941107432 100644 --- a/libnm-core/tests/meson.build +++ b/libnm-core/tests/meson.build @@ -33,7 +33,10 @@ foreach test_unit: test_units exe = executable( 'libnm-core-' + test_unit, [test_unit + '.c'] + enum, - dependencies: nm_core_dep, + dependencies: [ + nm_core_dep, + libnm_systemd_shared_no_logging_dep, + ], c_args: [ '-DNETWORKMANAGER_COMPILATION_TEST', '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE', diff --git a/libnm/meson.build b/libnm/meson.build index 64df4674b4..2e44a6a49b 100644 --- a/libnm/meson.build +++ b/libnm/meson.build @@ -147,6 +147,7 @@ deps = [ libudev_dep, shared_dep, uuid_dep, + libnm_systemd_shared_no_logging_dep, ] linker_script = join_paths(meson.current_source_dir(), 'libnm.ver') diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build index 16aafa60e9..d0a2dd306e 100644 --- a/libnm/tests/meson.build +++ b/libnm/tests/meson.build @@ -20,6 +20,7 @@ foreach test_unit: test_units dependencies: [ libnm_dep, nm_core_dep, + libnm_systemd_shared_no_logging_dep, ], c_args: cflags, link_with: test_unit[1], diff --git a/shared/meson.build b/shared/meson.build index 76f09ee8c0..54ef3a2e31 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -207,3 +207,28 @@ libnm_systemd_shared_dep = declare_dependency( libnm_systemd_shared, ], ) + +libnm_systemd_logging_stub = static_library( + 'nm-systemd-logging-stub', + sources: files( + 'systemd/nm-logging-stub.c', + ), + include_directories: include_directories( + 'systemd/sd-adapt-shared', + 'systemd/src/basic', + ), + dependencies: shared_dep, + c_args: [ + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_SYSTEMD_SHARED', + '-DG_LOG_DOMAIN="libnm"', + ], +) + +libnm_systemd_shared_no_logging_dep = declare_dependency( + dependencies: [ + libnm_systemd_shared_dep, + ], + link_with: [ + libnm_systemd_logging_stub, + ], +) diff --git a/shared/systemd/nm-logging-stub.c b/shared/systemd/nm-logging-stub.c new file mode 100644 index 0000000000..80d4360783 --- /dev/null +++ b/shared/systemd/nm-logging-stub.c @@ -0,0 +1,45 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright 2018 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-utils/nm-logging-fwd.h" + +/*****************************************************************************/ + +gboolean +_nm_log_enabled (NMLogLevel level, + NMLogDomain domain) +{ + return FALSE; +} + +void +_nm_log_impl (const char *file, + guint line, + const char *func, + NMLogLevel level, + NMLogDomain domain, + int error, + const char *ifname, + const char *con_uuid, + const char *fmt, + ...) +{ +} diff --git a/src/systemd/meson.build b/src/systemd/meson.build index 7619783490..9dea4fb593 100644 --- a/src/systemd/meson.build +++ b/src/systemd/meson.build @@ -38,7 +38,6 @@ libnm_systemd_core = static_library( ) ], dependencies: [ - libnm_systemd_shared_dep, nm_core_dep, ], c_args: [ |