[gtkmm-documentation] meson.build: Use gnome.yelp()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] meson.build: Use gnome.yelp()
- Date: Sun, 12 May 2019 13:30:15 +0000 (UTC)
commit efef6a876a2626487d83f92c64fffb2a560ea346
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Sun May 12 15:26:41 2019 +0200
meson.build: Use gnome.yelp()
README | 3 +-
docs/tutorial/LINGUAS | 10 ++++
docs/tutorial/meson.build | 83 ++++++++++------------------------
meson.build | 5 +-
meson_options.txt | 4 +-
tools/meson_aux/compile-schemas.sh | 2 +-
tools/meson_aux/copy-to-subdir.sh | 2 +-
tools/meson_aux/extra-dist-cmd.sh | 27 ++++++++---
tools/meson_aux/tutorial-custom-cmd.sh | 19 +++-----
9 files changed, 70 insertions(+), 85 deletions(-)
---
diff --git a/README b/README
index 6e835de..3a4293a 100644
--- a/README
+++ b/README
@@ -31,7 +31,8 @@ Example of changing options:
Create a PDF file
$ meson -Dbuild-pdf=true
$ ninja
-This requires that you have the xmllint and docbook2pdf commands installed.
+This requires that you have either the dblatex or the xmllint and docbook2pdf
+commands installed.
Make a tarball:
$ ninja dist
diff --git a/docs/tutorial/LINGUAS b/docs/tutorial/LINGUAS
new file mode 100644
index 0000000..49fbe0f
--- /dev/null
+++ b/docs/tutorial/LINGUAS
@@ -0,0 +1,10 @@
+# Please keep this list sorted alphabetically.
+#
+cs
+de
+el
+es
+fr
+pt_BR
+sl
+zh_CN
diff --git a/docs/tutorial/meson.build b/docs/tutorial/meson.build
index 169c54d..2ba9de7 100644
--- a/docs/tutorial/meson.build
+++ b/docs/tutorial/meson.build
@@ -1,11 +1,12 @@
# docs/tutorial
-# input: gtkmm_datadir, gtkmm_pcname, tutorial_custom_cmd_sh
+# input: gnome, gtkmm_datadir, gtkmm_pcname, tutorial_custom_cmd_sh
# output: can_parse_and_validate, build_translations_by_default, can_build_translations,
-# build_pdf_by_default, can_build_pdf, tutorial_languages
+# build_pdf_by_default, can_build_pdf
-# xsltproc is required because it is called by tutorial_custom_cmd_sh html.
+# xsltproc is required by tutorial_custom_cmd_sh html.
xsltproc = find_program('xsltproc', required: true)
+# perl is required by tutorial_custom_cmd_sh insert_example_code.
perl = find_program('perl', required: true)
xmllint = find_program('xmllint', required: false)
@@ -21,8 +22,6 @@ can_build_pdf = dblatex.found() or (xmllint.found() and \
find_program('docbook2pdf', required: false).found())
build_pdf_by_default = get_option('build-pdf')
-tutorial_languages = ['cs', 'de', 'el', 'es', 'fr', 'pt_BR', 'sl', 'zh_CN']
-
# Installation directories
tutorialdir = join_paths(gtkmm_datadir, 'doc', gtkmm_pcname, 'tutorial')
tutorial_htmldir = join_paths(tutorialdir, 'html')
@@ -113,8 +112,10 @@ tutorial_figurefiles = [
'update_ui.png',
]
tutorial_figures = []
+tutorial_C_figures = []
foreach f : tutorial_figurefiles
- tutorial_figures += join_paths('C', 'figures', f)
+ tutorial_figures += join_paths('figures', f)
+ tutorial_C_figures += join_paths('C', 'figures', f)
endforeach
tutorial_iconfiles = [
@@ -134,16 +135,17 @@ foreach i : tutorial_iconfiles
endforeach
# Create a DocBook C locale XML file with the examples' source code included.
+# Copy it to the source directory, where gnome.yelp() expects to find it.
index_docbook = custom_target('index.docbook',
input: join_paths('C', 'index-in.docbook'),
output: 'index.docbook',
command: [
- perl, '--',
+ tutorial_custom_cmd_sh, 'insert_example_code',
join_paths(meson.current_source_dir(), 'insert_example_code.pl'),
join_paths(meson.source_root(), 'examples', 'book'),
'@INPUT@',
+ '@OUTPUT@',
],
- capture: true,
build_by_default: true
)
@@ -178,55 +180,6 @@ if can_parse_and_validate
)
endif
-if can_build_translations
- # Create XML files with translations.
- foreach lang : tutorial_languages
- # Create .mo file.
- po2mo = custom_target(lang + '-po2mo',
- input: join_paths(lang, lang + '.po'),
- output: lang + '_mo.stamp',
- command: [
- tutorial_custom_cmd_sh, 'po2mo',
- lang,
- meson.current_build_dir(),
- '@INPUT@',
- join_paths(meson.current_build_dir(), lang, lang + '.mo'),
- '@OUTPUT@'
- ],
- build_by_default: build_translations_by_default,
- )
-
- # Create XML file.
- lang_index_docbook = custom_target(lang + '-index.docbook',
- input: [po2mo, index_docbook],
- output: lang + '_docbook.stamp',
- command: [
- tutorial_custom_cmd_sh, 'xmltrans',
- join_paths(meson.current_build_dir(), lang, lang + '.mo'),
- '@INPUT1@',
- join_paths(meson.current_build_dir(), lang),
- '@OUTPUT@'
- ],
- build_by_default: build_translations_by_default,
- )
-
- if can_parse_and_validate
- # Parse and possibly validate the translated version of the DocBook.
- custom_target(lang + '-xmllint',
- input: lang_index_docbook,
- output: lang + '_xmllint.stamp',
- command: [
- tutorial_custom_cmd_sh, 'xmllint',
- validate,
- join_paths(meson.current_build_dir(), lang, 'index.docbook'),
- '@OUTPUT@'
- ],
- build_by_default: build_translations_by_default,
- )
- endif
- endforeach # lang
-endif # can_build_translations
-
if can_build_pdf
# Create a PDF file of the C locale's version of the DocBook.
# Prefer dblatex, if both dblatex and docbook2pdf are available.
@@ -244,7 +197,21 @@ if can_build_pdf
)
endif
+if can_build_translations and build_translations_by_default
+ # Build translations. Install help documentation using Yelp.
+ # C/index.docbook is copied from the source directory.
+ # <lang>/index.docbook are written to the build directory, and copied from there.
+ # It's bad that gnome.yelp() builds only at install time.
+ # See https://github.com/mesonbuild/meson/issues/2775
+ gnome.yelp('gtkmm-tutorial',
+ sources: 'index.docbook',
+ media: tutorial_figures,
+ symlink_media: true
+)
+endif
+
+# Install extra files in the html directory.
install_data('style.css', install_dir: tutorial_htmldir)
-install_data(tutorial_figures, install_dir: tutorial_figuresdir)
+install_data(tutorial_C_figures, install_dir: tutorial_figuresdir)
install_data(tutorial_icons, install_dir: tutorial_iconsdir)
diff --git a/meson.build b/meson.build
index f1e70dd..5a2fc1c 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
# This file is part of gtkmm-documentation.
project('gtkmm-documentation', 'c', 'cpp',
- version: '3.89.0',
+ version: '3.95.1',
default_options: [
'cpp_std=c++17'
],
@@ -10,7 +10,7 @@ project('gtkmm-documentation', 'c', 'cpp',
)
gtkmm_pcname = 'gtkmm-4.0'
-gtkmm_dep = dependency(gtkmm_pcname, version: '>=3.93.0')
+gtkmm_dep = dependency(gtkmm_pcname, version: '>=3.95.1')
giomm_dep = dependency('giomm-2.62', version: '>=2.61.1')
gnome = import('gnome')
@@ -55,7 +55,6 @@ meson.add_dist_script(
meson.current_source_dir(),
meson.current_build_dir(),
join_paths('meson-dist', meson.project_name() + '-' + meson.project_version()),
- ' '.join(tutorial_languages)
)
# Print a summary.
diff --git a/meson_options.txt b/meson_options.txt
index 6643355..6d39784 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,8 +7,8 @@ option('build-examples', type: 'boolean', value: false,
option('build-dist-examples', type: 'boolean', value: true,
description : 'Build all example programs when creating distribution tarball')
option('validation', type: 'boolean', value: true,
- description : 'Validate generated XML files')
+ description : 'Validate the untranslated XML file')
option('build-translations', type: 'boolean', value: true,
- description : 'Build translated tutorials')
+ description : 'Build translated tutorials (built during installation)')
option('build-pdf', type: 'boolean', value: false,
description : 'Build tutorial PDF file')
diff --git a/tools/meson_aux/compile-schemas.sh b/tools/meson_aux/compile-schemas.sh
index f5e61bc..2656089 100755
--- a/tools/meson_aux/compile-schemas.sh
+++ b/tools/meson_aux/compile-schemas.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -e
# External command, intended to be called with custom_target() in meson.build
diff --git a/tools/meson_aux/copy-to-subdir.sh b/tools/meson_aux/copy-to-subdir.sh
index 31db7a0..7e82a6a 100755
--- a/tools/meson_aux/copy-to-subdir.sh
+++ b/tools/meson_aux/copy-to-subdir.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -e
# External command, intended to be called with custom_target() in meson.build
diff --git a/tools/meson_aux/extra-dist-cmd.sh b/tools/meson_aux/extra-dist-cmd.sh
index 1cb4307..01568a5 100755
--- a/tools/meson_aux/extra-dist-cmd.sh
+++ b/tools/meson_aux/extra-dist-cmd.sh
@@ -1,8 +1,8 @@
-#!/bin/bash
+#!/bin/bash -e
# External command, intended to be called with add_dist_script() in meson.build
-# extra-dist-cmd.sh <root_source_dir> <root_build_dir> <relative_dist_dir> <tutorial_languages>
+# extra-dist-cmd.sh <root_source_dir> <root_build_dir> <relative_dist_dir>
# relative_dist_dir is the distribution directory path relative to root_build_dir.
# Meson does not preserve timestamps on distributed files. Neither does this script.
@@ -19,17 +19,32 @@ dist_docs_tutorial="$3/docs/tutorial"
cp "docs/tutorial/index.docbook" "$dist_docs_tutorial/C/"
cp --recursive "docs/tutorial/html/" "$dist_docs_tutorial/"
-# .mo files with translations and translated index.docbook files.
-for lang in $4; do
- cp "docs/tutorial/$lang/$lang.mo" "docs/tutorial/$lang/index.docbook" "$dist_docs_tutorial/$lang/"
+# Read the distributed LINGUAS file, containing a list of available translations.
+linguas="$dist_docs_tutorial/LINGUAS"
+langs=
+if [ -f "$linguas" ]; then
+ langs="$(sed '/^ *#/d' "$linguas")"
+else
+ echo "=== Warning: File $linguas not found."
+fi
+
+# .gmo files with translations and translated index.docbook files.
+for lang in $langs; do
+ for file in "$lang.gmo" "index.docbook"; do
+ cp "docs/tutorial/$lang/$file" "$dist_docs_tutorial/$lang/"
+ done
done
# If there is an updated PDF file, include it in the tarball.
pdf_file="docs/tutorial/programming-with-gtkmm.pdf"
if [ -f "$pdf_file" -a "$pdf_file" -nt "docs/tutorial/index.docbook" ]; then
cp "$pdf_file" "$dist_docs_tutorial/C/"
+else
+ echo "--- Info: No updated PDF file found."
fi
# Remove all .gitignore files and an empty $3/build directory.
find "$3" -name ".gitignore" -exec rm '{}' \;
-rmdir --ignore-fail-on-non-empty "$3/build"
+if [ -d "$3/build" ]; then
+ rmdir --ignore-fail-on-non-empty "$3/build"
+fi
diff --git a/tools/meson_aux/tutorial-custom-cmd.sh b/tools/meson_aux/tutorial-custom-cmd.sh
index d134183..71b37c8 100755
--- a/tools/meson_aux/tutorial-custom-cmd.sh
+++ b/tools/meson_aux/tutorial-custom-cmd.sh
@@ -1,8 +1,13 @@
-#!/bin/bash
+#!/bin/bash -e
# External command, intended to be called with custom_target() in meson.build
case $1 in
+insert_example_code)
+ # tutorial-custom-cmd.sh insert_example_code <perl_script_file> <examples_book_dir> <input_xml_file>
<output_xml_file>
+ perl -- "$2" "$3" "$4" >"$5"
+ cp "$5" "$(dirname "$4")/$(basename "$5")"
+ ;;
html)
# tutorial-custom-cmd.sh html <relative_dir_name> <build_dir> <input_xml_file> <output_html_dir>
@@ -31,18 +36,6 @@ html)
set -o pipefail # Return the exit status of xsltproc, if sed succeeds.
xsltproc $xslt_params -o "$5/" --xinclude $xslt_stylesheet "$4" |& sed '/^Writing /d'
;;
-po2mo)
- # tutorial-custom-cmd.sh po2mo <relative_dir_name> <build_dir> <input_po_file> <output_mo_file>
<stamp_file_path>
- ( cd "$3"; mkdir --parents "$2" )
- msgfmt -o "$5" "$4"
- touch "$6"
- ;;
-xmltrans)
- # tutorial-custom-cmd.sh docbook <input_mo_file> <input_xml_file> <output_xml_dir> <stamp_file_path>
- # Create XML file with translation.
- itstool -m "$2" -o "$4" "$3"
- touch "$5"
- ;;
xmllint)
# tutorial-custom-cmd.sh xmllint <validate> <input_xml_file> <stamp_file_path>
validate=""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]