Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
scripts.idlsync Namespace Reference

Functions

 isDryRun ()
 
 isVerbose ()
 
 chromiumDirectory ()
 
 RunCommand (cmd, valid_exits=[0])
 
 anyDartFixMe (filepath)
 
 subpath (path, base_dir)
 
 copy_files (source_dir, src_prefix, destination_dir)
 
 remove_obsolete_webcore_files (webcore_dir, webkit_dir, subdir)
 
 ParseOptions ()
 
 GetDepsFromGit ()
 
 ValidateGitRemotes ()
 
 getChromiumSHA ()
 
 getCurrentDartSHA ()
 
 GetDEPSWebCoreGitRevision (deps, component)
 
 copy_subdir (src, src_prefix, dest, subdir)
 
 main ()
 

Variables

str DEPS_GIT = "https://raw.githubusercontent.com/dart-lang/sdk/master/DEPS"
 
str CHROME_TRUNK = "https://chromium.googlesource.com"
 
str WEBKIT_SHA_PATTERN = r'"WebCore_rev": "(\S+)",'
 
str GIT_REMOTES_CHROMIUM = 'https://chromium.googlesource.com/chromium/src.git'
 
str SOURCE_FILE_DIR = 'tools/dom/scripts'
 
str WEBKIT_SOURCE = 'src/third_party/WebKit/Source'
 
str WEBCORE_SOURCE = 'third_party/WebCore'
 
str WEBKIT_BLINK_SOURCE = 'src/third_party/blink'
 
str WEBCORE_BLINK_SOURCE = 'third_party/WebCore/blink'
 
str IDL_EXTENDED_ATTRIBUTES_FILE = 'IDLExtendedAttributes.txt'
 
str DART_SDK_GENERATOR_SCRIPTS = 'bindings/dart/scripts'
 
str PYTHON_INITS = '__init__.py'
 
list SUBDIRS
 
str IDL_EXT = '.idl'
 
str PY_EXT = '.py'
 
str LICENSE_FILE_PREFIX = 'LICENSE'
 
str DART_CHANGES = ' FIXMEDART: '
 
 options = None
 
list warning_messages = []
 

Function Documentation

◆ anyDartFixMe()

scripts.idlsync.anyDartFixMe (   filepath)

Definition at line 132 of file idlsync.py.

132def anyDartFixMe(filepath):
133 if os.path.exists(filepath):
134 data = open(filepath, 'r').read()
135 return data.find(DART_CHANGES) != -1
136 else:
137 return False
138
139
140# Give a base_dir compute the trailing directory after base_dir
141# returns the subpath from base_dir for the path passed in.
static bool read(SkStream *stream, void *buffer, size_t amount)

◆ chromiumDirectory()

scripts.idlsync.chromiumDirectory ( )

Definition at line 110 of file idlsync.py.

110def chromiumDirectory():
111 global options
112 if options['chromium_dir'] is not None:
113 return os.path.expanduser(options['chromium_dir'])
114 return os.cwd()
115
116

◆ copy_files()

scripts.idlsync.copy_files (   source_dir,
  src_prefix,
  destination_dir 
)

Definition at line 157 of file idlsync.py.

157def copy_files(source_dir, src_prefix, destination_dir):
158 original_cwd = os.getcwd()
159 try:
160 os.makedirs(destination_dir)
161 except OSError as e:
162 if e.errno != errno.EEXIST:
163 raise
164 os.chdir(destination_dir)
165
166 idls = 0 # *.idl files copied
167 pys = 0 # *.py files copied
168 others = 0 # all other files copied
169
170 for (root, _, files) in os.walk(source_dir, topdown=False):
171 dir_portion = subpath(root, source_dir)
172 for f in files:
173 # Never automatically add any Dart generator scripts (these are the original
174 # sources in WebCore) from WebKit to WebCore.
175 if dir_portion != DART_SDK_GENERATOR_SCRIPTS:
176 if (f.endswith(IDL_EXT) or f == IDL_EXTENDED_ATTRIBUTES_FILE or
177 f.endswith(PY_EXT) or
178 f.startswith(LICENSE_FILE_PREFIX)):
179 if f.endswith(IDL_EXT):
180 idls += 1
181 elif f.endswith(PY_EXT):
182 pys += 1
183 else:
184 others += 1
185 src_file = os.path.join(root, f)
186
187 # Compute the destination path using sdk/third_party/WebCore
188 subdir_root = src_file[src_file.rfind(src_prefix) +
189 len(src_prefix):]
190 if subdir_root.startswith(os.path.sep):
191 subdir_root = subdir_root[1:]
192 dst_file = os.path.join(destination_dir, subdir_root)
193
194 # Need to make src/third_party/WebKit/Source/* to sdk/third_party/WebCore/*
195
196 destination = os.path.dirname(dst_file)
197 if not os.path.exists(destination):
198 os.makedirs(destination)
199
200 has_Dart_fix_me = anyDartFixMe(dst_file)
201
202 if not isDryRun():
203 copyfile(src_file, dst_file)
204 if isVerbose():
205 #print('...copying %s' % os.path.split(dst_file)[1])
206 print('...copying %s' % dst_file)
207 if f == IDL_EXTENDED_ATTRIBUTES_FILE:
208 warning_messages.append(dst_file)
209 else:
210 if has_Dart_fix_me:
211 warning_messages.append(dst_file)
212 if not (isDryRun() or has_Dart_fix_me):
213 # git add the file
214 RunCommand(['git', 'add', dst_file])
215
216 os.chdir(original_cwd)
217
218 return [idls, pys, others]
219
220
221# Remove any file in webcore_dir that no longer exist in the webkit_dir
222# webcore_dir src/dart/third_party/WebCore location
223# webkit_dir src/third_party/WebKit/Source location (blink)
224# only check if the subdir off from webcore_dir
225# return list of files deleted
void print(void *str)
Definition bridge.cpp:126

◆ copy_subdir()

scripts.idlsync.copy_subdir (   src,
  src_prefix,
  dest,
  subdir 
)

Definition at line 356 of file idlsync.py.

356def copy_subdir(src, src_prefix, dest, subdir):
357 idls_deleted = remove_obsolete_webcore_files(dest, src, subdir)
358 print("%s files removed in WebCore %s" % (idls_deleted.__len__(), subdir))
359 if isVerbose():
360 for delete_file in idls_deleted:
361 print(" %s" % delete_file)
362
363 idls_copied, py_copied, other_copied = copy_files(
364 os.path.join(src, subdir), src_prefix, dest)
365 if idls_copied > 0:
366 print("Copied %s IDLs to %s" % (idls_copied, subdir))
367 if py_copied > 0:
368 print("Copied %s PYs to %s" % (py_copied, subdir))
369 if other_copied > 0:
370 print("Copied %s other to %s\n" % (other_copied, subdir))
371
372

◆ getChromiumSHA()

scripts.idlsync.getChromiumSHA ( )

Definition at line 306 of file idlsync.py.

306def getChromiumSHA():
307 cwd = os.getcwd()
308 chromiumDir = chromiumDirectory()
309
310 webkit_dir = os.path.join(chromiumDir, WEBKIT_SOURCE)
311 os.chdir(webkit_dir)
312
313 if ValidateGitRemotes():
314 chromium_sha = RunCommand(['git', 'log', '--format=format:%H', '-1'])
315 else:
316 chromium_sha = -1
317
318 os.chdir(cwd)
319 return chromium_sha
320
321

◆ getCurrentDartSHA()

scripts.idlsync.getCurrentDartSHA ( )

Definition at line 322 of file idlsync.py.

322def getCurrentDartSHA():
323 cwd = os.getcwd()
324
325 if cwd.endswith('dart'):
326 # In src/dart
327 src_dir, _ = os.path.split(cwd)
328 elif cwd.endswith('sdk'):
329 src_dir = cwd
330 else:
331 src_dir = os.path.join(cwd, 'sdk')
332 os.chdir(src_dir)
333
334 if ValidateGitRemotes():
335 dart_sha = RunCommand(['git', 'log', '--format=format:%H', '-1'])
336 else:
337 dart_sha = -1
338
339 os.chdir(cwd)
340 return dart_sha
341
342
343# Returns the SHA of the Dartium/Chromium in the DEPS file.

◆ GetDepsFromGit()

scripts.idlsync.GetDepsFromGit ( )

Definition at line 289 of file idlsync.py.

289def GetDepsFromGit():
290 req = requests.get(DEPS_GIT)
291 return req.text
292
293

◆ GetDEPSWebCoreGitRevision()

scripts.idlsync.GetDEPSWebCoreGitRevision (   deps,
  component 
)
Returns a tuple with the (dartium chromium repo, latest revision).

Definition at line 344 of file idlsync.py.

344def GetDEPSWebCoreGitRevision(deps, component):
345 """Returns a tuple with the (dartium chromium repo, latest revision)."""
346 foundIt = re.search(WEBKIT_SHA_PATTERN, deps)
347 #url_base, url_pattern = DEPS_PATTERNS[component]
348 #url = url_base + re.search(url_pattern, deps).group(1)
349 # Get the SHA for the Chromium/WebKit changes for Dartium.
350 #revision = url[len(url_base):]
351 revision = foundIt.group(1)[1:]
352 print('%s' % revision)
353 return revision
354
355

◆ isDryRun()

scripts.idlsync.isDryRun ( )

Definition at line 97 of file idlsync.py.

97def isDryRun():
98 global options
99 return options['dry_run'] is not None
100
101
102# Is --verbose passed in.

◆ isVerbose()

scripts.idlsync.isVerbose ( )

Definition at line 103 of file idlsync.py.

103def isVerbose():
104 global options
105 return options['verbose'] is not None
106
107
108# If --WebKit= is specified then compute the directory of the Chromium
109# source.

◆ main()

scripts.idlsync.main ( )

Definition at line 373 of file idlsync.py.

373def main():
374 global options
375 options = ParseOptions()
376
377 current_dir = os.path.dirname(os.path.abspath(__file__))
378 if not current_dir.endswith(SOURCE_FILE_DIR):
379 print('ERROR: idlsync.py not run in proper directory (%s)\n',
380 current_dir)
381
382 base_directory = current_dir[:current_dir.rfind(SOURCE_FILE_DIR)]
383
384 # Validate DEPS WebCore_rev SHA DOES NOT match the SHA of chromium master.
385 deps = GetDepsFromGit()
386 webcore_revision = GetDEPSWebCoreGitRevision(deps, 'webkit')
387 chromium_sha = getChromiumSHA()
388 if webcore_revision == chromium_sha:
389 print("ERROR: Nothing to update in WebCore, WebCore_rev SHA in DEPS "
390 "matches Chromium GIT master SHA in %s" % options['webkit_dir'])
391 return
392
393 start_time = time.time()
394
395 # Copy scripts from third_party/blink/tools to third_party/WebCore/blink/tools
396 #
397 # This also implies that the files:
398 # WebCore/bindings/scripts/code_generator_web_agent_api.py
399 # WebCore/bindings/scripts/utilities.py
400 #
401 # Need to have sys.path.append at beginning of the above files changed from:
402 #
403 # sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', '..',
404 # 'third_party', 'blink', 'tools'))
405 # to
406 #
407 # sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',
408 # 'blink', 'tools'))
409 #
410 webkit_blink_dir = os.path.join(chromiumDirectory(), WEBKIT_BLINK_SOURCE)
411 webcore_blink_dir = os.path.join(base_directory, WEBCORE_BLINK_SOURCE)
412 copy_subdir(webkit_blink_dir, WEBKIT_BLINK_SOURCE, webcore_blink_dir, "")
413
414 chromium_webkit_dir = os.path.join(chromiumDirectory(), WEBKIT_SOURCE)
415 dart_webcore_dir = os.path.join(base_directory, WEBCORE_SOURCE)
416 for subdir in SUBDIRS:
417 copy_subdir(chromium_webkit_dir, WEBKIT_SOURCE, dart_webcore_dir,
418 subdir)
419
420 end_time = time.time()
421
422 print(
423 'WARNING: File(s) contain FIXMEDART and are NOT "git add " please review:'
424 )
425 for warning in warning_messages:
426 print(' %s' % warning)
427
428 print('\nDone idlsync completed in %s seconds' %
429 round(end_time - start_time, 2))
430
431
static void round(SkPoint *p)
Definition main.py:1

◆ ParseOptions()

scripts.idlsync.ParseOptions ( )

Definition at line 255 of file idlsync.py.

255def ParseOptions():
256 parser = optparse.OptionParser()
257 parser.add_option(
258 '--chromium',
259 '-c',
260 dest='chromium_dir',
261 action='store',
262 type='string',
263 help='WebKit Chrome directory (e.g., --chromium=~/chrome63',
264 default=None)
265 parser.add_option(
266 '--verbose',
267 '-v',
268 dest='verbose',
269 action='store_true',
270 help='Dump all information',
271 default=None)
272 parser.add_option(
273 '--dry_run',
274 '-d',
275 dest='dry_run',
276 action='store_true',
277 help='Display results without adding, updating or deleting any files',
278 default=None)
279 args, _ = parser.parse_args()
280
281 argOptions = {}
282 argOptions['chromium_dir'] = args.chromium_dir
283 argOptions['verbose'] = args.verbose
284 argOptions['dry_run'] = args.dry_run
285 return argOptions
286
287
288# Fetch the DEPS file in src/dart/tools/deps/dartium.deps/DEPS from the GIT repro.

◆ remove_obsolete_webcore_files()

scripts.idlsync.remove_obsolete_webcore_files (   webcore_dir,
  webkit_dir,
  subdir 
)

Definition at line 226 of file idlsync.py.

226def remove_obsolete_webcore_files(webcore_dir, webkit_dir, subdir):
227 files_to_delete = []
228
229 original_cwd = os.getcwd()
230
231 if os.path.exists(webcore_dir):
232 os.chdir(webcore_dir)
233
234 for (root, _, files) in os.walk(
235 os.path.join(webcore_dir, subdir), topdown=False):
236 dir_portion = subpath(root, webcore_dir)
237 for f in files:
238 # Never automatically deleted any Dart generator scripts (these are the
239 # original sources in WebCore).
240 if dir_portion != DART_SDK_GENERATOR_SCRIPTS:
241 check_file = os.path.join(dir_portion, f)
242 check_file_full_path = os.path.join(webkit_dir, check_file)
243 if not os.path.exists(check_file_full_path) and \
244 not(check_file_full_path.endswith(PYTHON_INITS)):
245 if not isDryRun():
246 # Remove the file using git
247 RunCommand(['git', 'rm', check_file])
248 files_to_delete.append(check_file)
249
250 os.chdir(original_cwd)
251
252 return files_to_delete
253
254

◆ RunCommand()

scripts.idlsync.RunCommand (   cmd,
  valid_exits = [0] 
)
Executes a shell command and return its stdout.

Definition at line 117 of file idlsync.py.

117def RunCommand(cmd, valid_exits=[0]):
118 """Executes a shell command and return its stdout."""
119 if isVerbose():
120 print(' '.join(cmd))
121 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
122 output = pipe.communicate()
123 if pipe.returncode in valid_exits:
124 return output[0]
125 else:
126 print(output[1])
127 print('FAILED. RET_CODE=%d' % pipe.returncode)
128 sys.exit(pipe.returncode)
129
130
131# returns True if // FIXMEDART: is in the file.

◆ subpath()

scripts.idlsync.subpath (   path,
  base_dir 
)

Definition at line 142 of file idlsync.py.

142def subpath(path, base_dir):
143 dir_portion = ''
144 head = path
145 while True:
146 head, tail = os.path.split(head)
147 dir_portion = os.path.join(tail, dir_portion)
148 if head == base_dir or tail == '':
149 break
150 return dir_portion
151
152
153# Copy any file in source_dir (WebKit) to destination_dir (dart/third_party/WebCore)
154# source_dir is the src/third_party/WebKit/Source location (blink)
155# destination_dir is the src/dart/third_party/WebCore location
156# returns idls_copied, py_copied, other_copied

◆ ValidateGitRemotes()

scripts.idlsync.ValidateGitRemotes ( )

Definition at line 294 of file idlsync.py.

294def ValidateGitRemotes():
295 #origin https://chromium.googlesource.com/dart/dartium/src.git (fetch)
296 remotes_list = RunCommand(['git', 'remote', '--verbose']).split()
297 if (len(remotes_list) > 2 and remotes_list[0] == 'origin' and
298 remotes_list[1] == GIT_REMOTES_CHROMIUM):
299 return True
300
301 print('ERROR: Unable to find dart/dartium/src repository %s' %
302 GIT_REMOTES_CHROMIUM)
303 return False
304
305

Variable Documentation

◆ CHROME_TRUNK

str scripts.idlsync.CHROME_TRUNK = "https://chromium.googlesource.com"

Definition at line 46 of file idlsync.py.

◆ DART_CHANGES

str scripts.idlsync.DART_CHANGES = ' FIXMEDART: '

Definition at line 88 of file idlsync.py.

◆ DART_SDK_GENERATOR_SCRIPTS

str scripts.idlsync.DART_SDK_GENERATOR_SCRIPTS = 'bindings/dart/scripts'

Definition at line 69 of file idlsync.py.

◆ DEPS_GIT

str scripts.idlsync.DEPS_GIT = "https://raw.githubusercontent.com/dart-lang/sdk/master/DEPS"

Definition at line 45 of file idlsync.py.

◆ GIT_REMOTES_CHROMIUM

str scripts.idlsync.GIT_REMOTES_CHROMIUM = 'https://chromium.googlesource.com/chromium/src.git'

Definition at line 50 of file idlsync.py.

◆ IDL_EXT

str scripts.idlsync.IDL_EXT = '.idl'

Definition at line 82 of file idlsync.py.

◆ IDL_EXTENDED_ATTRIBUTES_FILE

str scripts.idlsync.IDL_EXTENDED_ATTRIBUTES_FILE = 'IDLExtendedAttributes.txt'

Definition at line 63 of file idlsync.py.

◆ LICENSE_FILE_PREFIX

str scripts.idlsync.LICENSE_FILE_PREFIX = 'LICENSE'

Definition at line 84 of file idlsync.py.

◆ options

scripts.idlsync.options = None

Definition at line 91 of file idlsync.py.

◆ PY_EXT

str scripts.idlsync.PY_EXT = '.py'

Definition at line 83 of file idlsync.py.

◆ PYTHON_INITS

str scripts.idlsync.PYTHON_INITS = '__init__.py'

Definition at line 73 of file idlsync.py.

◆ SOURCE_FILE_DIR

str scripts.idlsync.SOURCE_FILE_DIR = 'tools/dom/scripts'

Definition at line 53 of file idlsync.py.

◆ SUBDIRS

list scripts.idlsync.SUBDIRS
Initial value:
1= [
2 'bindings',
3 'core',
4 'modules',
5]

Definition at line 77 of file idlsync.py.

◆ warning_messages

list scripts.idlsync.warning_messages = []

Definition at line 93 of file idlsync.py.

◆ WEBCORE_BLINK_SOURCE

str scripts.idlsync.WEBCORE_BLINK_SOURCE = 'third_party/WebCore/blink'

Definition at line 59 of file idlsync.py.

◆ WEBCORE_SOURCE

str scripts.idlsync.WEBCORE_SOURCE = 'third_party/WebCore'

Definition at line 56 of file idlsync.py.

◆ WEBKIT_BLINK_SOURCE

str scripts.idlsync.WEBKIT_BLINK_SOURCE = 'src/third_party/blink'

Definition at line 58 of file idlsync.py.

◆ WEBKIT_SHA_PATTERN

str scripts.idlsync.WEBKIT_SHA_PATTERN = r'"WebCore_rev": "(\S+)",'

Definition at line 47 of file idlsync.py.

◆ WEBKIT_SOURCE

str scripts.idlsync.WEBKIT_SOURCE = 'src/third_party/WebKit/Source'

Definition at line 55 of file idlsync.py.