aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-12-15 13:35:46 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-12-15 14:58:43 +0530
commitd5f7ba862bb37ad75b68e007b8b55f40b6f6fd19 (patch)
tree67f17d6ba20b1cdbbc3499c4f74f60a2c51aba4e
parentde0ce7f25c1bc1038fdca66237281722eca64494 (diff)
downloadmeson-d5f7ba862bb37ad75b68e007b8b55f40b6f6fd19.zip
meson-d5f7ba862bb37ad75b68e007b8b55f40b6f6fd19.tar.gz
meson-d5f7ba862bb37ad75b68e007b8b55f40b6f6fd19.tar.bz2
gnome.mkenums: Use absolute paths for all commandline args
Closes #973 test cases/vala/8 generated sources/ tests this.
-rw-r--r--mesonbuild/backend/backends.py19
-rw-r--r--mesonbuild/backend/vs2010backend.py3
-rw-r--r--mesonbuild/build.py4
-rw-r--r--mesonbuild/modules/gnome.py5
4 files changed, 19 insertions, 12 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index a489d04..e8d6beb 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -504,7 +504,7 @@ class Backend():
libs.append(os.path.join(self.get_target_dir(t), f))
return libs
- def get_custom_target_sources(self, target, absolute_paths=False):
+ def get_custom_target_sources(self, target):
'''
Custom target sources can be of various object types; strings, File,
BuildTarget, even other CustomTargets.
@@ -524,23 +524,24 @@ class Backend():
fname = [os.path.join(self.get_target_private_dir(target), p) for p in i.get_outputs()]
else:
fname = [i.rel_to_builddir(self.build_to_src)]
- if absolute_paths:
+ if target.absolute_paths:
fname = [os.path.join(self.environment.get_build_dir(), f) for f in fname]
srcs += fname
return srcs
- def eval_custom_target_command(self, target, absolute_paths=False):
- if not absolute_paths:
+ def eval_custom_target_command(self, target, absolute_outputs=False):
+ # We only want the outputs to be absolute when using the VS backend
+ if not absolute_outputs:
ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output]
else:
ofilenames = [os.path.join(self.environment.get_build_dir(), self.get_target_dir(target), i) \
for i in target.output]
- srcs = self.get_custom_target_sources(target, absolute_paths)
+ srcs = self.get_custom_target_sources(target)
outdir = self.get_target_dir(target)
# Many external programs fail on empty arguments.
if outdir == '':
outdir = '.'
- if absolute_paths:
+ if target.absolute_paths:
outdir = os.path.join(self.environment.get_build_dir(), outdir)
cmd = []
for i in target.command:
@@ -554,9 +555,9 @@ class Backend():
i = os.path.join(self.get_target_dir(i), tmp)
elif isinstance(i, mesonlib.File):
i = i.rel_to_builddir(self.build_to_src)
- if absolute_paths:
+ if target.absolute_paths:
i = os.path.join(self.environment.get_build_dir(), i)
- # FIXME: str types are blindly added and ignore the 'absolute_paths' argument
+ # FIXME: str types are blindly added ignoring 'target.absolute_paths'
elif not isinstance(i, str):
err_msg = 'Argument {0} is of unknown type {1}'
raise RuntimeError(err_msg.format(str(i), str(type(i))))
@@ -602,7 +603,7 @@ class Backend():
''.format(target.name, i)
raise MesonException(msg)
source = match.group(0)
- if match.group(1) is None and not absolute_paths:
+ if match.group(1) is None and not target.absolute_paths:
lead_dir = ''
else:
lead_dir = self.environment.get_build_dir()
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index d043455..f3e9b4f 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -392,6 +392,9 @@ class Vs2010Backend(backends.Backend):
root = self.create_basic_crap(target)
action = ET.SubElement(root, 'ItemDefinitionGroup')
customstep = ET.SubElement(action, 'CustomBuildStep')
+ # We need to always use absolute paths because our invocation is always
+ # from the target dir, not the build root.
+ target.absolute_paths = True
(srcs, ofilenames, cmd) = self.eval_custom_target_command(target, True)
cmd_templ = '''"%s" '''*len(cmd)
ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd)
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 106386c..1c3f4e8 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1218,7 +1218,7 @@ class CustomTarget:
'depfile' : True,
}
- def __init__(self, name, subdir, kwargs):
+ def __init__(self, name, subdir, kwargs, absolute_paths=False):
self.name = name
self.subdir = subdir
self.dependencies = []
@@ -1227,6 +1227,8 @@ class CustomTarget:
self.depfile = None
self.process_kwargs(kwargs)
self.extra_files = []
+ # Whether to use absolute paths for all files on the commandline
+ self.absolute_paths = absolute_paths
unknowns = []
for k in kwargs:
if k not in CustomTarget.known_kwargs:
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: