Skip to content

Commit d57b41e

Browse files
committed
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.
1 parent 2e77e6a commit d57b41e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

utils/gyb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import os
88
import re
9+
import sys
910
try:
1011
from cStringIO import StringIO
1112
except ImportError:
@@ -572,6 +573,8 @@ def append_text(self, text, file, line):
572573
# We can only insert the line directive at a line break
573574
if len(self.result_text) == 0 \
574575
or self.result_text[-1].endswith('\n'):
576+
if sys.platform == 'win32':
577+
file = file.replace('\\', '/')
575578
substitutions = {'file': file, 'line': line + 1}
576579
format_str = self.line_directive + '\n'
577580
self.result_text.append(format_str % substitutions)

0 commit comments

Comments
 (0)