[recipes/meson2: 11/19] meson: Fix generation of various sources
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/meson2: 11/19] meson: Fix generation of various sources
- Date: Sat, 18 Feb 2017 19:58:19 +0000 (UTC)
commit abf45f1eacc24b0825d033124df9ee9979dbb441
Author: Nirbheek Chauhan <nirbheek centricular com>
Date: Sat Feb 18 22:22:51 2017 +0530
meson: Fix generation of various sources
Enumtypes are generated from gr-diet.h, not gr-recipe.h
cuisine.css is generated at configure-time from cuisine.css.in
segments.inc, ingredients.inc, no-ingredients.inc are generated using
`sed` in Autotools, but this is not cross-platform-compatible, so use
a Python script for it. This is also simpler to understand and bypasses
potential string quoting/escaping issues.
compile_resources needs a unique `c_name:` or there will be a symbol
redefinition error.
The target name of gdbus_codegen is used to generate the .h and .c
files, so use the same name as Autotools and add it to the list of
sources.
meson.build | 9 ++++++---
src/list_to_c.py | 17 +++++++++++++++++
src/meson.build | 46 +++++++++++++++++++++++++++++++++++++---------
3 files changed, 60 insertions(+), 12 deletions(-)
---
diff --git a/meson.build b/meson.build
index 1f3fc46..b20a2cd 100644
--- a/meson.build
+++ b/meson.build
@@ -5,16 +5,19 @@ i18n = import('i18n')
conf = configuration_data()
+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', join_paths([ get_option('prefix'),
- get_option('datadir'),
- '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)
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
index 6fce05f..317f30a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,27 +1,54 @@
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',
+ c_name: '_recipes_ui',
source_dir: 'src')
resources_images = gnome.compile_resources('resources_images',
'recipes-images.gresource.xml',
- c_name: '_recipes',
- source_dir: 'src')
+ c_name: '_recipes_images',
+ source_dir: 'src',
+ dependencies: cuisine_css)
-enums = gnome.mkenums('types',
- sources: 'gr-recipe.h',
- c_template: 'types.c.template',
- h_template: 'types.h.template')
+enums += gnome.mkenums('types',
+ sources: 'gr-diet.h',
+ c_template: 'types.c.template',
+ h_template: 'types.h.template')
-search_provider = gnome.gdbus_codegen('search-provider',
+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',
+src += ['main.c',
'gr-about-dialog.c',
'gr-account.c',
'gr-app.c',
@@ -77,6 +104,7 @@ src = ['main.c',
'gr-utils.c',
'gr-window.c',
enums,
+ search_provider,
resources_ui,
resources_images]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]