gnome.mkenums: Use absolute paths for all commandline args

Closes #973

test cases/vala/8 generated sources/ tests this.
pull/1194/head
Nirbheek Chauhan 8 years ago
parent de0ce7f25c
commit d5f7ba862b
  1. 19
      mesonbuild/backend/backends.py
  2. 3
      mesonbuild/backend/vs2010backend.py
  3. 4
      mesonbuild/build.py
  4. 5
      mesonbuild/modules/gnome.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()

@ -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)

@ -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:

@ -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:

Loading…
Cancel
Save