flutter/engine/src/tools/dart/create_updated_flutter_deps.py
Alexander Aprelev 895f0e291a
Roll dart sdk to 3.7.0-266.0.dev (#160624)
Changes since last roll:

```
85569ab5b39 Version 3.7.0-266.0.dev
8c1fa6d05b8 [tfa,aot,dart2wasm] Allow tree-shaking of extension type members independently of their tear-offs
5078a20a6d5 [cfe] Use OffsetMap for BodyBuilder.finishFields
a6b0fced839 [tfa,aot,dart2wasm] Retain libraries which only have extensions and extension types
4bcb4b10443 (tag: 3.7.0-265.0.dev) Version 3.7.0-265.0.dev
982b9fad444 [vm] Turn on entry point checking in JIT mode.
04530d578ff Roll dart_style 3.0.1 into the SDK.
c2abea31557 [deps] Roll dart-lang/native
3b056e1d500 [dart2wasm] Fix deferred loading tests on optimized configs.
ca668b701c3 (tag: 3.7.0-264.0.dev) Version 3.7.0-264.0.dev
54af9b3a39a (tag: 3.7.0-263.0.dev) Version 3.7.0-263.0.dev
72acd9d0ff3 [dart:svg] Add value->newLength parameter name change to templates
57c4da6911d Make Driver.instrumentationService private and final
f934e392f2d analyzer: Remove unnecessary Driver.httpServer
c5c3544b71f Fix Fuchsia build error.
2f857baba7e [dart2js] Make  an  check.
b3e7e027380 (tag: 3.7.0-262.0.dev) Version 3.7.0-262.0.dev
08252fc9e91 [dartdev] Use VmInteropHandler for invoking sub commands
96c4e4c81f8 [dart2wasm] Use field type instead of global type for static field type.
e3e7ca846a8 [gardening] Fix service/uri_mappings_lookup_test.
580107f8474 Migrate generic_type_alias.test
0a5a8f17af8 [vm] Remove BaseIsolate as it serves no purposes anymore.
9820487a3c4 [analyzer] Support enclosingFragments that are local variables
dbf60082974 DAS: Support monospaced text (eg code snippets) in generated doc comments
59499d362a2 [dart2wasm] Add support for declaring functions as module elements.
a0e1bce4b27 (tag: 3.7.0-261.0.dev) Version 3.7.0-261.0.dev
96fbc264ca1 [dart2wasm] Add indirection for dispatch table calls.
d261ded4c72 Bump tools to febccb92d228e678196aa90c109c708ed7ad6ea8
54d62b478d8 [analysis_server] Move Type Hierarchy off ElementLocation to its own internal uri/name encoding
b67f61a66c3 [tests] Additional tests for ?? with enum shorthands.
e1be04c4704 Implement element and fragment for generic function types
a9c3991a7a6 [analysis_server] Migrate LSP Find References to new element model
11904ed3871 [analyzer] Add LinterContext.currentUnit and use it for content in eol_at_end_of_file
38bce3f507d Elements. Migrate test/generated/simple_resolver_test.dart
34cf29701be Elements. Migrate test/src/dart/analysis/search_test.dart
e70a91d8e38 [analyzer/linter] Simplify implementation of rule State
ee5c4b00840 Roll BoringSSL from 57f525e425a9 to ee0c13ad1808 (22 revisions)
42f0e9aa15b analyzer: Report bad type arg on implicit call
8cc449ac8c1 [dart2wasm] Add utils for pragma reading and updating.
04d70b9fb40 analyzer: Make ResolutionVisitor._libraryElement final
d0f34d918f2 [dynamic_modules] Fix multiple_classes/dynamic_interfaces.yaml for vm.
3fba5fb4633 DAS: Seal TypeDecl for simpler switches
946f3287b46 [dart2wasm] Clean up some dead or unnecessary code.
231b463e8fc Roll Fuchsia SDK from 26.20241210.5.1 to 26.20241211.4.1
4e4fec1830b DAS: Correct some broken comment references
69fef4b123c Elements. Use impl types in a few places to avoid casts.
```
2024-12-20 17:38:31 +00:00

147 lines
5.4 KiB
Python
Executable File

#!/usr/bin/env python3
#
# Copyright 2017 The Dart project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Usage: tools/dart/create_updated_flutter_deps.py [-d dart/DEPS] [-f flutter/DEPS]
#
# This script parses existing flutter DEPS file, identifies all 'dart_' prefixed
# dependencies, looks up revision from dart DEPS file, updates those dependencies
# and rewrites flutter DEPS file.
import argparse
import os
import sys
DART_SCRIPT_DIR = os.path.dirname(sys.argv[0])
OLD_DART_DEPS = os.path.realpath(os.path.join(DART_SCRIPT_DIR, '../../third_party/dart/DEPS'))
DART_DEPS = os.path.realpath(os.path.join(DART_SCRIPT_DIR, '../../flutter/third_party/dart/DEPS'))
FLUTTER_DEPS = os.path.realpath(os.path.join(DART_SCRIPT_DIR, '../../../../DEPS'))
class VarImpl(object):
def __init__(self, local_scope):
self._local_scope = local_scope
def Lookup(self, var_name):
"""Implements the Var syntax."""
if var_name in self._local_scope.get("vars", {}):
return self._local_scope["vars"][var_name]
if var_name == 'host_os':
return 'linux' # assume some default value
if var_name == 'host_cpu':
return 'x64' # assume some default value
raise Exception("Var is not defined: %s" % var_name)
def ParseDepsFile(deps_file):
local_scope = {}
var = VarImpl(local_scope)
global_scope = {
'Var': var.Lookup,
'deps_os': {},
}
# Read the content.
with open(deps_file, 'r') as fp:
deps_content = fp.read()
# Eval the content.
exec(deps_content, global_scope, local_scope)
return (local_scope.get('vars', {}), local_scope.get('deps', {}))
def ParseArgs(args):
args = args[1:]
parser = argparse.ArgumentParser(
description='A script to generate updated dart dependencies for flutter DEPS.')
parser.add_argument('--dart_deps', '-d',
type=str,
help='Dart DEPS file.',
default=DART_DEPS)
parser.add_argument('--flutter_deps', '-f',
type=str,
help='Flutter DEPS file.',
default=FLUTTER_DEPS)
return parser.parse_args(args)
def Main(argv):
args = ParseArgs(argv)
if args.dart_deps == DART_DEPS and not os.path.isfile(DART_DEPS):
args.dart_deps = OLD_DART_DEPS
(new_vars, new_deps) = ParseDepsFile(args.dart_deps)
(old_vars, old_deps) = ParseDepsFile(args.flutter_deps)
updated_vars = {}
# Collect updated dependencies
for (k,v) in sorted(old_vars.items()):
if k not in ('dart_revision', 'dart_git') and k.startswith('dart_'):
dart_key = k[len('dart_'):]
if dart_key in new_vars:
updated_revision = new_vars[dart_key].lstrip('@') if dart_key in new_vars else v
updated_vars[k] = updated_revision
# Write updated DEPS file to a side
updatedfilename = args.flutter_deps + ".new"
updatedfile = open(updatedfilename, "w")
file = open(args.flutter_deps)
lines = file.readlines()
i = 0
while i < len(lines):
updatedfile.write(lines[i])
if lines[i].startswith(" 'dart_revision':"):
i = i + 2
updatedfile.writelines([
'\n',
' # WARNING: DO NOT EDIT MANUALLY\n',
' # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py\n'])
while i < len(lines) and len(lines[i].strip()) > 0:
i = i + 1
for (k, v) in sorted(updated_vars.items()):
updatedfile.write(" '%s': '%s',\n" % (k, v))
updatedfile.write('\n')
elif lines[i].startswith(" # WARNING: Unused Dart dependencies"):
updatedfile.write('\n')
i = i + 1
while i < len(lines) and (lines[i].startswith(" # WARNING: end of dart dependencies") == 0):
i = i + 1
for (k, v) in sorted(old_deps.items()):
if (k.startswith('engine/src/flutter/third_party/dart/')):
for (dart_k, dart_v) in (list(new_deps.items())):
dart_k_suffix = dart_k[len('sdk/') if dart_k.startswith('sdk/') else 0:]
if (k.endswith(dart_k_suffix)):
if (isinstance(dart_v, str)):
updated_value = dart_v.replace(new_vars["dart_git"], "Var('dart_git') + '/")
updated_value = updated_value.replace(old_vars["chromium_git"], "Var('chromium_git') + '")
plain_v = dart_k[dart_k.rfind('/') + 1:]
# This dependency has to be special-cased here because the
# repository name is not the same as the directory name.
if plain_v == "quiver":
plain_v = "quiver-dart"
if ('dart_' + plain_v + '_tag' in updated_vars):
updated_value = updated_value[:updated_value.rfind('@')] + "' + '@' + Var('dart_" + plain_v + "_tag')"
elif ('dart_' + plain_v + '_rev' in updated_vars):
updated_value = updated_value[:updated_value.rfind('@')] + "' + '@' + Var('dart_" + plain_v + "_rev')"
else:
updated_value = updated_value + "'"
else:
# Non-string values(dicts) copy verbatim, keeping them sorted
# to ensure stable ordering of items.
updated_value = dict(sorted(dart_v.items()))
updatedfile.write(" '%s':\n %s,\n\n" % (k, updated_value))
break
updatedfile.write(lines[i])
i = i + 1
# Rename updated DEPS file into a new DEPS file
os.remove(args.flutter_deps)
os.rename(updatedfilename, args.flutter_deps)
return 0
if __name__ == '__main__':
sys.exit(Main(sys.argv))