mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -6,6 +6,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
try:
|
try:
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -572,6 +573,8 @@ class ExecutionContext(object):
|
|||||||
# We can only insert the line directive at a line break
|
# We can only insert the line directive at a line break
|
||||||
if len(self.result_text) == 0 \
|
if len(self.result_text) == 0 \
|
||||||
or self.result_text[-1].endswith('\n'):
|
or self.result_text[-1].endswith('\n'):
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
file = file.replace('\\', '/')
|
||||||
substitutions = {'file': file, 'line': line + 1}
|
substitutions = {'file': file, 'line': line + 1}
|
||||||
format_str = self.line_directive + '\n'
|
format_str = self.line_directive + '\n'
|
||||||
self.result_text.append(format_str % substitutions)
|
self.result_text.append(format_str % substitutions)
|
||||||
|
|||||||
Reference in New Issue
Block a user