[flutter_tools] Reland: fix multiple dart defines (#54973)
This commit is contained in:
@@ -7,7 +7,6 @@ import '../../base/build.dart';
|
||||
import '../../base/file_system.dart';
|
||||
import '../../build_info.dart';
|
||||
import '../../compile.dart';
|
||||
import '../../convert.dart';
|
||||
import '../../globals.dart' as globals;
|
||||
import '../../project.dart';
|
||||
import '../build_system.dart';
|
||||
@@ -390,21 +389,10 @@ abstract class CopyFlutterAotBundle extends Target {
|
||||
}
|
||||
}
|
||||
|
||||
/// Dart defines are encoded inside [Environment] as a JSON array.
|
||||
/// Dart defines are encoded inside [Environment] as a comma-separated list.
|
||||
List<String> parseDartDefines(Environment environment) {
|
||||
if (!environment.defines.containsKey(kDartDefines) || environment.defines[kDartDefines].isEmpty) {
|
||||
return const <String>[];
|
||||
}
|
||||
|
||||
final String dartDefinesJson = environment.defines[kDartDefines];
|
||||
try {
|
||||
final List<Object> parsedDefines = jsonDecode(dartDefinesJson) as List<Object>;
|
||||
return parsedDefines.cast<String>();
|
||||
} on FormatException {
|
||||
throw Exception(
|
||||
'The value of -D$kDartDefines is not formatted correctly.\n'
|
||||
'The value must be a JSON-encoded list of strings but was:\n'
|
||||
'$dartDefinesJson'
|
||||
);
|
||||
}
|
||||
return environment.defines[kDartDefines].split(',');
|
||||
}
|
||||
|
||||
@@ -168,6 +168,8 @@ class Dart2JSTarget extends Target {
|
||||
'--libraries-spec=$specPath',
|
||||
'-o',
|
||||
outputKernel.path,
|
||||
for (final String dartDefine in dartDefines)
|
||||
'-D$dartDefine',
|
||||
'--packages=$packageFile',
|
||||
'--cfe-only',
|
||||
environment.buildDir.childFile('main.dart').path,
|
||||
|
||||
Reference in New Issue
Block a user