From 3814467b88afa64733f445ebb013619223a72657 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 1 Jul 2020 17:58:44 +0200 Subject: [PATCH] libnm,shared: move nm-json.[hc] to shared/nm-glib-aux nm-json.[hc] uses libjansson, but only loads it at runtime with dlopen. There is no more run compile time dependency. Move it to shared, so that it can be (theoretically) used by other components. Also, drop the conditional compilation. Granted, if you don't build with libjansson enabled, then the JANSSON_SONAME define is unset and the code will fail to load at runtime (which is fine). However, we can still build against our JSON wrappers. The code savings of conditional build are minimal so drop it. --- Makefile.am | 14 ++------------ libnm-core/meson.build | 6 ------ libnm-core/nm-team-utils.c | 2 +- libnm-core/nm-utils.c | 5 +---- shared/meson.build | 1 + {libnm-core => shared/nm-glib-aux}/nm-json.c | 0 {libnm-core => shared/nm-glib-aux}/nm-json.h | 0 7 files changed, 5 insertions(+), 23 deletions(-) rename {libnm-core => shared/nm-glib-aux}/nm-json.c (100%) rename {libnm-core => shared/nm-glib-aux}/nm-json.h (100%) diff --git a/Makefile.am b/Makefile.am index e6d55b0bc1..7f694d755a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -403,6 +403,8 @@ shared_nm_glib_aux_libnm_glib_aux_la_SOURCES = \ shared/nm-glib-aux/nm-jansson.h \ shared/nm-glib-aux/nm-json-aux.c \ shared/nm-glib-aux/nm-json-aux.h \ + shared/nm-glib-aux/nm-json.c \ + shared/nm-glib-aux/nm-json.h \ shared/nm-glib-aux/nm-keyfile-aux.c \ shared/nm-glib-aux/nm-keyfile-aux.h \ shared/nm-glib-aux/nm-logging-base.c \ @@ -1031,13 +1033,6 @@ libnm_core_lib_c_real = \ libnm-core/nm-vpn-plugin-info.c \ $(NULL) -if WITH_JSON_VALIDATION -libnm_core_lib_h_priv += \ - libnm-core/nm-json.h -libnm_core_lib_c_real += \ - libnm-core/nm-json.c -endif - libnm_core_lib_c_mkenums = \ libnm-core/nm-core-enum-types.c @@ -1092,11 +1087,6 @@ libnm_core_libnm_core_la_CPPFLAGS = \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE \ $(NULL) -if WITH_JSON_VALIDATION -libnm_core_libnm_core_la_CPPFLAGS += $(JANSSON_CFLAGS) -libnm_core_libnm_core_la_CPPFLAGS += -fcommon -endif - libnm_core_libnm_core_la_SOURCES = \ $(libnm_core_lib_h_pub_real) \ $(libnm_core_lib_h_priv) \ diff --git a/libnm-core/meson.build b/libnm-core/meson.build index 89acaf72ad..0509deaa54 100644 --- a/libnm-core/meson.build +++ b/libnm-core/meson.build @@ -196,12 +196,6 @@ links = [ libnm_core_c_args = common_c_flags -if enable_json_validation - libnm_core_sources += files('nm-json.c') - deps += jansson_dep - libnm_core_c_args += ['-fcommon'] -endif - libnm_core = static_library( 'nm-core', sources: libnm_core_sources + libnm_core_enum_sources + nm_meta_setting_source + [nm_version_macro_header], diff --git a/libnm-core/nm-team-utils.c b/libnm-core/nm-team-utils.c index 758766a251..1e0ddc79c8 100644 --- a/libnm-core/nm-team-utils.c +++ b/libnm-core/nm-team-utils.c @@ -11,7 +11,7 @@ #include "nm-errors.h" #include "nm-utils-private.h" -#include "nm-json.h" +#include "nm-glib-aux/nm-json.h" #include "nm-glib-aux/nm-json-aux.h" #include "nm-core-internal.h" #include "nm-setting-team.h" diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index f188ec8250..d04dca5596 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -16,10 +16,7 @@ #include #include -#if WITH_JSON_VALIDATION -#include "nm-json.h" -#endif - +#include "nm-glib-aux/nm-json.h" #include "nm-glib-aux/nm-str-buf.h" #include "nm-glib-aux/nm-enum-utils.h" #include "nm-glib-aux/nm-time-utils.h" diff --git a/shared/meson.build b/shared/meson.build index 0f46a00cbb..0041c5cba3 100644 --- a/shared/meson.build +++ b/shared/meson.build @@ -134,6 +134,7 @@ sources = files( 'nm-glib-aux/nm-hash-utils.c', 'nm-glib-aux/nm-io-utils.c', 'nm-glib-aux/nm-json-aux.c', + 'nm-glib-aux/nm-json.c', 'nm-glib-aux/nm-keyfile-aux.c', 'nm-glib-aux/nm-logging-base.c', 'nm-glib-aux/nm-random-utils.c', diff --git a/libnm-core/nm-json.c b/shared/nm-glib-aux/nm-json.c similarity index 100% rename from libnm-core/nm-json.c rename to shared/nm-glib-aux/nm-json.c diff --git a/libnm-core/nm-json.h b/shared/nm-glib-aux/nm-json.h similarity index 100% rename from libnm-core/nm-json.h rename to shared/nm-glib-aux/nm-json.h