gyb: alter windows path for filename substitutions

When building on Windows, the filepath contains `\` as the path
separator.  Substitute `/` for the path separator prior to replacement.
This allows clang to properly compile the source file.  Windows supports
both as a path separator and this matches what clang does by default for
the filepaths when preprocessing.  This allows gyb generated files to
build on Windows.
This commit is contained in:
Saleem Abdulrasool
2018-02-28 22:48:08 -08:00
parent 2e77e6a8b1
commit d57b41e717

View File

@@ -6,6 +6,7 @@ from __future__ import print_function
import os
import re
import sys
try:
from cStringIO import StringIO
except ImportError:
@@ -572,6 +573,8 @@ class ExecutionContext(object):
# We can only insert the line directive at a line break
if len(self.result_text) == 0 \
or self.result_text[-1].endswith('\n'):
if sys.platform == 'win32':
file = file.replace('\\', '/')
substitutions = {'file': file, 'line': line + 1}
format_str = self.line_directive + '\n'
self.result_text.append(format_str % substitutions)