Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: Source/bindings/scripts/utilities.py

Issue 429853002: IDL: Add build target for IDL dictionary impl generation in core (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/scripts/scripts.gypi ('k') | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/utilities.py
diff --git a/Source/bindings/scripts/utilities.py b/Source/bindings/scripts/utilities.py
index 367476598a1b8e0b115f749d41ce258941e91d78..5dc5e7c6fb6e1eab76f31eb6b1377dde48250ad7 100644
--- a/Source/bindings/scripts/utilities.py
+++ b/Source/bindings/scripts/utilities.py
@@ -11,6 +11,7 @@ import os
import cPickle as pickle
import re
import string
+import subprocess
class IdlBadFilenameError(Exception):
@@ -38,6 +39,34 @@ def read_file_to_list(filename):
return [line.rstrip('\n') for line in f]
+def resolve_cygpath(cygdrive_names):
+ if not cygdrive_names:
+ return []
+ cmd = ['cygpath', '-f', '-', '-wa']
+ process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ idl_file_names = []
+ for file_name in cygdrive_names:
+ process.stdin.write('%s\n' % file_name)
+ process.stdin.flush()
+ idl_file_names.append(process.stdout.readline().rstrip())
+ process.stdin.close()
+ process.wait()
+ return idl_file_names
+
+
+def read_idl_files_list_from_file(filename):
+ """Similar to read_file_to_list, but also resolves cygpath."""
+ with open(filename) as input_file:
+ file_names = sorted([os.path.realpath(line.rstrip('\n'))
+ for line in input_file])
+ idl_file_names = [file_name for file_name in file_names
+ if not file_name.startswith('/cygdrive')]
+ cygdrive_names = [file_name for file_name in file_names
+ if file_name.startswith('/cygdrive')]
+ idl_file_names.extend(resolve_cygpath(cygdrive_names))
+ return idl_file_names
+
+
def read_pickle_files(pickle_filenames):
for pickle_filename in pickle_filenames:
with open(pickle_filename) as pickle_file:
@@ -49,6 +78,9 @@ def write_file(new_text, destination_filename, only_if_changed):
with open(destination_filename) as destination_file:
if destination_file.read() == new_text:
return
+ destination_dirname = os.path.dirname(destination_filename)
+ if not os.path.exists(destination_dirname):
+ os.makedirs(destination_dirname)
with open(destination_filename, 'w') as destination_file:
destination_file.write(new_text)
« no previous file with comments | « Source/bindings/scripts/scripts.gypi ('k') | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698