gnome.mkenums: Use absolute paths for all commandline args

Closes #973

test cases/vala/8 generated sources/ tests this.
This commit is contained in:
Nirbheek Chauhan 2016-12-15 13:35:46 +05:30
parent de0ce7f25c
commit d5f7ba862b
4 changed files with 19 additions and 12 deletions

View File

@ -504,7 +504,7 @@ class Backend():
libs.append(os.path.join(self.get_target_dir(t), f)) libs.append(os.path.join(self.get_target_dir(t), f))
return libs 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, Custom target sources can be of various object types; strings, File,
BuildTarget, even other CustomTargets. 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()] fname = [os.path.join(self.get_target_private_dir(target), p) for p in i.get_outputs()]
else: else:
fname = [i.rel_to_builddir(self.build_to_src)] 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] fname = [os.path.join(self.environment.get_build_dir(), f) for f in fname]
srcs += fname srcs += fname
return srcs return srcs
def eval_custom_target_command(self, target, absolute_paths=False): def eval_custom_target_command(self, target, absolute_outputs=False):
if not absolute_paths: # 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] ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output]
else: else:
ofilenames = [os.path.join(self.environment.get_build_dir(), self.get_target_dir(target), i) \ ofilenames = [os.path.join(self.environment.get_build_dir(), self.get_target_dir(target), i) \
for i in target.output] 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) outdir = self.get_target_dir(target)
# Many external programs fail on empty arguments. # Many external programs fail on empty arguments.
if outdir == '': if outdir == '':
outdir = '.' outdir = '.'
if absolute_paths: if target.absolute_paths:
outdir = os.path.join(self.environment.get_build_dir(), outdir) outdir = os.path.join(self.environment.get_build_dir(), outdir)
cmd = [] cmd = []
for i in target.command: for i in target.command:
@ -554,9 +555,9 @@ class Backend():
i = os.path.join(self.get_target_dir(i), tmp) i = os.path.join(self.get_target_dir(i), tmp)
elif isinstance(i, mesonlib.File): elif isinstance(i, mesonlib.File):
i = i.rel_to_builddir(self.build_to_src) 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) 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): elif not isinstance(i, str):
err_msg = 'Argument {0} is of unknown type {1}' err_msg = 'Argument {0} is of unknown type {1}'
raise RuntimeError(err_msg.format(str(i), str(type(i)))) raise RuntimeError(err_msg.format(str(i), str(type(i))))
@ -602,7 +603,7 @@ class Backend():
''.format(target.name, i) ''.format(target.name, i)
raise MesonException(msg) raise MesonException(msg)
source = match.group(0) 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 = '' lead_dir = ''
else: else:
lead_dir = self.environment.get_build_dir() lead_dir = self.environment.get_build_dir()

View File

@ -392,6 +392,9 @@ class Vs2010Backend(backends.Backend):
root = self.create_basic_crap(target) root = self.create_basic_crap(target)
action = ET.SubElement(root, 'ItemDefinitionGroup') action = ET.SubElement(root, 'ItemDefinitionGroup')
customstep = ET.SubElement(action, 'CustomBuildStep') 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) (srcs, ofilenames, cmd) = self.eval_custom_target_command(target, True)
cmd_templ = '''"%s" '''*len(cmd) cmd_templ = '''"%s" '''*len(cmd)
ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd) ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd)

View File

@ -1218,7 +1218,7 @@ class CustomTarget:
'depfile' : True, 'depfile' : True,
} }
def __init__(self, name, subdir, kwargs): def __init__(self, name, subdir, kwargs, absolute_paths=False):
self.name = name self.name = name
self.subdir = subdir self.subdir = subdir
self.dependencies = [] self.dependencies = []
@ -1227,6 +1227,8 @@ class CustomTarget:
self.depfile = None self.depfile = None
self.process_kwargs(kwargs) self.process_kwargs(kwargs)
self.extra_files = [] self.extra_files = []
# Whether to use absolute paths for all files on the commandline
self.absolute_paths = absolute_paths
unknowns = [] unknowns = []
for k in kwargs: for k in kwargs:
if k not in CustomTarget.known_kwargs: if k not in CustomTarget.known_kwargs:

View File

@ -799,7 +799,7 @@ can not be used with the current version of glib-compiled-resources, due to
install_header = False install_header = False
for arg, value in kwargs.items(): for arg, value in kwargs.items():
if arg == 'sources': if arg == 'sources':
sources = [value] + sources raise AssertionError("sources should've already been handled")
elif arg == 'c_template': elif arg == 'c_template':
c_template = value c_template = value
if 'template' in kwargs: if 'template' in kwargs:
@ -883,7 +883,8 @@ can not be used with the current version of glib-compiled-resources, due to
'command': cmd 'command': cmd
} }
custom_kwargs.update(kwargs) 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): def genmarshal(self, state, args, kwargs):
if len(args) != 1: if len(args) != 1: