From ab004ab1895b562af6dd16d396327b2ae2b52dd0 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 25 Aug 2016 01:42:40 -0400 Subject: Add support for glib-mkenums to gnome module. --- mesonbuild/modules/gnome.py | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'mesonbuild') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 11abf88..6a190b7 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -473,6 +473,53 @@ class GnomeModule: } return build.CustomTarget(namebase + '-gdbus', state.subdir, custom_kwargs) + def mkenums(self, state, args, kwargs): + if len(args) != 1: + raise MesonException('Mkenums requires one positional argument.') + output = args[0] + + if 'sources' not in kwargs: + raise MesonException('Missing keyword argument "sources".') + sources = kwargs.pop('sources') + if isinstance(sources, str): + sources = [sources] + elif not isinstance(sources, list): + raise MesonException( + 'Sources keyword argument must be a string or array.') + + cmd = ['glib-mkenums'] + known_kwargs = ['comments', 'eprod', 'fhead', 'fprod', 'ftail', + 'identifier-prefix', 'symbol-prefix', 'template', + 'vhead', 'vprod', 'vtail'] + known_custom_target_kwargs = ['install', 'install_dir', 'build_always', + 'depends', 'depend_files'] + add_template = False + for arg, value in kwargs.items(): + if arg == 'template': + add_template = True + sources = [value] + sources + elif arg in known_kwargs: + cmd += ['--' + arg, value] + elif arg not in known_custom_target_kwargs: + raise MesonException( + 'Mkenums does not take a %s keyword argument.' % (arg, )) + if add_template: + cmd += ['--template', '@INPUT@'] + else: + cmd += ['@INPUT@'] + + custom_kwargs = { + 'input': sources, + 'output': output, + 'capture': True, + 'command': cmd + } + for arg in known_custom_target_kwargs: + if arg in kwargs: + custom_kwargs[arg] = kwargs[arg] + return build.CustomTarget(output, state.subdir, custom_kwargs) + + def initialize(): return GnomeModule() -- cgit v1.1 From 2a8a0727fcf84fa0bb8d4b4eb095594976b30ef9 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 25 Aug 2016 04:20:46 -0400 Subject: Add support for glib-genmarshal to gnome module. --- mesonbuild/modules/gnome.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'mesonbuild') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 6a190b7..5f0f737 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -519,6 +519,48 @@ class GnomeModule: custom_kwargs[arg] = kwargs[arg] return build.CustomTarget(output, state.subdir, custom_kwargs) + def genmarshal(self, state, args, kwargs): + if len(args) != 1: + raise MesonException( + 'Genmarshal requires one positional argument.') + output = args[0] + + if 'sources' not in kwargs: + raise MesonException('Missing keyword argument "sources".') + sources = kwargs.pop('sources') + if isinstance(sources, str): + sources = [sources] + elif not isinstance(sources, list): + raise MesonException( + 'Sources keyword argument must be a string or array.') + + cmd = ['glib-genmarshal'] + known_kwargs = ['body', 'header', 'internal', 'nostdinc', + 'skip-source', 'stdinc', 'valist-marshallers'] + known_custom_target_kwargs = ['install', 'install_dir', 'build_always', + 'depends', 'depend_files'] + for arg, value in kwargs.items(): + if arg == 'prefix': + cmd += ['--prefix', value] + elif arg in known_kwargs and value: + cmd += ['--' + arg] + elif arg not in known_custom_target_kwargs: + raise MesonException( + 'Genmarshal does not take a %s keyword argument.' % ( + arg, )) + cmd += ['@INPUT@'] + + custom_kwargs = { + 'input': sources, + 'output': output, + 'capture': True, + 'command': cmd + } + for arg in known_custom_target_kwargs: + if arg in kwargs: + custom_kwargs[arg] = kwargs[arg] + return build.CustomTarget(output, state.subdir, custom_kwargs) + def initialize(): return GnomeModule() -- cgit v1.1 From ceee8bc6b26eb2d7ec45090a3945853456d895a0 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 28 Aug 2016 18:18:17 -0400 Subject: Generate genmarshal header and body simultaneously. This follows the same style as gnome.compile_resources, which produces both files from one invocation. --- mesonbuild/modules/gnome.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 5f0f737..edd3f93 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -535,10 +535,11 @@ class GnomeModule: 'Sources keyword argument must be a string or array.') cmd = ['glib-genmarshal'] - known_kwargs = ['body', 'header', 'internal', 'nostdinc', - 'skip-source', 'stdinc', 'valist-marshallers'] - known_custom_target_kwargs = ['install', 'install_dir', 'build_always', - 'depends', 'depend_files'] + known_kwargs = ['internal', 'nostdinc', 'skip-source', 'stdinc', + 'valist-marshallers'] + known_custom_target_kwargs = ['build_always', 'depends', + 'depend_files', 'install_dir', + 'install_header'] for arg, value in kwargs.items(): if arg == 'prefix': cmd += ['--prefix', value] @@ -548,18 +549,30 @@ class GnomeModule: raise MesonException( 'Genmarshal does not take a %s keyword argument.' % ( arg, )) - cmd += ['@INPUT@'] + + install_header = kwargs.pop('install_header', False) + install_dir = kwargs.pop('install_dir', None) custom_kwargs = { 'input': sources, - 'output': output, 'capture': True, - 'command': cmd } for arg in known_custom_target_kwargs: if arg in kwargs: custom_kwargs[arg] = kwargs[arg] - return build.CustomTarget(output, state.subdir, custom_kwargs) + + custom_kwargs['command'] = cmd + ['--header', '--body', '@INPUT@'] + custom_kwargs['output'] = output + '.c' + body = build.CustomTarget(output + '_c', state.subdir, custom_kwargs) + + custom_kwargs['install'] = install_header + if install_dir is not None: + custom_kwargs['install_dir'] = install_dir + custom_kwargs['command'] = cmd + ['--header', '@INPUT@'] + custom_kwargs['output'] = output + '.h' + header = build.CustomTarget(output + '_h', state.subdir, custom_kwargs) + + return [body, header] def initialize(): -- cgit v1.1 From 1033728c8573c1dee5b06237e2dc0a99d2a3500d Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 19 Sep 2016 01:34:56 -0400 Subject: Fix mkenums and genmarshal argument names. Dashes aren't allowed in keyword argument names. --- mesonbuild/modules/gnome.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index edd3f93..8cbc404 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -489,7 +489,7 @@ class GnomeModule: cmd = ['glib-mkenums'] known_kwargs = ['comments', 'eprod', 'fhead', 'fprod', 'ftail', - 'identifier-prefix', 'symbol-prefix', 'template', + 'identifier_prefix', 'symbol_prefix', 'template', 'vhead', 'vprod', 'vtail'] known_custom_target_kwargs = ['install', 'install_dir', 'build_always', 'depends', 'depend_files'] @@ -499,7 +499,7 @@ class GnomeModule: add_template = True sources = [value] + sources elif arg in known_kwargs: - cmd += ['--' + arg, value] + cmd += ['--' + arg.replace('_', '-'), value] elif arg not in known_custom_target_kwargs: raise MesonException( 'Mkenums does not take a %s keyword argument.' % (arg, )) @@ -535,8 +535,8 @@ class GnomeModule: 'Sources keyword argument must be a string or array.') cmd = ['glib-genmarshal'] - known_kwargs = ['internal', 'nostdinc', 'skip-source', 'stdinc', - 'valist-marshallers'] + known_kwargs = ['internal', 'nostdinc', 'skip_source', 'stdinc', + 'valist_marshallers'] known_custom_target_kwargs = ['build_always', 'depends', 'depend_files', 'install_dir', 'install_header'] @@ -544,7 +544,7 @@ class GnomeModule: if arg == 'prefix': cmd += ['--prefix', value] elif arg in known_kwargs and value: - cmd += ['--' + arg] + cmd += ['--' + arg.replace('_', '-')] elif arg not in known_custom_target_kwargs: raise MesonException( 'Genmarshal does not take a %s keyword argument.' % ( -- cgit v1.1 From d61b71fdc2fdd0b3c6cb60f9ab55c5b511a95fd9 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 25 Sep 2016 18:42:57 +0300 Subject: Converted mkenums to be single invocation. --- mesonbuild/modules/gnome.py | 51 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 8cbc404..e2333a8 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -476,7 +476,9 @@ class GnomeModule: def mkenums(self, state, args, kwargs): if len(args) != 1: raise MesonException('Mkenums requires one positional argument.') - output = args[0] + basename = args[0] + c_target_name = basename + '_c' + h_target_hame = basename + '_h' if 'sources' not in kwargs: raise MesonException('Missing keyword argument "sources".') @@ -487,36 +489,61 @@ class GnomeModule: raise MesonException( 'Sources keyword argument must be a string or array.') - cmd = ['glib-mkenums'] + cmd = [] known_kwargs = ['comments', 'eprod', 'fhead', 'fprod', 'ftail', 'identifier_prefix', 'symbol_prefix', 'template', 'vhead', 'vprod', 'vtail'] known_custom_target_kwargs = ['install', 'install_dir', 'build_always', 'depends', 'depend_files'] - add_template = False + c_template = h_template = None + install_header = False for arg, value in kwargs.items(): - if arg == 'template': - add_template = True + if arg == 'sources': sources = [value] + sources + elif arg == 'c_template': + c_template = value + elif arg == 'h_template': + h_template = value + elif arg == 'install_header': + install_header = value elif arg in known_kwargs: cmd += ['--' + arg.replace('_', '-'), value] elif arg not in known_custom_target_kwargs: raise MesonException( 'Mkenums does not take a %s keyword argument.' % (arg, )) - if add_template: - cmd += ['--template', '@INPUT@'] - else: - cmd += ['@INPUT@'] + if c_template is None or h_template is None: + raise MesonException('Must specify both a C and H template.') + # We always set template as the first element in the source array so + # --template consumes it. + cmd = ['glib-mkenums', '--template', '@INPUT@'] + cmd + custom_kwargs = {} + for arg in known_custom_target_kwargs: + if arg in kwargs: + custom_kwargs[arg] = kwargs[arg] + + c_output = os.path.splitext(c_template)[0] + h_output = os.path.splitext(h_template)[0] + c_sources = [c_template] + sources + h_sources = [h_template] + sources + + custom_kwargs['install'] = install_header + if 'install_dir' not in custom_kwargs: + custom_kwargs['install_dir'] = state.environment.coredata.get_builtin_option('includedir') + h_target = self.make_mkenum_custom_target(state, h_sources, h_output, cmd, custom_kwargs) + custom_kwargs['install'] = False # Never install the C file. Complain on bug tracker if you need this. + custom_kwargs['depends'] = h_target + c_target = self.make_mkenum_custom_target(state, c_sources, c_output, cmd, custom_kwargs) + return [c_target, h_target] + + def make_mkenum_custom_target(self, state, sources, output, cmd, kwargs): custom_kwargs = { 'input': sources, 'output': output, 'capture': True, 'command': cmd } - for arg in known_custom_target_kwargs: - if arg in kwargs: - custom_kwargs[arg] = kwargs[arg] + custom_kwargs.update(kwargs) return build.CustomTarget(output, state.subdir, custom_kwargs) def genmarshal(self, state, args, kwargs): -- cgit v1.1 From 8f024c06970dcaec1564516c4583ae8543713ea8 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 28 Sep 2016 18:18:00 -0400 Subject: Allow running mkenums without templates. --- mesonbuild/modules/gnome.py | 67 +++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 21 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index e2333a8..f3baeca 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -477,8 +477,6 @@ class GnomeModule: if len(args) != 1: raise MesonException('Mkenums requires one positional argument.') basename = args[0] - c_target_name = basename + '_c' - h_target_hame = basename + '_h' if 'sources' not in kwargs: raise MesonException('Missing keyword argument "sources".') @@ -511,30 +509,57 @@ class GnomeModule: elif arg not in known_custom_target_kwargs: raise MesonException( 'Mkenums does not take a %s keyword argument.' % (arg, )) - if c_template is None or h_template is None: - raise MesonException('Must specify both a C and H template.') - # We always set template as the first element in the source array so - # --template consumes it. - cmd = ['glib-mkenums', '--template', '@INPUT@'] + cmd + cmd = ['glib-mkenums'] + cmd custom_kwargs = {} for arg in known_custom_target_kwargs: if arg in kwargs: custom_kwargs[arg] = kwargs[arg] - c_output = os.path.splitext(c_template)[0] - h_output = os.path.splitext(h_template)[0] - - c_sources = [c_template] + sources - h_sources = [h_template] + sources - - custom_kwargs['install'] = install_header - if 'install_dir' not in custom_kwargs: - custom_kwargs['install_dir'] = state.environment.coredata.get_builtin_option('includedir') - h_target = self.make_mkenum_custom_target(state, h_sources, h_output, cmd, custom_kwargs) - custom_kwargs['install'] = False # Never install the C file. Complain on bug tracker if you need this. - custom_kwargs['depends'] = h_target - c_target = self.make_mkenum_custom_target(state, c_sources, c_output, cmd, custom_kwargs) - return [c_target, h_target] + targets = [] + + if h_template is not None: + h_output = os.path.splitext(h_template)[0] + # We always set template as the first element in the source array + # so --template consumes it. + h_cmd = cmd + ['--template', '@INPUT@'] + h_sources = [h_template] + sources + custom_kwargs['install'] = install_header + if 'install_dir' not in custom_kwargs: + custom_kwargs['install_dir'] = \ + state.environment.coredata.get_builtin_option('includedir') + h_target = self.make_mkenum_custom_target(state, h_sources, + h_output, h_cmd, + custom_kwargs) + targets.append(h_target) + + if c_template is not None: + c_output = os.path.splitext(c_template)[0] + # We always set template as the first element in the source array + # so --template consumes it. + c_cmd = cmd + ['--template', '@INPUT@'] + c_sources = [c_template] + sources + # Never install the C file. Complain on bug tracker if you need it. + custom_kwargs['install'] = False + if h_template is not None: + custom_kwargs['depends'] = h_target + c_target = self.make_mkenum_custom_target(state, c_sources, + c_output, c_cmd, + custom_kwargs) + targets.insert(0, c_target) + + if c_template is None and h_template is None: + generic_cmd = cmd + ['@INPUT@'] + custom_kwargs['install'] = install_header + if 'install_dir' not in custom_kwargs: + custom_kwargs['install_dir'] = \ + state.environment.coredata.get_builtin_option('includedir') + target = self.make_mkenum_custom_target(state, sources, basename, + generic_cmd, custom_kwargs) + return target + elif len(targets) == 1: + return targets[0] + else: + return targets def make_mkenum_custom_target(self, state, sources, output, cmd, kwargs): custom_kwargs = { -- cgit v1.1 From 2840539a08ff03aa33ecc4f1cd7e64cc12791ae1 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 28 Sep 2016 18:32:56 -0400 Subject: Don't overwrite mkenums C file dependencies. --- mesonbuild/modules/gnome.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index f3baeca..ddff5aa 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -541,7 +541,10 @@ class GnomeModule: # Never install the C file. Complain on bug tracker if you need it. custom_kwargs['install'] = False if h_template is not None: - custom_kwargs['depends'] = h_target + if 'depends' in custom_kwargs: + custom_kwargs['depends'] += [h_target] + else: + custom_kwargs['depends'] = h_target c_target = self.make_mkenum_custom_target(state, c_sources, c_output, c_cmd, custom_kwargs) -- cgit v1.1