[gtkmm-documentation] buildapp examples: Add meson.build files



commit 29aa097ad40c418331ed6fce2decef9e22a5d042
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Apr 14 10:20:13 2019 +0200

    buildapp examples: Add meson.build files
    
    * examples/book/buildapp/README: Describe how to build with meson and ninja.
    * examples/book/buildapp/step1/install-cmd.sh:
    * examples/book/buildapp/step[1-9]/meson.build: New files

 examples/book/buildapp/README               | 19 +++++++++++--
 examples/book/buildapp/step1/install-cmd.sh | 28 ++++++++++++++++++
 examples/book/buildapp/step1/meson.build    | 31 ++++++++++++++++++++
 examples/book/buildapp/step2/meson.build    | 35 +++++++++++++++++++++++
 examples/book/buildapp/step3/meson.build    | 35 +++++++++++++++++++++++
 examples/book/buildapp/step4/meson.build    | 35 +++++++++++++++++++++++
 examples/book/buildapp/step5/meson.build    | 44 +++++++++++++++++++++++++++++
 examples/book/buildapp/step6/meson.build    | 44 +++++++++++++++++++++++++++++
 examples/book/buildapp/step7/meson.build    | 44 +++++++++++++++++++++++++++++
 examples/book/buildapp/step8/meson.build    | 44 +++++++++++++++++++++++++++++
 examples/book/buildapp/step9/meson.build    | 44 +++++++++++++++++++++++++++++
 11 files changed, 400 insertions(+), 3 deletions(-)
---
diff --git a/examples/book/buildapp/README b/examples/book/buildapp/README
index 1d4d26d..f3da867 100644
--- a/examples/book/buildapp/README
+++ b/examples/book/buildapp/README
@@ -5,17 +5,25 @@
 The examples in this directory are built with 'make check' alongside the rest of
 the examples in gtkmm-documentation.
 
-The examples in the step[1-9] directories can also be built independently,
-by doing:
+The examples in the step[1-9] directories can also be built separately.
+You can then choose to build with make or with meson and ninja.
 
   $ cd step1  # or step2, step3, etc.
   $ make -f Makefile.example
+or
+  $ cd step1  # or step2, step3, etc.
+  $ meson build  # or another name for the build directory
+  $ cd build
+  $ ninja
 
 To make gnome-shell use the desktop file and icon for one of the examples
 while running it uninstalled, do the following:
 
   $ cd step1  # or step2, step3, etc.
   $ make -f Makefile.example install-desktop-file
+or
+  $ cd step1/build  # or step2/build, step3/build, etc.
+  $ ninja install-desktop-file
 
 To make Gio::Settings find the preferences in step[5-9], they must be stored
 where they can be found via one of the environment variables XDG_DATA_DIRS,
@@ -23,6 +31,9 @@ XDG_DATA_HOME or GSETTINGS_SCHEMA_DIR. One way to achieve this is:
 
   $ cd step5  # or step6, step7, etc.
   $ export GSETTINGS_SCHEMA_DIR=.
+or
+  $ cd step5/build  # or step6/build, step7/build, etc.
+  $ export GSETTINGS_SCHEMA_DIR=.
 
 But then the program can only be run from that directory. Alternatively,
 set GSETTINGS_SCHEMA_DIR to an absolute path, such as
@@ -33,4 +44,6 @@ and do the following:
 
   $ cd step5  # or step6, step7, etc.
   $ make -f Makefile.example install-gschema-file
-
+or
+  $ cd step5/build  # or step6/build, step7/build, etc.
+  $ ninja install-gschema-file
diff --git a/examples/book/buildapp/step1/install-cmd.sh b/examples/book/buildapp/step1/install-cmd.sh
new file mode 100755
index 0000000..354009a
--- /dev/null
+++ b/examples/book/buildapp/step1/install-cmd.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# External command, intended to be called from
+#   ninja install-desktop-file
+# and
+#   ninja install-gschema-file
+
+cd $MESON_SOURCE_ROOT
+
+if [ "x$1" = "xdesktop" ]; then
+  # ./install-cmd.sh desktop <program_name> <desktop_file> <icon_file>
+  mkdir -p ~/.local/share/applications
+  sed -e "s#@bindir@#$MESON_BUILD_ROOT#" "$3" > ~/.local/share/applications/$2.desktop
+  mkdir -p ~/.local/share/icons/hicolor/48x48/apps
+  cp "$4" ~/.local/share/icons/hicolor/48x48/apps
+
+elif [ "x$1" = "xgschema" ]; then
+  # ./install-cmd.sh gschema <gschema_file>
+  if [ -n "$GSETTINGS_SCHEMA_DIR" -a "$GSETTINGS_SCHEMA_DIR" != . ]; then
+    mkdir -p "$GSETTINGS_SCHEMA_DIR"
+    cp "$2" "$GSETTINGS_SCHEMA_DIR"
+    glib-compile-schemas "$GSETTINGS_SCHEMA_DIR"
+  fi
+
+else
+  echo Unknown subcommand: $*
+  exit 1
+fi
diff --git a/examples/book/buildapp/step1/meson.build b/examples/book/buildapp/step1/meson.build
new file mode 100644
index 0000000..9ca481b
--- /dev/null
+++ b/examples/book/buildapp/step1/meson.build
@@ -0,0 +1,31 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+]
+
+executable(program_name,
+  cpp_sources,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = './install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    'exampleapp.desktop',
+    'exampleapp.png'
+  ]
+)
diff --git a/examples/book/buildapp/step2/meson.build b/examples/book/buildapp/step2/meson.build
new file mode 100644
index 0000000..b2b7548
--- /dev/null
+++ b/examples/book/buildapp/step2/meson.build
@@ -0,0 +1,35 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gnome = import('gnome')
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+]
+
+resources = gnome.compile_resources('resources',
+                                    'exampleapp.gresource.xml',
+                                    source_dir: '.')
+executable(program_name,
+  cpp_sources, resources,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = '../step1/install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    '../step1/exampleapp.desktop',
+    '../step1/exampleapp.png'
+  ]
+)
diff --git a/examples/book/buildapp/step3/meson.build b/examples/book/buildapp/step3/meson.build
new file mode 100644
index 0000000..b2b7548
--- /dev/null
+++ b/examples/book/buildapp/step3/meson.build
@@ -0,0 +1,35 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gnome = import('gnome')
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+]
+
+resources = gnome.compile_resources('resources',
+                                    'exampleapp.gresource.xml',
+                                    source_dir: '.')
+executable(program_name,
+  cpp_sources, resources,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = '../step1/install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    '../step1/exampleapp.desktop',
+    '../step1/exampleapp.png'
+  ]
+)
diff --git a/examples/book/buildapp/step4/meson.build b/examples/book/buildapp/step4/meson.build
new file mode 100644
index 0000000..b2b7548
--- /dev/null
+++ b/examples/book/buildapp/step4/meson.build
@@ -0,0 +1,35 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gnome = import('gnome')
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+]
+
+resources = gnome.compile_resources('resources',
+                                    'exampleapp.gresource.xml',
+                                    source_dir: '.')
+executable(program_name,
+  cpp_sources, resources,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = '../step1/install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    '../step1/exampleapp.desktop',
+    '../step1/exampleapp.png'
+  ]
+)
diff --git a/examples/book/buildapp/step5/meson.build b/examples/book/buildapp/step5/meson.build
new file mode 100644
index 0000000..ee9ba53
--- /dev/null
+++ b/examples/book/buildapp/step5/meson.build
@@ -0,0 +1,44 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gnome = import('gnome')
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+  'exampleappprefs.cc',
+]
+
+resources = gnome.compile_resources('resources',
+                                    'exampleapp.gresource.xml',
+                                    source_dir: '.')
+schemas = gnome.compile_schemas(depend_files: 'org.gtkmm.exampleapp.gschema.xml')
+
+executable(program_name,
+  cpp_sources, resources, schemas,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = '../step1/install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    '../step1/exampleapp.desktop',
+    '../step1/exampleapp.png'
+  ]
+)
+
+run_target('install-gschema-file',
+  command: [install_cmd, 'gschema',
+    'org.gtkmm.exampleapp.gschema.xml'
+  ]
+)
diff --git a/examples/book/buildapp/step6/meson.build b/examples/book/buildapp/step6/meson.build
new file mode 100644
index 0000000..ee9ba53
--- /dev/null
+++ b/examples/book/buildapp/step6/meson.build
@@ -0,0 +1,44 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gnome = import('gnome')
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+  'exampleappprefs.cc',
+]
+
+resources = gnome.compile_resources('resources',
+                                    'exampleapp.gresource.xml',
+                                    source_dir: '.')
+schemas = gnome.compile_schemas(depend_files: 'org.gtkmm.exampleapp.gschema.xml')
+
+executable(program_name,
+  cpp_sources, resources, schemas,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = '../step1/install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    '../step1/exampleapp.desktop',
+    '../step1/exampleapp.png'
+  ]
+)
+
+run_target('install-gschema-file',
+  command: [install_cmd, 'gschema',
+    'org.gtkmm.exampleapp.gschema.xml'
+  ]
+)
diff --git a/examples/book/buildapp/step7/meson.build b/examples/book/buildapp/step7/meson.build
new file mode 100644
index 0000000..ee9ba53
--- /dev/null
+++ b/examples/book/buildapp/step7/meson.build
@@ -0,0 +1,44 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gnome = import('gnome')
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+  'exampleappprefs.cc',
+]
+
+resources = gnome.compile_resources('resources',
+                                    'exampleapp.gresource.xml',
+                                    source_dir: '.')
+schemas = gnome.compile_schemas(depend_files: 'org.gtkmm.exampleapp.gschema.xml')
+
+executable(program_name,
+  cpp_sources, resources, schemas,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = '../step1/install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    '../step1/exampleapp.desktop',
+    '../step1/exampleapp.png'
+  ]
+)
+
+run_target('install-gschema-file',
+  command: [install_cmd, 'gschema',
+    'org.gtkmm.exampleapp.gschema.xml'
+  ]
+)
diff --git a/examples/book/buildapp/step8/meson.build b/examples/book/buildapp/step8/meson.build
new file mode 100644
index 0000000..ee9ba53
--- /dev/null
+++ b/examples/book/buildapp/step8/meson.build
@@ -0,0 +1,44 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gnome = import('gnome')
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+  'exampleappprefs.cc',
+]
+
+resources = gnome.compile_resources('resources',
+                                    'exampleapp.gresource.xml',
+                                    source_dir: '.')
+schemas = gnome.compile_schemas(depend_files: 'org.gtkmm.exampleapp.gschema.xml')
+
+executable(program_name,
+  cpp_sources, resources, schemas,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = '../step1/install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    '../step1/exampleapp.desktop',
+    '../step1/exampleapp.png'
+  ]
+)
+
+run_target('install-gschema-file',
+  command: [install_cmd, 'gschema',
+    'org.gtkmm.exampleapp.gschema.xml'
+  ]
+)
diff --git a/examples/book/buildapp/step9/meson.build b/examples/book/buildapp/step9/meson.build
new file mode 100644
index 0000000..ee9ba53
--- /dev/null
+++ b/examples/book/buildapp/step9/meson.build
@@ -0,0 +1,44 @@
+project('gtkmm exampleapp', 'c', 'cpp',
+  version: '0.0.0',
+  default_options: [
+    'cpp_std=c++17'
+  ]
+)
+
+gnome = import('gnome')
+gtkmm_dep = dependency('gtkmm-4.0')
+
+program_name = 'exampleapp'
+
+cpp_sources = [
+  'main.cc',
+  'exampleappwindow.cc',
+  'exampleapplication.cc',
+  'exampleappprefs.cc',
+]
+
+resources = gnome.compile_resources('resources',
+                                    'exampleapp.gresource.xml',
+                                    source_dir: '.')
+schemas = gnome.compile_schemas(depend_files: 'org.gtkmm.exampleapp.gschema.xml')
+
+executable(program_name,
+  cpp_sources, resources, schemas,
+  dependencies: gtkmm_dep
+)
+
+install_cmd = '../step1/install-cmd.sh'
+
+run_target('install-desktop-file',
+  command: [install_cmd, 'desktop',
+    program_name,
+    '../step1/exampleapp.desktop',
+    '../step1/exampleapp.png'
+  ]
+)
+
+run_target('install-gschema-file',
+  command: [install_cmd, 'gschema',
+    'org.gtkmm.exampleapp.gschema.xml'
+  ]
+)


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