diff options
-rwxr-xr-x | backends.py | 14 | ||||
-rwxr-xr-x | environment.py | 19 | ||||
-rw-r--r-- | test cases/common/13 pch/prog.c | 5 |
3 files changed, 25 insertions, 13 deletions
diff --git a/backends.py b/backends.py index 1f4c1dd..5adca9c 100755 --- a/backends.py +++ b/backends.py @@ -182,8 +182,8 @@ class Backend(): if len(p) == 0: continue if compiler.can_compile(p[-1]): - args.append('-include') - args.append(os.path.split(p[0])[-1]) + header = p[0] + args += compiler.get_pch_use_args(pchpath, header) if len(args) > 0: args = [includearg] + args return args @@ -633,10 +633,8 @@ class NinjaBackend(Backend): pch_dep = [] else: arr = [] - for pch in pchlist: - i = os.path.join(self.get_target_private_dir(target), - os.path.split(pch)[-1] + '.' + compiler.get_pch_suffix()) - arr.append(i) + i = os.path.join(self.get_target_private_dir(target), compiler.get_pch_name(pchlist[0])) + arr.append(i) pch_dep = arr for i in target.get_include_dirs(): basedir = i.get_curdir() @@ -666,9 +664,7 @@ class NinjaBackend(Backend): raise RuntimeError('MSVC requires one header and one source to produce precompiled headers.') header = pch[0] source = pch[1] - chopped = os.path.split(header)[-1].split('.')[:-1] - chopped.append(compiler.get_pch_suffix()) - pchname = '.'.join(chopped) + pchname = compiler.get_pch_name(header) dst = os.path.join(self.get_target_private_dir(target), pchname) commands = [] diff --git a/environment.py b/environment.py index 9274651..376ebfa 100755 --- a/environment.py +++ b/environment.py @@ -93,7 +93,13 @@ class CCompiler(): def name_string(self): return ' '.join(self.exelist) - + + def get_pch_use_args(self, pch_dir, header): + return ['-include', os.path.split(header)[-1]] + + def get_pch_name(self, header_name): + return os.path.split(header_name)[-1] + '.' + self.get_pch_suffix() + def sanity_check(self, work_dir): source_name = os.path.join(work_dir, 'sanitycheckc.c') binary_name = os.path.join(work_dir, 'sanitycheckc') @@ -251,6 +257,17 @@ class VisualStudioCCompiler(CCompiler): def get_pch_suffix(self): return 'pch' + + def get_pch_name(self, header): + chopped = os.path.split(header)[-1].split('.')[:-1] + chopped.append(self.get_pch_suffix()) + pchname = '.'.join(chopped) + return pchname + + def get_pch_use_args(self, pch_dir, header): + base = os.path.split(header)[-1] + pchname = self.get_pch_name(header) + return ['/FI' + base, '/Yu' + base, '/Fp' + os.path.join(pch_dir, pchname)] def get_debug_flags(self): return ['/D_DEBUG', '/Zi', '/MDd', '/Ob0', '/RTC1'] diff --git a/test cases/common/13 pch/prog.c b/test cases/common/13 pch/prog.c index 23125f5..0ce3d0a 100644 --- a/test cases/common/13 pch/prog.c +++ b/test cases/common/13 pch/prog.c @@ -1,6 +1,4 @@ -#if defined(_MSC_VER) -#include"prog.pch" -#endif +// No includes here, they need to come from the PCH void func() { fprintf(stdout, "This is a function that fails if stdio is not #included.\n"); @@ -9,3 +7,4 @@ void func() { int main(int argc, char **argv) { return 0; } + |