[gtkmm-documentation] meson.build: "ninja test" builds the example programs



commit 8c2bf265c67e61038ae8f85212e24a1fe72d45db
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Wed May 15 19:15:20 2019 +0200

    meson.build: "ninja test" builds the example programs
    
    That's mainly because "ninja dist" shall check that the example programs
    can be built. The dist-warnings and build-dist-examples options are removed.
    It's not safe to try to detect distribution-in-progress the way it was done.

 README                             |  2 ++
 docs/tutorial/meson.build          |  4 ++--
 examples/book/buildapp/meson.build | 11 +++++++++--
 examples/book/giomm/meson.build    | 12 ++++++++++--
 examples/book/meson.build          | 15 ++++++++++++---
 examples/book/treeview/meson.build | 17 ++++++++++++-----
 examples/meson.build               |  9 ++++++---
 examples/others/meson.build        | 12 ++++++++++--
 meson.build                        | 10 ++++------
 meson_options.txt                  |  6 +-----
 10 files changed, 68 insertions(+), 30 deletions(-)
---
diff --git a/README b/README
index 3a4293a..7b80315 100644
--- a/README
+++ b/README
@@ -21,6 +21,8 @@ Install them:
 
 Build the example programs:
   $ ninja examples
+or (probably slower)
+  $ ninja test
 
 Print a list of configuration options:
   $ meson configure
diff --git a/docs/tutorial/meson.build b/docs/tutorial/meson.build
index 2ba9de7..ce56a6c 100644
--- a/docs/tutorial/meson.build
+++ b/docs/tutorial/meson.build
@@ -1,6 +1,6 @@
 # docs/tutorial
 
-# input: gnome, gtkmm_datadir, gtkmm_pcname, tutorial_custom_cmd_sh
+# 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
 
@@ -142,7 +142,7 @@ index_docbook = custom_target('index.docbook',
   command: [
     tutorial_custom_cmd_sh, 'insert_example_code',
     join_paths(meson.current_source_dir(), 'insert_example_code.pl'),
-    join_paths(meson.source_root(), 'examples', 'book'),
+    join_paths(project_source_root, 'examples', 'book'),
     '@INPUT@',
     '@OUTPUT@',
   ],
diff --git a/examples/book/buildapp/meson.build b/examples/book/buildapp/meson.build
index 91b1e22..8a31339 100644
--- a/examples/book/buildapp/meson.build
+++ b/examples/book/buildapp/meson.build
@@ -1,7 +1,7 @@
 # examples/book/buildapp
 
 # input: gnome, gtkmm_dep, build_examples_by_default, compile_schemas_sh,
-#        copy_to_subdir_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']
@@ -77,6 +77,13 @@ foreach ex : examples_book_buildapp
     build_by_default: build_examples_by_default
   )
 
-  examples_targets += join_paths('examples', 'book', 'buildapp', stamp_file_name)
+  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
index 2a46ab7..85d9f75 100644
--- a/examples/book/giomm/meson.build
+++ b/examples/book/giomm/meson.build
@@ -1,6 +1,7 @@
 # examples/book/giomm
 
-# input: gnome, giomm_dep, build_examples_by_default, copy_to_subdir_sh
+# 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 = [
@@ -53,5 +54,12 @@ foreach ex : examples_book_giomm
     build_by_default: build_examples_by_default
   )
 
-  examples_targets += join_paths('examples', 'book', 'giomm', stamp_file_name)
+  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
index 45b9dcd..4ee21b5 100644
--- a/examples/book/meson.build
+++ b/examples/book/meson.build
@@ -1,7 +1,8 @@
 # examples/book
 
 # input: gnome, gtkmm_dep, giomm_dep, build_examples_by_default,
-#        compile_schemas_sh, copy_to_subdir_sh, config_include_dir
+#        compile_schemas_sh, copy_to_subdir_sh, config_include_dir,
+#        meson_backend, test_timeout, project_build_root
 # input and output: examples_targets
 
 subdir('buildapp')
@@ -60,8 +61,8 @@ examples_book = [
   [['expander'], 'example', exwindow_main],
   [['flowbox'], 'example', exwindow_main],
   [['frame'], 'example', exwindow_main],
-  [['headerbar'], '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],
@@ -90,6 +91,7 @@ examples_book = [
   [['searchbar'], 'example', exwindow_main],
   [['signals', 'custom'], 'example', ['client.cc', 'main.cc', 'server.cc']],
   [['spinbutton'], 'example', exwindow_main],
+  [['textview'], 'example', exwindow_main],
   [['timeout'], 'timeout', ['main.cc', 'timerexample.cc']],
   [['toolbar'], 'example', exwindow_main],
   [['tooltips'], 'example', exwindow_main],
@@ -149,5 +151,12 @@ foreach ex : examples_book
     build_by_default: build_examples_by_default
   )
 
-  examples_targets += join_paths('examples', 'book', stamp_file_name)
+  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
index e3ed64c..6eac69c 100644
--- a/examples/book/treeview/meson.build
+++ b/examples/book/treeview/meson.build
@@ -1,12 +1,12 @@
 # examples/book/treeview
 
-# input: gnome, gtkmm_dep, build_examples_by_default,
-#        compile_schemas_sh, copy_to_subdir_sh
+# 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 = [
+examples_book_treeview = [
 # [[dir-name], exe-name, [sources]]
   [['combo_renderer'], 'example', exwindow_main],
   [['drag_and_drop'], 'example', exwindow_main + ['treemodel_dnd.cc']],
@@ -20,7 +20,7 @@ examples_book = [
   [['tree'], 'example', exwindow_main],
 ]
 
-foreach ex : examples_book
+foreach ex : examples_book_treeview
   dir = ''
   foreach dir_part : ex[0]
     dir = join_paths(dir, dir_part)
@@ -59,5 +59,12 @@ foreach ex : examples_book
     build_by_default: build_examples_by_default
   )
 
-  examples_targets += join_paths('examples', 'book', 'treeview', stamp_file_name)
+  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
index 6342979..28d759a 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -1,6 +1,7 @@
 # examples
 
-# input: gnome, gtkmm_dep, giomm_dep, compile_schemas_sh, copy_to_subdir_sh, is_dist
+# 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.
@@ -25,12 +26,14 @@ custom_target('build_config',
 )
 config_include_dir = include_directories('.')
 
-build_examples_by_default = get_option(is_dist ? 'build-dist-examples' : 'build-examples')
+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 ' + meson.build_root() + '; ' + meson.backend() + ' ' + ' 
'.join(examples_targets)]
+  command: ['bash', '-c', 'cd ' + project_build_root + '; ' + meson.backend() + ' ' + ' 
'.join(examples_targets)]
 )
diff --git a/examples/others/meson.build b/examples/others/meson.build
index 7130c59..051bb3a 100644
--- a/examples/others/meson.build
+++ b/examples/others/meson.build
@@ -1,6 +1,7 @@
 # examples/others
 
-# input: gnome, gtkmm_dep, build_examples_by_default, copy_to_subdir_sh
+# 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 = [
@@ -59,5 +60,12 @@ foreach ex : examples_others
     build_by_default: build_examples_by_default
   )
 
-  examples_targets += join_paths('examples', 'others', stamp_file_name)
+  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
index 5a2fc1c..b0e2c83 100644
--- a/meson.build
+++ b/meson.build
@@ -21,14 +21,12 @@ 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')
+project_source_root = meson.current_source_dir()
+project_build_root = meson.current_build_dir()
 
-# Is this configuration done during creation of a tarball (ninja dist)?
-# The "real" source directory contains a .git subdirectory. The temporary
-# source directory created by "ninja dist" does not.
-is_dist = run_command('test', '-d', join_paths(meson.current_source_dir(), '.git')).returncode() != 0
+cpp_compiler = meson.get_compiler('cpp')
 
-warning_level = get_option(is_dist ? 'dist-warnings' : 'warnings')
+warning_level = get_option('warnings')
 warning_flags = []
 if warning_level == 'min'
   warning_flags = [ '-Wall' ]
diff --git a/meson_options.txt b/meson_options.txt
index 6d39784..62dbad2 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,11 +1,7 @@
-option('warnings', type: 'combo', choices : ['no', 'min', 'max', 'fatal'], value : 'min',
+option('warnings', type: 'combo', choices : ['no', 'min', 'max', 'fatal'], value : 'fatal',
   description : 'Compiler warning level')
-option('dist-warnings', type: 'combo', choices : ['no', 'min', 'max', 'fatal'], value : 'fatal',
-  description : 'Compiler warning level when creating distribution tarball')
 option('build-examples', type: 'boolean', value: false,
   description : 'Build all example programs')
-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 the untranslated XML file')
 option('build-translations', type: 'boolean', value: true,


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