Commit 359564ee authored by emx's avatar emx Committed by Commit bot

Fixed some issues with boilerplate.py to make it work on Windows

It now support backslashes in file paths and uses LF as EOL (instead of CRLF) even on Windows.

BUG=none

Review-Url: https://codereview.chromium.org/2846223002
Cr-Commit-Position: refs/heads/master@{#468063}
parent 9309126a
...@@ -39,7 +39,7 @@ def _GetHeader(filename): ...@@ -39,7 +39,7 @@ def _GetHeader(filename):
def _CppHeader(filename): def _CppHeader(filename):
guard = filename.upper() + '_' guard = filename.upper() + '_'
for char in '/.+': for char in '/\\.+':
guard = guard.replace(char, '_') guard = guard.replace(char, '_')
return '\n'.join([ return '\n'.join([
'', '',
...@@ -69,8 +69,13 @@ def _IsIOSFile(filename): ...@@ -69,8 +69,13 @@ def _IsIOSFile(filename):
return False return False
def _FilePathSlashesToCpp(filename):
return filename.replace('\\', '/')
def _CppImplementation(filename): def _CppImplementation(filename):
return '\n#include "' + _RemoveTestSuffix(filename) + '.h"\n' return '\n#include "' + _FilePathSlashesToCpp(_RemoveTestSuffix(filename)) \
+ '.h"\n'
def _ObjCppImplementation(filename): def _ObjCppImplementation(filename):
...@@ -94,7 +99,7 @@ def _CreateFile(filename): ...@@ -94,7 +99,7 @@ def _CreateFile(filename):
elif filename.endswith('.mm'): elif filename.endswith('.mm'):
contents += _ObjCppImplementation(filename) contents += _ObjCppImplementation(filename)
fd = open(filename, 'w') fd = open(filename, 'wb')
fd.write(contents) fd.write(contents)
fd.close() fd.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment