2011-09-10 11:13:51 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
2018-01-01 20:53:49 +01:00
|
|
|
# Thomas Nagy, 2006-2018 (ita)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
Support for GLib2 tools:
|
|
|
|
|
|
|
|
* marshal
|
|
|
|
* enums
|
|
|
|
* gsettings
|
2014-09-21 18:48:38 +02:00
|
|
|
* gresource
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
2016-12-22 18:31:07 +01:00
|
|
|
import functools
|
2014-09-21 18:48:38 +02:00
|
|
|
from waflib import Context, Task, Utils, Options, Errors, Logs
|
2015-10-11 11:32:27 +02:00
|
|
|
from waflib.TaskGen import taskgen_method, before_method, feature, extension
|
2014-01-27 02:32:09 +01:00
|
|
|
from waflib.Configure import conf
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
################## marshal files
|
|
|
|
|
|
|
|
@taskgen_method
|
|
|
|
def add_marshal_file(self, filename, prefix):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Adds a file to the list of marshal files to process. Store them in the attribute *marshal_list*.
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
:param filename: xml file to compile
|
|
|
|
:type filename: string
|
|
|
|
:param prefix: marshal prefix (--prefix=prefix)
|
|
|
|
:type prefix: string
|
|
|
|
"""
|
|
|
|
if not hasattr(self, 'marshal_list'):
|
|
|
|
self.marshal_list = []
|
|
|
|
self.meths.append('process_marshal')
|
|
|
|
self.marshal_list.append((filename, prefix))
|
|
|
|
|
|
|
|
@before_method('process_source')
|
|
|
|
def process_marshal(self):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Processes the marshal files stored in the attribute *marshal_list* to create :py:class:`waflib.Tools.glib2.glib_genmarshal` instances.
|
|
|
|
Adds the c file created to the list of source to process.
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
for f, prefix in getattr(self, 'marshal_list', []):
|
|
|
|
node = self.path.find_resource(f)
|
|
|
|
|
|
|
|
if not node:
|
|
|
|
raise Errors.WafError('file not found %r' % f)
|
|
|
|
|
|
|
|
h_node = node.change_ext('.h')
|
|
|
|
c_node = node.change_ext('.c')
|
|
|
|
|
|
|
|
task = self.create_task('glib_genmarshal', node, [h_node, c_node])
|
|
|
|
task.env.GLIB_GENMARSHAL_PREFIX = prefix
|
|
|
|
self.source = self.to_nodes(getattr(self, 'source', []))
|
|
|
|
self.source.append(c_node)
|
|
|
|
|
|
|
|
class glib_genmarshal(Task.Task):
|
2016-01-11 05:25:46 +01:00
|
|
|
vars = ['GLIB_GENMARSHAL_PREFIX', 'GLIB_GENMARSHAL']
|
|
|
|
color = 'BLUE'
|
|
|
|
ext_out = ['.h']
|
2011-09-10 11:13:51 +02:00
|
|
|
def run(self):
|
2016-01-11 05:25:46 +01:00
|
|
|
bld = self.generator.bld
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
get = self.env.get_flat
|
|
|
|
cmd1 = "%s %s --prefix=%s --header > %s" % (
|
|
|
|
get('GLIB_GENMARSHAL'),
|
|
|
|
self.inputs[0].srcpath(),
|
|
|
|
get('GLIB_GENMARSHAL_PREFIX'),
|
|
|
|
self.outputs[0].abspath()
|
|
|
|
)
|
|
|
|
|
|
|
|
ret = bld.exec_command(cmd1)
|
2017-04-17 12:26:47 +02:00
|
|
|
if ret:
|
|
|
|
return ret
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
#print self.outputs[1].abspath()
|
|
|
|
c = '''#include "%s"\n''' % self.outputs[0].name
|
|
|
|
self.outputs[1].write(c)
|
|
|
|
|
|
|
|
cmd2 = "%s %s --prefix=%s --body >> %s" % (
|
|
|
|
get('GLIB_GENMARSHAL'),
|
|
|
|
self.inputs[0].srcpath(),
|
|
|
|
get('GLIB_GENMARSHAL_PREFIX'),
|
|
|
|
self.outputs[1].abspath()
|
|
|
|
)
|
|
|
|
return bld.exec_command(cmd2)
|
|
|
|
|
|
|
|
########################## glib-mkenums
|
|
|
|
|
|
|
|
@taskgen_method
|
|
|
|
def add_enums_from_template(self, source='', target='', template='', comments=''):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Adds a file to the list of enum files to process. Stores them in the attribute *enums_list*.
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
:param source: enum file to process
|
|
|
|
:type source: string
|
|
|
|
:param target: target file
|
|
|
|
:type target: string
|
|
|
|
:param template: template file
|
|
|
|
:type template: string
|
|
|
|
:param comments: comments
|
|
|
|
:type comments: string
|
|
|
|
"""
|
|
|
|
if not hasattr(self, 'enums_list'):
|
|
|
|
self.enums_list = []
|
|
|
|
self.meths.append('process_enums')
|
|
|
|
self.enums_list.append({'source': source,
|
|
|
|
'target': target,
|
|
|
|
'template': template,
|
|
|
|
'file-head': '',
|
|
|
|
'file-prod': '',
|
|
|
|
'file-tail': '',
|
|
|
|
'enum-prod': '',
|
|
|
|
'value-head': '',
|
|
|
|
'value-prod': '',
|
|
|
|
'value-tail': '',
|
|
|
|
'comments': comments})
|
|
|
|
|
|
|
|
@taskgen_method
|
|
|
|
def add_enums(self, source='', target='',
|
|
|
|
file_head='', file_prod='', file_tail='', enum_prod='',
|
|
|
|
value_head='', value_prod='', value_tail='', comments=''):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Adds a file to the list of enum files to process. Stores them in the attribute *enums_list*.
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
:param source: enum file to process
|
|
|
|
:type source: string
|
|
|
|
:param target: target file
|
|
|
|
:type target: string
|
|
|
|
:param file_head: unused
|
|
|
|
:param file_prod: unused
|
|
|
|
:param file_tail: unused
|
|
|
|
:param enum_prod: unused
|
|
|
|
:param value_head: unused
|
|
|
|
:param value_prod: unused
|
|
|
|
:param value_tail: unused
|
|
|
|
:param comments: comments
|
|
|
|
:type comments: string
|
|
|
|
"""
|
|
|
|
if not hasattr(self, 'enums_list'):
|
|
|
|
self.enums_list = []
|
|
|
|
self.meths.append('process_enums')
|
|
|
|
self.enums_list.append({'source': source,
|
|
|
|
'template': '',
|
|
|
|
'target': target,
|
|
|
|
'file-head': file_head,
|
|
|
|
'file-prod': file_prod,
|
|
|
|
'file-tail': file_tail,
|
|
|
|
'enum-prod': enum_prod,
|
|
|
|
'value-head': value_head,
|
|
|
|
'value-prod': value_prod,
|
|
|
|
'value-tail': value_tail,
|
|
|
|
'comments': comments})
|
|
|
|
|
|
|
|
@before_method('process_source')
|
|
|
|
def process_enums(self):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Processes the enum files stored in the attribute *enum_list* to create :py:class:`waflib.Tools.glib2.glib_mkenums` instances.
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
for enum in getattr(self, 'enums_list', []):
|
|
|
|
task = self.create_task('glib_mkenums')
|
|
|
|
env = task.env
|
|
|
|
|
|
|
|
inputs = []
|
|
|
|
|
|
|
|
# process the source
|
|
|
|
source_list = self.to_list(enum['source'])
|
|
|
|
if not source_list:
|
|
|
|
raise Errors.WafError('missing source ' + str(enum))
|
|
|
|
source_list = [self.path.find_resource(k) for k in source_list]
|
|
|
|
inputs += source_list
|
2016-06-25 23:54:12 +02:00
|
|
|
env.GLIB_MKENUMS_SOURCE = [k.abspath() for k in source_list]
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
# find the target
|
|
|
|
if not enum['target']:
|
|
|
|
raise Errors.WafError('missing target ' + str(enum))
|
|
|
|
tgt_node = self.path.find_or_declare(enum['target'])
|
|
|
|
if tgt_node.name.endswith('.c'):
|
|
|
|
self.source.append(tgt_node)
|
2016-06-25 23:54:12 +02:00
|
|
|
env.GLIB_MKENUMS_TARGET = tgt_node.abspath()
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
options = []
|
|
|
|
|
|
|
|
if enum['template']: # template, if provided
|
|
|
|
template_node = self.path.find_resource(enum['template'])
|
|
|
|
options.append('--template %s' % (template_node.abspath()))
|
|
|
|
inputs.append(template_node)
|
|
|
|
params = {'file-head' : '--fhead',
|
|
|
|
'file-prod' : '--fprod',
|
|
|
|
'file-tail' : '--ftail',
|
|
|
|
'enum-prod' : '--eprod',
|
|
|
|
'value-head' : '--vhead',
|
|
|
|
'value-prod' : '--vprod',
|
|
|
|
'value-tail' : '--vtail',
|
|
|
|
'comments': '--comments'}
|
|
|
|
for param, option in params.items():
|
|
|
|
if enum[param]:
|
|
|
|
options.append('%s %r' % (option, enum[param]))
|
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
env.GLIB_MKENUMS_OPTIONS = ' '.join(options)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
# update the task instance
|
|
|
|
task.set_inputs(inputs)
|
|
|
|
task.set_outputs(tgt_node)
|
|
|
|
|
|
|
|
class glib_mkenums(Task.Task):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Processes enum files
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
run_str = '${GLIB_MKENUMS} ${GLIB_MKENUMS_OPTIONS} ${GLIB_MKENUMS_SOURCE} > ${GLIB_MKENUMS_TARGET}'
|
|
|
|
color = 'PINK'
|
|
|
|
ext_out = ['.h']
|
|
|
|
|
|
|
|
######################################### gsettings
|
|
|
|
|
|
|
|
@taskgen_method
|
|
|
|
def add_settings_schemas(self, filename_list):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Adds settings files to process to *settings_schema_files*
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
:param filename_list: files
|
|
|
|
:type filename_list: list of string
|
|
|
|
"""
|
|
|
|
if not hasattr(self, 'settings_schema_files'):
|
|
|
|
self.settings_schema_files = []
|
|
|
|
|
|
|
|
if not isinstance(filename_list, list):
|
|
|
|
filename_list = [filename_list]
|
|
|
|
|
|
|
|
self.settings_schema_files.extend(filename_list)
|
|
|
|
|
|
|
|
@taskgen_method
|
|
|
|
def add_settings_enums(self, namespace, filename_list):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Called only once by task generator to set the enums namespace.
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
:param namespace: namespace
|
|
|
|
:type namespace: string
|
|
|
|
:param filename_list: enum files to process
|
|
|
|
:type filename_list: file list
|
|
|
|
"""
|
|
|
|
if hasattr(self, 'settings_enum_namespace'):
|
2016-04-26 19:35:46 +02:00
|
|
|
raise Errors.WafError("Tried to add gsettings enums to %r more than once" % self.name)
|
2011-09-10 11:13:51 +02:00
|
|
|
self.settings_enum_namespace = namespace
|
|
|
|
|
2017-04-22 22:12:11 +02:00
|
|
|
if not isinstance(filename_list, list):
|
2011-09-10 11:13:51 +02:00
|
|
|
filename_list = [filename_list]
|
|
|
|
self.settings_enum_files = filename_list
|
|
|
|
|
|
|
|
@feature('glib2')
|
|
|
|
def process_settings(self):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Processes the schema files in *settings_schema_files* to create :py:class:`waflib.Tools.glib2.glib_mkenums` instances. The
|
2011-09-10 11:13:51 +02:00
|
|
|
same files are validated through :py:class:`waflib.Tools.glib2.glib_validate_schema` tasks.
|
|
|
|
|
|
|
|
"""
|
|
|
|
enums_tgt_node = []
|
|
|
|
install_files = []
|
|
|
|
|
|
|
|
settings_schema_files = getattr(self, 'settings_schema_files', [])
|
2016-06-25 23:54:12 +02:00
|
|
|
if settings_schema_files and not self.env.GLIB_COMPILE_SCHEMAS:
|
2011-09-10 11:13:51 +02:00
|
|
|
raise Errors.WafError ("Unable to process GSettings schemas - glib-compile-schemas was not found during configure")
|
|
|
|
|
|
|
|
# 1. process gsettings_enum_files (generate .enums.xml)
|
|
|
|
#
|
|
|
|
if hasattr(self, 'settings_enum_files'):
|
|
|
|
enums_task = self.create_task('glib_mkenums')
|
|
|
|
|
|
|
|
source_list = self.settings_enum_files
|
|
|
|
source_list = [self.path.find_resource(k) for k in source_list]
|
|
|
|
enums_task.set_inputs(source_list)
|
2016-06-25 23:54:12 +02:00
|
|
|
enums_task.env.GLIB_MKENUMS_SOURCE = [k.abspath() for k in source_list]
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
target = self.settings_enum_namespace + '.enums.xml'
|
|
|
|
tgt_node = self.path.find_or_declare(target)
|
|
|
|
enums_task.set_outputs(tgt_node)
|
2016-06-25 23:54:12 +02:00
|
|
|
enums_task.env.GLIB_MKENUMS_TARGET = tgt_node.abspath()
|
2011-09-10 11:13:51 +02:00
|
|
|
enums_tgt_node = [tgt_node]
|
|
|
|
|
2016-05-06 15:51:21 +02:00
|
|
|
install_files.append(tgt_node)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
options = '--comments "<!-- @comment@ -->" --fhead "<schemalist>" --vhead " <@type@ id=\\"%s.@EnumName@\\">" --vprod " <value nick=\\"@valuenick@\\" value=\\"@valuenum@\\"/>" --vtail " </@type@>" --ftail "</schemalist>" ' % (self.settings_enum_namespace)
|
2016-06-25 23:54:12 +02:00
|
|
|
enums_task.env.GLIB_MKENUMS_OPTIONS = options
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
# 2. process gsettings_schema_files (validate .gschema.xml files)
|
|
|
|
#
|
|
|
|
for schema in settings_schema_files:
|
|
|
|
schema_task = self.create_task ('glib_validate_schema')
|
|
|
|
|
|
|
|
schema_node = self.path.find_resource(schema)
|
|
|
|
if not schema_node:
|
2016-04-26 19:35:46 +02:00
|
|
|
raise Errors.WafError("Cannot find the schema file %r" % schema)
|
2011-09-10 11:13:51 +02:00
|
|
|
install_files.append(schema_node)
|
|
|
|
source_list = enums_tgt_node + [schema_node]
|
|
|
|
|
|
|
|
schema_task.set_inputs (source_list)
|
2016-06-25 23:54:12 +02:00
|
|
|
schema_task.env.GLIB_COMPILE_SCHEMAS_OPTIONS = [("--schema-file=" + k.abspath()) for k in source_list]
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2014-10-01 00:25:04 +02:00
|
|
|
target_node = schema_node.change_ext('.xml.valid')
|
2011-09-10 11:13:51 +02:00
|
|
|
schema_task.set_outputs (target_node)
|
2016-06-25 23:54:12 +02:00
|
|
|
schema_task.env.GLIB_VALIDATE_SCHEMA_OUTPUT = target_node.abspath()
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
# 3. schemas install task
|
|
|
|
def compile_schemas_callback(bld):
|
2016-12-20 14:01:17 +01:00
|
|
|
if not bld.is_install:
|
|
|
|
return
|
2016-12-22 18:31:07 +01:00
|
|
|
compile_schemas = Utils.to_list(bld.env.GLIB_COMPILE_SCHEMAS)
|
2016-12-14 21:34:21 +01:00
|
|
|
destdir = Options.options.destdir
|
2016-12-22 18:31:07 +01:00
|
|
|
paths = bld._compile_schemas_registered
|
2016-12-14 21:34:21 +01:00
|
|
|
if destdir:
|
2016-12-22 18:31:07 +01:00
|
|
|
paths = (os.path.join(destdir, path.lstrip(os.sep)) for path in paths)
|
|
|
|
for path in paths:
|
|
|
|
Logs.pprint('YELLOW', 'Updating GSettings schema cache %r' % path)
|
|
|
|
if self.bld.exec_command(compile_schemas + [path]):
|
|
|
|
Logs.warn('Could not update GSettings schema cache %r' % path)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
if self.bld.is_install:
|
2016-12-22 18:31:07 +01:00
|
|
|
schemadir = self.env.GSETTINGSSCHEMADIR
|
|
|
|
if not schemadir:
|
2011-09-10 11:13:51 +02:00
|
|
|
raise Errors.WafError ('GSETTINGSSCHEMADIR not defined (should have been set up automatically during configure)')
|
|
|
|
|
|
|
|
if install_files:
|
2016-12-22 18:31:07 +01:00
|
|
|
self.add_install_files(install_to=schemadir, install_from=install_files)
|
|
|
|
registered_schemas = getattr(self.bld, '_compile_schemas_registered', None)
|
|
|
|
if not registered_schemas:
|
|
|
|
registered_schemas = self.bld._compile_schemas_registered = set()
|
2015-10-11 11:32:27 +02:00
|
|
|
self.bld.add_post_fun(compile_schemas_callback)
|
2016-12-22 18:31:07 +01:00
|
|
|
registered_schemas.add(schemadir)
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
class glib_validate_schema(Task.Task):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Validates schema files
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
run_str = 'rm -f ${GLIB_VALIDATE_SCHEMA_OUTPUT} && ${GLIB_COMPILE_SCHEMAS} --dry-run ${GLIB_COMPILE_SCHEMAS_OPTIONS} && touch ${GLIB_VALIDATE_SCHEMA_OUTPUT}'
|
|
|
|
color = 'PINK'
|
|
|
|
|
2014-09-21 18:48:38 +02:00
|
|
|
################## gresource
|
|
|
|
|
|
|
|
@extension('.gresource.xml')
|
|
|
|
def process_gresource_source(self, node):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Creates tasks that turn ``.gresource.xml`` files to C code
|
2014-09-21 18:48:38 +02:00
|
|
|
"""
|
2016-06-25 23:54:12 +02:00
|
|
|
if not self.env.GLIB_COMPILE_RESOURCES:
|
2014-09-21 18:48:38 +02:00
|
|
|
raise Errors.WafError ("Unable to process GResource file - glib-compile-resources was not found during configure")
|
|
|
|
|
|
|
|
if 'gresource' in self.features:
|
|
|
|
return
|
|
|
|
|
|
|
|
h_node = node.change_ext('_xml.h')
|
|
|
|
c_node = node.change_ext('_xml.c')
|
|
|
|
self.create_task('glib_gresource_source', node, [h_node, c_node])
|
|
|
|
self.source.append(c_node)
|
|
|
|
|
|
|
|
@feature('gresource')
|
|
|
|
def process_gresource_bundle(self):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Creates tasks to turn ``.gresource`` files from ``.gresource.xml`` files::
|
2014-09-21 18:48:38 +02:00
|
|
|
|
|
|
|
def build(bld):
|
|
|
|
bld(
|
|
|
|
features='gresource',
|
|
|
|
source=['resources1.gresource.xml', 'resources2.gresource.xml'],
|
|
|
|
install_path='${LIBDIR}/${PACKAGE}'
|
|
|
|
)
|
|
|
|
|
|
|
|
:param source: XML files to process
|
|
|
|
:type source: list of string
|
|
|
|
:param install_path: installation path
|
|
|
|
:type install_path: string
|
|
|
|
"""
|
|
|
|
for i in self.to_list(self.source):
|
|
|
|
node = self.path.find_resource(i)
|
|
|
|
|
|
|
|
task = self.create_task('glib_gresource_bundle', node, node.change_ext(''))
|
|
|
|
inst_to = getattr(self, 'install_path', None)
|
|
|
|
if inst_to:
|
2016-05-06 15:51:21 +02:00
|
|
|
self.add_install_files(install_to=inst_to, install_from=task.outputs)
|
2014-09-21 18:48:38 +02:00
|
|
|
|
|
|
|
class glib_gresource_base(Task.Task):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Base class for gresource based tasks
|
2014-09-21 18:48:38 +02:00
|
|
|
"""
|
|
|
|
color = 'BLUE'
|
|
|
|
base_cmd = '${GLIB_COMPILE_RESOURCES} --sourcedir=${SRC[0].parent.srcpath()} --sourcedir=${SRC[0].bld_dir()}'
|
|
|
|
|
|
|
|
def scan(self):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Scans gresource dependencies through ``glib-compile-resources --generate-dependencies command``
|
2014-09-21 18:48:38 +02:00
|
|
|
"""
|
|
|
|
bld = self.generator.bld
|
|
|
|
kw = {}
|
2016-01-11 05:25:46 +01:00
|
|
|
kw['cwd'] = self.get_cwd()
|
2014-09-21 18:48:38 +02:00
|
|
|
kw['quiet'] = Context.BOTH
|
|
|
|
|
|
|
|
cmd = Utils.subst_vars('${GLIB_COMPILE_RESOURCES} --sourcedir=%s --sourcedir=%s --generate-dependencies %s' % (
|
|
|
|
self.inputs[0].parent.srcpath(),
|
|
|
|
self.inputs[0].bld_dir(),
|
|
|
|
self.inputs[0].bldpath()
|
|
|
|
), self.env)
|
|
|
|
|
|
|
|
output = bld.cmd_and_log(cmd, **kw)
|
|
|
|
|
|
|
|
nodes = []
|
|
|
|
names = []
|
|
|
|
for dep in output.splitlines():
|
|
|
|
if dep:
|
|
|
|
node = bld.bldnode.find_node(dep)
|
|
|
|
if node:
|
|
|
|
nodes.append(node)
|
|
|
|
else:
|
|
|
|
names.append(dep)
|
|
|
|
|
|
|
|
return (nodes, names)
|
|
|
|
|
|
|
|
class glib_gresource_source(glib_gresource_base):
|
|
|
|
"""
|
|
|
|
Task to generate C source code (.h and .c files) from a gresource.xml file
|
|
|
|
"""
|
|
|
|
vars = ['GLIB_COMPILE_RESOURCES']
|
|
|
|
fun_h = Task.compile_fun_shell(glib_gresource_base.base_cmd + ' --target=${TGT[0].abspath()} --generate-header ${SRC}')
|
|
|
|
fun_c = Task.compile_fun_shell(glib_gresource_base.base_cmd + ' --target=${TGT[1].abspath()} --generate-source ${SRC}')
|
|
|
|
ext_out = ['.h']
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
return self.fun_h[0](self) or self.fun_c[0](self)
|
|
|
|
|
|
|
|
class glib_gresource_bundle(glib_gresource_base):
|
|
|
|
"""
|
|
|
|
Task to generate a .gresource binary file from a gresource.xml file
|
|
|
|
"""
|
|
|
|
run_str = glib_gresource_base.base_cmd + ' --target=${TGT} ${SRC}'
|
|
|
|
shell = True # temporary workaround for #795
|
|
|
|
|
2014-01-27 02:32:09 +01:00
|
|
|
@conf
|
|
|
|
def find_glib_genmarshal(conf):
|
2011-09-10 11:13:51 +02:00
|
|
|
conf.find_program('glib-genmarshal', var='GLIB_GENMARSHAL')
|
2014-01-27 02:32:09 +01:00
|
|
|
|
|
|
|
@conf
|
|
|
|
def find_glib_mkenums(conf):
|
|
|
|
if not conf.env.PERL:
|
|
|
|
conf.find_program('perl', var='PERL')
|
2013-09-04 06:44:56 +02:00
|
|
|
conf.find_program('glib-mkenums', interpreter='PERL', var='GLIB_MKENUMS')
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2014-01-27 02:32:09 +01:00
|
|
|
@conf
|
|
|
|
def find_glib_compile_schemas(conf):
|
2011-09-10 11:13:51 +02:00
|
|
|
# when cross-compiling, gsettings.m4 locates the program with the following:
|
|
|
|
# pkg-config --variable glib_compile_schemas gio-2.0
|
2014-01-27 02:32:09 +01:00
|
|
|
conf.find_program('glib-compile-schemas', var='GLIB_COMPILE_SCHEMAS')
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
def getstr(varname):
|
|
|
|
return getattr(Options.options, varname, getattr(conf.env,varname, ''))
|
|
|
|
|
|
|
|
gsettingsschemadir = getstr('GSETTINGSSCHEMADIR')
|
|
|
|
if not gsettingsschemadir:
|
|
|
|
datadir = getstr('DATADIR')
|
|
|
|
if not datadir:
|
2016-06-25 23:54:12 +02:00
|
|
|
prefix = conf.env.PREFIX
|
2011-09-10 11:13:51 +02:00
|
|
|
datadir = os.path.join(prefix, 'share')
|
|
|
|
gsettingsschemadir = os.path.join(datadir, 'glib-2.0', 'schemas')
|
|
|
|
|
2016-06-25 23:54:12 +02:00
|
|
|
conf.env.GSETTINGSSCHEMADIR = gsettingsschemadir
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2014-09-21 18:48:38 +02:00
|
|
|
@conf
|
|
|
|
def find_glib_compile_resources(conf):
|
|
|
|
conf.find_program('glib-compile-resources', var='GLIB_COMPILE_RESOURCES')
|
|
|
|
|
2014-01-27 02:32:09 +01:00
|
|
|
def configure(conf):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Finds the following programs:
|
2014-01-27 02:32:09 +01:00
|
|
|
|
|
|
|
* *glib-genmarshal* and set *GLIB_GENMARSHAL*
|
|
|
|
* *glib-mkenums* and set *GLIB_MKENUMS*
|
|
|
|
* *glib-compile-schemas* and set *GLIB_COMPILE_SCHEMAS* (not mandatory)
|
2014-09-21 18:48:38 +02:00
|
|
|
* *glib-compile-resources* and set *GLIB_COMPILE_RESOURCES* (not mandatory)
|
2014-01-27 02:32:09 +01:00
|
|
|
"""
|
|
|
|
conf.find_glib_genmarshal()
|
|
|
|
conf.find_glib_mkenums()
|
|
|
|
conf.find_glib_compile_schemas(mandatory=False)
|
2014-09-21 18:48:38 +02:00
|
|
|
conf.find_glib_compile_resources(mandatory=False)
|
2014-01-27 02:32:09 +01:00
|
|
|
|
2011-09-10 11:13:51 +02:00
|
|
|
def options(opt):
|
|
|
|
"""
|
2016-06-26 11:59:27 +02:00
|
|
|
Adds the ``--gsettingsschemadir`` command-line option
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
2014-01-25 18:24:51 +01:00
|
|
|
gr = opt.add_option_group('Installation directories')
|
|
|
|
gr.add_option('--gsettingsschemadir', help='GSettings schema location [DATADIR/glib-2.0/schemas]', default='', dest='GSETTINGSSCHEMADIR')
|
2011-09-10 11:13:51 +02:00
|
|
|
|