[repo] auto-generate the .packages file
Change-Id: Ia651685d7f5bc34f396f6c6d0d6a1356c7a88fe3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233523 Reviewed-by: Nate Bosch <nbosch@google.com> Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
"constraint, update this by running tools/generate_package_config.dart."
|
||||
],
|
||||
"configVersion": 2,
|
||||
"generated": "2022-02-17T08:48:00.006717",
|
||||
"generator": "tools/generate_package_config.dart",
|
||||
"packages": [
|
||||
{
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
#
|
||||
# .package file containing links to all packages in /pkg, and checked out
|
||||
# by DEPS into /third_party/pkg and /third_party/pkg_tested.
|
||||
# Please update this file if you add a package to DEPS or /pkg
|
||||
#
|
||||
# This file is generated; do not edit. To re-generate, run:
|
||||
# 'dart tools/generate_package_config.dart'.
|
||||
|
||||
_fe_analyzer_shared:pkg/_fe_analyzer_shared/lib
|
||||
_js_interop_checks:pkg/_js_interop_checks/lib
|
||||
analysis_server:pkg/analysis_server/lib
|
||||
@@ -20,10 +19,12 @@ async_helper:pkg/async_helper/lib
|
||||
bazel_worker:third_party/pkg/bazel_worker/lib
|
||||
benchmark_harness:third_party/pkg/benchmark_harness/lib
|
||||
boolean_selector:third_party/pkg/boolean_selector/lib
|
||||
build_integration:pkg/build_integration/lib
|
||||
browser_launcher:third_party/pkg/browser_launcher/lib
|
||||
build_integration:pkg/build_integration/lib
|
||||
characters:third_party/pkg/characters/lib
|
||||
charcode:third_party/pkg/charcode/lib
|
||||
cli_util:third_party/pkg/cli_util/lib
|
||||
clock:third_party/pkg/clock/lib
|
||||
collection:third_party/pkg/collection/lib
|
||||
compiler:pkg/compiler/lib
|
||||
convert:third_party/pkg/convert/lib
|
||||
@@ -44,9 +45,12 @@ dev_compiler:pkg/dev_compiler/lib
|
||||
devtools_shared:third_party/devtools/devtools_shared/lib
|
||||
expect:pkg/expect/lib
|
||||
ffi:third_party/pkg/ffi/lib
|
||||
file:third_party/pkg/file/packages/file/lib
|
||||
file_testing:third_party/pkg/file/packages/file_testing/lib
|
||||
fixnum:third_party/pkg/fixnum/lib
|
||||
frontend_server:pkg/frontend_server/lib
|
||||
front_end:pkg/front_end/lib
|
||||
frontend_server:pkg/frontend_server/lib
|
||||
frontend_server_client:third_party/pkg/webdev/frontend_server_client/lib
|
||||
glob:third_party/pkg/glob/lib
|
||||
html:third_party/pkg/html/lib
|
||||
http:third_party/pkg/http/lib
|
||||
@@ -72,7 +76,7 @@ native_stack_traces:pkg/native_stack_traces/lib
|
||||
nnbd_migration:pkg/nnbd_migration/lib
|
||||
oauth2:third_party/pkg/oauth2/lib
|
||||
observatory:runtime/observatory/lib
|
||||
observatory_test_package:runtime/observatory/tests/service/observatory_test_package
|
||||
observatory_2:runtime/observatory_2/lib
|
||||
package_config:third_party/pkg_tested/package_config/lib
|
||||
path:third_party/pkg/path/lib
|
||||
pedantic:third_party/pkg/pedantic/lib
|
||||
@@ -82,6 +86,7 @@ process:third_party/pkg/process/lib
|
||||
protobuf:third_party/pkg/protobuf/protobuf/lib
|
||||
pub:third_party/pkg/pub/lib
|
||||
pub_semver:third_party/pkg/pub_semver/lib
|
||||
scrape:pkg/scrape/lib
|
||||
sdk_library_metadata:sdk/lib/_internal/sdk_library_metadata/lib
|
||||
shelf:third_party/pkg/shelf/lib
|
||||
shelf_packages_handler:third_party/pkg/shelf_packages_handler/lib
|
||||
@@ -90,9 +95,9 @@ shelf_static:third_party/pkg/shelf_static/lib
|
||||
shelf_web_socket:third_party/pkg/shelf_web_socket/lib
|
||||
smith:pkg/smith/lib
|
||||
source_map_stack_trace:third_party/pkg/source_map_stack_trace/lib
|
||||
sourcemap_testing:pkg/sourcemap_testing/lib
|
||||
source_maps:third_party/pkg/source_maps/lib
|
||||
source_span:third_party/pkg/source_span/lib
|
||||
sourcemap_testing:pkg/sourcemap_testing/lib
|
||||
sse:third_party/pkg/sse/lib
|
||||
stack_trace:third_party/pkg/stack_trace/lib
|
||||
status_file:pkg/status_file/lib
|
||||
@@ -105,7 +110,6 @@ test:third_party/pkg/test/pkgs/test/lib
|
||||
test_api:third_party/pkg/test/pkgs/test_api/lib
|
||||
test_core:third_party/pkg/test/pkgs/test_core/lib
|
||||
test_descriptor:third_party/pkg/test_descriptor/lib
|
||||
test_package:pkg/vm_service/test/test_package
|
||||
test_process:third_party/pkg/test_process/lib
|
||||
test_reflective_loader:third_party/pkg/test_reflective_loader/lib
|
||||
test_runner:pkg/test_runner/lib
|
||||
@@ -118,8 +122,9 @@ vm_service:pkg/vm_service/lib
|
||||
vm_snapshot_analysis:pkg/vm_snapshot_analysis/lib
|
||||
wasm_builder:pkg/wasm_builder/lib
|
||||
watcher:third_party/pkg/watcher/lib
|
||||
webdriver:third_party/pkg/webdriver/lib
|
||||
webkit_inspection_protocol:third_party/pkg/webkit_inspection_protocol/lib
|
||||
web_components:third_party/pkg/web_components/lib
|
||||
web_socket_channel:third_party/pkg/web_socket_channel/lib
|
||||
webdriver:third_party/pkg/webdriver/lib
|
||||
webkit_inspection_protocol:third_party/pkg/webkit_inspection_protocol/lib
|
||||
yaml:third_party/pkg/yaml/lib
|
||||
yaml_edit:third_party/pkg/yaml_edit/lib
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#!/usr/bin/env dart
|
||||
|
||||
/// Generates the repo's ".dart_tool/package_config.json" file.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
@@ -90,23 +87,24 @@ void main(List<String> args) {
|
||||
...makeCfePackageConfigs(cfePackageDirs),
|
||||
...makeFeAnalyzerSharedPackageConfigs(feAnalyzerSharedPackageDirs)
|
||||
];
|
||||
packages.sort((a, b) => a["name"].compareTo(b["name"]));
|
||||
packages.sort((a, b) => a['name']!.compareTo(b['name']!));
|
||||
|
||||
var configFile = File(p.join(repoRoot, '.dart_tool', 'package_config.json'));
|
||||
var json =
|
||||
jsonDecode(configFile.readAsStringSync()) as Map<dynamic, dynamic>;
|
||||
var json = jsonDecode(configFile.readAsStringSync()) as Map<dynamic, dynamic>;
|
||||
var oldPackages = json['packages'] as List<dynamic>;
|
||||
|
||||
// Validate the packages entry only, to avoid spurious failures from changes
|
||||
// in the dates embedded in the other entries.
|
||||
if (jsonEncode(packages) == jsonEncode(oldPackages)) {
|
||||
print("Package config up to date");
|
||||
exit(0);
|
||||
} else if (checkOnly) {
|
||||
print("Package config out of date");
|
||||
print("Run `gclient sync -D && dart tools/generate_package_config.dart` "
|
||||
"to update.");
|
||||
exit(1);
|
||||
if (checkOnly) {
|
||||
// Validate the packages entry only, to avoid spurious failures from changes
|
||||
// in the dates embedded in the other entries.
|
||||
if (jsonEncode(packages) == jsonEncode(oldPackages)) {
|
||||
print("Package config up to date.");
|
||||
exit(0);
|
||||
} else {
|
||||
print("Package config out of date.");
|
||||
print("Run `gclient sync -D && dart tools/generate_package_config.dart` "
|
||||
"to update.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
var year = DateTime.now().year;
|
||||
@@ -123,7 +121,6 @@ void main(List<String> args) {
|
||||
'constraint, update this by running tools/generate_package_config.dart.'
|
||||
],
|
||||
'configVersion': 2,
|
||||
'generated': DateTime.now().toIso8601String(),
|
||||
'generator': 'tools/generate_package_config.dart',
|
||||
'packages': packages,
|
||||
};
|
||||
@@ -131,8 +128,33 @@ void main(List<String> args) {
|
||||
// TODO(rnystrom): Consider using package_config_v2 to generate this instead.
|
||||
var jsonString = JsonEncoder.withIndent(' ').convert(config);
|
||||
configFile.writeAsStringSync('$jsonString\n');
|
||||
print('Generated .dart_tool/package_config.dart containing '
|
||||
'${packages.length} packages.');
|
||||
|
||||
// Also generate the reop's .packages file.
|
||||
var packagesFile = File(p.join(repoRoot, '.packages'));
|
||||
var buffer = StringBuffer('''
|
||||
# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
#
|
||||
# This file is generated; do not edit. To re-generate, run:
|
||||
# 'dart tools/generate_package_config.dart'.
|
||||
|
||||
''');
|
||||
for (var package in packages) {
|
||||
final name = package['name'];
|
||||
var path = package['rootUri']!;
|
||||
if (path.startsWith('../')) {
|
||||
path = path.substring('../'.length);
|
||||
}
|
||||
var packageUri = package['packageUri'];
|
||||
if (packageUri != null && packageUri.endsWith('/')) {
|
||||
packageUri = packageUri.substring(0, packageUri.length - 1);
|
||||
}
|
||||
if (packageUri != null && packageUri != '.nonexisting') {
|
||||
buffer.writeln('$name:$path/$packageUri');
|
||||
}
|
||||
}
|
||||
packagesFile.writeAsStringSync(buffer.toString());
|
||||
}
|
||||
|
||||
/// Generates package configurations for each package in [packageDirs].
|
||||
@@ -198,9 +220,9 @@ Iterable<String> listSubdirectories(String packagesDir) sync* {
|
||||
|
||||
/// Infers the language version from the SDK constraint in the pubspec for
|
||||
/// [packageDir].
|
||||
///
|
||||
/// Returns `null` if there is no pubspec or no SDK constraint.
|
||||
Version pubspecLanguageVersion(String packageDir) {
|
||||
final dartVersion2 = Version.parse('2.0.0');
|
||||
|
||||
var pubspecFile = File(p.join(packageDir, 'pubspec.yaml'));
|
||||
var relative = p.relative(packageDir, from: repoRoot);
|
||||
|
||||
@@ -223,7 +245,9 @@ Version pubspecLanguageVersion(String packageDir) {
|
||||
}
|
||||
|
||||
var sdkConstraint = VersionConstraint.parse(environment['sdk'] as String);
|
||||
if (sdkConstraint is VersionRange) return sdkConstraint.min;
|
||||
if (sdkConstraint is VersionRange) {
|
||||
return sdkConstraint.min ?? dartVersion2;
|
||||
}
|
||||
|
||||
print("Error: SDK constraint $relative is not a version range.");
|
||||
exit(1);
|
||||
|
||||
Reference in New Issue
Block a user