@@ -100,37 +100,32 @@ final class BuildConfigImpl extends HookConfigImpl implements BuildConfig {
100
100
_supportedAssetTypesBackwardsCompatibility (supportedAssetTypes),
101
101
);
102
102
103
- factory BuildConfigImpl ._fromConfig (Config config) =>
104
- _readFieldsFromConfig (config);
105
-
106
103
static BuildConfigImpl fromArguments (
107
- List <String > args , {
104
+ List <String > arguments , {
108
105
Map <String , String >? environment,
109
106
Uri ? workingDirectory,
110
107
}) {
111
- // TODO(https://github.com/dart-lang/native/issues/1000): At some point,
112
- // migrate away from package:cli_config, to get rid of package:yaml
113
- // dependency.
114
- final config = Config .fromArgumentsSync (
115
- arguments: args,
116
- environment: environment,
117
- workingDirectory: workingDirectory,
118
- );
119
- return BuildConfigImpl ._fromConfig (config);
108
+ final configPath = getConfigArgument (arguments);
109
+ final bytes = File (configPath).readAsBytesSync ();
110
+ final linkConfigJson = const Utf8Decoder ()
111
+ .fuse (const JsonDecoder ())
112
+ .convert (bytes) as Map <String , Object ?>;
113
+ return fromJson (linkConfigJson, baseUri: Uri .parse (configPath));
120
114
}
121
115
122
116
static const dependencyMetadataConfigKey = 'dependency_metadata' ;
123
117
124
118
static const linkingEnabledKey = 'linking_enabled' ;
125
119
126
- static BuildConfigImpl _readFieldsFromConfig (Config config) {
120
+ static BuildConfigImpl fromJson (Map <String , dynamic > config, {Uri ? baseUri}) {
121
+ baseUri ?? = Uri .base ;
127
122
final dryRun = HookConfigImpl .parseDryRun (config) ?? false ;
128
123
final targetOS = HookConfigImpl .parseTargetOS (config);
129
124
return BuildConfigImpl (
130
- outputDirectory: HookConfigImpl .parseOutDir (config),
131
- outputDirectoryShared: HookConfigImpl .parseOutDirShared (config),
125
+ outputDirectory: HookConfigImpl .parseOutDir (baseUri, config),
126
+ outputDirectoryShared: HookConfigImpl .parseOutDirShared (baseUri, config),
132
127
packageName: HookConfigImpl .parsePackageName (config),
133
- packageRoot: HookConfigImpl .parsePackageRoot (config),
128
+ packageRoot: HookConfigImpl .parsePackageRoot (baseUri, config),
134
129
buildMode: HookConfigImpl .parseBuildMode (config, dryRun),
135
130
targetOS: targetOS,
136
131
targetArchitecture:
@@ -139,7 +134,7 @@ final class BuildConfigImpl extends HookConfigImpl implements BuildConfig {
139
134
dependencyMetadata: parseDependencyMetadata (config),
140
135
linkingEnabled: parseHasLinkPhase (config),
141
136
version: HookConfigImpl .parseVersion (config),
142
- cCompiler: HookConfigImpl .parseCCompiler (config, dryRun),
137
+ cCompiler: HookConfigImpl .parseCCompiler (baseUri, config, dryRun),
143
138
supportedAssetTypes: HookConfigImpl .parseSupportedAssetTypes (config),
144
139
targetAndroidNdkApi:
145
140
HookConfigImpl .parseTargetAndroidNdkApi (config, dryRun, targetOS),
@@ -152,9 +147,9 @@ final class BuildConfigImpl extends HookConfigImpl implements BuildConfig {
152
147
);
153
148
}
154
149
155
- static Map <String , Metadata >? parseDependencyMetadata (Config config) {
156
- final fileValue =
157
- config.valueOf < Map < Object ?, Object ?>?> (dependencyMetadataConfigKey);
150
+ static Map <String , Metadata >? parseDependencyMetadata (
151
+ Map < String , Object ?> config) {
152
+ final fileValue = config.optionalMap (dependencyMetadataConfigKey);
158
153
if (fileValue == null ) {
159
154
return null ;
160
155
}
@@ -177,12 +172,9 @@ final class BuildConfigImpl extends HookConfigImpl implements BuildConfig {
177
172
).sortOnKey ();
178
173
}
179
174
180
- static bool ? parseHasLinkPhase (Config config) =>
175
+ static bool ? parseHasLinkPhase (Map < String , Object ?> config) =>
181
176
config.optionalBool (linkingEnabledKey);
182
177
183
- static BuildConfigImpl fromJson (Map <String , dynamic > buildConfigJson) =>
184
- BuildConfigImpl ._fromConfig (Config (fileParsed: buildConfigJson));
185
-
186
178
@override
187
179
Map <String , Object > toJson () => {
188
180
...hookToJson (),
0 commit comments