aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/build.py11
-rw-r--r--mesonbuild/interpreter.py24
-rw-r--r--mesonbuild/modules/gnome.py23
-rw-r--r--mesonbuild/modules/i18n.py14
-rwxr-xr-xmesonbuild/scripts/meson_install.py27
-rw-r--r--test cases/common/60 install script/meson.build8
-rw-r--r--test cases/common/60 install script/myinstall.py12
-rwxr-xr-xtest cases/common/60 install script/myinstall.sh10
8 files changed, 59 insertions, 70 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 1c3f4e8..db92858 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1482,7 +1482,10 @@ class Data():
for s in self.sources:
assert(isinstance(s, File))
-class InstallScript:
- def __init__(self, cmd_arr):
- assert(isinstance(cmd_arr, list))
- self.cmd_arr = cmd_arr
+class InstallScript(dict):
+ def __init__(self, script, args):
+ super(InstallScript, self).__init__()
+ assert(isinstance(script, list))
+ assert(isinstance(args, list))
+ self['exe'] = script
+ self['args'] = args
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index b586997..5dc87cc 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1007,26 +1007,26 @@ class MesonMain(InterpreterObject):
})
def add_install_script_method(self, args, kwargs):
- if len(args) != 1:
- raise InterpreterException('Set_install_script takes exactly one argument.')
- check_stringlist(args)
+ 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]
- scriptfile = os.path.join(self.interpreter.environment.source_dir,
- self.interpreter.subdir, scriptbase)
- if not os.path.isfile(scriptfile):
- raise InterpreterException('Can not find install script %s.' % scriptbase)
- self.build.install_scripts.append(build.InstallScript([scriptfile]))
+ 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})
def add_postconf_script_method(self, args, kwargs):
if len(args) < 1:
- raise InterpreterException('Not enough arguments')
- check_stringlist(args, 'add_postconf_script arguments must be strings.')
+ 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)
- exe = dependencies.ExternalProgram(scriptbase, search_dir=search_dir)
+ script = dependencies.ExternalProgram(scriptbase, search_dir=search_dir)
extras = args[1:]
- self.build.postconf_scripts.append({'exe': exe, 'args': extras})
+ self.build.postconf_scripts.append({'exe': script, 'args': extras})
def current_source_dir_method(self, args, kwargs):
src = self.interpreter.environment.source_dir
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 7a3d51a..9b606f3 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -599,10 +599,8 @@ can not be used with the current version of glib-compiled-resources, due to
if kwargs:
raise MesonException('Unknown arguments passed: {}'.format(', '.join(kwargs.keys())))
- install_cmd = [
- sys.executable,
- state.environment.get_build_command(),
- '--internal',
+ script = [sys.executable, state.environment.get_build_command()]
+ args = ['--internal',
'yelphelper',
'install',
'--subdir=' + state.subdir,
@@ -611,12 +609,12 @@ can not be used with the current version of glib-compiled-resources, due to
'--sources=' + source_str,
]
if symlinks:
- install_cmd.append('--symlinks=true')
+ args.append('--symlinks=true')
if media:
- install_cmd.append('--media=' + '@@'.join(media))
+ args.append('--media=' + '@@'.join(media))
if langs:
- install_cmd.append('--langs=' + '@@'.join(langs))
- inscript = build.InstallScript(install_cmd)
+ args.append('--langs=' + '@@'.join(langs))
+ inscript = build.InstallScript(script, args)
potargs = [state.environment.get_build_command(), '--internal', 'yelphelper', 'pot',
'--subdir=' + state.subdir,
@@ -654,7 +652,7 @@ can not be used with the current version of glib-compiled-resources, due to
raise MesonException('You can only specify main_xml or main_sgml, not both.')
main_file = main_xml
targetname = modulename + '-doc'
- command = [state.environment.get_build_command(), '--internal', 'gtkdoc']
+ command = [sys.executable, state.environment.get_build_command()]
namespace = kwargs.get('namespace', '')
mode = kwargs.get('mode', 'auto')
@@ -677,7 +675,8 @@ can not be used with the current version of glib-compiled-resources, due to
else:
header_dirs.append(src_dir)
- args = ['--sourcedir=' + state.environment.get_source_dir(),
+ args = ['--internal', 'gtkdoc',
+ '--sourcedir=' + state.environment.get_source_dir(),
'--builddir=' + state.environment.get_build_dir(),
'--subdir=' + state.subdir,
'--headerdirs=' + '@@'.join(header_dirs),
@@ -697,9 +696,9 @@ can not be used with the current version of glib-compiled-resources, due to
args += self._unpack_args('--ignore-headers=', 'ignore_headers', kwargs)
args += self._unpack_args('--installdir=', 'install_dir', kwargs, state)
args += self._get_build_args(kwargs, state)
- res = [build.RunTarget(targetname, command[0], command[1:] + args, [], state.subdir)]
+ res = [build.RunTarget(targetname, command[0], command[1:] + sargs, [], state.subdir)]
if kwargs.get('install', True):
- res.append(build.InstallScript(command + args))
+ res.append(build.InstallScript(command, args))
return res
def _get_build_args(self, kwargs, state):
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index 29db960..eaeb0a3 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -102,14 +102,14 @@ class I18nModule:
updatepoargs.append(extra_args)
updatepotarget = build.RunTarget(packagename + '-update-po', sys.executable, updatepoargs, [], state.subdir)
- installcmd = [sys.executable, state.environment.get_build_command(),
- '--internal', 'gettext', 'install',
- '--subdir=' + state.subdir,
- '--localedir=' + state.environment.coredata.get_builtin_option('localedir'),
- pkg_arg]
+ script = [sys.executable, state.environment.get_build_command()]
+ args = ['--internal', 'gettext', 'install',
+ '--subdir=' + state.subdir,
+ '--localedir=' + state.environment.coredata.get_builtin_option('localedir'),
+ pkg_arg]
if lang_arg:
- installcmd.append(lang_arg)
- iscript = build.InstallScript(installcmd)
+ args.append(lang_arg)
+ iscript = build.InstallScript(script, args)
return [pottarget, gmotarget, iscript, updatepotarget]
diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py
index 3d22022..3206a67 100755
--- a/mesonbuild/scripts/meson_install.py
+++ b/mesonbuild/scripts/meson_install.py
@@ -132,34 +132,23 @@ def install_headers(d):
def run_install_script(d):
env = {'MESON_SOURCE_ROOT' : d.source_dir,
'MESON_BUILD_ROOT' : d.build_dir,
- 'MESON_INSTALL_PREFIX' : d.prefix
+ 'MESON_INSTALL_PREFIX' : d.prefix,
+ 'MESON_INSTALL_DESTDIR_PREFIX' : d.fullprefix,
}
child_env = os.environ.copy()
child_env.update(env)
for i in d.install_scripts:
- final_command = i.cmd_arr
- script = i.cmd_arr[0]
- print('Running custom install script %s' % script)
- suffix = os.path.splitext(script)[1].lower()
- if platform.system().lower() == 'windows' and suffix != '.bat':
- with open(script, encoding='latin_1', errors='ignore') as f:
- first_line = f.readline().strip()
- if first_line.startswith('#!'):
- if shutil.which(first_line[2:]):
- commands = [first_line[2:]]
- else:
- commands = first_line[2:].split('#')[0].strip().split()
- commands[0] = shutil.which(commands[0].split('/')[-1])
- if commands[0] is None:
- raise RuntimeError("Don't know how to run script %s." % script)
- final_command = commands + [script] + i.cmd_arr[1:]
+ script = i['exe']
+ args = i['args']
+ name = ' '.join(script + args)
+ print('Running custom install script {!r}'.format(name))
try:
- rc = subprocess.call(final_command, env=child_env)
+ rc = subprocess.call(script + args, env=child_env)
if rc != 0:
sys.exit(rc)
except:
- print('Failed to run install script:', *i.cmd_arr)
+ print('Failed to run install script {!r}'.format(name))
sys.exit(1)
def is_elf_platform():
diff --git a/test cases/common/60 install script/meson.build b/test cases/common/60 install script/meson.build
index 6cab840..7cbde8d 100644
--- a/test cases/common/60 install script/meson.build
+++ b/test cases/common/60 install script/meson.build
@@ -1,8 +1,4 @@
project('custom install script', 'c')
-if meson.get_compiler('c').get_id() == 'msvc'
- install_data('no-installed-files', install_dir : '')
-else
- meson.add_install_script('myinstall.sh')
- executable('prog', 'prog.c', install : true)
-endif
+executable('prog', 'prog.c', install : true)
+meson.add_install_script('myinstall.py', 'diiba/daaba', 'file.dat')
diff --git a/test cases/common/60 install script/myinstall.py b/test cases/common/60 install script/myinstall.py
new file mode 100644
index 0000000..969aba5
--- /dev/null
+++ b/test cases/common/60 install script/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]), 'w') as f:
+ f.write('')
diff --git a/test cases/common/60 install script/myinstall.sh b/test cases/common/60 install script/myinstall.sh
deleted file mode 100755
index 79512c9..0000000
--- a/test cases/common/60 install script/myinstall.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-set -eu
-
-echo Starting custom installation step
-
-mkdir -p "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba"
-touch "${DESTDIR}${MESON_INSTALL_PREFIX}/diiba/daaba/file.dat"
-
-echo Finished custom install step