meson: add check on settings docs

Move the autotools check on settings docs to a shell script and call
it from meson too.
This commit is contained in:
Beniamino Galvani 2018-12-06 15:36:55 +01:00
parent f606124b62
commit 81bc218e6d
4 changed files with 26 additions and 20 deletions

View File

@ -3833,16 +3833,7 @@ $(clients_common_settings_doc_h): clients/common/settings-docs.xsl libnm/nm-prop
$(AM_V_GEN) $(XSLTPROC) --output $@ $< $(word 2,$^)
DISTCLEANFILES += $(clients_common_settings_doc_h)
check-local-settings-docs: $(clients_common_settings_doc_h)
@if test -z "$$NMTST_NO_CHECK_SETTINGS_DOCS" ; then \
if ! cmp -s "$(srcdir)/$(clients_common_settings_doc_h).in" "$(builddir)/$(clients_common_settings_doc_h)" ; then \
if test "$$NM_TEST_REGENERATE" == 1 ; then \
cp -f "$(builddir)/$(clients_common_settings_doc_h)" "$(srcdir)/$(clients_common_settings_doc_h).in"; \
else \
echo "The generated file \"$(builddir)/$(clients_common_settings_doc_h)\" differs from the source file \"$(srcdir)/$(clients_common_settings_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 ; \
false; \
fi; \
fi;\
fi
$(srcdir)/tools/check-settings-docs.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
@ -5166,6 +5157,7 @@ EXTRA_DIST += \
tools/check-config-options.sh \
tools/check-docs.sh \
tools/check-exports.sh \
tools/check-settings-docs.sh \
tools/create-exports-NetworkManager.sh \
tools/debug-helper.py \
tools/meson-post-install.sh \

View File

@ -37,15 +37,11 @@ if enable_introspection
command: [xsltproc, '--output', '@OUTPUT@', join_paths(meson.current_source_dir(), 'settings-docs.xsl'), '@INPUT@']
)
# FIXME: if enabled the check happens even if the settings_docs_source is not set
'''
if get_option('check_settings_docs')
res = run_command(find_program('cmp'), '-s', settings_docs + '.in', settings_docs_source.full_path())
if res.returncode() != 0
message('The generated file ' + settings_docs_source.full_path() + ' differs from the source file ' + settings_docs + '.in' + '. You probably should copy the generated file over to the source file. You can skip this test by setting -Dcheck_settings_docs=false')
endif
endif
'''
test(
'check-settings-docs',
find_program(join_paths(meson.source_root(), 'tools', 'check-settings-docs.sh')),
args: [meson.source_root(), meson.build_root(), 'clients/common/' + settings_docs]
)
else
settings_docs_source = configure_file(
input: settings_docs + '.in',

View File

@ -74,4 +74,3 @@ option('libpsl', type: 'boolean', value: true, description: 'Link against libpsl
option('json_validation', type: 'boolean', value: true, description: 'Enable JSON validation in libnm')
option('crypto', type: 'combo', choices: ['nss', 'gnutls'], value: 'nss', description: 'Cryptography library to use for certificate and key operations')
option('qt', type: 'boolean', value: true, description: 'enable Qt examples')
option('check_settings_docs', type: 'boolean', value: false, description: 'compare check settings-docs.h file')

19
tools/check-settings-docs.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
srcdir=$1
builddir=$2
doc_h=$3
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
fi
exit 0