Skip to content

Commit c4a1eaf

Browse files
munificentcommit-bot@chromium.org
authored andcommitted
Require an SDK constraint in the package config generator.
Also, fix the one package that didn't have one, and regenerate the config. Change-Id: Id7f210e9a3f73b2070e52df6ae9d4b1c4d4aeae3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172081 Commit-Queue: Leaf Petersen <[email protected]> Reviewed-by: Leaf Petersen <[email protected]> Auto-Submit: Bob Nystrom <[email protected]>
1 parent c36ba8b commit c4a1eaf

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

sdk/lib/_internal/sdk_library_metadata/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
# make it easer to depend on libraries.dart from sdk packages like dart2js.
33
name: sdk_library_metadata
44
publish_to: none
5+
environment:
6+
sdk: '>=2.11.0 <3.0.0'

tools/generate_package_config.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ Iterable<Map<String, String>> makePackageConfigs(
9898
.toUri(p.relative(packageDir, from: p.dirname(configFilePath)))
9999
.toString(),
100100
if (hasLibDirectory) 'packageUri': 'lib/',
101-
if (version != null)
102-
'languageVersion': '${version.major}.${version.minor}'
101+
'languageVersion': '${version.major}.${version.minor}'
103102
};
104103
}
105104
}
@@ -153,18 +152,29 @@ Iterable<String> listSubdirectories(String packagesDir) sync* {
153152
/// Returns `null` if there is no pubspec or no SDK constraint.
154153
Version pubspecLanguageVersion(String packageDir) {
155154
var pubspecFile = File(p.join(packageDir, 'pubspec.yaml'));
155+
var relative = p.relative(packageDir, from: repoRoot);
156156

157-
if (!pubspecFile.existsSync()) return null;
157+
if (!pubspecFile.existsSync()) {
158+
print("Error: Missing pubspec for $relative.");
159+
exit(1);
160+
}
158161

159162
var pubspec =
160163
loadYaml(pubspecFile.readAsStringSync()) as Map<dynamic, dynamic>;
161-
if (!pubspec.containsKey('environment')) return null;
164+
if (!pubspec.containsKey('environment')) {
165+
print("Error: Pubspec for $relative has no SDK constraint.");
166+
exit(1);
167+
}
162168

163169
var environment = pubspec['environment'] as Map<dynamic, dynamic>;
164-
if (!environment.containsKey('sdk')) return null;
170+
if (!environment.containsKey('sdk')) {
171+
print("Error: Pubspec for $relative has no SDK constraint.");
172+
exit(1);
173+
}
165174

166175
var sdkConstraint = VersionConstraint.parse(environment['sdk'] as String);
167176
if (sdkConstraint is VersionRange) return sdkConstraint.min;
168177

169-
return null;
178+
print("Error: SDK constraint $relative is not a version range.");
179+
exit(1);
170180
}

0 commit comments

Comments
 (0)