From 79f66268676ec8bf94c6964a555ecc9144daca8e Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 14 Dec 2016 22:03:56 +0530 Subject: Pass --gresources to valac for each compiled gresource Without this, the user has to both compile the resource with gnome.compile_resources, pass that to the target sources, and also pass --gresources=/path/to/gres.xml to vala_args in the target. With this, we will do that automatically. --- mesonbuild/modules/gnome.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mesonbuild/modules') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 6d05b4e..af3073f 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -162,6 +162,9 @@ can not be used with the current version of glib-compiled-resources, due to kwargs['depfile'] = depfile kwargs['command'] = copy.copy(cmd) + ['--dependency-file', '@DEPFILE@'] target_c = build.CustomTarget(name, state.subdir, kwargs) + # Used in backend/ninjabackend.py:generate_vala_compile() to pass + # --gresources to valac when GResources are used in Vala targets + target_c.gresource_c_output = True if gresource: # Only one target for .gresource files return [target_c] -- cgit v1.1 From e6f48a03fc989119bb56ea5c7b748f99f0404b5b Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 14 Dec 2016 22:13:38 +0530 Subject: Allow all code to access module target classes It is often useful to be able to check if a specific object is of a type defined in a module. To that end, define all such targets in modules/__init__.py so that everyone can refer to them without poking into module-specific code. --- mesonbuild/modules/__init__.py | 21 +++++++++++++++++++++ mesonbuild/modules/gnome.py | 20 +++----------------- mesonbuild/modules/rpm.py | 6 +++--- 3 files changed, 27 insertions(+), 20 deletions(-) (limited to 'mesonbuild/modules') diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index e69de29..493a7b9 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -0,0 +1,21 @@ +from .. import build + +class GResourceTarget(build.CustomTarget): + def __init__(self, name, subdir, kwargs): + super().__init__(name, subdir, kwargs) + +class GResourceHeaderTarget(build.CustomTarget): + def __init__(self, name, subdir, kwargs): + super().__init__(name, subdir, kwargs) + +class GirTarget(build.CustomTarget): + def __init__(self, name, subdir, kwargs): + super().__init__(name, subdir, kwargs) + +class TypelibTarget(build.CustomTarget): + def __init__(self, name, subdir, kwargs): + super().__init__(name, subdir, kwargs) + +class VapiTarget(build.CustomTarget): + def __init__(self, name, subdir, kwargs): + super().__init__(name, subdir, kwargs) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index af3073f..6ddfb85 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -25,6 +25,7 @@ from .. import dependencies from .. import mlog from .. import mesonlib from .. import interpreter +from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget # gresource compilation is broken due to the way # the resource compiler and Ninja clash about it @@ -161,10 +162,7 @@ can not be used with the current version of glib-compiled-resources, due to depfile = kwargs['output'] + '.d' kwargs['depfile'] = depfile kwargs['command'] = copy.copy(cmd) + ['--dependency-file', '@DEPFILE@'] - target_c = build.CustomTarget(name, state.subdir, kwargs) - # Used in backend/ninjabackend.py:generate_vala_compile() to pass - # --gresources to valac when GResources are used in Vala targets - target_c.gresource_c_output = True + target_c = GResourceTarget(name, state.subdir, kwargs) if gresource: # Only one target for .gresource files return [target_c] @@ -180,7 +178,7 @@ can not be used with the current version of glib-compiled-resources, due to h_kwargs['install'] = install_header h_kwargs['install_dir'] = kwargs.get('install_dir', state.environment.coredata.get_builtin_option('includedir')) - target_h = build.CustomTarget(args[0] + '_h', state.subdir, h_kwargs) + target_h = GResourceHeaderTarget(args[0] + '_h', state.subdir, h_kwargs) return [target_c, target_h] def _get_gresource_dependencies(self, state, input_file, source_dirs, dependencies): @@ -1090,15 +1088,3 @@ can not be used with the current version of glib-compiled-resources, due to def initialize(): return GnomeModule() - -class GirTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) - -class TypelibTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) - -class VapiTarget(build.CustomTarget): - def __init__(self, name, subdir, kwargs): - super().__init__(name, subdir, kwargs) diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py index dca1ad6..a0f79aa 100644 --- a/mesonbuild/modules/rpm.py +++ b/mesonbuild/modules/rpm.py @@ -19,7 +19,7 @@ from .. import build from .. import compilers import datetime from .. import mlog -from ..modules import gnome +from . import GirTarget, TypelibTarget import os @@ -65,9 +65,9 @@ class RPMModule: to_delete.add('%%{buildroot}%%{_libdir}/%s' % target.get_filename()) mlog.warning('removing', mlog.bold(target.get_filename()), 'from package because packaging static libs not recommended') - elif isinstance(target, gnome.GirTarget) and target.should_install(): + elif isinstance(target, GirTarget) and target.should_install(): files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0]) - elif isinstance(target, gnome.TypelibTarget) and target.should_install(): + elif isinstance(target, TypelibTarget) and target.should_install(): files.add('%%{_libdir}/girepository-1.0/%s' % target.get_filename()[0]) for header in state.headers: if len(header.get_install_subdir()) > 0: -- cgit v1.1 From d5f7ba862bb37ad75b68e007b8b55f40b6f6fd19 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 15 Dec 2016 13:35:46 +0530 Subject: gnome.mkenums: Use absolute paths for all commandline args Closes #973 test cases/vala/8 generated sources/ tests this. --- mesonbuild/modules/gnome.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mesonbuild/modules') diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index 6ddfb85..eca894a 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -799,7 +799,7 @@ can not be used with the current version of glib-compiled-resources, due to install_header = False for arg, value in kwargs.items(): if arg == 'sources': - sources = [value] + sources + raise AssertionError("sources should've already been handled") elif arg == 'c_template': c_template = value if 'template' in kwargs: @@ -883,7 +883,8 @@ can not be used with the current version of glib-compiled-resources, due to 'command': cmd } custom_kwargs.update(kwargs) - return build.CustomTarget(output, state.subdir, custom_kwargs) + return build.CustomTarget(output, state.subdir, custom_kwargs, + absolute_paths=True) def genmarshal(self, state, args, kwargs): if len(args) != 1: -- cgit v1.1 From 5e5b3f00d8485949634b4411d8304cc467ad8fc7 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 15 Dec 2016 13:42:28 +0530 Subject: modules: Cache programs found by find_program This avoids printing several 'Found:' messages during configure, and also avoids doing several searches for the same binary. This is already done by the interpreter for `find_program` calls from build files. Also move it to the module-wide __init__.py file so it can be used by other modules as-needed. Also use it for g-ir-scanner where it was missed in one place, also fix exception name in the same place. --- mesonbuild/modules/__init__.py | 13 +++++++++++++ mesonbuild/modules/gnome.py | 16 +++++----------- mesonbuild/modules/qt4.py | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) (limited to 'mesonbuild/modules') diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 493a7b9..8986d7a 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.py @@ -1,4 +1,17 @@ from .. import build +from .. import dependencies + +_found_programs = {} + +def find_program(program_name, target_name): + if program_name in _found_programs: + return _found_programs[program_name] + program = dependencies.ExternalProgram(program_name) + if not program.found(): + m = "Target {!r} can't be generated as {!r} could not be found" + raise MesonException(m.format(target_name, program_name)) + _found_programs[program_name] = program + return program class GResourceTarget(build.CustomTarget): def __init__(self, name, subdir, kwargs): diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index eca894a..e291c98 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -25,7 +25,7 @@ from .. import dependencies from .. import mlog from .. import mesonlib from .. import interpreter -from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget +from . import find_program, GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget # gresource compilation is broken due to the way # the resource compiler and Ninja clash about it @@ -46,19 +46,13 @@ def gir_has_extra_lib_arg(): _gir_has_extra_lib_arg = False try: - scanner_options = subprocess.check_output(['g-ir-scanner', '--help']).decode() - _gir_has_extra_lib_arg = '--extra-library' in scanner_options - except (FileNotFound, subprocess.CalledProcessError): + g_ir_scanner = find_program('g-ir-scanner', '').get_command() + opts = Popen_safe(g_ir_scanner + ['--help'], stderr=subprocess.STDOUT)[1] + _gir_has_extra_lib_arg = '--extra-library' in opts + except (MesonException, FileNotFoundError, subprocess.CalledProcessError): pass return _gir_has_extra_lib_arg -def find_program(program_name, target_name): - program = dependencies.ExternalProgram(program_name) - if not program.found(): - raise MesonException('%s can\'t be generated as %s could not be found' % ( - target_name, program_name)) - return program - class GnomeModule: @staticmethod diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py index ab285fb..63dfef8 100644 --- a/mesonbuild/modules/qt4.py +++ b/mesonbuild/modules/qt4.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os, subprocess +import os from .. import mlog from .. import build from ..mesonlib import MesonException, Popen_safe -- cgit v1.1