aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/backends.py2
-rw-r--r--mesonbuild/build.py4
-rw-r--r--mesonbuild/compilers.py6
-rw-r--r--mesonbuild/dependencies.py5
-rw-r--r--mesonbuild/environment.py18
-rw-r--r--mesonbuild/interpreter.py44
-rw-r--r--mesonbuild/mesonlib.py4
-rw-r--r--mesonbuild/modules/gnome.py5
-rw-r--r--mesonbuild/modules/i18n.py2
-rw-r--r--test cases/common/60 install script/installed_files.txt2
-rw-r--r--test cases/common/60 install script/meson.build3
-rw-r--r--test cases/common/60 install script/src/meson.build1
-rw-r--r--test cases/common/60 install script/src/myinstall.py12
13 files changed, 64 insertions, 44 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index bc61c96..b265a24 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -650,7 +650,7 @@ class Backend():
child_env.update(env)
for s in self.build.postconf_scripts:
- cmd = s['exe'].get_command() + s['args']
+ cmd = s['exe'] + s['args']
subprocess.check_call(cmd, env=child_env)
# Subprojects of subprojects may cause the same dep args to be used
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index db92858..a9f10c5 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1482,9 +1482,9 @@ class Data():
for s in self.sources:
assert(isinstance(s, File))
-class InstallScript(dict):
+class RunScript(dict):
def __init__(self, script, args):
- super(InstallScript, self).__init__()
+ super().__init__()
assert(isinstance(script, list))
assert(isinstance(args, list))
self['exe'] = script
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 54c1300..18f2791 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -18,7 +18,7 @@ import subprocess, os.path
import tempfile
from .import mesonlib
from . import mlog
-from .mesonlib import MesonException, version_compare, Popen_safe
+from .mesonlib import EnvironmentException, MesonException, version_compare, Popen_safe
from . import coredata
"""This file contains the data files of all compilers Meson knows
@@ -314,10 +314,6 @@ def build_unix_rpath_args(build_dir, rpath_paths, install_rpath):
paths = paths + ':' + padding
return ['-Wl,-rpath,' + paths]
-class EnvironmentException(MesonException):
- def __init(self, *args, **kwargs):
- Exception.__init__(self, *args, **kwargs)
-
class CrossNoRunException(MesonException):
def __init(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py
index aa3927f..da73a57 100644
--- a/mesonbuild/dependencies.py
+++ b/mesonbuild/dependencies.py
@@ -65,9 +65,6 @@ class Dependency():
def need_threads(self):
return False
- def type_name(self):
- return self.type_name
-
def get_pkgconfig_variable(self, variable_name):
raise MesonException('Tried to get a pkg-config variable from a non-pkgconfig dependency.')
@@ -476,7 +473,7 @@ class ExternalProgram():
return self.fullpath[0] is not None
def get_command(self):
- return self.fullpath
+ return self.fullpath[:]
def get_name(self):
return self.name
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 3231fa8..52f5752 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -17,16 +17,12 @@ from . import coredata
from . import mesonlib
from . import mlog
from .compilers import *
-from .mesonlib import Popen_safe
+from .mesonlib import EnvironmentException, Popen_safe
import configparser
import shutil
build_filename = 'meson.build'
-class EnvironmentException(mesonlib.MesonException):
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
-
def find_coverage_tools():
gcovr_exe = 'gcovr'
lcov_exe = 'lcov'
@@ -65,7 +61,7 @@ def detect_native_windows_arch():
# If this doesn't exist, something is messing with the environment
arch = os.environ['PROCESSOR_ARCHITECTURE'].lower()
except KeyError:
- raise InterpreterException('Unable to detect native OS architecture')
+ raise EnvironmentException('Unable to detect native OS architecture')
return arch
def detect_windows_arch(compilers):
@@ -629,7 +625,7 @@ class Environment():
return RustCompiler(exelist, version)
raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
- def detect_d_compiler(self):
+ def detect_d_compiler(self, want_cross):
exelist = None
is_cross = False
# Search for a D compiler.
@@ -847,20 +843,20 @@ class CrossBuildInfo():
for entry in config[s]:
value = config[s][entry]
if ' ' in entry or '\t' in entry or "'" in entry or '"' in entry:
- raise EnvironmentException('Malformed variable name %s in cross file..' % varname)
+ raise EnvironmentException('Malformed variable name %s in cross file..' % entry)
try:
res = eval(value, {'true' : True, 'false' : False})
except Exception:
- raise EnvironmentException('Malformed value in cross file variable %s.' % varname)
+ raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
if self.ok_type(res):
self.config[s][entry] = res
elif isinstance(res, list):
for i in res:
if not self.ok_type(i):
- raise EnvironmentException('Malformed value in cross file variable %s.' % varname)
+ raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
self.config[s][entry] = res
else:
- raise EnvironmentException('Malformed value in cross file variable %s.' % varname)
+ raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
def has_host(self):
return 'host_machine' in self.config
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index c92adaf..7e55b88 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -987,6 +987,7 @@ class MesonMain(InterpreterObject):
InterpreterObject.__init__(self)
self.build = build
self.interpreter = interpreter
+ self._found_source_scripts = {}
self.methods.update({'get_compiler': self.get_compiler_method,
'is_cross_build' : self.is_cross_build_method,
'has_exe_wrapper' : self.has_exe_wrapper_method,
@@ -1006,27 +1007,34 @@ class MesonMain(InterpreterObject):
'backend' : self.backend_method,
})
+ def _find_source_script(self, name, args):
+ # Prefer scripts in the current source directory
+ search_dir = os.path.join(self.interpreter.environment.source_dir,
+ self.interpreter.subdir)
+ key = (name, search_dir)
+ if key in self._found_source_scripts:
+ found = self._found_source_scripts[key]
+ else:
+ found = dependencies.ExternalProgram(name, search_dir=search_dir)
+ if found:
+ self._found_source_scripts[key] = found
+ else:
+ raise InterpreterException('Script {!r} not found'.format(name))
+ return build.RunScript(found.get_command(), args)
+
def add_install_script_method(self, args, kwargs):
if len(args) < 1:
raise InterpreterException('add_install_script takes one or more arguments')
check_stringlist(args, 'add_install_script args must be strings')
- scriptbase = args[0]
- search_dir = os.path.join(self.interpreter.environment.source_dir,
- self.interpreter.subdir)
- script = dependencies.ExternalProgram(scriptbase, search_dir=search_dir)
- extras = args[1:]
- self.build.install_scripts.append({'exe': script.get_command(), 'args': extras})
+ script = self._find_source_script(args[0], args[1:])
+ self.build.install_scripts.append(script)
def add_postconf_script_method(self, args, kwargs):
if len(args) < 1:
raise InterpreterException('add_postconf_script takes one or more arguments')
check_stringlist(args, 'add_postconf_script arguments must be strings')
- scriptbase = args[0]
- search_dir = os.path.join(self.interpreter.environment.source_dir,
- self.interpreter.subdir)
- script = dependencies.ExternalProgram(scriptbase, search_dir=search_dir)
- extras = args[1:]
- self.build.postconf_scripts.append({'exe': script, 'args': extras})
+ script = self._find_source_script(args[0], args[1:])
+ self.build.postconf_scripts.append(script)
def current_source_dir_method(self, args, kwargs):
src = self.interpreter.environment.source_dir
@@ -1229,14 +1237,14 @@ class Interpreter(InterpreterBase):
outvalues.append(v)
elif isinstance(v, build.Executable):
self.add_target(v.name, v)
- outvalues.append(ExecutableHolder(v))
+ outvalues.append(ExecutableHolder(v, self))
elif isinstance(v, list):
outvalues.append(self.module_method_callback(v))
elif isinstance(v, build.GeneratedList):
outvalues.append(GeneratedListHolder(v))
elif isinstance(v, build.RunTarget):
self.add_target(v.name, v)
- elif isinstance(v, build.InstallScript):
+ elif isinstance(v, build.RunScript):
self.build.install_scripts.append(v)
elif isinstance(v, build.Data):
self.build.data.append(v)
@@ -1572,15 +1580,15 @@ class Interpreter(InterpreterBase):
elif lang == 'vala':
comp = self.environment.detect_vala_compiler()
if need_cross_compiler:
- cross_comp = comp # Vala is too (I think).
+ cross_comp = comp # Vala compiles to platform-independent C
elif lang == 'd':
- comp = self.environment.detect_d_compiler()
+ comp = self.environment.detect_d_compiler(False)
if need_cross_compiler:
- cross_comp = comp # D as well (AFAIK).
+ cross_comp = self.environment.detect_d_compiler(True)
elif lang == 'rust':
comp = self.environment.detect_rust_compiler()
if need_cross_compiler:
- cross_comp = comp # FIXME, probably not correct.
+ cross_comp = comp # FIXME, not correct.
elif lang == 'fortran':
comp = self.environment.detect_fortran_compiler(False)
if need_cross_compiler:
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 622cd04..551bda2 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -22,6 +22,10 @@ class MesonException(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
+class EnvironmentException(MesonException):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
class File:
def __init__(self, is_built, subdir, fname):
self.is_built = is_built
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 3a991e9..f72ddfa 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -24,6 +24,7 @@ from ..mesonlib import MesonException, Popen_safe
from ..dependencies import Dependency, PkgConfigDependency, InternalDependency
from .. import mlog
from .. import mesonlib
+from .. import compilers
from .. import interpreter
from . import find_program, GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
@@ -614,7 +615,7 @@ can not be used with the current version of glib-compiled-resources, due to
args.append('--media=' + '@@'.join(media))
if langs:
args.append('--langs=' + '@@'.join(langs))
- inscript = build.InstallScript(script, args)
+ inscript = build.RunScript(script, args)
potargs = [state.environment.get_build_command(), '--internal', 'yelphelper', 'pot',
'--subdir=' + state.subdir,
@@ -698,7 +699,7 @@ can not be used with the current version of glib-compiled-resources, due to
args += self._get_build_args(kwargs, state)
res = [build.RunTarget(targetname, command[0], command[1:] + args, [], state.subdir)]
if kwargs.get('install', True):
- res.append(build.InstallScript(command, args))
+ res.append(build.RunScript(command, args))
return res
def _get_build_args(self, kwargs, state):
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index eaeb0a3..4df62f2 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -109,7 +109,7 @@ class I18nModule:
pkg_arg]
if lang_arg:
args.append(lang_arg)
- iscript = build.InstallScript(script, args)
+ iscript = build.RunScript(script, args)
return [pottarget, gmotarget, iscript, updatepotarget]
diff --git a/test cases/common/60 install script/installed_files.txt b/test cases/common/60 install script/installed_files.txt
index 94e3164..94c1fed 100644
--- a/test cases/common/60 install script/installed_files.txt
+++ b/test cases/common/60 install script/installed_files.txt
@@ -1,2 +1,4 @@
usr/bin/prog?exe
usr/diiba/daaba/file.dat
+usr/this/should/also-work.dat
+usr/this/does/something-different.dat.in
diff --git a/test cases/common/60 install script/meson.build b/test cases/common/60 install script/meson.build
index 7cbde8d..6351518 100644
--- a/test cases/common/60 install script/meson.build
+++ b/test cases/common/60 install script/meson.build
@@ -2,3 +2,6 @@ project('custom install script', 'c')
executable('prog', 'prog.c', install : true)
meson.add_install_script('myinstall.py', 'diiba/daaba', 'file.dat')
+meson.add_install_script('myinstall.py', 'this/should', 'also-work.dat')
+
+subdir('src')
diff --git a/test cases/common/60 install script/src/meson.build b/test cases/common/60 install script/src/meson.build
new file mode 100644
index 0000000..b23574a
--- /dev/null
+++ b/test cases/common/60 install script/src/meson.build
@@ -0,0 +1 @@
+meson.add_install_script('myinstall.py', 'this/does', 'something-different.dat')
diff --git a/test cases/common/60 install script/src/myinstall.py b/test cases/common/60 install script/src/myinstall.py
new file mode 100644
index 0000000..d8a5714
--- /dev/null
+++ b/test cases/common/60 install script/src/myinstall.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+
+import os
+import sys
+
+prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX']
+
+dirname = os.path.join(prefix, sys.argv[1])
+
+os.makedirs(dirname)
+with open(os.path.join(dirname, sys.argv[2] + '.in'), 'w') as f:
+ f.write('')