aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-12-15 22:20:03 +0200
committerGitHub <noreply@github.com>2016-12-15 22:20:03 +0200
commit21e475b64b2eaadfc9f5209562d008999417ee7d (patch)
treecc4aaddfc75f60751c3c1ccc0c7a41343ae7b6ad /mesonbuild/modules
parent925f880e6ba4155a9a2d9b075cde20eff25039ca (diff)
parentff8cdf86f4a36290156424bfeb5efbde788a5953 (diff)
downloadmeson-21e475b64b2eaadfc9f5209562d008999417ee7d.zip
meson-21e475b64b2eaadfc9f5209562d008999417ee7d.tar.gz
meson-21e475b64b2eaadfc9f5209562d008999417ee7d.tar.bz2
Merge pull request #1194 from centricular/critical-bugfixes-vala
A bunch of bugfixes for Vala
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/__init__.py34
-rw-r--r--mesonbuild/modules/gnome.py36
-rw-r--r--mesonbuild/modules/qt4.py2
-rw-r--r--mesonbuild/modules/rpm.py6
4 files changed, 48 insertions, 30 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py
index e69de29..8986d7a 100644
--- a/mesonbuild/modules/__init__.py
+++ b/mesonbuild/modules/__init__.py
@@ -0,0 +1,34 @@
+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):
+ 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 6d05b4e..e291c98 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 find_program, GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
# gresource compilation is broken due to the way
# the resource compiler and Ninja clash about it
@@ -45,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
@@ -161,7 +156,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)
+ target_c = GResourceTarget(name, state.subdir, kwargs)
if gresource: # Only one target for .gresource files
return [target_c]
@@ -177,7 +172,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):
@@ -798,7 +793,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:
@@ -882,7 +877,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:
@@ -1087,15 +1083,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/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
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: