[gtkmm-documentation/gtkmm-3-24] Add meson.build files and auxiliary scripts for meson builds



commit 24ec48c494707feb2eda6b65f643661a45d31bc7
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri May 17 15:03:19 2019 +0200

    Add meson.build files and auxiliary scripts for meson builds
    
    New files copied from git's master branch and modified where necessary.
    See the README file for instructions how to use it.

 README                                 |  43 +++++++
 docs/tutorial/LINGUAS                  |   9 ++
 docs/tutorial/meson.build              | 223 +++++++++++++++++++++++++++++++++
 examples/book/buildapp/meson.build     |  89 +++++++++++++
 examples/book/giomm/meson.build        |  65 ++++++++++
 examples/book/meson.build              | 169 +++++++++++++++++++++++++
 examples/book/treeview/meson.build     |  70 +++++++++++
 examples/meson.build                   |  39 ++++++
 examples/others/meson.build            |  71 +++++++++++
 meson.build                            |  93 ++++++++++++++
 meson_options.txt                      |  10 ++
 tools/meson_aux/compile-schemas.sh     |  16 +++
 tools/meson_aux/copy-to-subdir.sh      |  19 +++
 tools/meson_aux/extra-dist-cmd.sh      |  50 ++++++++
 tools/meson_aux/tutorial-custom-cmd.sh |  76 +++++++++++
 15 files changed, 1042 insertions(+)
---
diff --git a/README b/README
index 0bdb830..e0ed5e1 100644
--- a/README
+++ b/README
@@ -1,2 +1,45 @@
 This is the documentation for gtkmm, a C++ API for GTK+.
 See http://www.gtkmm.org/
+
+Building with meson
+-------------------
+This is experimental, but it's believed to work correctly.
+You're encouraged to test it.
+
+Create a build directory:
+  $ cd gtkmm-3-documentation
+  $ meson <build-dir>
+Do not call the build-dir gtkmm-3-documentation/build. There is already such a
+directory, used when building with autotools.
+
+Create the html files of the tutorial:
+  $ cd <build-dir>
+  $ ninja
+
+Install them:
+  $ ninja install
+
+Build the example programs:
+  $ ninja examples
+or (probably slower)
+  $ ninja test
+
+Print a list of configuration options:
+  $ meson configure
+
+Example of changing options:
+  $ meson configure --prefix=/opt/gnome -Dwarnings=fatal
+
+Create a PDF file
+  $ meson -Dbuild-pdf=true
+  $ ninja
+This requires that you have either the dblatex or the xmllint and docbook2pdf
+commands installed.
+
+Make a tarball:
+  $ ninja dist
+
+This tarball is not identical to one made with "make dist" or "make distcheck".
+There is e.g. no "configure" file. If you want to use a tarball made with
+"ninja dist" for building with autotools, you have to start with ./autogen.sh.
+"make dist" and "make distcheck" don't distribute the meson.build files.
diff --git a/docs/tutorial/LINGUAS b/docs/tutorial/LINGUAS
new file mode 100644
index 0000000..372e5c6
--- /dev/null
+++ b/docs/tutorial/LINGUAS
@@ -0,0 +1,9 @@
+# Please keep this list sorted alphabetically.
+#
+de
+el
+es
+fr
+pt_BR
+sl
+zh_CN
diff --git a/docs/tutorial/meson.build b/docs/tutorial/meson.build
new file mode 100644
index 0000000..084b3d9
--- /dev/null
+++ b/docs/tutorial/meson.build
@@ -0,0 +1,223 @@
+# docs/tutorial
+
+# input: gnome, gtkmm_datadir, gtkmm_pcname, tutorial_custom_cmd_sh, project_source_root
+# output: can_parse_and_validate, build_translations_by_default, can_build_translations,
+#         build_pdf_by_default, can_build_pdf
+
+# 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)
+
+can_parse_and_validate = xmllint.found()
+
+can_build_translations = find_program('msgfmt', required: false).found() and \
+                         find_program('itstool', required: false).found()
+build_translations_by_default = get_option('build-translations')
+validate = get_option('validation') ? 'true' : 'false'
+
+dblatex = find_program('dblatex', required: false)
+can_build_pdf = dblatex.found() or (xmllint.found() and \
+                find_program('docbook2pdf', required: false).found())
+build_pdf_by_default = get_option('build-pdf')
+
+# Installation directories
+tutorialdir = join_paths(gtkmm_datadir, 'doc', gtkmm_pcname, 'tutorial')
+tutorial_htmldir = join_paths(tutorialdir, 'html')
+tutorial_figuresdir = join_paths(tutorial_htmldir, 'figures')
+tutorial_iconsdir = join_paths(tutorial_htmldir, 'icons')
+
+tutorial_figurefiles = [
+  'alignment.png',
+  'aspectframe.png',
+  'assistant.png',
+  'box_packing1.png',
+  'box_packing2.png',
+  'box_packing3.png',
+  'buildapp_app_menu.png',
+  'buildapp_header_bar.png',
+  'buildapp_opening_files.png',
+  'buildapp_populating_window.png',
+  'buildapp_pref_dialog.png',
+  'buildapp_properties.png',
+  'buildapp_search_bar.png',
+  'buildapp_side_bar.png',
+  'buildapp_trivial_app.png',
+  'buttonbox.png',
+  'buttons.png',
+  'cairo_clock.png',
+  'cairo_joins.png',
+  'checkbutton.png',
+  'clipboard_ideal.png',
+  'clipboard_simple.png',
+  'combo.png',
+  'combobox_complex.png',
+  'combobox_text.png',
+  'comboboxentry_complex.png',
+  'comboboxentry_text.png',
+  'custom_container.png',
+  'custom_widget.png',
+  'dialogs_about.png',
+  'dialogs_colorchooserdialog.png',
+  'dialogs_filechooser.png',
+  'dialogs_fontchooserdialog.png',
+  'dialogs_messagedialog.png',
+  'dialogs_simple.png',
+  'drag_and_drop.png',
+  'drawingarea_arcs.png',
+  'drawingarea_curve.png',
+  'drawingarea_image.png',
+  'drawingarea_lines.png',
+  'drawingarea_pango_text.png',
+  'drawingarea_text.png',
+  'drawingarea_thin_lines.png',
+  'entry.png',
+  'entry_completion.png',
+  'entry_icon.png',
+  'entry_progress.png',
+  'eventbox.png',
+  'expander.png',
+  'filechooserbutton.png',
+  'frame.png',
+  'grid.png',
+  'helloworld.png',
+  'helloworld2.png',
+  'idle.png',
+  'infobar.png',
+  'keyboardevents_simple.png',
+  'keyboardevents_propagation.png',
+  'label.png',
+  'main_menu.png',
+  'menu_popup.png',
+  'menus_and_toolbars.png',
+  'menus_menu.png',
+  'menus_menubar.png',
+  'multithread.png',
+  'notebook.png',
+  'paned.png',
+  'printing.png',
+  'progressbar.png',
+  'radiobuttons.png',
+  'range_widgets.png',
+  'recentchooserdialog.png',
+  'scrolledwindow.png',
+  'socket-fail.png',
+  'socket.png',
+  'spinbutton.png',
+  'textview.png',
+  'toolbar.png',
+  'toolpalette.png',
+  'tooltip.png',
+  'treeview_combo_renderer.png',
+  'treeview_draganddrop.png',
+  'treeview_editablecells.png',
+  'treeview_list.png',
+  'treeview_popup.png',
+  'treeview_tree.png',
+  'update_ui.png',
+]
+tutorial_figures = []
+tutorial_C_figures = []
+foreach f : tutorial_figurefiles
+  tutorial_figures += join_paths('figures', f)
+  tutorial_C_figures += join_paths('C', 'figures', f)
+endforeach
+
+tutorial_iconfiles = [
+  'caution.png',
+  'home.png',
+  'important.png',
+  'next.png',
+  'note.png',
+  'prev.png',
+  'tip.png',
+  'up.png',
+  'warning.png',
+]
+tutorial_icons = []
+foreach i : tutorial_iconfiles
+  tutorial_icons += join_paths('icons', i)
+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: [
+    tutorial_custom_cmd_sh, 'insert_example_code',
+    join_paths(meson.current_source_dir(), 'insert_example_code.pl'),
+    join_paths(project_source_root, 'examples', 'book'),
+    '@INPUT@',
+    '@OUTPUT@',
+  ],
+  build_by_default: true
+)
+
+# Create an html version of the C locale's version of the DocBook.
+custom_target('html_index.html',
+  input: index_docbook,
+  output: 'html',
+  command: [
+    tutorial_custom_cmd_sh, 'html',
+    'html',
+    meson.current_build_dir(),
+    '@INPUT@',
+    '@OUTPUT@',    
+  ],
+  build_by_default: true,
+  install: true,
+  install_dir: tutorialdir
+)
+
+if can_parse_and_validate
+  # Parse and possibly validate the C locale's version of the DocBook.
+  custom_target('C-xmllint',
+    input: index_docbook,
+    output: 'C_xmllint.stamp',
+    command: [
+      tutorial_custom_cmd_sh, 'xmllint',
+      validate,
+      '@INPUT@',
+      '@OUTPUT@'
+    ],
+    build_by_default: true,
+  )
+endif
+
+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.
+  custom_target('C-pdf',
+    input: index_docbook,
+    output: 'programming-with-gtkmm.pdf',
+    command: [
+      tutorial_custom_cmd_sh,
+      dblatex.found() ? 'dblatex' : 'docbook2pdf',
+      '@INPUT@',
+      join_paths(meson.current_source_dir(), 'C', 'figures'),
+      '@OUTPUT@'
+    ],
+    build_by_default: build_pdf_by_default,
+  )
+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_C_figures, install_dir: tutorial_figuresdir)
+install_data(tutorial_icons, install_dir: tutorial_iconsdir)
+
diff --git a/examples/book/buildapp/meson.build b/examples/book/buildapp/meson.build
new file mode 100644
index 0000000..8a31339
--- /dev/null
+++ b/examples/book/buildapp/meson.build
@@ -0,0 +1,89 @@
+# examples/book/buildapp
+
+# input: gnome, gtkmm_dep, build_examples_by_default, compile_schemas_sh,
+#        copy_to_subdir_sh, meson_backend, test_timeout, project_build_root
+# input and output: examples_targets
+
+exapp_main = ['exampleapplication.cc', 'exampleappwindow.cc', 'main.cc']
+exapp_prefs = exapp_main + \
+  ['exampleappprefs.cc', 'exampleapp.gresource.xml', 'org.gtkmm.exampleapp.gschema.xml']
+
+examples_book_buildapp = [
+# [[dir-name], exe-name, [sources]]
+  [['step1'], 'exampleapp', exapp_main],
+  [['step2'], 'exampleapp', exapp_main + ['exampleapp.gresource.xml']],
+  [['step3'], 'exampleapp', exapp_main + ['exampleapp.gresource.xml']],
+  [['step4'], 'exampleapp', exapp_main + ['exampleapp.gresource.xml']],
+  [['step5'], 'exampleapp', exapp_prefs],
+  [['step6'], 'exampleapp', exapp_prefs],
+  [['step7'], 'exampleapp', exapp_prefs],
+  [['step8'], 'exampleapp', exapp_prefs],
+  [['step9'], 'exampleapp', exapp_prefs],
+]
+
+glib_compile_schemas = find_program('glib-compile-schemas', required: false)
+
+foreach ex : examples_book_buildapp
+  dir = ''
+  foreach dir_part : ex[0]
+    dir = join_paths(dir, dir_part)
+  endforeach
+  ex_name = join_paths(dir, ex[1]).underscorify()
+  ex_sources = []
+  resources = []
+  schemas = []
+  foreach src : ex[2]
+    if src.endswith('.gresource.xml')
+      resources = gnome.compile_resources(dir.underscorify() + '_resources',
+        join_paths(dir, src),
+        source_dir: dir
+      )
+    elif src.endswith('.gschema.xml')
+      if glib_compile_schemas.found()
+        schemas = custom_target(dir.underscorify() + '_schemas',
+          input: join_paths(dir, src),
+          output: dir.underscorify() + '_gschemas.compiled',
+          command: [
+            compile_schemas_sh,
+            dir,
+            meson.current_source_dir(),
+            meson.current_build_dir(),            
+            '@OUTPUT@'
+          ]
+        )
+      endif
+    else
+      ex_sources += join_paths(dir, src)
+    endif
+  endforeach
+
+  exe_file = executable(ex_name, ex_sources, resources, schemas,
+    dependencies: gtkmm_dep,
+    gui_app: true,
+    build_by_default: build_examples_by_default
+  )
+
+  stamp_file_name = ex_name + '_copy.stamp'
+  custom_target(stamp_file_name,
+    input: exe_file,
+    output: stamp_file_name,
+    command: [
+      copy_to_subdir_sh,
+      '@INPUT@',
+      dir,
+      ex[1],
+      '@OUTPUT@',
+    ],
+    build_by_default: build_examples_by_default
+  )
+
+  target_name = join_paths('examples', 'book', 'buildapp', stamp_file_name)
+  examples_targets += target_name
+
+  test('book_buildapp_' + ex_name, meson_backend,
+    args: target_name,
+    workdir: project_build_root,
+    timeout: test_timeout
+  )
+endforeach
+
diff --git a/examples/book/giomm/meson.build b/examples/book/giomm/meson.build
new file mode 100644
index 0000000..85d9f75
--- /dev/null
+++ b/examples/book/giomm/meson.build
@@ -0,0 +1,65 @@
+# examples/book/giomm
+
+# input: gnome, giomm_dep, build_examples_by_default, copy_to_subdir_sh,
+#        meson_backend, project_build_root
+# input and output: examples_targets
+
+examples_book_giomm = [
+# [[dir-name], exe-name, [sources]]
+  [['directory_list'], 'example', ['main.cc']],
+  [['getline'], 'example', ['getline.cc']],
+  [['monitor_directory'], 'monitor_directory', ['monitor_directory.cc']],
+  [['read_file'], 'example', ['main.cc']],
+  [['read_file_async'], 'example', ['main.cc']],
+  [['usage'], 'usage', ['usage.cc']],
+  [['volumes'], 'example', ['main.cc']],
+  [['write_file'], 'example', ['main.cc']],
+]
+
+foreach ex : examples_book_giomm
+  dir = ''
+  foreach dir_part : ex[0]
+    dir = join_paths(dir, dir_part)
+  endforeach
+  ex_name = join_paths(dir, ex[1]).underscorify()
+  ex_sources = []
+  resources = []
+  foreach src : ex[2]
+    if src.endswith('.gresource.xml')
+      resources = gnome.compile_resources(dir.underscorify() + '_resources',
+        join_paths(dir, src),
+        source_dir: dir
+      )
+    else
+      ex_sources += join_paths(dir, src)
+    endif
+  endforeach
+
+  exe_file = executable(ex_name, ex_sources, resources,
+    dependencies: giomm_dep,
+    build_by_default: build_examples_by_default
+  )
+
+  stamp_file_name = ex_name + '_copy.stamp'
+  custom_target(stamp_file_name,
+    input: exe_file,
+    output: stamp_file_name,
+    command: [
+      copy_to_subdir_sh,
+      '@INPUT@',
+      dir,
+      ex[1],
+      '@OUTPUT@',
+    ],
+    build_by_default: build_examples_by_default
+  )
+
+  target_name = join_paths('examples', 'book', 'giomm', stamp_file_name)
+  examples_targets += target_name
+
+  # These example programs build quite fast. No need for extra timeout time.
+  test('book_giomm_' + ex_name, meson_backend,
+    args: target_name,
+    workdir: project_build_root
+  )
+endforeach
diff --git a/examples/book/meson.build b/examples/book/meson.build
new file mode 100644
index 0000000..5a2b913
--- /dev/null
+++ b/examples/book/meson.build
@@ -0,0 +1,169 @@
+# examples/book
+
+# input: gnome, gtkmm_dep, giomm_dep, build_examples_by_default,
+#        compile_schemas_sh, copy_to_subdir_sh, config_include_dir,
+#        meson_backend, test_timeout, project_build_root
+# input and output: examples_targets
+
+subdir('buildapp')
+subdir('giomm')
+subdir('treeview')
+
+exwindow_main = ['examplewindow.cc', 'main.cc']
+
+examples_book = [
+# [[dir-name], exe-name, [sources]]
+  [['actionbar'], 'example', exwindow_main],
+  [['alignment'], 'example', exwindow_main],
+  [['application', 'simple'], 'example', ['exampleapplication.cc'] + exwindow_main],
+  [['application', 'command_line_handling'], 'example', ['exampleapplication.cc'] + exwindow_main],
+  [['application', 'app_and_win_menus'], 'example', ['exampleapplication.cc'] + exwindow_main],
+  [['aspectframe'], 'example', exwindow_main],
+  [['assistant'], 'example', ['exampleassistant.cc'] + exwindow_main],
+  [['base'], 'base', ['base.cc']],
+  [['box'], 'example', exwindow_main + ['packbox.cc']],
+  [['builder', 'basic'], 'example', ['main.cc']],
+  [['builder', 'derived'], 'example', ['deriveddialog.cc', 'main.cc']],
+  [['buttonbox'], 'example', ['examplebuttonbox.cc'] + exwindow_main],
+  [['buttons', 'button'], 'buttons', ['buttons.cc', 'main.cc']],
+  [['buttons', 'checkbutton'], 'example', exwindow_main],
+  [['buttons', 'filechooserbutton'], 'example', exwindow_main],
+  [['buttons', 'radiobutton'], 'radiobuttons', ['main.cc', 'radiobuttons.cc']],
+  [['buttons', 'scalebutton'], 'example', exwindow_main],
+  [['buttons', 'togglebutton'], 'example', exwindow_main],
+  [['buttons', 'volumebutton'], 'example', exwindow_main],
+  [['clipboard', 'ideal'], 'example', exwindow_main],
+  [['clipboard', 'simple'], 'example', exwindow_main],
+  [['combobox', 'complex'], 'example', exwindow_main],
+  [['combobox', 'text'], 'example', exwindow_main],
+  [['combobox', 'entry_complex'], 'example', exwindow_main],
+  [['combobox', 'entry_text'], 'example', exwindow_main],
+  [['custom', 'custom_container'], 'example', exwindow_main + ['mycontainer.cc']],
+  [['custom', 'custom_widget'], 'example', exwindow_main + ['myextrainit.cc', 'mywidget.cc']],
+  [['dialogs', 'aboutdialog'], 'example',  exwindow_main + ['aboutdialog.gresource.xml']],
+  [['dialogs', 'colorchooserdialog'], 'example', exwindow_main],
+  [['dialogs', 'filechooserdialog'], 'example', exwindow_main],
+  [['dialogs', 'filechoosernative'], 'example', exwindow_main],
+  [['dialogs', 'fontchooserdialog'], 'example', exwindow_main],
+  [['dialogs', 'messagedialog'], 'example', exwindow_main],
+  [['dialogs', 'simple'], 'example', exwindow_main],
+  [['drag_and_drop'], 'drag_and_drop', ['dndwindow.cc', 'main.cc']],
+  [['drawingarea', 'arcs'], 'drawingareaarcs', ['main.cc', 'myarea.cc']],
+  [['drawingarea', 'clock'], 'cairoclock', ['clock.cc', 'main.cc']],
+  [['drawingarea', 'curve'], 'drawingareacurve', ['main.cc', 'myarea.cc']],
+  [['drawingarea', 'image'], 'drawingareaimage', ['main.cc', 'myarea.cc', 'image.gresource.xml']],
+  [['drawingarea', 'joins'], 'cairojoins', ['main.cc', 'myarea.cc']],
+  [['drawingarea', 'pango_text'], 'example', ['main.cc', 'myarea.cc']],
+  [['drawingarea', 'simple'], 'drawingarea', ['main.cc', 'myarea.cc']],
+  [['drawingarea', 'thin_lines'], 'example', exwindow_main + ['myarea.cc']],
+  [['entry', 'completion'], 'example', exwindow_main],
+  [['entry', 'icon'], 'example', exwindow_main],
+  [['entry', 'progress'], 'example', exwindow_main],
+  [['entry', 'simple'], 'example', exwindow_main],
+  [['eventbox'], 'example', exwindow_main],
+  [['expander'], 'example', exwindow_main],
+  [['flowbox'], 'example', exwindow_main],
+  [['frame'], 'example', exwindow_main],
+  [['grid'], 'example', exwindow_main],
+  [['headerbar'], 'example', exwindow_main],
+  [['helloworld'], 'helloworld', ['helloworld.cc', 'main.cc']],
+  [['helloworld2'], 'helloworld2', ['helloworld.cc', 'main.cc']],
+  [['iconview'], 'example', exwindow_main],
+  [['idle'], 'idle', ['idleexample.cc', 'main.cc']],
+  [['infobar'], 'example', exwindow_main],
+  [['input'], 'example', ['main.cc']],
+  [['keyboard_events', 'simple'], 'example', exwindow_main],
+  [['keyboard_events', 'propagation'], 'example', exwindow_main],
+  [['label'], 'example', exwindow_main],
+  [['listbox'], 'example', exwindow_main + ['examplerow.cc']],
+  [['listmodel'], 'example', exwindow_main + ['myobject.cc']],
+  [['menus', 'main_menu'], 'main_menu', ['exampleapplication.cc'] + exwindow_main],
+  [['menus', 'popup'], 'example', exwindow_main],
+  [['menus_and_toolbars'], 'example', exwindow_main + ['toolbar.gresource.xml']],
+  [['multithread'], 'example', exwindow_main + ['exampleworker.cc']],
+  [['notebook'], 'example', exwindow_main],
+  [['paned'], 'example', exwindow_main + ['messageslist.cc', 'messagetext.cc']],
+  [['placessidebar'], 'example', exwindow_main],
+  [['popover'], 'example', exwindow_main],
+  [['printing', 'advanced'], 'example', exwindow_main + ['previewdialog.cc', 'printformoperation.cc']],
+  [['printing', 'simple'], 'example', exwindow_main + ['printformoperation.cc']],
+  [['progressbar'], 'example', exwindow_main],
+  [['range_widgets'], 'example', exwindow_main],
+  [['recent_files'], 'example', exwindow_main],
+  [['revealer'], 'example', exwindow_main],
+  [['scrolledwindow'], 'example', exwindow_main],
+  [['searchbar'], 'example', exwindow_main],
+  [['signals', 'custom'], 'example', ['client.cc', 'main.cc', 'server.cc']],
+  [['socket'], 'plug', ['plug.cc']],
+  [['socket'], 'socket', ['socket.cc']],
+  [['spinbutton'], 'example', exwindow_main],
+  [['textview'], 'example', exwindow_main],
+  [['timeout'], 'timeout', ['main.cc', 'timerexample.cc']],
+  [['toolbar'], 'example', exwindow_main],
+  [['toolpalette'], 'example', exwindow_main + ['canvas.cc']],
+  [['tooltips'], 'example', exwindow_main],
+  [['update_ui'], 'example', exwindow_main],
+]
+
+thread_dep = dependency('threads')
+
+foreach ex : examples_book
+  dir = ''
+  foreach dir_part : ex[0]
+    dir = join_paths(dir, dir_part)
+  endforeach
+  ex_name = join_paths(dir, ex[1]).underscorify()
+  ex_sources = []
+  resources = []
+  foreach src : ex[2]
+    if src.endswith('.gresource.xml')
+      resources = gnome.compile_resources(dir.underscorify() + '_resources',
+        join_paths(dir, src),
+        source_dir: dir
+      )
+    else
+      ex_sources += join_paths(dir, src)
+    endif
+  endforeach
+
+  if ex[0][0] == 'input'
+    # input/main.cc includes build/config.h.
+    exe_file = executable(ex_name, ex_sources, resources,
+      dependencies: gtkmm_dep,
+      include_directories: config_include_dir,
+      build_by_default: build_examples_by_default
+    )
+  else
+    # multi-threaded programs need thread support
+    deps = (ex[0][0] == 'multithread') ? [gtkmm_dep, thread_dep] : gtkmm_dep
+
+    exe_file = executable(ex_name, ex_sources, resources,
+      dependencies: deps,
+      gui_app: true,
+      build_by_default: build_examples_by_default
+    )
+  endif
+
+  stamp_file_name = ex_name + '_copy.stamp'
+  custom_target(stamp_file_name,
+    input: exe_file,
+    output: stamp_file_name,
+    command: [
+      copy_to_subdir_sh,
+      '@INPUT@',
+      dir,
+      ex[1],
+      '@OUTPUT@',
+    ],
+    build_by_default: build_examples_by_default
+  )
+
+  target_name = join_paths('examples', 'book', stamp_file_name)
+  examples_targets += target_name
+
+  test('book_' + ex_name, meson_backend,
+    args: target_name,
+    workdir: project_build_root,
+    timeout: test_timeout
+  )
+endforeach
diff --git a/examples/book/treeview/meson.build b/examples/book/treeview/meson.build
new file mode 100644
index 0000000..6eac69c
--- /dev/null
+++ b/examples/book/treeview/meson.build
@@ -0,0 +1,70 @@
+# examples/book/treeview
+
+# input: gnome, gtkmm_dep, build_examples_by_default, compile_schemas_sh,
+#        copy_to_subdir_sh, meson_backend, test_timeout, project_build_root
+# input and output: examples_targets
+
+exwindow_main = ['examplewindow.cc', 'main.cc']
+
+examples_book_treeview = [
+# [[dir-name], exe-name, [sources]]
+  [['combo_renderer'], 'example', exwindow_main],
+  [['drag_and_drop'], 'example', exwindow_main + ['treemodel_dnd.cc']],
+  [['editable_cells'], 'example', exwindow_main],
+  [['filter'], 'example', exwindow_main],
+  [['filter_modify'], 'example', exwindow_main],
+  [['list'], 'example', exwindow_main],
+  [['listviewtext'], 'example', exwindow_main],
+  [['modelsort'], 'example', exwindow_main],
+  [['popup'], 'example', exwindow_main + ['treeview_withpopup.cc']],
+  [['tree'], 'example', exwindow_main],
+]
+
+foreach ex : examples_book_treeview
+  dir = ''
+  foreach dir_part : ex[0]
+    dir = join_paths(dir, dir_part)
+  endforeach
+  ex_name = join_paths(dir, ex[1]).underscorify()
+  ex_sources = []
+  resources = []
+  foreach src : ex[2]
+    if src.endswith('.gresource.xml')
+      resources = gnome.compile_resources(dir.underscorify() + '_resources',
+        join_paths(dir, src),
+        source_dir: dir
+      )
+    else
+      ex_sources += join_paths(dir, src)
+    endif
+  endforeach
+
+  exe_file = executable(ex_name, ex_sources, resources,
+    dependencies: gtkmm_dep,
+    gui_app: true,
+    build_by_default: build_examples_by_default
+  )
+
+  stamp_file_name = ex_name + '_copy.stamp'
+  custom_target(stamp_file_name,
+    input: exe_file,
+    output: stamp_file_name,
+    command: [
+      copy_to_subdir_sh,
+      '@INPUT@',
+      dir,
+      ex[1],
+      '@OUTPUT@',
+    ],
+    build_by_default: build_examples_by_default
+  )
+
+  target_name = join_paths('examples', 'book', 'treeview', stamp_file_name)
+  examples_targets += target_name
+
+  test('book_treeview_' + ex_name, meson_backend,
+    args: target_name,
+    workdir: project_build_root,
+    timeout: test_timeout
+  )
+endforeach
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..28d759a
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,39 @@
+# examples
+
+# input: gnome, gtkmm_dep, giomm_dep, compile_schemas_sh, copy_to_subdir_sh,
+#        project_build_root
+# output: build_examples_by_default
+
+# examples/book/input/main.cc includes build/config.h.
+has_mkfifo = cpp_compiler.has_function('mkfifo')
+conf_data = configuration_data()
+conf_data.set('HAVE_MKFIFO', has_mkfifo)
+conf_file = configure_file(
+  output: 'config.h',
+  configuration: conf_data
+)
+custom_target('build_config',
+  input: conf_file,
+  output: 'config.stamp',
+  command: [
+    copy_to_subdir_sh,
+    '@INPUT@',
+    'build',
+    'config.h',
+    '@OUTPUT@',
+  ],
+  build_by_default: true
+)
+config_include_dir = include_directories('.')
+
+meson_backend = find_program(meson.backend(), required: true)
+build_examples_by_default = get_option('build-examples')
+test_timeout = 80 # max seconds per test
+examples_targets = []
+
+subdir('book')
+subdir('others')
+
+run_target('examples',
+  command: ['bash', '-c', 'cd ' + project_build_root + '; ' + meson.backend() + ' ' + ' 
'.join(examples_targets)]
+)
diff --git a/examples/others/meson.build b/examples/others/meson.build
new file mode 100644
index 0000000..051bb3a
--- /dev/null
+++ b/examples/others/meson.build
@@ -0,0 +1,71 @@
+# examples/others
+
+# input: gnome, gtkmm_dep, build_examples_by_default, copy_to_subdir_sh,
+#        meson_backend, test_timeout, project_build_root
+# input and output: examples_targets
+
+examples_others = [
+# [[dir-name], exe-name, [sources]]
+  [['arrow'], 'arrow', ['arrow.cc']],
+  [['calendar'], 'calendar', ['calendar.cc']],
+  [['cellrenderercustom'], 'cellrenderertoggle', ['cellrenderertoggle.cc']],
+  [['cellrenderercustom'], 'testpopup',
+    ['cellrendererlist.cc', 'cellrendererpopup.cc', 'popupentry.cc', 'testpopup.cc']],
+  [['dnd'], 'testdnd', ['dndwindow.cc', 'main.cc']],
+  [['exception'], 'exceptiontest', ['exceptiontest.cc']],
+  [['idle'], 'idle', ['idle.cc']],
+  [['statusbar'], 'statusbar', ['statusbar.cc']],
+  [['tictactoe'], 'ttt_test', ['tictactoe.cc', 'ttt_test.cc']],
+  [['treemodelcustom'], 'example', ['exampletreemodel.cc', 'examplewindow.cc', 'main.cc']],
+  # Waiting for a gdk_cairo_region_from_surface():
+  # [['window'], 'wheelbarrow', ['wheelbarrow.cc']],
+]
+
+foreach ex : examples_others
+  dir = ''
+  foreach dir_part : ex[0]
+    dir = join_paths(dir, dir_part)
+  endforeach
+  ex_name = join_paths(dir, ex[1]).underscorify()
+  ex_sources = []
+  resources = []
+  foreach src : ex[2]
+    if src.endswith('.gresource.xml')
+      resources = gnome.compile_resources(dir.underscorify() + '_resources',
+        join_paths(dir, src),
+        source_dir: dir
+      )
+    else
+      ex_sources += join_paths(dir, src)
+    endif
+  endforeach
+
+  exe_file = executable(ex_name, ex_sources, resources,
+    dependencies: gtkmm_dep,
+    gui_app: true,
+    build_by_default: build_examples_by_default
+  )
+
+  stamp_file_name = ex_name + '_copy.stamp'
+  custom_target(stamp_file_name,
+    input: exe_file,
+    output: stamp_file_name,
+    command: [
+      copy_to_subdir_sh,
+      '@INPUT@',
+      dir,
+      ex[1],
+      '@OUTPUT@',
+    ],
+    build_by_default: build_examples_by_default
+  )
+
+  target_name = join_paths('examples', 'others', stamp_file_name)
+  examples_targets += target_name
+
+  test('others_' + ex_name, meson_backend,
+    args: target_name,
+    workdir: project_build_root,
+    timeout: test_timeout
+  )
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..8c102ce
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,93 @@
+# This file is part of gtkmm-documentation.
+
+project('gtkmm-documentation', 'c', 'cpp',
+  version: '3.24.0',
+  default_options: [
+    'cpp_std=c++14'
+  ],
+  meson_version: '>= 0.49.0',
+  license: 'GPLv2'
+)
+
+gtkmm_pcname = 'gtkmm-3.0'
+gtkmm_dep = dependency(gtkmm_pcname, version: '>=3.24.0')
+giomm_dep = dependency('giomm-2.4', version: '>=2.54.0')
+gnome = import('gnome')
+
+gtkmm_prefix = get_option('prefix')
+gtkmm_datadir = join_paths(gtkmm_prefix, get_option('datadir'))
+
+compile_schemas_sh = files(join_paths('tools', 'meson_aux', 'compile-schemas.sh'))
+copy_to_subdir_sh = files(join_paths('tools', 'meson_aux', 'copy-to-subdir.sh'))
+tutorial_custom_cmd_sh = files(join_paths('tools', 'meson_aux', 'tutorial-custom-cmd.sh'))
+
+project_source_root = meson.current_source_dir()
+project_build_root = meson.current_build_dir()
+
+cpp_compiler = meson.get_compiler('cpp')
+
+warning_level = get_option('warnings')
+warning_flags = []
+if warning_level == 'min'
+  warning_flags = [ '-Wall' ]
+elif warning_level == 'max' or warning_level == 'fatal'
+  warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow 
-Wno-long-long'.split()
+  if warning_level == 'fatal'
+    warning_flags += [ '-Werror' ]
+    deprecations = 'G PANGO ATK GDK GDK_PIXBUF GTK GLIBMM GIOMM GDKMM ATKMM PANGOMM GTKMM SIGCXX'.split()
+    foreach d : deprecations
+      warning_flags += '-D@0@_DISABLED_DEPRECATED'.format(d)
+    endforeach
+  endif
+endif
+
+warning_flags = cpp_compiler.get_supported_arguments(warning_flags)
+add_project_arguments(warning_flags, language: 'cpp')
+
+subdir('docs/tutorial')
+subdir('examples')
+
+# Modify the contents of the distribution directory.
+meson.add_dist_script(
+  join_paths('tools', 'meson_aux', 'extra-dist-cmd.sh'),
+  meson.current_source_dir(),
+  meson.current_build_dir(),
+  join_paths('meson-dist', meson.project_name() + '-' + meson.project_version()),
+)
+
+# Print a summary.
+validate = get_option('validation') and can_parse_and_validate
+explain_val = ''
+if get_option('validation') and not validate
+  explain_val = ' (requires xmllint)'
+endif
+
+build_translations = build_translations_by_default and can_build_translations
+explain_trans = ''
+if build_translations_by_default and not build_translations
+  explain_trans = ' (requires msgfmt and itstool)'
+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 (xmllint and docbook2pdf))'
+endif
+
+summary = [
+  '',
+  '------',
+  meson.project_name() + ' ' + meson.project_version(),
+  '',
+  '    Build examples: @0@'.format(build_examples_by_default),
+  ' 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),
+  'Directories:',
+  '            prefix: @0@'.format(gtkmm_prefix),
+  '           datadir: @0@'.format(gtkmm_datadir),
+  '------'
+]
+
+message('\n'.join(summary))
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..62dbad2
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,10 @@
+option('warnings', type: 'combo', choices : ['no', 'min', 'max', 'fatal'], value : 'fatal',
+  description : 'Compiler warning level')
+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('build-translations', type: 'boolean', value: true,
+  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
new file mode 100755
index 0000000..2656089
--- /dev/null
+++ b/tools/meson_aux/compile-schemas.sh
@@ -0,0 +1,16 @@
+#!/bin/bash -e
+
+# External command, intended to be called with custom_target() in meson.build
+
+# compile-schemas.sh <relative_dir_name> <source_dir> <build_dir> <output_file>
+
+# relative_dir_name: where the .gschema.xml file is located, relative to source_dir 
+# source_dir: where the meson.build file is located.
+# build_dir: the corresponding location in the build tree.
+# output_file: contains the path relative to the directory where this script starts executing.
+
+( cd "$3"; mkdir --parents "$1" )
+glib-compile-schemas --strict --targetdir="$3/$1" "$2/$1"
+cp "$3/$1/gschemas.compiled" "$4"
+
+
diff --git a/tools/meson_aux/copy-to-subdir.sh b/tools/meson_aux/copy-to-subdir.sh
new file mode 100755
index 0000000..7e82a6a
--- /dev/null
+++ b/tools/meson_aux/copy-to-subdir.sh
@@ -0,0 +1,19 @@
+#!/bin/bash -e
+
+# External command, intended to be called with custom_target() in meson.build
+
+# copy-to-subdir.sh <input_file_path> <relative_subdir> <output_file_name> <stamp_file_path>
+
+# input_file_path: input file, possibly including path.
+# relative_subdir: to where the file shall be copied, relative to the input file's directory.
+# output_file_name: output file, without path.
+# stamp_file_path: stamp file, possibly including path.
+
+# Paths can be either absolute paths, or paths relative to the directory which
+# is current when this script is called.
+
+input_dir_path="$(dirname "$1")"
+( cd "$input_dir_path"; mkdir --parents "$2" )
+cp --preserve "$1" "$input_dir_path/$2/$3"
+touch "$4"
+
diff --git a/tools/meson_aux/extra-dist-cmd.sh b/tools/meson_aux/extra-dist-cmd.sh
new file mode 100755
index 0000000..01568a5
--- /dev/null
+++ b/tools/meson_aux/extra-dist-cmd.sh
@@ -0,0 +1,50 @@
+#!/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>
+
+# 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.
+
+# Make a ChangeLog file for distribution.
+git --git-dir="$1/.git" --work-tree="$1" log --no-merges --date=short --max-count=200 \
+    --pretty='tformat:%cd  %an  <%ae>%n%n  %s%n%w(0,0,2)%+b' > "$2/$3/ChangeLog"
+
+# Distribute some built files in addition to the files in the local git clone.
+cd "$2"
+dist_docs_tutorial="$3/docs/tutorial"
+
+# English index.docbook and html files.
+cp "docs/tutorial/index.docbook" "$dist_docs_tutorial/C/"
+cp --recursive "docs/tutorial/html/" "$dist_docs_tutorial/"
+
+# 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 '{}' \;
+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
new file mode 100755
index 0000000..71b37c8
--- /dev/null
+++ b/tools/meson_aux/tutorial-custom-cmd.sh
@@ -0,0 +1,76 @@
+#!/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>
+
+  # 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
+  # re-ordered or inserted in the documentation.
+  # For a list of available parameters, see http://docbook.sourceforge.net/release/xsl/current/doc/html/
+  xslt_params='
+    --param       toc.section.depth 1
+    --stringparam html.stylesheet style.css
+    --stringparam admon.graphics 1
+    --stringparam admon.graphics.path icons/
+    --stringparam admon.graphics.extension .png
+    --stringparam chunker.output.indent yes
+    --stringparam chunker.output.encoding UTF-8
+    --stringparam navig.graphics yes
+    --stringparam navig.graphics.extension .png
+    --stringparam navig.graphics.path icons/
+    --stringparam toc.list.type ul
+    --stringparam use.id.as.filename 1'
+  xslt_stylesheet='http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl'
+
+  ( cd "$3"; rm --force --recursive "$2"; mkdir --parents "$2" )
+  # Don't use grep instead of sed. grep returns a non-zero exit status if no line
+  # is selected, which is the normal case.
+  set -o pipefail # Return the exit status of xsltproc, if sed succeeds.
+  xsltproc $xslt_params -o "$5/" --xinclude $xslt_stylesheet "$4" |& sed '/^Writing /d'
+  ;;
+xmllint)
+  # tutorial-custom-cmd.sh xmllint <validate> <input_xml_file> <stamp_file_path>
+  validate=""
+  if [ "x$2" = "xtrue" ]; then
+    validate="--postvalid"
+  fi
+  xmllint --noout --noent --xinclude $validate "$3"
+  touch "$4"
+  ;;
+dblatex)
+  # tutorial-custom-cmd.sh dblatex <input_xml_file> <figures_dir> <output_pdf_file>
+  # Create a PDF file, using dblatex.
+
+  # For a list of available parameters, see http://dblatex.sourceforge.net/doc/manual/
+  dblatex_params='
+    -P toc.section.depth=2
+    -P paper.type=a4paper'
+  figures_dir_parent="$(dirname "$3")"
+  dblatex $dblatex_params -I "$figures_dir_parent" -o "$4" --pdf "$2"
+  ;;
+docbook2pdf)
+  # tutorial-custom-cmd.sh docbook2pdf <input_xml_file> <figures_dir> <output_pdf_file>
+  # Create a PDF file, using docbook2pdf.
+  output_dir="$(dirname "$4")"
+  output_basename="$(basename -s .pdf "$4")"
+  xml_file="$output_dir/$output_basename.xml"
+
+  # We need to produce a full examples XML with all of the XIncludes done.
+       xmllint --xinclude --postvalid --output "$xml_file" "$2"
+
+       # We also need to copy the figures from the source directory, so they
+       # can be found from the XML file.
+       cp --preserve --recursive "$3" "$output_dir/$(basename "$3")"
+
+       docbook2pdf --output "$output_dir" "$xml_file"
+       ;;
+esac
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]