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



commit 9991f289900743ba5ce7f66986e07e1fc4bb74e4
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Apr 22 16:13:42 2019 +0200

    Add meson.build files and auxiliary scripts for meson builds
    
    This is experimental and incomplete, but hopefully useful.
    See the README file for instructions how to use it.

 README                                 |  35 ++++-
 docs/tutorial/meson.build              | 238 +++++++++++++++++++++++++++++++++
 examples/book/buildapp/meson.build     |  82 ++++++++++++
 examples/book/giomm/meson.build        |  57 ++++++++
 examples/book/meson.build              | 145 ++++++++++++++++++++
 examples/book/treeview/meson.build     |  63 +++++++++
 examples/meson.build                   |  14 ++
 examples/others/meson.build            |  63 +++++++++
 meson.build                            |  77 +++++++++++
 meson_options.txt                      |   7 +
 tools/meson_aux/compile-schemas.sh     |  16 +++
 tools/meson_aux/copy-to-subdir.sh      |  19 +++
 tools/meson_aux/extra-dist-cmd.sh      |  17 +++
 tools/meson_aux/tutorial-custom-cmd.sh |  19 +++
 14 files changed, 851 insertions(+), 1 deletion(-)
---
diff --git a/README b/README
index 0bdb830..7d8698f 100644
--- a/README
+++ b/README
@@ -1,2 +1,35 @@
-This is the documentation for gtkmm, a C++ API for GTK+.
+This is the documentation for gtkmm, a C++ API for GTK.
 See http://www.gtkmm.org/
+
+Building with meson
+-------------------
+This is experimental and incomplete.
+Use autotools for production builds.
+
+Create a build directory:
+  $ cd gtkmm-documentation
+  $ meson <build-dir>
+Do not call the build-dir gtkmm-documenation/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
+
+Print a list of configuration options:
+  $ meson configure
+
+Example of changing options:
+  $ meson configure --prefix=/opt/gnome -Dwarnings=fatal
+
+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.
diff --git a/docs/tutorial/meson.build b/docs/tutorial/meson.build
new file mode 100644
index 0000000..8fc8a27
--- /dev/null
+++ b/docs/tutorial/meson.build
@@ -0,0 +1,238 @@
+# docs/tutorial
+
+# input: gtkmm_datadir, gtkmm_pcname, tutorial_custom_cmd_sh
+# output: tutorial_languages
+
+xsltproc = find_program('xsltproc', required: true)
+perl = find_program('perl', required: true)
+xmllint = find_program('xmllint', required: false)
+
+can_build_translations = find_program('msgfmt', required: false).found() and \
+                         find_program('itstool', required: false).found()
+build_translations_by_default = get_option('build-translations')
+
+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')
+tutorial_figuresdir = join_paths(tutorial_htmldir, 'figures')
+tutorial_iconsdir = join_paths(tutorial_htmldir, 'icons')
+
+tutorial_figurefiles = [
+  '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',
+  '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',
+  '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',
+  'recentfiles.png',
+  'scrolledwindow.png',
+  'spinbutton.png',
+  'textview.png',
+  'toolbar.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 = []
+foreach f : tutorial_figurefiles
+  tutorial_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
+
+# 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
+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',
+]
+
+index_docbook = custom_target('index.docbook',
+  input: join_paths('C', 'index-in.docbook'),
+  output: 'index.docbook',
+  command: [
+    perl, '--',
+    join_paths(meson.current_source_dir(), 'insert_example_code.pl'),
+    join_paths(meson.source_root(), 'examples', 'book'),
+    '@INPUT@',
+  ],
+  capture: true,
+  build_by_default: true
+)
+
+custom_target('html_index.html',
+  input: index_docbook,
+  output: 'html',
+  command: [
+    xsltproc,
+    xslt_params,
+    '-o', '@OUTPUT@/',
+    '--xinclude',
+    '--catalogs',
+    'http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl',
+    '@INPUT@',
+  ],
+  build_by_default: true,
+  install: true,
+  install_dir: tutorialdir
+)
+
+if xmllint.found()
+  custom_target('C-xmllint',
+    input: index_docbook,
+    output: 'C_xmllint.stamp',
+    command: [
+      tutorial_custom_cmd_sh,
+      'xmllint',
+      '@INPUT@',
+      '@OUTPUT@'
+    ],
+    build_by_default: true,
+  )
+endif
+
+if can_build_translations
+  foreach lang : tutorial_languages
+    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,
+    )
+
+    lang_index_docbook = custom_target(lang + '-index.docbook',
+      input: [po2mo, index_docbook],
+      output: lang + '_docbook.stamp',
+      command: [
+        tutorial_custom_cmd_sh,
+        'docbook',
+        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 xmllint.found()
+      custom_target(lang + '-xmllint',
+        input: lang_index_docbook,
+        output: lang + '_xmllint.stamp',
+        command: [
+          tutorial_custom_cmd_sh,
+          'xmllint',
+          join_paths(meson.current_build_dir(), lang, 'index.docbook'),
+          '@OUTPUT@'
+        ],
+        build_by_default: build_translations_by_default,
+      )
+    endif
+  endforeach # lang
+endif # can_build_translations
+
+install_data('style.css', install_dir: tutorial_htmldir)
+install_data(tutorial_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..91b1e22
--- /dev/null
+++ b/examples/book/buildapp/meson.build
@@ -0,0 +1,82 @@
+# examples/book/buildapp
+
+# input: gnome, gtkmm_dep, build_examples_by_default, compile_schemas_sh,
+#        copy_to_subdir_sh
+# 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
+  )
+
+  examples_targets += join_paths('examples', 'book', 'buildapp', stamp_file_name)
+endforeach
+
diff --git a/examples/book/giomm/meson.build b/examples/book/giomm/meson.build
new file mode 100644
index 0000000..2a46ab7
--- /dev/null
+++ b/examples/book/giomm/meson.build
@@ -0,0 +1,57 @@
+# examples/book/giomm
+
+# input: gnome, giomm_dep, build_examples_by_default, copy_to_subdir_sh
+# 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
+  )
+
+  examples_targets += join_paths('examples', 'book', 'giomm', stamp_file_name)
+endforeach
diff --git a/examples/book/meson.build b/examples/book/meson.build
new file mode 100644
index 0000000..91cf473
--- /dev/null
+++ b/examples/book/meson.build
@@ -0,0 +1,145 @@
+# examples/book
+
+# input: gnome, gtkmm_dep, giomm_dep, build_examples_by_default,
+#        compile_schemas_sh, copy_to_subdir_sh, config_include_dir
+# 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],
+  [['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']],
+  [['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],
+  [['expander'], 'example', exwindow_main],
+  [['flowbox'], 'example', exwindow_main],
+  [['frame'], 'example', exwindow_main],
+  [['headerbar'], 'example', exwindow_main],
+  [['grid'], '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']],
+  [['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']],
+  [['spinbutton'], 'example', exwindow_main],
+  [['timeout'], 'timeout', ['main.cc', 'timerexample.cc']],
+  [['toolbar'], 'example', exwindow_main],
+  [['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
+
+  # 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,
+    include_directories: config_include_dir, # only input/example needs this
+    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
+  )
+
+  examples_targets += join_paths('examples', 'book', stamp_file_name)
+endforeach
diff --git a/examples/book/treeview/meson.build b/examples/book/treeview/meson.build
new file mode 100644
index 0000000..e3ed64c
--- /dev/null
+++ b/examples/book/treeview/meson.build
@@ -0,0 +1,63 @@
+# examples/book/treeview
+
+# input: gnome, gtkmm_dep, build_examples_by_default,
+#        compile_schemas_sh, copy_to_subdir_sh
+# input and output: examples_targets
+
+exwindow_main = ['examplewindow.cc', 'main.cc']
+
+examples_book = [
+# [[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
+  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
+  )
+
+  examples_targets += join_paths('examples', 'book', 'treeview', stamp_file_name)
+endforeach
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..7e6f830
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,14 @@
+# examples
+
+# input: gnome, gtkmm_dep, giomm_dep, compile_schemas_sh, copy_to_subdir_sh,
+#        config_include_dir
+
+build_examples_by_default = get_option('build-examples')
+examples_targets = []
+
+subdir('book')
+subdir('others')
+
+run_target('examples',
+  command: ['bash', '-c', 'cd ' + meson.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..7130c59
--- /dev/null
+++ b/examples/others/meson.build
@@ -0,0 +1,63 @@
+# examples/others
+
+# input: gnome, gtkmm_dep, build_examples_by_default, copy_to_subdir_sh
+# 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
+  )
+
+  examples_targets += join_paths('examples', 'others', stamp_file_name)
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..7ef7b88
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,77 @@
+# Building gtkmm-documentation with meson is experimental.
+# Use autotools for production builds.
+
+project('gtkmm-documentation', 'c', 'cpp',
+  version: '3.89.0',
+  default_options: [
+    'cpp_std=c++17'
+  ],
+  meson_version: '>= 0.49.0',
+  license: 'GPLv2'
+)
+
+gtkmm_pcname = 'gtkmm-4.0'
+gtkmm_dep = dependency(gtkmm_pcname, version: '>=3.93.0')
+giomm_dep = dependency('giomm-2.62', version: '>=2.61.1')
+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'))
+
+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')
+
+# This fix is necessary to make examples/book/input/example compile.
+# TODO: Improve it.
+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('.')
+# end of examples/book/input/example fix
+
+subdir('docs/tutorial')
+subdir('examples')
+
+meson.add_dist_script(
+  join_paths('tools', 'meson_aux', 'extra-dist-cmd.sh'),
+  meson.current_build_dir(),
+  join_paths('meson-dist', meson.project_name() + '-' + meson.project_version()),
+  ' '.join(tutorial_languages)
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..26d4486
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,7 @@
+option('warnings', type: 'combo', choices : ['no', 'min', 'max', 'fatal'], value : 'min',
+  description : 'Set compiler pedantry level')
+option('build-examples', type: 'boolean', value: false,
+  description : 'Build all example programs by default')
+option('build-translations', type: 'boolean', value: true,
+  description : 'Build translated tutorials by default')
+
diff --git a/tools/meson_aux/compile-schemas.sh b/tools/meson_aux/compile-schemas.sh
new file mode 100755
index 0000000..f5e61bc
--- /dev/null
+++ b/tools/meson_aux/compile-schemas.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# 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..31db7a0
--- /dev/null
+++ b/tools/meson_aux/copy-to-subdir.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# 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..d734051
--- /dev/null
+++ b/tools/meson_aux/extra-dist-cmd.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# External command, intended to be called with add_dist_script() in meson.build
+
+# extra-dist-cmd.sh <root_build_dir> <relative_dist_dir> <tutorial_languages>
+
+# relative_dist_dir is the distribution directory path relative to root_build_dir.
+
+# Distribute some built files in addition to the files in the local git clone.
+cd "$1"
+# English index.docbook and html files
+cp "docs/tutorial/index.docbook" "$2/docs/tutorial/C/"
+cp --recursive "docs/tutorial/html/" "$2/docs/tutorial/"
+# .mo files with translations and translated index.docbook files.
+for lang in $3; do
+  cp "docs/tutorial/$lang/$lang.mo" "docs/tutorial/$lang/index.docbook" "$2/docs/tutorial/$lang/"
+done
diff --git a/tools/meson_aux/tutorial-custom-cmd.sh b/tools/meson_aux/tutorial-custom-cmd.sh
new file mode 100755
index 0000000..765b552
--- /dev/null
+++ b/tools/meson_aux/tutorial-custom-cmd.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# External command, intended to be called with custom_target() in meson.build
+
+if [ "x$1" = "xpo2mo" ]; then
+  # 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"
+elif [ "x$1" = "xdocbook" ]; then
+  # tutorial-custom-cmd.sh docbook <input_mo_file> <input_xml_file> <output_xml_dir> <stamp_file_path>
+  itstool -m "$2" -o "$4" "$3"
+  touch "$5"
+elif [ "x$1" = "xxmllint" ]; then
+  # tutorial-custom-cmd.sh xmllint <input_xml_file> <stamp_file_path>
+  xmllint --nonet --noout --noent --path "$(dirname "$2")" --xinclude "$2"
+  touch "$3"
+fi
+


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