@@ -103,9 +103,10 @@ final class BuildConfigImpl implements BuildConfig {
103
103
required LinkModePreferenceImpl linkModePreference,
104
104
Map <String , Metadata >? dependencyMetadata,
105
105
Iterable <String >? supportedAssetTypes,
106
+ Version ? version,
106
107
}) {
107
108
final nonValidated = BuildConfigImpl ._()
108
- .._version = latestVersion
109
+ .._version = version ?? latestVersion
109
110
.._outDir = outDir
110
111
.._packageName = packageName
111
112
.._packageRoot = packageRoot
@@ -120,7 +121,7 @@ final class BuildConfigImpl implements BuildConfig {
120
121
.._dryRun = false
121
122
.._supportedAssetTypes =
122
123
_supportedAssetTypesBackwardsCompatibility (supportedAssetTypes);
123
- final parsedConfigFile = nonValidated.toYaml ();
124
+ final parsedConfigFile = nonValidated.toJson ();
124
125
final config = Config (fileParsed: parsedConfigFile);
125
126
return BuildConfigImpl .fromConfig (config);
126
127
}
@@ -145,7 +146,7 @@ final class BuildConfigImpl implements BuildConfig {
145
146
.._dryRun = true
146
147
.._supportedAssetTypes =
147
148
_supportedAssetTypesBackwardsCompatibility (supportedAssetTypes);
148
- final parsedConfigFile = nonValidated.toYaml ();
149
+ final parsedConfigFile = nonValidated.toJson ();
149
150
final config = Config (fileParsed: parsedConfigFile);
150
151
return BuildConfigImpl .fromConfig (config);
151
152
}
@@ -189,7 +190,7 @@ final class BuildConfigImpl implements BuildConfig {
189
190
if (dependencyMetadata != null )
190
191
for (final entry in dependencyMetadata.entries) ...[
191
192
entry.key,
192
- json.encode (entry.value.toYaml ()),
193
+ json.encode (entry.value.toJson ()),
193
194
],
194
195
..._supportedAssetTypesBackwardsCompatibility (supportedAssetTypes),
195
196
].join ('###' );
@@ -217,9 +218,9 @@ final class BuildConfigImpl implements BuildConfig {
217
218
/// and packages through `build.dart` invocations.
218
219
///
219
220
/// If we ever were to make breaking changes, it would be useful to give
220
- /// proper error messages rather than just fail to parse the YAML
221
+ /// proper error messages rather than just fail to parse the JSON
221
222
/// representation in the protocol.
222
- static Version latestVersion = Version (1 , 1 , 0 );
223
+ static Version latestVersion = Version (1 , 2 , 0 );
223
224
224
225
factory BuildConfigImpl .fromConfig (Config config) {
225
226
final result = BuildConfigImpl ._().._cCompiler = CCompilerConfigImpl ._();
@@ -246,6 +247,9 @@ final class BuildConfigImpl implements BuildConfig {
246
247
Map <String , String >? environment,
247
248
Uri ? workingDirectory,
248
249
}) {
250
+ // TODO(https://github.com/dart-lang/native/issues/1000): At some point,
251
+ // migrate away from package:cli_config, to get rid of package:yaml
252
+ // dependency.
249
253
final config = Config .fromArgumentsSync (
250
254
arguments: args,
251
255
environment: environment,
@@ -451,10 +455,10 @@ final class BuildConfigImpl implements BuildConfig {
451
455
return result.sortOnKey ();
452
456
}
453
457
454
- Map <String , Object > toYaml () {
455
- late Map <String , Object > cCompilerYaml ;
458
+ Map <String , Object > toJson () {
459
+ late Map <String , Object > cCompilerJson ;
456
460
if (! dryRun) {
457
- cCompilerYaml = _cCompiler.toYaml ();
461
+ cCompilerJson = _cCompiler.toJson ();
458
462
}
459
463
460
464
return {
@@ -464,7 +468,7 @@ final class BuildConfigImpl implements BuildConfig {
464
468
OSImpl .configKey: _targetOS.toString (),
465
469
LinkModePreferenceImpl .configKey: _linkModePreference.toString (),
466
470
supportedAssetTypesKey: _supportedAssetTypes,
467
- _versionKey: latestVersion .toString (),
471
+ _versionKey: version .toString (),
468
472
if (dryRun) dryRunConfigKey: dryRun,
469
473
if (! dryRun) ...{
470
474
BuildModeImpl .configKey: _buildMode.toString (),
@@ -473,18 +477,18 @@ final class BuildConfigImpl implements BuildConfig {
473
477
IOSSdkImpl .configKey: _targetIOSSdk.toString (),
474
478
if (_targetAndroidNdkApi != null )
475
479
targetAndroidNdkApiConfigKey: _targetAndroidNdkApi,
476
- if (cCompilerYaml .isNotEmpty)
477
- CCompilerConfigImpl .configKey: cCompilerYaml ,
480
+ if (cCompilerJson .isNotEmpty)
481
+ CCompilerConfigImpl .configKey: cCompilerJson ,
478
482
if (_dependencyMetadata != null && _dependencyMetadata.isNotEmpty)
479
483
dependencyMetadataConfigKey: {
480
484
for (final entry in _dependencyMetadata.entries)
481
- entry.key: entry.value.toYaml (),
485
+ entry.key: entry.value.toJson (),
482
486
},
483
487
},
484
488
}.sortOnKey ();
485
489
}
486
490
487
- String toYamlString () => yamlEncode ( toYaml ());
491
+ String toJsonString () => const JsonEncoder . withIndent ( ' ' ). convert ( toJson ());
488
492
489
493
@override
490
494
bool operator == (Object other) {
@@ -533,7 +537,7 @@ final class BuildConfigImpl implements BuildConfig {
533
537
]);
534
538
535
539
@override
536
- String toString () => 'BuildConfig.build(${toYaml ()})' ;
540
+ String toString () => 'BuildConfig.build(${toJson ()})' ;
537
541
538
542
void _ensureNotDryRun () {
539
543
if (dryRun) {
0 commit comments