libnm: generate "gen-metadata-nm-settings-libnm-core.xml" with meta data
libnm-core-impl has lots of internal meta data about the properties. In particular, which properties exist (their names), and their D-Bus type. We should use this information for our manual pages. For example, currently `man nm-settings-dbus` has nonsense like: "Value Type: array of string", when it should be reall "as". In a first step, generate an XML with that meta data for later use.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -145,6 +145,8 @@ test-*.trs
|
|||||||
/src/libnm-core-impl/tests/test-need-secrets
|
/src/libnm-core-impl/tests/test-need-secrets
|
||||||
/src/libnm-core-impl/tests/test-secrets
|
/src/libnm-core-impl/tests/test-secrets
|
||||||
/src/libnm-core-impl/tests/test-setting
|
/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-json-aux
|
||||||
/src/libnm-glib-aux/tests/test-shared-general
|
/src/libnm-glib-aux/tests/test-shared-general
|
||||||
/src/libnm-platform/tests/test-nm-platform
|
/src/libnm-platform/tests/test-nm-platform
|
||||||
|
49
Makefile.am
49
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
|
noinst_LTLIBRARIES += src/libnm-client-impl/libnm-client-impl.la
|
||||||
|
|
||||||
src_libnm_client_impl_libnm_client_impl_la_CPPFLAGS = \
|
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
|
INTROSPECTION_GIRS += src/libnm-client-impl/NM-1.0.gir
|
||||||
|
|
||||||
libnm_noinst_data = \
|
libnm_noinst_data = \
|
||||||
|
src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml \
|
||||||
src/nmcli/gen-metadata-nm-settings-nmcli.xml \
|
src/nmcli/gen-metadata-nm-settings-nmcli.xml \
|
||||||
man/nm-settings-docs-dbus.xml \
|
man/nm-settings-docs-dbus.xml \
|
||||||
man/nm-settings-docs-nmcli.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:
|
check-local-gen-metadata-nm-settings-nmcli:
|
||||||
endif
|
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)
|
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)
|
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)
|
||||||
|
77
src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.c
Normal file
77
src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.c
Normal file
@@ -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("<nm-setting-docs>\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("%s<setting", _indent_level(INDENT));
|
||||||
|
g_print(" name=%s", (tmp_s1 = _xml_escape_attribute(msi->setting_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("%s<property", _indent_level(2 * INDENT));
|
||||||
|
g_print(" name=%s", (tmp2 = _xml_escape_attribute(sip->name)));
|
||||||
|
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</setting>\n", _indent_level(INDENT));
|
||||||
|
}
|
||||||
|
g_print("</nm-setting-docs>\n");
|
||||||
|
return 0;
|
||||||
|
}
|
1135
src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in
Normal file
1135
src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in
Normal file
File diff suppressed because it is too large
Load Diff
@@ -88,3 +88,52 @@ libnm_core_impl = static_library(
|
|||||||
uuid_dep,
|
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
|
||||||
|
Reference in New Issue
Block a user