[recipes] meson build support



commit 1e9bacab5fbc53889b28996d8ad6044b03ec45ae
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Dec 2 17:04:32 2016 -0500

    meson build support
    
    Add meson build infrastructure.
    Thanks for much of this work goes to Nirbheek Chauhan.

 .gitignore                  |    2 +
 data/images/adria.jpg       |  Bin 271824 -> 271824 bytes
 data/meson.build            |  187 +++++++++++++++++++++++++++++++++++++++++++
 meson.build                 |   91 +++++++++++++++++++++
 meson_options.txt           |    3 +
 po/meson.build              |    3 +
 src/list_to_c.py            |   17 ++++
 src/meson.build             |  116 ++++++++++++++++++++++++++
 subprojects/libgd.wrap      |    4 +
 tests/meson.build           |   24 ++++++
 tools/meson.build           |    3 +
 tools/meson_post_install.py |   17 ++++
 types.c.template            |   37 +++++++++
 types.h.template            |   26 ++++++
 14 files changed, 530 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c4c1443
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+build/
+subprojects/libgd/
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..4d864ee
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,187 @@
+custom_target('recipes.db.h',
+              input: ['recipes.db'],
+              output: ['recipes.db.h'],
+              command: ['../tools/recipe-extract', '@INPUT@'],
+              capture: true,
+              build_by_default: true)
+
+custom_target('chefs.db.h',
+              input: ['chefs.db'],
+              output: ['chefs.db.h'],
+              command: ['../tools/recipe-extract', '--chefs', '@INPUT@'],
+              capture: true,
+              build_by_default: true)
+
+install_data(  'images/adelia.jpg',
+                'images/adria.jpg',
+                'images/afranke.jpg',
+                'images/alex.png',
+                'images/allan_day.jpg',
+                'images/american.png',
+                'images/bagel.jpg',
+                'images/Bastian.jpg',
+                'images/big-american.png',
+                'images/big-chinese.png',
+                'images/big-french.jpg',
+                'images/big-indian.jpg',
+                'images/big-italian.png',
+                'images/big-mediterranean.png',
+                'images/big-turkish.png',
+                'images/borscht.jpg',
+                'images/burger-fries.jpg',
+                'images/cake_aux_lardons.jpg',
+                'images/cake_aux_lardons2.jpg',
+                'images/chickencurry.jpg',
+                'images/chickensoup.jpg',
+                'images/chinese.png',
+                'images/coffee.jpg',
+                'images/donauwellen0.jpg',
+                'images/donauwellen1.jpg',
+                'images/donauwellen2.jpg',
+                'images/donauwellen3.jpg',
+                'images/donauwellen4.jpg',
+                'images/donauwellen5.jpg',
+                'images/donauwellen6.jpg',
+                'images/donauwellen7.jpg',
+                'images/donauwellen8.jpg',
+                'images/donauwellen_final.jpg',
+                'images/ebassi-carbonara-cover.JPG',
+                'images/ebassi-carbonara-01.JPG',
+                'images/ebassi-carbonara-02.JPG',
+                'images/ebassi-carbonara-03.JPG',
+                'images/ebassi-carbonara-04.JPG',
+                'images/ebassi-carbonara-05.JPG',
+                'images/ebassi-carbonara-06.JPG',
+                'images/ebassi-hackergotchi.png',
+                'images/elvin.jpg',
+                'images/erusan.gif',
+                'images/food.jpg',
+                'images/french.jpg',
+                'images/fyksen.jpg',
+                'images/geisha.jpg',
+                'images/gingered_carrot_soup.jpg',
+                'images/grumbeerekiechle_1.JPG',
+                'images/grumbeerekiechle_2.JPG',
+                'images/grumbeerekiechle_3.JPG',
+                'images/halfline.jpg',
+                'images/indian.jpg',
+                'images/italian.png',
+                'images/kiwi-mandarin1.jpg',
+                'images/kiwi-mandarin2.jpg',
+                'images/kiwi-mandarin3.jpg',
+                'images/kiwi-mandarin4.jpg',
+                'images/kiwi-mandarin5.jpg',
+                'images/kiwi-mandarin6.jpg',
+                'images/kiwi-mandarin7.jpg',
+                'images/mantovana.jpg',
+                'images/mclasen.jpg',
+                'images/meatballs.jpg',
+                'images/mediterranean.png',
+                'images/mwleeds.jpg',
+                'images/non_knead_buns.png',
+                'images/non_knead_buns1.jpg',
+                'images/non_knead_buns2.jpg',
+                'images/non_knead_buns3.jpg',
+                'images/non_knead_buns4.jpg',
+                'images/non_knead_buns5.jpg',
+                'images/oats1.jpg',
+                'images/oats2.jpg',
+                'images/oats3.jpg',
+                'images/pan_pizza1.png',
+                'images/pan_pizza2.png',
+                'images/pan_pizza3.png',
+                'images/pesto.jpg',
+                'images/pineapple_upside_down.jpg',
+                'images/pizzaburger.jpg',
+                'images/pizza.jpg',
+                'images/plain-bagel.jpg',
+                'images/rootspie1.jpg',
+                'images/rootspie2.jpg',
+                'images/rootspie3.jpg',
+                'images/rootspie4.jpg',
+                'images/rootspie5.jpg',
+                'images/rootspie6.jpg',
+                'images/rootspie7.jpg',
+                'images/rootspie8.jpg',
+                'images/rootspie9.jpg',
+                'images/rootspie10.jpg',
+                'images/rootspie11.jpg',
+                'images/rootspie12.jpg',
+                'images/rootspie13.jpg',
+                'images/rosemary-potatos1.jpg',
+                'images/rosemary-potatos2.jpg',
+                'images/salad.jpg',
+                'images/Sonic.jpg',
+                'images/spanish_omelet1.jpg',
+                'images/spanish_omelet2.jpg',
+                'images/spanish_omelet3.jpg',
+                'images/spanish_omelet4.jpg',
+                'images/spanish_omelet5.jpg',
+                'images/spanish_omelet6.jpg',
+                'images/spanish_omelet7.jpg',
+                'images/spanish_omelet8.jpg',
+                'images/spanish_omelet9.jpg',
+                'images/spring-rolls.jpg',
+                'images/tagliatelle1.jpg',
+                'images/tagliatelle2.jpg',
+                'images/tagliatelle3.jpg',
+                'images/tagliatelle4.jpg',
+                'images/tigert.jpg',
+                'images/tofuscramble.jpg',
+                'images/turkish.png',
+                'images/whitefish1.jpg',
+                'images/whitefish2.jpg',
+                'images/whitefish3.jpg',
+                'images/whitefish4.jpg',
+                'images/wholesale-crackers.jpg',
+                install_dir: 'share/gnome-recipes/images')
+
+install_data('sounds/complete.oga',
+             install_dir: 'share/gnome-recipes/sounds')
+
+install_data('chefs.db',
+             'picks.db',
+             'recipes.db',
+             install_dir: 'share/gnome-recipes')
+
+install_data('org.gnome.Recipes-mime.xml',
+             install_dir: 'share/mime/packages')
+
+msgfmt = find_program('msgfmt')
+
+custom_target('desktop-file',
+              output: 'org.gnome.Recipes.desktop',
+              input: files('org.gnome.Recipes.desktop.in'),
+              install: true,
+              install_dir: 'share/applications',
+              command: [msgfmt, '--desktop', '-d', '../po', '--template', '@INPUT@', '-o', '@OUTPUT@'])
+
+custom_target('appdata',
+              output: 'org.gnome.Recipes.appdata.xml',
+              input: files('appdata/org.gnome.Recipes.appdata.xml.in'),
+              install: true,
+              install_dir: 'share/appdata',
+              command: [msgfmt, '--xml', '-d', '../po', '--template', '@INPUT@', '-o', '@OUTPUT@'])
+
+configure_file(input: 'org.gnome.Recipes.service.in',
+               output: 'org.gnome.Recipes.service',
+               configuration: conf,
+               install_dir: 'share/dbus-1/services')
+
+install_data(   'icons/16x16/org.gnome.Recipes.png',
+                'icons/16x16/org.gnome.Recipes-symbolic.symbolic.png',
+                install_dir: 'share/icons/hicolor/16x16/apps')
+install_data(   'icons/24x24/org.gnome.Recipes.png',
+                'icons/24x24/org.gnome.Recipes-symbolic.symbolic.png',
+                install_dir: 'share/icons/hicolor/24x24/apps')
+install_data(   'icons/32x32/org.gnome.Recipes.png',
+                'icons/32x32/org.gnome.Recipes-symbolic.symbolic.png',
+                install_dir: 'share/icons/hicolor/32x32/apps')
+install_data(   'icons/48x48/org.gnome.Recipes.png',
+                'icons/48x48/org.gnome.Recipes-symbolic.symbolic.png',
+                install_dir: 'share/icons/hicolor/48x48/apps')
+install_data(   'icons/512x512/org.gnome.Recipes.png',
+                'icons/512x512/org.gnome.Recipes-symbolic.symbolic.png',
+                install_dir: 'share/icons/hicolor/512x512/apps')
+install_data(   'icons/symbolic/org.gnome.Recipes-symbolic.svg',
+                install_dir: 'share/icons/hicolor/symbolic/apps')
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..e92f149
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,91 @@
+project('gnome-recipes', 'c', version: '0.1.0',
+        meson_version : '>=0.36.0')
+
+i18n = import('i18n')
+
+conf = configuration_data()
+
+# Needed to find config.h
+top_inc = include_directories('.')
+
+libgd = subproject('libgd',
+           default_options: [
+                'with-tagged-entry=true',
+                'static=true'
+           ])
+libgd_dep = libgd.get_variable('libgd_dep')
+
+# Extract LIBGD_INFO
+libgd_path = join_paths([meson.source_root(), 'subprojects', 'libgd'])
+git_run = run_command('git', ['-C', libgd_path, 'log', '-1', '--pretty=%h'])
+if git_run.returncode() == 0
+  conf.set_quoted('LIBGD_INFO', git_run.stdout().strip())
+else
+  message('Failed to extract git commit hash for libgd:\n' + git_run.stderr())
+  conf.set_quoted('LIBGD_INFO', 'unknown')
+endif
+
+# Options + dependency checking is overly verbose and repetitive right now, but
+# there is work ongoing to fix it: https://github.com/mesonbuild/meson/pull/1330
+autoar_dep = []
+if get_option('autoar') != 'no'
+  autoar_dep = dependency('gnome-autoar-0', required : false)
+  if autoar_dep.found()
+    conf.set('ENABLE_AUTOAR', true)
+    conf.set_quoted('AUTOAR_VERSION', autoar_dep.version())
+  elif get_option('autoar') == 'yes'
+    error('Support for gnome-autoar was requested but not found')
+  endif
+endif
+
+gspell_dep = []
+if get_option('gspell') != 'no'
+  gspell_dep = dependency('gspell-1', required : false)
+  if gspell_dep.found()
+    conf.set('ENABLE_GSPELL', true)
+    conf.set_quoted('GSPELL_VERSION', gspell_dep.version())
+  elif get_option('gspell') == 'yes'
+    error('Support for gspell was requested but not found')
+  endif
+endif
+
+canberra_dep = []
+if get_option('canberra') != 'no'
+  canberra_dep = dependency('libcanberra', required : false)
+  if canberra_dep.found()
+    conf.set('ENABLE_CANBERRA', true)
+    conf.set_quoted('CANBERRA_VERSION', canberra_dep.version())
+  elif get_option('canberra') == 'yes'
+    error('Support for canberra was requested but not found')
+  endif
+endif
+
+deps = [ dependency('gtk+-3.0', version : '>=3.20'),
+         autoar_dep,
+         gspell_dep,
+         canberra_dep,
+         libgd_dep ]
+
+pkgdatadir = join_paths([ get_option('prefix'),
+                          get_option('datadir'),
+                          'gnome-recipes' ])
+conf.set_quoted('G_LOG_DOMAIN', 'org.gnome.Recipes')
+conf.set_quoted('PACKAGE_NAME', 'gnome-recipes')
+conf.set_quoted('PACKAGE_VERSION', meson.project_version())
+conf.set_quoted('GETTEXT_PACKAGE', 'gnome-recipes')
+conf.set_quoted('PKGDATADIR', pkgdatadir)
+conf.set_quoted('LOCALEDIR', join_paths([ get_option('prefix'),
+                                          get_option('datadir'),
+                                          'locale' ]))
+# Used while generating cuisine.css
+conf.set('pkgdatadir', pkgdatadir)
+
+configure_file(output : 'config.h', configuration : conf)
+
+subdir('src')
+subdir('tools')
+subdir('data')
+subdir('po')
+subdir('tests')
+
+meson.add_install_script('tools/meson_post_install.py')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..14312f8
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option('autoar', type : 'combo', choices : ['auto', 'yes', 'no'], default : 'auto')
+option('gspell', type : 'combo', choices : ['auto', 'yes', 'no'], default : 'auto')
+option('canberra', type : 'combo', choices : ['auto', 'yes', 'no'], default : 'auto')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..16f002b
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,3 @@
+langs = ['ar', 'cs', 'de', 'es', 'nl', 'pl', 'pt_BR', 'sr']
+
+i18n.gettext('gnome-recipes', languages: langs)
diff --git a/src/list_to_c.py b/src/list_to_c.py
new file mode 100644
index 0000000..af22a3d
--- /dev/null
+++ b/src/list_to_c.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+ifile = sys.argv[1]
+ofile = sys.argv[2]
+prefix = sys.argv[3]
+
+i = open(ifile, 'r', encoding='utf-8')
+o = open(ofile, 'w', encoding='utf-8')
+
+out_templ = '\tN_("{prefix}{line}"),\n'
+values = {'prefix': prefix}
+for line in i.readlines():
+    values['line'] = line.strip()
+    o.write(out_templ.format(**values))
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..317f30a
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,116 @@
+gnome = import('gnome')
+
+src = []
+enums = []
+
+# Used in recipes-images.gresource.xml
+cuisine_css = configure_file(output : 'cuisine.css',
+                             input : 'cuisine.css.in',
+                             configuration : conf)
+
+# These generated files are #included
+list_to_c = find_program('list_to_c.py')
+foreach f : ['segments', 'ingredients']
+  ofile = f + '.inc'
+  ifile = files('../data/' + f + '.list')
+  src += [custom_target(f,
+                        output : ofile,
+                        input : ifile,
+                        command : [list_to_c, '@INPUT@', '@OUTPUT@', ''])]
+endforeach
+ofile = 'no-ingredients.inc'
+ifile = files('../data/ingredients.list')
+src += [custom_target('no-ingredients',
+                      output : ofile,
+                      input : ifile,
+                      command : [list_to_c, '@INPUT@', '@OUTPUT@', 'no '])]
+
+# Resource compilation
+resources_ui = gnome.compile_resources('resources_ui',
+                                       'recipes-ui.gresource.xml',
+                                       c_name: '_recipes_ui',
+                                       source_dir: 'src')
+
+resources_images = gnome.compile_resources('resources_images',
+                                       'recipes-images.gresource.xml',
+                                       c_name: '_recipes_images',
+                                       source_dir: 'src',
+                                       dependencies: cuisine_css)
+
+enums += gnome.mkenums('types',
+                       sources: 'gr-diet.h',
+                       c_template: 'types.c.template',
+                       h_template: 'types.h.template')
+
+search_provider = gnome.gdbus_codegen('gr-shell-search-provider-dbus',
+                                      'shell-search-provider-dbus-interfaces.xml',
+                                      interface_prefix: 'org.gnome.',
+                                      namespace: 'Gr')
+
+
+src += ['main.c',
+       'gr-about-dialog.c',
+       'gr-account.c',
+       'gr-app.c',
+       'gr-category-tile.c',
+       'gr-chef.c',
+       'gr-chef-dialog.c',
+       'gr-chef-tile.c',
+       'gr-cooking-page.c',
+       'gr-cooking-view.c',
+       'gr-cuisine.c',
+       'gr-cuisine-page.c',
+       'gr-cuisine-tile.c',
+       'gr-cuisines-page.c',
+       'gr-cuisine-tile.c',
+       'gr-cuisines-page.c',
+       'gr-details-page.c',
+       'gr-diet.c',
+       'gr-diet-row.c',
+       'gr-edit-page.c',
+       'gr-image-page.c',
+       'gr-images.c',
+       'gr-image-viewer.c',
+       'gr-image-page.c',
+       'gr-ingredient.c',
+       'gr-ingredient-row.c',
+       'gr-ingredients-list.c',
+       'gr-list-page.c',
+       'gr-mail.c',
+       'gr-meal.c',
+       'gr-meal-row.c',
+       'gr-number.c',
+       'gr-query-editor.c',
+       'gr-recipe.c',
+       'gr-recipe-exporter.c',
+       'gr-recipe-formatter.c',
+       'gr-recipe-importer.c',
+       'gr-recipe-printer.c',
+       'gr-recipe-small-tile.c',
+       'gr-recipe-store.c',
+       'gr-recipe-tile.c',
+       'gr-recipes-page.c',
+       'gr-search-page.c',
+       'gr-season.c',
+       'gr-shell-search-provider.c',
+       'gr-shopping-list-formatter.c',
+       'gr-shopping-list-printer.c',
+       'gr-shopping-page.c',
+       'gr-spice-row.c',
+       'gr-time-widget.c',
+       'gr-timer.c',
+       'gr-timer-widget.c',
+       'gr-unit.c',
+       'gr-utils.c',
+       'gr-window.c',
+  enums,
+  search_provider,
+  resources_ui,
+  resources_images]
+
+executable('gnome-recipes',
+           src,
+           install : true,
+           include_directories : top_inc,
+           dependencies: deps)
+
diff --git a/subprojects/libgd.wrap b/subprojects/libgd.wrap
new file mode 100644
index 0000000..fd83a39
--- /dev/null
+++ b/subprojects/libgd.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+directory=libgd
+url=https://git.gnome.org/browse/libgd
+revision=master
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..95ec4e8
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,24 @@
+tests_inc = [include_directories('../src'), top_inc]
+env = environment()
+env.set('G_TEST_SRCDIR', meson.current_source_dir())
+env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+env.set('G_DEBUG', 'gc-friendly')
+env.set('MALLOC_CHECK_', '2')
+# FIXME: Add a meson helper to get a random number
+env.set('MALLOC_PERTURB_', '113') # Guaranteed random!
+
+ingredients = executable('ingredients', 'ingredients-test.c',
+                         include_directories : tests_inc,
+                         dependencies: deps)
+test('ingredients', ingredients, env : env)
+
+number = executable('number', 'number.c',
+                     include_directories : tests_inc,
+                     dependencies: deps)
+test('number', number, env : env)
+
+unit = executable('unit', 'unit.c',
+                  include_directories : tests_inc,
+                  dependencies: deps)
+
+test('unit', unit, env : env)
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..27edff8
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,3 @@
+executable('recipe-extract', 'recipe-extract.c',
+           include_directories : top_inc,
+           dependencies: deps)
diff --git a/tools/meson_post_install.py b/tools/meson_post_install.py
new file mode 100755
index 0000000..3d4d975
--- /dev/null
+++ b/tools/meson_post_install.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+datadir = os.path.join(prefix, 'share')
+
+# Packaging tools define DESTDIR and this isn't needed for them
+if 'DESTDIR' not in os.environ:
+    print('Updating icon cache...')
+    subprocess.call(['gtk-update-icon-cache', '-qtf',
+                     os.path.join(datadir, 'icons', 'hicolor')])
+
+    print('Updating desktop database...')
+    subprocess.call(['update-desktop-database', '-q',
+                    os.path.join(datadir, 'applications')])
diff --git a/types.c.template b/types.c.template
new file mode 100644
index 0000000..22b2994
--- /dev/null
+++ b/types.c.template
@@ -0,0 +1,37 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+#include "types.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+    static GType etype = 0;
+    if (G_UNLIKELY(etype == 0)) {
+        static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+            { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+            { 0, NULL, NULL }
+        };
+        etype = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
+    }
+    return etype;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+
+/*** END file-tail ***/
+
diff --git a/types.h.template b/types.h.template
new file mode 100644
index 0000000..51f953d
--- /dev/null
+++ b/types.h.template
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+#pragma once
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+
+#include "@filename@"
+
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+/*** END file-tail ***/
+~                                         


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