From 6968c4141c901f6c2fc43c7885c5907be9c206c7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 1 Nov 2020 18:38:54 +0100 Subject: [PATCH 1/5] build/meson: move enable_docs variable It will be used in subdirectories. Move it. --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 6ee66ab01c..bd99b79ca6 100644 --- a/meson.build +++ b/meson.build @@ -751,6 +751,8 @@ if enable_nm_cloud_setup assert(libcurl_dep.found(), 'nm-cloud-setup requires libcurl library. Use -Dnm_cloud_setup=false to disable it') endif +enable_docs = get_option('docs') + more_asserts = get_option('more_asserts') if more_asserts == 'auto' if nm_minor_version % 2 == 0 @@ -920,8 +922,6 @@ if enable_qt subdir('examples/C/qt') endif -enable_docs = get_option('docs') - if enable_docs assert(enable_introspection, '-Ddocs=true requires -Dintrospection=true') assert(meson.version().version_compare('>= 0.46.0'), '-Ddocs requires meson >= 0.46') From a208da4139c6ce53c7c2e386e43f48a876e7f75d Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 1 Nov 2020 17:57:33 +0100 Subject: [PATCH 2/5] build: only generate "settings-docs.h" with "--enable-gtk-doc" Note that "--enable-gtk-doc" requires "--enable-introspection". For generating "settings-docs.h" we (only) need introspection/pygobject. We also have a pre-generated .in file that we can use if introspection is not available. Since we have a pre-generated variant, it would be fine to always use that one. However, we want to use generate the file if we have the necessary dependencies, because thereby we can check whether the pre-generated file is identical to what would be generated. We have a similar problem with "generate-docs-nm-settings-nmcli.xml". However there we don't need introspection, but merely being able to execute a binary that we build. That does not work during cross compilation, so we will honor "--enable-gtk-doc" flag to decide when to generate the file. For consistency, also adjust the condition for "settings-docs.h" to only generate the file if we have "--enable-gtk-doc" (but not it we build with "--enable-introspection" alone). --- Makefile.am | 2 +- clients/common/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6e5b9446af..90c719f175 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4453,7 +4453,7 @@ $(clients_common_libnmc_base_la_OBJECTS): $(libnm_lib_h_pub_mkenums) $(clients_common_libnmc_base_la_OBJECTS): clients/common/.dirstamp clients_common_settings_doc_h = clients/common/settings-docs.h -if HAVE_INTROSPECTION +if BUILD_DOCS $(clients_common_settings_doc_h): clients/common/settings-docs.xsl libnm/nm-settings-docs-gir.xml clients/common/.dirstamp $(AM_V_GEN) $(XSLTPROC) --output $@ $< $(word 2,$^) DISTCLEANFILES += $(clients_common_settings_doc_h) diff --git a/clients/common/meson.build b/clients/common/meson.build index cefcfce02d..81fc22d695 100644 --- a/clients/common/meson.build +++ b/clients/common/meson.build @@ -31,7 +31,7 @@ libnmc_base_dep = declare_dependency( settings_docs = 'settings-docs.h' -if enable_introspection +if enable_docs settings_docs_source = custom_target( settings_docs, input: nm_settings_docs_xml_gir, From ab8fdb73e6be76dc812574e040ac907d6eaad4b8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 1 Nov 2020 17:36:22 +0100 Subject: [PATCH 3/5] build: commit pre-generated "generate-docs-nm-settings-nmcli.xml" to git We can generate "generate-docs-nm-settings-nmcli.xml" by running "clients/cli/generate-docs-nm-settings-nmcli". However, during cross compilation, that binary gets build in the target architecture, it can thus not run to generate the XML. --- Makefile.am | 14 +- .../generate-docs-nm-settings-nmcli.xml.in | 1108 +++++++++++++++++ clients/cli/meson.build | 26 +- 3 files changed, 1141 insertions(+), 7 deletions(-) create mode 100644 clients/cli/generate-docs-nm-settings-nmcli.xml.in diff --git a/Makefile.am b/Makefile.am index 90c719f175..3282db0c03 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1602,8 +1602,20 @@ libnm_noinst_data = \ noinst_DATA += $(libnm_noinst_data) +EXTRA_DIST += clients/cli/generate-docs-nm-settings-nmcli.xml.in + +if BUILD_DOCS clients/cli/generate-docs-nm-settings-nmcli.xml: clients/cli/generate-docs-nm-settings-nmcli - $(AM_V_GEN) clients/cli/generate-docs-nm-settings-nmcli > $@ + $(AM_V_GEN) clients/cli/generate-docs-nm-settings-nmcli > "$@" +check-local-generate-docs-nm-settings-nmcli: clients/cli/generate-docs-nm-settings-nmcli.xml + $(srcdir)/tools/check-settings-docs.sh "$(srcdir)" "$(builddir)" "$<" +check_local += check-local-generate-docs-nm-settings-nmcli +DISTCLEANFILES += clients/cli/generate-docs-nm-settings-nmcli.xml +else +clients/cli/generate-docs-nm-settings-nmcli.xml: clients/cli/generate-docs-nm-settings-nmcli.xml.in + $(AM_V_GEN) cp $^ $@ +check-local-generate-docs-nm-settings-nmcli: +endif libnm_docs_sources = $(libnm_core_lib_c_settings_real) diff --git a/clients/cli/generate-docs-nm-settings-nmcli.xml.in b/clients/cli/generate-docs-nm-settings-nmcli.xml.in new file mode 100644 index 0000000000..25675a1ec7 --- /dev/null +++ b/clients/cli/generate-docs-nm-settings-nmcli.xml.in @@ -0,0 +1,1108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/clients/cli/meson.build b/clients/cli/meson.build index 517deffa69..582076bdd0 100644 --- a/clients/cli/meson.build +++ b/clients/cli/meson.build @@ -50,9 +50,23 @@ generate_docs_nm_settings_nmcli = executable( link_depends: linker_script_binary, ) -generate_docs_nm_settings_nmcli_xml = custom_target( - 'generate-docs-nm-settings-nmcli.xml', - output: 'generate-docs-nm-settings-nmcli.xml', - command: [ generate_docs_nm_settings_nmcli ], - capture: true, -) +if enable_docs + generate_docs_nm_settings_nmcli_xml = custom_target( + 'generate-docs-nm-settings-nmcli.xml', + output: 'generate-docs-nm-settings-nmcli.xml', + command: [ generate_docs_nm_settings_nmcli ], + capture: true, + ) + + test( + 'check-local-generate-docs-nm-settings-nmcli', + find_program(join_paths(source_root, 'tools', 'check-settings-docs.sh')), + args: [source_root, build_root, 'clients/cli/generate-docs-nm-settings-nmcli.xml'], + ) +else + settings_docs_source = configure_file( + input: 'generate-docs-nm-settings-nmcli.xml.in', + output: '@BASENAME@', + configuration: configuration_data(), + ) +endif From 82ebd73bec83210a36a4c7cd77d027511650887a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 1 Nov 2020 18:22:32 +0100 Subject: [PATCH 4/5] build: cleanup "tools/check-settings-docs.sh" script --- tools/check-settings-docs.sh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tools/check-settings-docs.sh b/tools/check-settings-docs.sh index 8695ccc030..44b70f95c6 100755 --- a/tools/check-settings-docs.sh +++ b/tools/check-settings-docs.sh @@ -1,19 +1,18 @@ #!/bin/sh -srcdir=$1 -builddir=$2 -doc_h=$3 +set -e -if [ -z "$NMTST_NO_CHECK_SETTINGS_DOCS" ] ; then - if ! cmp -s "${srcdir}/${doc_h}.in" "${builddir}/${doc_h}"; then - if [ "$NM_TEST_REGENERATE" = 1 ] ; then - cp -f "${builddir}/${doc_h}" "${srcdir}/${doc_h}.in" - else - echo "*** Error: the generated file '${builddir}/${doc_h}' differs from the source file '${srcdir}/${doc_h}.in'. You probably should copy the generated file over to the source file. You can skip this test by setting NMTST_NO_CHECK_SETTINGS_DOCS=yes. You can also automatically copy the file by rerunning the test with NM_TEST_REGENERATE=1" - exit 1 - fi - fi +srcdir="$1" +builddir="$2" +doc_h="$3" + +[ -n "$NMTST_NO_CHECK_SETTINGS_DOCS" ] && exit 0 + +cmp -s "${srcdir}/${doc_h}.in" "${builddir}/${doc_h}" && exit 0 + +if [ "$NM_TEST_REGENERATE" = 1 ] ; then + cp -f "${builddir}/${doc_h}" "${srcdir}/${doc_h}.in" +else + echo "*** Error: the generated file '${builddir}/${doc_h}' differs from the source file '${srcdir}/${doc_h}.in'. You probably should copy the generated file over to the source file. You can skip this test by setting NMTST_NO_CHECK_SETTINGS_DOCS=yes. You can also automatically copy the file by rerunning the test with NM_TEST_REGENERATE=1" + exit 1 fi - -exit 0 - From 62411390e2c8ed48f8c79c5df704f84bc276d0c4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 1 Nov 2020 18:28:37 +0100 Subject: [PATCH 5/5] build: rename "tools/check-settings-docs.sh" to "check-compare-generated.sh" It's a better name, because the script merely compiles files and is not specific to "settings-docs.h". --- Makefile.am | 6 +++--- clients/cli/meson.build | 2 +- clients/common/meson.build | 2 +- .../{check-settings-docs.sh => check-compare-generated.sh} | 0 4 files changed, 5 insertions(+), 5 deletions(-) rename tools/{check-settings-docs.sh => check-compare-generated.sh} (100%) diff --git a/Makefile.am b/Makefile.am index 3282db0c03..473a763d74 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1608,7 +1608,7 @@ if BUILD_DOCS clients/cli/generate-docs-nm-settings-nmcli.xml: clients/cli/generate-docs-nm-settings-nmcli $(AM_V_GEN) clients/cli/generate-docs-nm-settings-nmcli > "$@" check-local-generate-docs-nm-settings-nmcli: clients/cli/generate-docs-nm-settings-nmcli.xml - $(srcdir)/tools/check-settings-docs.sh "$(srcdir)" "$(builddir)" "$<" + $(srcdir)/tools/check-compare-generated.sh "$(srcdir)" "$(builddir)" "$<" check_local += check-local-generate-docs-nm-settings-nmcli DISTCLEANFILES += clients/cli/generate-docs-nm-settings-nmcli.xml else @@ -4470,7 +4470,7 @@ $(clients_common_settings_doc_h): clients/common/settings-docs.xsl libnm/nm-sett $(AM_V_GEN) $(XSLTPROC) --output $@ $< $(word 2,$^) DISTCLEANFILES += $(clients_common_settings_doc_h) check-local-settings-docs: $(clients_common_settings_doc_h) - $(srcdir)/tools/check-settings-docs.sh "$(srcdir)" "$(builddir)" "$(clients_common_settings_doc_h)" + $(srcdir)/tools/check-compare-generated.sh "$(srcdir)" "$(builddir)" "$(clients_common_settings_doc_h)" check_local += check-local-settings-docs else $(clients_common_settings_doc_h): $(clients_common_settings_doc_h).in clients/common/.dirstamp @@ -5297,7 +5297,7 @@ EXTRA_DIST += \ tools/check-config-options.sh \ tools/check-docs.sh \ tools/check-exports.sh \ - tools/check-settings-docs.sh \ + tools/check-compare-generated.sh \ tools/create-exports-NetworkManager.sh \ tools/debug-helper.py \ tools/meson-post-install.sh \ diff --git a/clients/cli/meson.build b/clients/cli/meson.build index 582076bdd0..585a5a7382 100644 --- a/clients/cli/meson.build +++ b/clients/cli/meson.build @@ -60,7 +60,7 @@ if enable_docs test( 'check-local-generate-docs-nm-settings-nmcli', - find_program(join_paths(source_root, 'tools', 'check-settings-docs.sh')), + find_program(join_paths(source_root, 'tools', 'check-compare-generated.sh')), args: [source_root, build_root, 'clients/cli/generate-docs-nm-settings-nmcli.xml'], ) else diff --git a/clients/common/meson.build b/clients/common/meson.build index 81fc22d695..0e3f0d4f6f 100644 --- a/clients/common/meson.build +++ b/clients/common/meson.build @@ -41,7 +41,7 @@ if enable_docs test( 'check-settings-docs', - find_program(join_paths(source_root, 'tools', 'check-settings-docs.sh')), + find_program(join_paths(source_root, 'tools', 'check-compare-generated.sh')), args: [source_root, build_root, 'clients/common/' + settings_docs], ) else diff --git a/tools/check-settings-docs.sh b/tools/check-compare-generated.sh similarity index 100% rename from tools/check-settings-docs.sh rename to tools/check-compare-generated.sh