Use pub get --offline for flutter_frontend_server and const_finder (flutter/engine#26019)
This commit is contained in:
12
DEPS
12
DEPS
@@ -135,7 +135,7 @@ deps = {
|
||||
|
||||
'src/third_party/khronos':
|
||||
Var('chromium_git') + '/chromium/src/third_party/khronos.git' + '@' + '7122230e90547962e0f0c627f62eeed3c701f275',
|
||||
|
||||
|
||||
'src/third_party/googletest':
|
||||
Var('github_git') + '/google/googletest' + '@' + 'f5e592d8ee5ffb1d9af5be7f715ce3576b8bf9c4',
|
||||
|
||||
@@ -598,12 +598,6 @@ hooks = [
|
||||
'pattern': '.',
|
||||
'action': ['python', 'src/build/vs_toolchain.py', 'update'],
|
||||
},
|
||||
{
|
||||
'name': 'generate_package_files',
|
||||
'pattern': '.',
|
||||
'cwd': 'src/',
|
||||
'action': ['python', 'flutter/tools/generate_package_files.py'],
|
||||
},
|
||||
{
|
||||
# Ensure that we don't accidentally reference any .pyc files whose
|
||||
# corresponding .py files have already been deleted.
|
||||
@@ -659,11 +653,11 @@ hooks = [
|
||||
'--arch=arm64'],
|
||||
},
|
||||
{
|
||||
'name': 'dart package config',
|
||||
'name': 'pub get --offline',
|
||||
'pattern': '.',
|
||||
'action': [
|
||||
'python',
|
||||
'src/flutter/tools/run_third_party_dart.py',
|
||||
'src/flutter/tools/pub_get_offline.py',
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
name: frontend_server
|
||||
name: flutter_frontend_server
|
||||
publish_to: none
|
||||
version: 0.1.1-dev
|
||||
description: Communication pipe to Dart Frontend
|
||||
homepage: http://flutter.io
|
||||
homepage: https://flutter.dev
|
||||
author: Flutter Authors <flutter-dev@googlegroups.com>
|
||||
|
||||
# Do not add any dependencies that require more than what is provided in
|
||||
# //third_party/dart/pkg or //third_party/dart/third_party/pkg.
|
||||
# In particular, package:test is not usable here.
|
||||
|
||||
# If you do add packages here, make sure you can run `pub get --offline`, and
|
||||
# check the .packages and .package_config to make sure all the paths are
|
||||
# relative to this directory into //third_party/dart
|
||||
|
||||
environment:
|
||||
sdk: ">=2.2.2 <3.0.0"
|
||||
|
||||
@@ -15,13 +24,75 @@ dependencies:
|
||||
convert: any
|
||||
crypto: any
|
||||
front_end: any
|
||||
frontend_server: any
|
||||
kernel: any
|
||||
logging: any
|
||||
meta: any
|
||||
quiver: any
|
||||
package_config: any
|
||||
path: any
|
||||
source_span: any
|
||||
typed_data: any
|
||||
usage: any
|
||||
vm: any
|
||||
|
||||
dependency_overrides:
|
||||
_fe_analyzer_shared:
|
||||
path: ../../third_party/dart/pkg/_fe_analyzer_shared
|
||||
_js_interop_checks:
|
||||
path: ../../third_party/dart/pkg/_js_interop_checks
|
||||
args:
|
||||
path: ../../third_party/dart/third_party/pkg/args
|
||||
async:
|
||||
path: ../../third_party/dart/third_party/pkg/async
|
||||
bazel_worker:
|
||||
path: ../../third_party/dart/third_party/pkg/bazel_worker
|
||||
build_integration:
|
||||
path: ../../third_party/dart/pkg/build_integration
|
||||
charcode:
|
||||
path: ../../third_party/dart/third_party/pkg/charcode
|
||||
cli_util:
|
||||
path: ../../third_party/dart/third_party/pkg/cli_util
|
||||
collection:
|
||||
path: ../../third_party/dart/third_party/pkg/collection
|
||||
convert:
|
||||
path: ../../third_party/dart/third_party/pkg/convert
|
||||
crypto:
|
||||
path: ../../third_party/dart/third_party/pkg/crypto
|
||||
dev_compiler:
|
||||
path: ../../third_party/dart/pkg/dev_compiler
|
||||
fixnum:
|
||||
path: ../../third_party/dart/third_party/pkg/fixnum
|
||||
front_end:
|
||||
path: ../../third_party/dart/pkg/front_end
|
||||
frontend_server:
|
||||
path: ../../third_party/dart/pkg/frontend_server
|
||||
kernel:
|
||||
path: ../../third_party/dart/pkg/kernel
|
||||
logging:
|
||||
path: ../../third_party/dart/third_party/pkg/logging
|
||||
matcher:
|
||||
path: ../../third_party/dart/third_party/pkg/matcher
|
||||
meta:
|
||||
path: ../../third_party/dart/pkg/meta
|
||||
package_config:
|
||||
path: ../../third_party/dart/third_party/pkg_tested/package_config
|
||||
path:
|
||||
path: ../../third_party/dart/third_party/pkg/path
|
||||
pedantic:
|
||||
path: ../../third_party/dart/third_party/pkg/pedantic
|
||||
protobuf:
|
||||
path: ../../third_party/dart/third_party/pkg/protobuf/protobuf
|
||||
source_maps:
|
||||
path: ../../third_party/dart/third_party/pkg/source_maps
|
||||
source_span:
|
||||
path: ../../third_party/dart/third_party/pkg/source_span
|
||||
stack_trace:
|
||||
path: ../../third_party/dart/third_party/pkg/stack_trace
|
||||
term_glyph:
|
||||
path: ../../third_party/dart/third_party/pkg/term_glyph
|
||||
typed_data:
|
||||
path: ../../third_party/dart/third_party/pkg/typed_data
|
||||
usage:
|
||||
path: ../../third_party/dart/third_party/pkg/usage
|
||||
vm:
|
||||
path: ../../third_party/dart/pkg/vm
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "const_finder",
|
||||
"rootUri": "../",
|
||||
"packageUri": "lib",
|
||||
"languageVersion": "2.4"
|
||||
},
|
||||
{
|
||||
"name": "kernel",
|
||||
"rootUri": "../../../../third_party/dart/pkg/kernel",
|
||||
"packageUri": "lib",
|
||||
"languageVersion": "2.12"
|
||||
},
|
||||
{
|
||||
"name": "meta",
|
||||
"rootUri": "../../../../third_party/dart/pkg/meta",
|
||||
"packageUri": "lib",
|
||||
"languageVersion": "2.12"
|
||||
},
|
||||
{
|
||||
"name": "args",
|
||||
"rootUri": "../../../../third_party/dart/third_party/pkg/args",
|
||||
"packageUri": "lib",
|
||||
"languageVersion": "2.12"
|
||||
},
|
||||
{
|
||||
"name": "collection",
|
||||
"rootUri": "../../../../third_party/dart/third_party/pkg/collection",
|
||||
"packageUri": "lib",
|
||||
"languageVersion": "2.12"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"rootUri": "../../../../third_party/dart/third_party/pkg/path",
|
||||
"packageUri": "lib",
|
||||
"languageVersion": "2.12"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
*.dill
|
||||
|
||||
!.dart_tool
|
||||
!.dart_tool/package_config.json
|
||||
!.packages
|
||||
!test/fixtures/.dart_tool
|
||||
!test/fixtures/.dart_tool/package_config.json
|
||||
!test/fixtures/.packages
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# Generated by pub on 2020-11-27 10:12:47.813477.
|
||||
args:../../../third_party/dart/third_party/pkg/args/lib/
|
||||
collection:../../../third_party/dart/third_party/pkg/collection/lib/
|
||||
kernel:../../../third_party/dart/pkg/kernel/lib/
|
||||
meta:../../../third_party/dart/pkg/meta/lib/
|
||||
path:../../../third_party/dart/third_party/pkg/path/lib/
|
||||
const_finder:lib/
|
||||
@@ -1,97 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart=2.8
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:package_config/packages_file.dart';
|
||||
import 'package:package_config/src/package_config_json.dart';
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
void main(List<String> args) async {
|
||||
if (args.length != 1) {
|
||||
throw ArgumentError('Unexpected arguments $args\n\n$usage');
|
||||
}
|
||||
if (args.first == 'help') {
|
||||
print(usage);
|
||||
return;
|
||||
}
|
||||
var packagesUri = Uri.base.resolve(args.first);
|
||||
var packagesFile = File.fromUri(packagesUri);
|
||||
if (!await packagesFile.exists()) {
|
||||
throw ArgumentError('Unable to read file at `$packagesUri`');
|
||||
}
|
||||
var packageMap = parse(await packagesFile.readAsBytes(), packagesFile.uri);
|
||||
var packages = <Package>[];
|
||||
for (var packageEntry in packageMap.entries) {
|
||||
var name = packageEntry.key;
|
||||
var uri = packageEntry.value;
|
||||
if (uri.scheme != 'file') {
|
||||
throw ArgumentError(
|
||||
'Only file: schemes are supported, but the `$name` package has '
|
||||
'the following uri: ${uri}');
|
||||
}
|
||||
Uri packageRoot;
|
||||
Uri pubspec;
|
||||
LanguageVersion languageVersion;
|
||||
// Pub packages will always have a path ending in `lib/`, and a pubspec
|
||||
// directly above that.
|
||||
if (uri.path.endsWith('lib/')) {
|
||||
packageRoot = uri.resolve('../');
|
||||
pubspec = packageRoot.resolve('pubspec.yaml');
|
||||
if (!File.fromUri(pubspec).existsSync()) {
|
||||
continue;
|
||||
}
|
||||
// Default to 2.7 if not found to prevent all packages from accidentally
|
||||
// opting into NNBD.
|
||||
languageVersion = await languageVersionFromPubspec(pubspec, name) ??
|
||||
LanguageVersion(2, 7);
|
||||
packages.add(Package(name, packageRoot,
|
||||
languageVersion: languageVersion, packageUriRoot: uri));
|
||||
}
|
||||
}
|
||||
var outputFile =
|
||||
File.fromUri(packagesFile.uri.resolve('.dart_tool/package_config.json'));
|
||||
if (!outputFile.parent.existsSync()) {
|
||||
outputFile.parent.createSync();
|
||||
}
|
||||
var baseUri = outputFile.uri;
|
||||
var sink = outputFile.openWrite(encoding: utf8);
|
||||
writePackageConfigJsonUtf8(PackageConfig(packages), baseUri, sink);
|
||||
await sink.close();
|
||||
}
|
||||
|
||||
const usage = 'Usage: pub run package_config:generate_from_legacy <input-file>';
|
||||
|
||||
Future<LanguageVersion> languageVersionFromPubspec(
|
||||
Uri pubspec, String packageName) async {
|
||||
var pubspecFile = File.fromUri(pubspec);
|
||||
if (!await pubspecFile.exists()) {
|
||||
return null;
|
||||
}
|
||||
var pubspecYaml =
|
||||
loadYaml(await pubspecFile.readAsString(), sourceUrl: pubspec) as YamlMap;
|
||||
|
||||
// Find the sdk constraint, or return null if none is present
|
||||
var environment = pubspecYaml['environment'] as YamlMap;
|
||||
if (environment == null) {
|
||||
return null;
|
||||
}
|
||||
var sdkConstraint = environment['sdk'] as String;
|
||||
if (sdkConstraint == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var parsedConstraint = VersionConstraint.parse(sdkConstraint);
|
||||
var min = parsedConstraint is Version
|
||||
? parsedConstraint
|
||||
: parsedConstraint is VersionRange
|
||||
? parsedConstraint.min
|
||||
: throw 'Unsupported version constraint type $parsedConstraint';
|
||||
|
||||
return LanguageVersion(min.major, min.minor);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
name: generate_package_config
|
||||
environment:
|
||||
sdk: ">=2.8.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
yaml: any
|
||||
pub_semver: any
|
||||
package_config: 1.9.3
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# This script generates .packages file for frontend_server from Dart SDKs
|
||||
# .packages file located in third_party/dart/.packages
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
ALL_PACKAGES = {
|
||||
'flutter_frontend_server': [],
|
||||
}
|
||||
|
||||
SRC_DIR = os.getcwd()
|
||||
|
||||
DOT_PACKAGES = '.packages'
|
||||
DART_PACKAGES_FILE = os.path.join(SRC_DIR, 'third_party', 'dart', DOT_PACKAGES)
|
||||
|
||||
# Generate .packages file in the given package.
|
||||
def GeneratePackages(package, local_deps):
|
||||
with open(os.path.join('flutter', package, DOT_PACKAGES), 'w') as packages:
|
||||
with open(DART_PACKAGES_FILE, 'r') as dart_packages:
|
||||
for line in dart_packages:
|
||||
if line.startswith('#'):
|
||||
packages.write(line)
|
||||
else:
|
||||
[name, path] = line.split(':', 1)
|
||||
packages.write('%s:../../third_party/dart/%s' % (name, path))
|
||||
packages.write('%s:./lib\n' % (package))
|
||||
for other_package in local_deps:
|
||||
packages.write('%s:../%s/lib\n' % (other_package, other_package))
|
||||
|
||||
for package, local_deps in ALL_PACKAGES.iteritems():
|
||||
GeneratePackages(package, local_deps)
|
||||
72
engine/src/flutter/tools/pub_get_offline.py
Normal file
72
engine/src/flutter/tools/pub_get_offline.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# This python script uses `pub get --offline` to fill in
|
||||
# .dart_tool/package_config.json files for Dart packages in the tree whose
|
||||
# dependencies should be entirely resolved without requesting data from pub.dev.
|
||||
# This allows us to be certain that the Dart code we are pulling for these
|
||||
# packages is explicitly fetched by `gclient sync` rather than implicitly
|
||||
# fetched by pub version solving, and pub fetching transitive dependencies.
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ALL_PACKAGES = [
|
||||
os.path.join("src", "flutter", "flutter_frontend_server"),
|
||||
os.path.join("src", "flutter", "tools", "const_finder"),
|
||||
]
|
||||
|
||||
|
||||
def FetchPackage(pub, package):
|
||||
try:
|
||||
subprocess.check_output(pub, cwd=package, stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as err:
|
||||
print("'%s' failed in '%s' with status %d:\n%s" %
|
||||
(' '.join(cmd), cwd, err.returncode, err.output))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def CheckPackage(package):
|
||||
package_config = os.path.join(package, ".dart_tool", "package_config.json")
|
||||
pub_count = 0
|
||||
with open(package_config) as f:
|
||||
data_dict = json.load(f)
|
||||
packages_data = data_dict["packages"]
|
||||
for package_data in packages_data:
|
||||
package_uri = package_data["rootUri"]
|
||||
package_name = package_data["name"]
|
||||
if ".pub-cache" in package_uri and "pub.dartlang.org" in package_uri:
|
||||
print("Error: package '%s' was fetched from pub" % package_name)
|
||||
pub_count = pub_count + 1
|
||||
if pub_count > 0:
|
||||
print("Error: %d packages were fetched from pub for %s" % (pub_count, package))
|
||||
print("Please fix the pubspec.yaml for %s "
|
||||
"so that all dependencies are path dependencies" % package)
|
||||
return pub_count
|
||||
|
||||
|
||||
def Main():
|
||||
leading = os.path.join("src", "third_party", "dart", "tools", "sdks", "dart-sdk", "bin")
|
||||
pub = "pub"
|
||||
if os.name == "nt":
|
||||
pub = "pub.bat"
|
||||
pubcmd = [os.path.abspath(os.path.join(leading, pub)), "get", "--offline"]
|
||||
|
||||
pub_count = 0
|
||||
for package in ALL_PACKAGES:
|
||||
if FetchPackage(pubcmd, package) != 0:
|
||||
return 1
|
||||
pub_count = pub_count + CheckPackage(package)
|
||||
|
||||
if pub_count > 0:
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(Main())
|
||||
@@ -1,15 +0,0 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
leading = os.path.join("src", "third_party", "dart", "tools", "sdks", "dart-sdk", "bin")
|
||||
pub = "pub"
|
||||
if os.name == "nt":
|
||||
pub = "pub.bat"
|
||||
subprocess.check_call([os.path.join(leading, pub), "global", "activate", "-spath", "./src/flutter/tools/generate_package_config"])
|
||||
subprocess.check_call([os.path.join(leading, pub), "global", "run", "generate_package_config:generate_from_legacy", "src/flutter/flutter_frontend_server/.packages"])
|
||||
subprocess.check_call([os.path.join(leading, pub), "global", "run", "generate_package_config:generate_from_legacy", "src/flutter/tools/const_finder/.packages"])
|
||||
Reference in New Issue
Block a user