From d0f1e68b3ef837140e8eafdb6c62069daf84fe57 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 17 Mar 2019 12:12:30 +0100 Subject: [PATCH] shared: add "shared/nm-libnm-core-utils.h" utils We have code in "shared/nm-utils" which are general purpose helpers, independent of "libnm", "libnm-core", "clients" and "src". We have shared code like "shared/nm-ethtool-utils.h" and "shared/nm-meta-setting.h", which is statically linked, shared code that contains libnm related helpers. But these helpers already have a specific use (e.g. they are related to ethtool or NMSetting metadata). Add a general purpose helper that: - depends (and extends) libnm-core - contains unrelated helpers - can be shared (meaning it will be statically linked). - this code can be used by any library user of "libnm.so" (nmcli, nm-applet) and by "libnm-core" itself. Thus, "src/" and "libnm/" may also use this code indirectly, via "libnm-core/". --- Makefile.am | 4 ++++ clients/common/meson.build | 2 +- libnm-core/meson.build | 1 + shared/meson.build | 2 ++ shared/nm-libnm-core-utils.c | 22 ++++++++++++++++++++++ shared/nm-libnm-core-utils.h | 23 +++++++++++++++++++++++ 6 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 shared/nm-libnm-core-utils.c create mode 100644 shared/nm-libnm-core-utils.h diff --git a/Makefile.am b/Makefile.am index 21c43884b7..a8353656da 100644 --- a/Makefile.am +++ b/Makefile.am @@ -669,6 +669,7 @@ libnm_core_lib_h_pub_mkenums = \ libnm-core/nm-core-enum-types.h libnm_core_lib_h_priv = \ shared/nm-ethtool-utils.h \ + shared/nm-libnm-core-utils.h \ shared/nm-meta-setting.h \ libnm-core/nm-crypto.h \ libnm-core/nm-crypto-impl.h \ @@ -731,6 +732,7 @@ libnm_core_lib_c_settings_real = \ libnm_core_lib_c_real = \ $(libnm_core_lib_c_settings_real) \ shared/nm-ethtool-utils.c \ + shared/nm-libnm-core-utils.c \ shared/nm-meta-setting.c \ libnm-core/nm-crypto.c \ libnm-core/nm-connection.c \ @@ -3914,6 +3916,8 @@ clients_common_libnmc_la_SOURCES = \ \ shared/nm-ethtool-utils.c \ shared/nm-ethtool-utils.h \ + shared/nm-libnm-core-utils.c \ + shared/nm-libnm-core-utils.h \ \ clients/common/nm-meta-setting-desc.c \ clients/common/nm-meta-setting-desc.h \ diff --git a/clients/common/meson.build b/clients/common/meson.build index b4b6bcacd3..c137d4463e 100644 --- a/clients/common/meson.build +++ b/clients/common/meson.build @@ -55,7 +55,7 @@ libnmc = static_library( sources: files( 'nm-meta-setting-access.c', 'nm-meta-setting-desc.c', - ) + shared_nm_meta_setting_c + shared_nm_ethtool_utils_c + [settings_docs_source], + ) + shared_nm_meta_setting_c + shared_nm_ethtool_utils_c + shared_nm_libnm_core_utils_c + [settings_docs_source], dependencies: deps, c_args: cflags, link_with: libnmc_base, diff --git a/libnm-core/meson.build b/libnm-core/meson.build index d10dd1c551..beee290e78 100644 --- a/libnm-core/meson.build +++ b/libnm-core/meson.build @@ -189,6 +189,7 @@ libnm_core_sources_all = libnm_core_sources libnm_core_sources_all += libnm_core_enum libnm_core_sources_all += shared_nm_meta_setting_c libnm_core_sources_all += shared_nm_ethtool_utils_c +libnm_core_sources_all += shared_nm_libnm_core_utils_c libnm_core_sources_all += [version_header] libnm_core = static_library( diff --git a/shared/meson.build b/shared/meson.build index a6e94d6b88..f9d9e62bff 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -75,6 +75,8 @@ version_header = configure_file( shared_nm_ethtool_utils_c = files('nm-ethtool-utils.c') +shared_nm_libnm_core_utils_c = files('nm-libnm-core-utils.c') + shared_nm_meta_setting_c = files('nm-meta-setting.c') shared_nm_test_utils_impl_c = files('nm-test-utils-impl.c') diff --git a/shared/nm-libnm-core-utils.c b/shared/nm-libnm-core-utils.c new file mode 100644 index 0000000000..244b318d72 --- /dev/null +++ b/shared/nm-libnm-core-utils.c @@ -0,0 +1,22 @@ +/* + * 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. + */ + +#include "nm-default.h" + +#include "nm-libnm-core-utils.h" + +/*****************************************************************************/ diff --git a/shared/nm-libnm-core-utils.h b/shared/nm-libnm-core-utils.h new file mode 100644 index 0000000000..fcdd425a54 --- /dev/null +++ b/shared/nm-libnm-core-utils.h @@ -0,0 +1,23 @@ +/* + * 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. + */ + +#ifndef __NM_LIBNM_SHARED_UTILS_H__ +#define __NM_LIBNM_SHARED_UTILS_H__ + +/****************************************************************************/ + +#endif /* __NM_LIBNM_SHARED_UTILS_H__ */