[gtkmm-documentation] Meson build: Add allow-network-access option
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Meson build: Add allow-network-access option
- Date: Wed, 23 Feb 2022 14:21:41 +0000 (UTC)
commit c135dad6d67c8b7a03c9eb1e1263b0b8de2ce6ff
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Wed Feb 23 15:14:28 2022 +0100
Meson build: Add allow-network-access option
If false, xmllint and xsltproc are not allowed to fetch files
over the network, and gtkmm-documentation requires the docbook5-xml
and docbook-xsl packages (Ubuntu names, can have other names in
other distros).
docs/tutorial/meson.build | 7 ++++-
meson.build | 19 ++++++------
meson_options.txt | 2 ++
tools/meson_aux/tutorial-custom-cmd.py | 54 ++++++++++++++++++++++------------
4 files changed, 54 insertions(+), 28 deletions(-)
---
diff --git a/docs/tutorial/meson.build b/docs/tutorial/meson.build
index 73dab49..eefdb06 100644
--- a/docs/tutorial/meson.build
+++ b/docs/tutorial/meson.build
@@ -11,12 +11,14 @@ xsltproc = find_program('xsltproc', required: true)
xmllint = find_program('xmllint', required: false)
can_parse_and_validate = xmllint.found()
validate = get_option('validation') ? 'true' : 'false'
+allow_network_access = get_option('allow-network-access') ? 'true' : 'false'
# Check if xmllint can be used.
if xmllint.found()
can_parse_and_validate = run_command(
python3, tutorial_custom_cmd, 'xmllint',
validate,
+ allow_network_access,
meson.current_source_dir() / 'can_use_xmllint.xml',
meson.current_build_dir() / 'can_use_xmllint.stamp',
check: false,
@@ -36,7 +38,7 @@ can_build_translations = find_program('msgfmt', required: false).found() and \
build_translations_by_default = get_option('build-translations')
dblatex = find_program('dblatex', required: false)
-can_build_pdf = dblatex.found() or (xsltproc.found() and \
+can_build_pdf = xsltproc.found() and (dblatex.found() or \
find_program('fop', required: false).found())
build_pdf_by_default = get_option('build-pdf')
@@ -182,6 +184,7 @@ custom_target('html_index.html',
output: 'html',
command: [
python3, tutorial_custom_cmd, 'html',
+ allow_network_access,
'@INPUT@',
'@OUTPUT@',
],
@@ -203,6 +206,7 @@ if can_parse_and_validate
command: [
python3, tutorial_custom_cmd, 'xmllint',
validate,
+ allow_network_access,
'@INPUT@',
'@OUTPUT@'
],
@@ -219,6 +223,7 @@ if can_build_pdf
command: [
python3, tutorial_custom_cmd,
dblatex.found() ? 'dblatex' : 'fop',
+ allow_network_access,
'@INPUT@',
meson.current_source_dir() / 'C' / 'figures',
'@OUTPUT@'
diff --git a/meson.build b/meson.build
index 17ef025..4e48f9e 100644
--- a/meson.build
+++ b/meson.build
@@ -121,7 +121,7 @@ endif
build_pdf = build_pdf_by_default and can_build_pdf
explain_pdf = ''
if build_pdf_by_default and not build_pdf
- explain_pdf = ' (requires dblatex or (xsltproc and fop))'
+ explain_pdf = ' (requires xsltproc and (dblatex or fop))'
endif
summary = [
@@ -129,15 +129,16 @@ summary = [
'------',
meson.project_name() + ' ' + meson.project_version(),
'',
- ' Build examples: @0@@1@'.format(build_examples_by_default, explain_ex),
- ' Compiler warnings: @0@'.format(warning_level),
- ' XML validation: @0@@1@'.format(validate, explain_val),
- 'Build translations: @0@@1@'.format(build_translations, explain_trans),
- ' Build PDF: @0@@1@'.format(build_pdf, explain_pdf),
+ ' Build examples: @0@@1@'.format(build_examples_by_default, explain_ex),
+ ' Compiler warnings: @0@'.format(warning_level),
+ ' XML validation: @0@@1@'.format(validate, explain_val),
+ 'Allow network access: @0@'.format(get_option('allow-network-access')),
+ ' Build translations: @0@@1@'.format(build_translations, explain_trans),
+ ' Build PDF: @0@@1@'.format(build_pdf, explain_pdf),
'Directories:',
- ' prefix: @0@'.format(install_prefix),
- ' datadir: @0@'.format(install_prefix / install_datadir),
- ' tutorialdir: @0@'.format(install_prefix / tutorialdir),
+ ' prefix: @0@'.format(install_prefix),
+ ' datadir: @0@'.format(install_prefix / install_datadir),
+ ' tutorialdir: @0@'.format(install_prefix / tutorialdir),
'------'
]
diff --git a/meson_options.txt b/meson_options.txt
index 95b8d50..8bedd06 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -6,6 +6,8 @@ option('build-examples', type: 'boolean', value: false,
description: 'Build all example programs')
option('validation', type: 'boolean', value: true,
description: 'Validate the untranslated XML file')
+option('allow-network-access', type: 'boolean', value: true,
+ description: 'Allow xmllint and xsltproc to fetch files over the network')
option('build-translations', type: 'boolean', value: true,
description: 'Build translated tutorials (built during installation)')
option('build-pdf', type: 'boolean', value: false,
diff --git a/tools/meson_aux/tutorial-custom-cmd.py b/tools/meson_aux/tutorial-custom-cmd.py
index a97c4c9..d775adc 100755
--- a/tools/meson_aux/tutorial-custom-cmd.py
+++ b/tools/meson_aux/tutorial-custom-cmd.py
@@ -51,11 +51,12 @@ def insert_ex_code():
# Called from custom_target()
def html():
- # argv[2] argv[3]
- # <input_xml_file> <output_html_dir>
+ # argv[2] argv[3] argv[4]
+ # <allow_network_access> <input_xml_file> <output_html_dir>
- input_xml_file = sys.argv[2]
- output_html_dir = sys.argv[3]
+ allow_network_access = sys.argv[2] == 'true'
+ input_xml_file = sys.argv[3]
+ output_html_dir = sys.argv[4]
# Set the use.id.as.filename param so that we don't use the chapter / section
# number as the filename, otherwise the url will change every time anything is
@@ -86,6 +87,10 @@ def html():
] + xslt_params + [
'-o', output_html_dir + '/',
'--xinclude',
+ ]
+ if not allow_network_access:
+ cmd += ['--nonet']
+ cmd += [
xslt_stylesheet,
input_xml_file,
]
@@ -101,12 +106,13 @@ def html():
# Called from custom_target()
def xmllint():
- # argv[2] argv[3] argv[4]
- # <validate> <input_xml_file> <stamp_file_path>
+ # argv[2] argv[3] argv[4] argv[5]
+ # <validate> <allow_network_access> <input_xml_file> <stamp_file_path>
validate = sys.argv[2]
- input_xml_file = sys.argv[3]
- stamp_file_path = sys.argv[4]
+ allow_network_access = sys.argv[3] == 'true'
+ input_xml_file = sys.argv[4]
+ stamp_file_path = sys.argv[5]
relax_ng_schema = 'http://docbook.org/xml/5.0/rng/docbook.rng'
# schematron_schema = 'http://docbook.org/xml/5.0/sch/docbook.sch'
@@ -128,6 +134,8 @@ def xmllint():
'--relaxng', relax_ng_schema,
#'--schematron', schematron_schema,
]
+ if not allow_network_access:
+ cmd += ['--nonet']
cmd += [input_xml_file]
result = subprocess.run(cmd)
if result.returncode:
@@ -180,13 +188,14 @@ def translate_xml():
# xsltproc+xmlroff (version 0.6.3) does not seem to work acceptably.
# Called from custom_target()
def dblatex():
- # argv[2] argv[3] argv[4]
- # <input_xml_file> <figures_dir> <output_pdf_file>
+ # argv[2] argv[3] argv[4] argv[5]
+ # <allow_network_access> <input_xml_file> <figures_dir> <output_pdf_file>
# Create a PDF file, using dblatex.
- input_xml_file = sys.argv[2]
- figures_dir = sys.argv[3]
- output_pdf_file = sys.argv[4]
+ allow_network_access = sys.argv[2] == 'true'
+ input_xml_file = sys.argv[3]
+ figures_dir = sys.argv[4]
+ output_pdf_file = sys.argv[5]
# For a list of available parameters, see http://dblatex.sourceforge.net/doc/manual/
dblatex_params = [
@@ -203,19 +212,24 @@ def dblatex():
'-I', figures_dir_parent,
'-o', output_pdf_file,
'--pdf',
+ ]
+ if not allow_network_access:
+ cmd += ['-x', '--nonet'] # --nonet is passed to xsltproc
+ cmd += [
input_xml_file,
]
return subprocess.run(cmd).returncode
# Called from custom_target()
def fop():
- # argv[2] argv[3] argv[4]
- # <input_xml_file> <figures_dir> <output_pdf_file>
+ # argv[2] argv[3] argv[4] argv[5]
+ # <allow_network_access> <input_xml_file> <figures_dir> <output_pdf_file>
# Create a PDF file, using fop.
- input_xml_file = sys.argv[2]
- figures_dir = sys.argv[3]
- output_pdf_file = sys.argv[4]
+ allow_network_access = sys.argv[2] == 'true'
+ input_xml_file = sys.argv[3]
+ figures_dir = sys.argv[4]
+ output_pdf_file = sys.argv[5]
fo_file = os.path.splitext(output_pdf_file)[0] + '.fo'
@@ -244,6 +258,10 @@ def fop():
] + xslt_params + [
'-o', fo_file,
'--xinclude',
+ ]
+ if not allow_network_access:
+ cmd += ['--nonet']
+ cmd += [
xslt_stylesheet,
input_xml_file,
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]