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.

pull/278/head
Jussi Pakkanen 9 years ago
parent e8cca681ca
commit 86c401e7b0
  1. 19
      backends.py
  2. 2
      vs2010backend.py

@ -351,14 +351,20 @@ class Backend():
deps.append(os.path.join(self.build_to_src, sp, 'meson_options.txt')) deps.append(os.path.join(self.build_to_src, sp, 'meson_options.txt'))
return deps 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] ofilenames = [os.path.join(self.get_target_dir(target), i) for i in target.output]
srcs = [] 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: for i in target.sources:
if isinstance(i, str): 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: 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 = [] cmd = []
for i in target.command: for i in target.command:
if isinstance(i, build.CustomTarget): if isinstance(i, build.CustomTarget):
@ -376,17 +382,18 @@ class Backend():
cmd += ofilenames cmd += ofilenames
else: else:
if '@OUTDIR@' in i: if '@OUTDIR@' in i:
i = i.replace('@OUTDIR@', self.get_target_dir(target)) i = i.replace('@OUTDIR@', outdir)
elif '@PRIVATE_OUTDIR_' in i: elif '@PRIVATE_OUTDIR_' in i:
match = re.search('@PRIVATE_OUTDIR_(ABS_)?([-a-zA-Z0-9.@:]*)@', i) match = re.search('@PRIVATE_OUTDIR_(ABS_)?([-a-zA-Z0-9.@:]*)@', i)
source = match.group(0) source = match.group(0)
if match.group(1) is None: if match.group(1) is None and not absolute_paths:
lead_dir = '' lead_dir = ''
else: else:
lead_dir = self.environment.get_build_dir() lead_dir = self.environment.get_build_dir()
target_id = match.group(2) target_id = match.group(2)
i = i.replace(source, i = i.replace(source,
os.path.join(lead_dir, 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.append(i)
cmd = [i.replace('\\', '/') for i in cmd]
return (srcs, ofilenames, cmd) return (srcs, ofilenames, cmd)

@ -245,7 +245,7 @@ class Vs2010Backend(backends.Backend):
tname.text = target.name tname.text = target.name
action = ET.SubElement(root, 'ItemDefinitionGroup') action = ET.SubElement(root, 'ItemDefinitionGroup')
customstep = ET.SubElement(action, 'CustomBuildStep') 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) cmd_templ = '''"%s" '''*len(cmd)
ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(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)\ ET.SubElement(customstep, 'Outputs').text = ';'.join([os.path.join(self.environment.get_build_dir(), i)\

Loading…
Cancel
Save