From 86c401e7b0e2ca6dfb28d857f756e1007117636d Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 6 Nov 2015 19:53:01 +0200 Subject: [PATCH] Use absolute paths on msvc projecte because their cwd varies. The correct solution would be to build target relative paths but I do not have suffient interest to spend the time. --- backends.py | 19 +++++++++++++------ vs2010backend.py | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/backends.py b/backends.py index 92a17fdc2..300f05d76 100644 --- a/backends.py +++ b/backends.py @@ -351,14 +351,20 @@ class Backend(): deps.append(os.path.join(self.build_to_src, sp, 'meson_options.txt')) return deps - def eval_custom_target_command(self, target): + def eval_custom_target_command(self, target, absolute_paths=False): ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output] srcs = [] + outdir = self.get_target_dir(target) + if absolute_paths: + outdir = os.path.join(self.environment.get_build_dir(), outdir) for i in target.sources: if isinstance(i, str): - srcs.append(os.path.join(self.build_to_src, target.subdir, i)) + fname = os.path.join(self.build_to_src, target.subdir, i) else: - srcs.append(i.rel_to_builddir(self.build_to_src)) + fname = i.rel_to_builddir(self.build_to_src) + if absolute_paths: + fname = os.path.join(self.environment.get_build_dir(), fname) + srcs.append(fname) cmd = [] for i in target.command: if isinstance(i, build.CustomTarget): @@ -376,17 +382,18 @@ class Backend(): cmd += ofilenames else: if '@OUTDIR@' in i: - i = i.replace('@OUTDIR@', self.get_target_dir(target)) + i = i.replace('@OUTDIR@', outdir) elif '@PRIVATE_OUTDIR_' in i: match = re.search('@PRIVATE_OUTDIR_(ABS_)?([-a-zA-Z0-9.@:]*)@', i) source = match.group(0) - if match.group(1) is None: + if match.group(1) is None and not absolute_paths: lead_dir = '' else: lead_dir = self.environment.get_build_dir() target_id = match.group(2) i = i.replace(source, os.path.join(lead_dir, - self.get_target_dir(self.build.targets[target_id]))) + self.get_target_private_dir(self.build.targets[target_id]))) cmd.append(i) + cmd = [i.replace('\\', '/') for i in cmd] return (srcs, ofilenames, cmd) diff --git a/vs2010backend.py b/vs2010backend.py index c431a59a6..199193b5f 100644 --- a/vs2010backend.py +++ b/vs2010backend.py @@ -245,7 +245,7 @@ class Vs2010Backend(backends.Backend): tname.text = target.name action = ET.SubElement(root, 'ItemDefinitionGroup') customstep = ET.SubElement(action, 'CustomBuildStep') - (srcs, ofilenames, cmd) = self.eval_custom_target_command(target) + (srcs, ofilenames, cmd) = self.eval_custom_target_command(target, True) cmd_templ = '''"%s" '''*len(cmd) ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd) ET.SubElement(customstep, 'Outputs').text = ';'.join([os.path.join(self.environment.get_build_dir(), i)\