aboutsummaryrefslogtreecommitdiff
path: root/ninjabackend.py
diff options
context:
space:
mode:
Diffstat (limited to 'ninjabackend.py')
-rw-r--r--ninjabackend.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/ninjabackend.py b/ninjabackend.py
index d8b9e8f..74892f0 100644
--- a/ninjabackend.py
+++ b/ninjabackend.py
@@ -22,7 +22,7 @@ from meson_install import InstallData
from build import InvalidArguments
from coredata import MesonException
import os, sys, pickle, re
-import subprocess
+import subprocess, shutil
if mesonlib.is_windows():
quote_char = '"'
@@ -130,6 +130,33 @@ class NinjaBackend(backends.Backend):
raise MesonException('Multiple producers for Ninja target "%s". Please rename your targets.' % n)
self.all_outputs[n] = True
+ def detect_vs_dep_prefix(self, outfile, tempfilename):
+ '''VS writes its dependency in a locale dependent format.
+ Detect the search prefix to use.'''
+ if shutil.which('cl') is None:
+ return outfile
+ outfile.close()
+ open(os.path.join(self.environment.get_scratch_dir(), 'incdetect.c'),
+ 'w').write('''#include<stdio.h>
+int dummy;
+''')
+
+ pc = subprocess.Popen(['cl', '/showIncludes', '/c', 'incdetect.c'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ cwd=self.environment.get_scratch_dir())
+
+ (stdo, _) = pc.communicate()
+
+ for line in stdo.split(b'\r\n'):
+ if line.endswith(b'stdio.h'):
+ matchstr = b':'.join(line.split(b':')[0:2]) + b':'
+ binfile = open(tempfilename, 'ab')
+ binfile.write(b'msvc_deps_prefix = ' + matchstr + b'\r\n')
+ binfile.close()
+ return open(tempfilename, 'a')
+ raise MesonException('Could not determine vs dep dependency prefix string.')
+
def generate(self, interp):
self.interpreter = interp
outfilename = os.path.join(self.environment.get_build_dir(), self.ninja_filename)
@@ -140,6 +167,7 @@ class NinjaBackend(backends.Backend):
outfile.write('# It is autogenerated by the Meson build system.\n')
outfile.write('# Do not edit by hand.\n\n')
outfile.write('ninja_required_version = 1.5.1\n\n')
+ outfile = self.detect_vs_dep_prefix(outfile, tempfilename)
self.generate_rules(outfile)
self.generate_phony(outfile)
outfile.write('# Build rules for targets\n\n')