diff --git a/.gitignore b/.gitignore index 3bcb240e9..bb2b8e6be 100644 --- a/.gitignore +++ b/.gitignore @@ -145,6 +145,8 @@ test-*.trs /src/libnm-core-impl/tests/test-need-secrets /src/libnm-core-impl/tests/test-secrets /src/libnm-core-impl/tests/test-setting +/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core +/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml /src/libnm-glib-aux/tests/test-json-aux /src/libnm-glib-aux/tests/test-shared-general /src/libnm-platform/tests/test-nm-platform diff --git a/Makefile.am b/Makefile.am index 04d394afa..8e60a5f5b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1848,6 +1848,39 @@ EXTRA_DIST += src/libnm-client-public/meson.build ############################################################################### +noinst_PROGRAMS += src/libnm-core-impl/gen-metadata-nm-settings-libnm-core + +src_libnm_core_impl_gen_metadata_nm_settings_libnm_core_SOURCES = \ + src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.c \ + $(NULL) + +src_libnm_core_impl_gen_metadata_nm_settings_libnm_core_CPPFLAGS = \ + $(clients_cppflags) \ + $(NULL) + +src_libnm_core_impl_gen_metadata_nm_settings_libnm_core_LDADD = \ + src/libnm-core-impl/libnm-core-impl.la \ + src/libnm-crypto/libnm-crypto.la \ + $(libnm_crypto_lib) \ + src/libnm-core-aux-intern/libnm-core-aux-intern.la \ + src/libnm-base/libnm-base.la \ + src/libnm-systemd-shared/libnm-systemd-shared.la \ + src/libnm-log-null/libnm-log-null.la \ + src/libnm-glib-aux/libnm-glib-aux.la \ + src/libnm-std-aux/libnm-std-aux.la \ + src/c-siphash/libc-siphash.la \ + $(GLIB_LIBS) \ + $(NULL) + +src_libnm_core_impl_gen_metadata_nm_settings_libnm_core_LDFLAGS = \ + -Wl,--version-script="$(srcdir)/linker-script-binary.ver" \ + $(SANITIZER_EXEC_LDFLAGS) \ + $(NULL) + +$(src_libnm_core_impl_gen_metadata_nm_settings_libnm_core_OBJECTS): $(src_libnm_core_public_mkenums_h) + +############################################################################### + noinst_LTLIBRARIES += src/libnm-client-impl/libnm-client-impl.la src_libnm_client_impl_libnm_client_impl_la_CPPFLAGS = \ @@ -1982,6 +2015,7 @@ src/libnm-client-impl/libnm.typelib: src/libnm-client-impl/libnm.gir INTROSPECTION_GIRS += src/libnm-client-impl/NM-1.0.gir libnm_noinst_data = \ + src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml \ src/nmcli/gen-metadata-nm-settings-nmcli.xml \ man/nm-settings-docs-dbus.xml \ man/nm-settings-docs-nmcli.xml \ @@ -2010,6 +2044,21 @@ src/nmcli/gen-metadata-nm-settings-nmcli.xml: src/nmcli/gen-metadata-nm-settings check-local-gen-metadata-nm-settings-nmcli: endif +EXTRA_DIST += src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in + +if BUILD_DOCS +src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml: src/libnm-core-impl/gen-metadata-nm-settings-libnm-core + $(AM_V_GEN) src/libnm-core-impl/gen-metadata-nm-settings-libnm-core > "$@" +check-local-gen-metadata-nm-settings-libnm-core: src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml + $(srcdir)/tools/check-compare-generated.sh "$(srcdir)/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in" "$(builddir)/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml" +check_local += check-local-gen-metadata-nm-settings-libnm-core +DISTCLEANFILES += src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml +else +src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml: src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in + $(AM_V_GEN) cp $^ $@ +check-local-gen-metadata-nm-settings-libnm-core: +endif + libnm_docs_sources = $(src_libnm_core_impl_lib_c_settings_real) src/libnm-client-impl/nm-property-infos-%.xml: tools/generate-docs-nm-property-infos.py src/libnm-core-impl/libnm-core-impl.la $(libnm_docs_sources) diff --git a/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.c b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.c new file mode 100644 index 000000000..eeadb19c3 --- /dev/null +++ b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.c @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +#include "libnm-core-impl/nm-default-libnm-core.h" + +#include "libnm-core-intern/nm-meta-setting-base.h" +#include "libnm-core-intern/nm-core-internal.h" + +#define INDENT 4 + +static char * +_xml_escape_attribute(const char *value) +{ + gs_free char *s = NULL; + + s = g_markup_escape_text(value, -1); + return g_strdup_printf("\"%s\"", s); +} + +static const char * +_indent_level(guint num_spaces) +{ + static const char spaces[] = " "; + + nm_assert(num_spaces < G_N_ELEMENTS(spaces)); + return &spaces[G_N_ELEMENTS(spaces) - num_spaces - 1]; +} + +int +main(int argc, char *argv[]) +{ + const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings(); + NMMetaSettingType meta_type; + + g_print("\n"); + for (meta_type = 0; meta_type < _NM_META_SETTING_TYPE_NUM; meta_type++) { + const NMSettInfoSetting *sis = &sett_info_settings[meta_type]; + const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; + nm_auto_unref_gtypeclass NMSettingClass *klass = NULL; + gs_free char *tmp_s1 = NULL; + gs_free char *tmp_s2 = NULL; + guint prop_idx; + GType gtype; + + gtype = msi->get_setting_gtype(); + klass = g_type_class_ref(gtype); + + g_print("%ssetting_name))); + g_print(" >\n"); + + for (prop_idx = 0; prop_idx < sis->property_infos_len; prop_idx++) { + const NMSettInfoProperty *sip = &sis->property_infos[prop_idx]; + gs_free char *tmp2 = NULL; + gs_free char *tmp3 = NULL; + + g_print("%sname))); + if (sip->is_deprecated) + g_print("\n%sis-deprecated=\"1\"", _indent_level(2 * INDENT + 10)); + if (sip->property_type->dbus_type) { + g_print( + "\n%sdbus-type=%s", + _indent_level(2 * INDENT + 10), + (tmp3 = _xml_escape_attribute((const char *) sip->property_type->dbus_type))); + } + if (sip->dbus_deprecated) { + nm_assert(sip->property_type->dbus_type); + g_print("\n%sdbus-deprecated=\"1\"", _indent_level(2 * INDENT + 10)); + } + g_print(" />\n"); + } + + g_print("%s\n", _indent_level(INDENT)); + } + g_print("\n"); + return 0; +} diff --git a/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in new file mode 100644 index 000000000..dfda03ac0 --- /dev/null +++ b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in @@ -0,0 +1,1135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libnm-core-impl/meson.build b/src/libnm-core-impl/meson.build index 83c290857..2de3ff084 100644 --- a/src/libnm-core-impl/meson.build +++ b/src/libnm-core-impl/meson.build @@ -88,3 +88,52 @@ libnm_core_impl = static_library( uuid_dep, ], ) + +############################################################################### + +gen_metadata_nm_settings_libnm_core = executable( + 'gen-metadata-nm-settings-libnm-core', + files( + 'gen-metadata-nm-settings-libnm-core.c', + ), + dependencies: [ + libnm_core_public_dep, + ], + link_with: [ + libnm_core_aux_intern, + libnm_core_impl, + libnm_crypto, + libnm_base, + libnm_systemd_shared, + libnm_log_null, + libnm_glib_aux, + libnm_std_aux, + libc_siphash, + ], + link_args: ldflags_linker_script_binary, + link_depends: linker_script_binary, +) + +if enable_docs + gen_metadata_nm_settings_libnm_core_xml = custom_target( + 'gen-metadata-nm-settings-libnm-core.xml', + output: 'gen-metadata-nm-settings-libnm-core.xml', + command: [ gen_metadata_nm_settings_libnm_core ], + capture: true, + ) + + test( + 'check-local-gen-metadata-nm-settings-libnm-core', + find_program(join_paths(source_root, 'tools', 'check-compare-generated.sh')), + args: [ + source_root + '/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in', + gen_metadata_nm_settings_libnm_core_xml, + ], + ) +else + gen_metadata_nm_settings_libnm_core_xml = configure_file( + input: 'gen-metadata-nm-settings-libnm-core.xml.in', + output: '@BASENAME@', + configuration: configuration_data(), + ) +endif