glib2

Support for GLib2 tools:

  • marshal

  • enums

  • gsettings

  • gresource

waflib.Tools.glib2.taskgen_method(func)

Decorator that registers method as a task generator method. The function must accept a task generator as first parameter:

from waflib.TaskGen import taskgen_method
@taskgen_method
def mymethod(self):
        pass
Parameters

func (function) – task generator method to add

Return type

function

waflib.Tools.glib2.before_method(*k)[source]

Decorator that registera task generator method which will be executed before the functions of given name(s):

from waflib.TaskGen import feature, before
@feature('myfeature')
@before_method('fun2')
def fun1(self):
        print('feature 1!')
@feature('myfeature')
def fun2(self):
        print('feature 2!')
def build(bld):
        bld(features='myfeature')
Parameters

k (list of string) – method names

waflib.Tools.glib2.feature(*k)

Decorator that registers a task generator method that will be executed when the object attribute feature contains the corresponding key(s):

from waflib.TaskGen import feature
@feature('myfeature')
def myfunction(self):
        print('that is my feature!')
def build(bld):
        bld(features='myfeature')
Parameters

k (list of string) – feature names

waflib.Tools.glib2.extension(*k)

Decorator that registers a task generator method which will be invoked during the processing of source files for the extension given:

from waflib import Task
class mytask(Task):
        run_str = 'cp ${SRC} ${TGT}'
@extension('.moo')
def create_maa_file(self, node):
        self.create_task('mytask', node, node.change_ext('.maa'))
def build(bld):
        bld(source='foo.moo')
waflib.Tools.glib2.conf(f)

Decorator: attach new configuration functions to waflib.Build.BuildContext and waflib.Configure.ConfigurationContext. The methods bound will accept a parameter named ‘mandatory’ to disable the configuration errors:

def configure(conf):
        conf.find_program('abc', mandatory=False)
Parameters

f (function) – method to bind

waflib.Tools.glib2.add_marshal_file(self, filename, prefix)[source]

Task generator method

Adds a file to the list of marshal files to process. Store them in the attribute marshal_list.

Parameters
  • filename (string) – xml file to compile

  • prefix (string) – marshal prefix (–prefix=prefix)

waflib.Tools.glib2.process_marshal(self)[source]

Processes the marshal files stored in the attribute marshal_list to create waflib.Tools.glib2.glib_genmarshal instances. Adds the c file created to the list of source to process.

class waflib.Tools.glib2.glib_genmarshal(*k, **kw)[source]
vars = ['GLIB_GENMARSHAL_PREFIX', 'GLIB_GENMARSHAL']

ConfigSet variables that should trigger a rebuild (class attribute used for waflib.Task.Task.sig_vars())

color = 'BLUE'

Color for the console display, see waflib.Logs.colors_lst

ext_out = ['.h']

File extensions that objects of this task class may create

hasrun
generator
env

waflib.ConfigSet.ConfigSet object (make sure to provide one)

inputs

List of input nodes, which represent the files used by the task instance

outputs

List of output nodes, which represent the files created by the task instance

dep_nodes

List of additional nodes to depend on

run_after

Set of tasks that must be executed before this one

hcode = b'\tdef run(self):\n\t\tbld = self.generator.bld\n\n\t\tget = self.env.get_flat\n\t\tcmd1 = "%s %s --prefix=%s --header > %s" % (\n\t\t\tget(\'GLIB_GENMARSHAL\'),\n\t\t\tself.inputs[0].srcpath(),\n\t\t\tget(\'GLIB_GENMARSHAL_PREFIX\'),\n\t\t\tself.outputs[0].abspath()\n\t\t)\n\n\t\tret = bld.exec_command(cmd1)\n\t\tif ret:\n\t\t\treturn ret\n\n\t\t#print self.outputs[1].abspath()\n\t\tc = \'\'\'#include "%s"\\n\'\'\' % self.outputs[0].name\n\t\tself.outputs[1].write(c)\n\n\t\tcmd2 = "%s %s --prefix=%s --body >> %s" % (\n\t\t\tget(\'GLIB_GENMARSHAL\'),\n\t\t\tself.inputs[0].srcpath(),\n\t\t\tget(\'GLIB_GENMARSHAL_PREFIX\'),\n\t\t\tself.outputs[1].abspath()\n\t\t)\n\t\treturn bld.exec_command(cmd2)\n'

String representing an additional hash for the class representation

waflib.Tools.glib2.add_enums_from_template(self, source='', target='', template='', comments='')[source]

Task generator method

Adds a file to the list of enum files to process. Stores them in the attribute enums_list.

Parameters
  • source (string) – enum file to process

  • target (string) – target file

  • template (string) – template file

  • comments (string) – comments

waflib.Tools.glib2.add_enums(self, source='', target='', file_head='', file_prod='', file_tail='', enum_prod='', value_head='', value_prod='', value_tail='', comments='')[source]

Task generator method

Adds a file to the list of enum files to process. Stores them in the attribute enums_list.

Parameters
  • source (string) – enum file to process

  • target (string) – target file

  • file_head – unused

  • file_prod – unused

  • file_tail – unused

  • enum_prod – unused

  • value_head – unused

  • value_prod – unused

  • value_tail – unused

  • comments (string) – comments

waflib.Tools.glib2.process_enums(self)[source]

Processes the enum files stored in the attribute enum_list to create waflib.Tools.glib2.glib_mkenums instances.

class waflib.Tools.glib2.glib_mkenums(*k, **kw)[source]

Processes enum files

color = 'PINK'

Color for the console display, see waflib.Logs.colors_lst

ext_out = ['.h']

File extensions that objects of this task class may create

hasrun
generator
env

waflib.ConfigSet.ConfigSet object (make sure to provide one)

inputs

List of input nodes, which represent the files used by the task instance

outputs

List of output nodes, which represent the files created by the task instance

dep_nodes

List of additional nodes to depend on

run_after

Set of tasks that must be executed before this one

hcode = b'${GLIB_MKENUMS} ${GLIB_MKENUMS_OPTIONS} ${GLIB_MKENUMS_SOURCE} > ${GLIB_MKENUMS_TARGET}'

String representing an additional hash for the class representation

orig_run_str = '${GLIB_MKENUMS} ${GLIB_MKENUMS_OPTIONS} ${GLIB_MKENUMS_SOURCE} > ${GLIB_MKENUMS_TARGET}'
vars = ['GLIB_MKENUMS', 'GLIB_MKENUMS_OPTIONS', 'GLIB_MKENUMS_SOURCE', 'GLIB_MKENUMS_TARGET']

ConfigSet variables that should trigger a rebuild (class attribute used for waflib.Task.Task.sig_vars())

waflib.Tools.glib2.add_settings_schemas(self, filename_list)[source]

Task generator method

Adds settings files to process to settings_schema_files

Parameters

filename_list (list of string) – files

waflib.Tools.glib2.add_settings_enums(self, namespace, filename_list)[source]

Task generator method

Called only once by task generator to set the enums namespace.

Parameters
  • namespace (string) – namespace

  • filename_list (file list) – enum files to process

waflib.Tools.glib2.process_settings(self)[source]

Task generator method

Processes the schema files in settings_schema_files to create waflib.Tools.glib2.glib_mkenums instances. The same files are validated through waflib.Tools.glib2.glib_validate_schema tasks.

Feature

glib2

class waflib.Tools.glib2.glib_validate_schema(*k, **kw)[source]

Validates schema files

color = 'PINK'

Color for the console display, see waflib.Logs.colors_lst

hasrun
generator
env

waflib.ConfigSet.ConfigSet object (make sure to provide one)

inputs

List of input nodes, which represent the files used by the task instance

outputs

List of output nodes, which represent the files created by the task instance

dep_nodes

List of additional nodes to depend on

run_after

Set of tasks that must be executed before this one

hcode = b'rm -f ${GLIB_VALIDATE_SCHEMA_OUTPUT} && ${GLIB_COMPILE_SCHEMAS} --dry-run ${GLIB_COMPILE_SCHEMAS_OPTIONS} && touch ${GLIB_VALIDATE_SCHEMA_OUTPUT}'

String representing an additional hash for the class representation

orig_run_str = 'rm -f ${GLIB_VALIDATE_SCHEMA_OUTPUT} && ${GLIB_COMPILE_SCHEMAS} --dry-run ${GLIB_COMPILE_SCHEMAS_OPTIONS} && touch ${GLIB_VALIDATE_SCHEMA_OUTPUT}'
vars = ['GLIB_COMPILE_SCHEMAS', 'GLIB_COMPILE_SCHEMAS_OPTIONS', 'GLIB_VALIDATE_SCHEMA_OUTPUT']

ConfigSet variables that should trigger a rebuild (class attribute used for waflib.Task.Task.sig_vars())

waflib.Tools.glib2.process_gresource_source(self, node)[source]

Creates tasks that turn .gresource.xml files to C code

waflib.Tools.glib2.process_gresource_bundle(self)[source]

Task generator method

Creates tasks to turn .gresource files from .gresource.xml files:

def build(bld):
        bld(
                features='gresource',
                source=['resources1.gresource.xml', 'resources2.gresource.xml'],
                install_path='${LIBDIR}/${PACKAGE}'
        )
Parameters
  • source (list of string) – XML files to process

  • install_path (string) – installation path

Feature

gresource

class waflib.Tools.glib2.glib_gresource_base(*k, **kw)[source]

Base class for gresource based tasks

color = 'BLUE'

Color for the console display, see waflib.Logs.colors_lst

base_cmd = '${GLIB_COMPILE_RESOURCES} --sourcedir=${SRC[0].parent.srcpath()} --sourcedir=${SRC[0].bld_dir()}'
scan()[source]

Scans gresource dependencies through glib-compile-resources --generate-dependencies command

hasrun
generator
env

waflib.ConfigSet.ConfigSet object (make sure to provide one)

inputs

List of input nodes, which represent the files used by the task instance

outputs

List of output nodes, which represent the files created by the task instance

dep_nodes

List of additional nodes to depend on

run_after

Set of tasks that must be executed before this one

class waflib.Tools.glib2.glib_gresource_source(*k, **kw)[source]

Task to generate C source code (.h and .c files) from a gresource.xml file

vars = ['GLIB_COMPILE_RESOURCES']

ConfigSet variables that should trigger a rebuild (class attribute used for waflib.Task.Task.sig_vars())

fun_h = (<function f>, ['GLIB_COMPILE_RESOURCES'])
fun_c = (<function f>, ['GLIB_COMPILE_RESOURCES'])
ext_out = ['.h']

File extensions that objects of this task class may create

hasrun
generator
env

waflib.ConfigSet.ConfigSet object (make sure to provide one)

inputs

List of input nodes, which represent the files used by the task instance

outputs

List of output nodes, which represent the files created by the task instance

dep_nodes

List of additional nodes to depend on

run_after

Set of tasks that must be executed before this one

hcode = b'\tdef run(self):\n\t\treturn self.fun_h[0](self) or self.fun_c[0](self)\n'

String representing an additional hash for the class representation

class waflib.Tools.glib2.glib_gresource_bundle(*k, **kw)[source]

Task to generate a .gresource binary file from a gresource.xml file

shell = True

Execute the command with the shell (class attribute)

hasrun
generator
env

waflib.ConfigSet.ConfigSet object (make sure to provide one)

inputs

List of input nodes, which represent the files used by the task instance

outputs

List of output nodes, which represent the files created by the task instance

dep_nodes

List of additional nodes to depend on

run_after

Set of tasks that must be executed before this one

hcode = b'${GLIB_COMPILE_RESOURCES} --sourcedir=${SRC[0].parent.srcpath()} --sourcedir=${SRC[0].bld_dir()} --target=${TGT} ${SRC}'

String representing an additional hash for the class representation

orig_run_str = '${GLIB_COMPILE_RESOURCES} --sourcedir=${SRC[0].parent.srcpath()} --sourcedir=${SRC[0].bld_dir()} --target=${TGT} ${SRC}'
vars = ['GLIB_COMPILE_RESOURCES']

ConfigSet variables that should trigger a rebuild (class attribute used for waflib.Task.Task.sig_vars())

waflib.Tools.glib2.find_glib_genmarshal(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.glib2.find_glib_mkenums(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.glib2.find_glib_compile_schemas(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.glib2.find_glib_compile_resources(conf)[source]

Configuration Method bound to waflib.Configure.ConfigurationContext

waflib.Tools.glib2.configure(conf)[source]

Finds the following programs:

  • glib-genmarshal and set GLIB_GENMARSHAL

  • glib-mkenums and set GLIB_MKENUMS

  • glib-compile-schemas and set GLIB_COMPILE_SCHEMAS (not mandatory)

  • glib-compile-resources and set GLIB_COMPILE_RESOURCES (not mandatory)

waflib.Tools.glib2.options(opt)[source]

Adds the --gsettingsschemadir command-line option

Features defined in this module: