42from shutil
import copyfile
45DEPS_GIT =
"https://raw.githubusercontent.com/dart-lang/sdk/master/DEPS"
46CHROME_TRUNK =
"https://chromium.googlesource.com"
47WEBKIT_SHA_PATTERN =
r'"WebCore_rev": "(\S+)",'
50GIT_REMOTES_CHROMIUM =
'https://chromium.googlesource.com/chromium/src.git'
53SOURCE_FILE_DIR =
'tools/dom/scripts'
55WEBKIT_SOURCE =
'src/third_party/WebKit/Source'
56WEBCORE_SOURCE =
'third_party/WebCore'
58WEBKIT_BLINK_SOURCE =
'src/third_party/blink'
59WEBCORE_BLINK_SOURCE =
'third_party/WebCore/blink'
63IDL_EXTENDED_ATTRIBUTES_FILE =
'IDLExtendedAttributes.txt'
69DART_SDK_GENERATOR_SCRIPTS =
'bindings/dart/scripts'
73PYTHON_INITS =
'__init__.py'
84LICENSE_FILE_PREFIX =
'LICENSE'
88DART_CHANGES =
' FIXMEDART: '
99 return options[
'dry_run']
is not None
105 return options[
'verbose']
is not None
112 if options[
'chromium_dir']
is not None:
113 return os.path.expanduser(options[
'chromium_dir'])
118 """Executes a shell command and return its stdout."""
121 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
122 output = pipe.communicate()
123 if pipe.returncode
in valid_exits:
127 print(
'FAILED. RET_CODE=%d' % pipe.returncode)
128 sys.exit(pipe.returncode)
133 if os.path.exists(filepath):
134 data = open(filepath,
'r').
read()
135 return data.find(DART_CHANGES) != -1
146 head, tail = os.path.split(head)
147 dir_portion = os.path.join(tail, dir_portion)
148 if head == base_dir
or tail ==
'':
158 original_cwd = os.getcwd()
160 os.makedirs(destination_dir)
162 if e.errno != errno.EEXIST:
164 os.chdir(destination_dir)
170 for (root, _, files)
in os.walk(source_dir, topdown=
False):
171 dir_portion =
subpath(root, source_dir)
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):
181 elif f.endswith(PY_EXT):
185 src_file = os.path.join(root, f)
188 subdir_root = src_file[src_file.rfind(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)
196 destination = os.path.dirname(dst_file)
197 if not os.path.exists(destination):
198 os.makedirs(destination)
203 copyfile(src_file, dst_file)
206 print(
'...copying %s' % dst_file)
207 if f == IDL_EXTENDED_ATTRIBUTES_FILE:
208 warning_messages.append(dst_file)
211 warning_messages.append(dst_file)
212 if not (
isDryRun()
or has_Dart_fix_me):
216 os.chdir(original_cwd)
218 return [idls, pys, others]
229 original_cwd = os.getcwd()
231 if os.path.exists(webcore_dir):
232 os.chdir(webcore_dir)
234 for (root, _, files)
in os.walk(
235 os.path.join(webcore_dir, subdir), topdown=
False):
236 dir_portion =
subpath(root, webcore_dir)
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)):
248 files_to_delete.append(check_file)
250 os.chdir(original_cwd)
252 return files_to_delete
256 parser = optparse.OptionParser()
263 help=
'WebKit Chrome directory (e.g., --chromium=~/chrome63',
270 help=
'Dump all information',
277 help=
'Display results without adding, updating or deleting any files',
279 args, _ = parser.parse_args()
282 argOptions[
'chromium_dir'] = args.chromium_dir
283 argOptions[
'verbose'] = args.verbose
284 argOptions[
'dry_run'] = args.dry_run
290 req = requests.get(DEPS_GIT)
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):
301 print(
'ERROR: Unable to find dart/dartium/src repository %s' %
302 GIT_REMOTES_CHROMIUM)
310 webkit_dir = os.path.join(chromiumDir, WEBKIT_SOURCE)
314 chromium_sha =
RunCommand([
'git',
'log',
'--format=format:%H',
'-1'])
325 if cwd.endswith(
'dart'):
327 src_dir, _ = os.path.split(cwd)
328 elif cwd.endswith(
'sdk'):
331 src_dir = os.path.join(cwd,
'sdk')
335 dart_sha =
RunCommand([
'git',
'log',
'--format=format:%H',
'-1'])
345 """Returns a tuple with the (dartium chromium repo, latest revision)."""
346 foundIt = re.search(WEBKIT_SHA_PATTERN, deps)
351 revision = foundIt.group(1)[1:]
352 print(
'%s' % revision)
358 print(
"%s files removed in WebCore %s" % (idls_deleted.__len__(), subdir))
360 for delete_file
in idls_deleted:
361 print(
" %s" % delete_file)
363 idls_copied, py_copied, other_copied =
copy_files(
364 os.path.join(src, subdir), src_prefix, dest)
366 print(
"Copied %s IDLs to %s" % (idls_copied, subdir))
368 print(
"Copied %s PYs to %s" % (py_copied, subdir))
370 print(
"Copied %s other to %s\n" % (other_copied, subdir))
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',
382 base_directory = current_dir[:current_dir.rfind(SOURCE_FILE_DIR)]
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'])
393 start_time = time.time()
411 webcore_blink_dir = os.path.join(base_directory, WEBCORE_BLINK_SOURCE)
412 copy_subdir(webkit_blink_dir, WEBKIT_BLINK_SOURCE, webcore_blink_dir,
"")
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,
420 end_time = time.time()
423 'WARNING: File(s) contain FIXMEDART and are NOT "git add " please review:'
425 for warning
in warning_messages:
426 print(
' %s' % warning)
428 print(
'\nDone idlsync completed in %s seconds' %
429 round(end_time - start_time, 2))
432if __name__ ==
'__main__':
static void round(SkPoint *p)
static bool read(SkStream *stream, void *buffer, size_t amount)
def print(*args, **kwargs)
def anyDartFixMe(filepath)
def RunCommand(cmd, valid_exits=[0])
def subpath(path, base_dir)
def GetDEPSWebCoreGitRevision(deps, component)
def copy_files(source_dir, src_prefix, destination_dir)
def copy_subdir(src, src_prefix, dest, subdir)
def remove_obsolete_webcore_files(webcore_dir, webkit_dir, subdir)
static SkString join(const CommandLineFlags::StringArray &)