Revert "[web] Add --local-web-sdk flag and use precompiled platform kernels for dart2js and ddc (#114639)" (#115242)

This reverts commit 0e9ee3679c.
This commit is contained in:
Jonah Williams
2022-11-13 12:23:26 -08:00
committed by GitHub
parent 1a460cfb93
commit 8230ef5e85
21 changed files with 234 additions and 606 deletions

View File

@@ -29,7 +29,6 @@ import '../features.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import '../web/compile.dart';
import 'flutter_command_runner.dart';
export '../cache.dart' show DevelopmentArtifact;
@@ -123,7 +122,6 @@ class FlutterOptions {
static const String kFatalWarnings = 'fatal-warnings';
static const String kUseApplicationBinary = 'use-application-binary';
static const String kWebBrowserFlag = 'web-browser-flag';
static const String kWebRendererFlag = 'web-renderer';
}
/// flutter command categories for usage.
@@ -151,25 +149,17 @@ abstract class FlutterCommand extends Command<void> {
/// The flag name for whether or not to use ipv6.
static const String ipv6Flag = 'ipv6';
/// Maps command line web renderer strings to the corresponding web renderer mode
static const Map<String, WebRendererMode> _webRendererModeMap =
<String, WebRendererMode> {
'auto': WebRendererMode.autoDetect,
'canvaskit': WebRendererMode.canvaskit,
'html': WebRendererMode.html,
};
/// The map used to convert web renderer mode to a List of dart-defines.
static const Map<WebRendererMode, Iterable<String>> _webRendererDartDefines =
<WebRendererMode, Iterable<String>> {
WebRendererMode.autoDetect: <String>[
/// The map used to convert web-renderer option to a List of dart-defines.
static const Map<String, Iterable<String>> _webRendererDartDefines =
<String, Iterable<String>> {
'auto': <String>[
'FLUTTER_WEB_AUTO_DETECT=true',
],
WebRendererMode.canvaskit: <String>[
'canvaskit': <String>[
'FLUTTER_WEB_AUTO_DETECT=false',
'FLUTTER_WEB_USE_SKIA=true',
],
WebRendererMode.html: <String>[
'html': <String>[
'FLUTTER_WEB_AUTO_DETECT=false',
'FLUTTER_WEB_USE_SKIA=false',
],
@@ -630,8 +620,7 @@ abstract class FlutterCommand extends Command<void> {
}
void usesWebRendererOption() {
argParser.addOption(
FlutterOptions.kWebRendererFlag,
argParser.addOption('web-renderer',
defaultsTo: 'auto',
allowed: <String>['auto', 'canvaskit', 'html'],
help: 'The renderer implementation to use when building for the web.',
@@ -1155,13 +1144,8 @@ abstract class FlutterCommand extends Command<void> {
? stringsArg(FlutterOptions.kDartDefinesOption)
: <String>[];
WebRendererMode webRenderer = WebRendererMode.autoDetect;
if (argParser.options.containsKey(FlutterOptions.kWebRendererFlag)) {
final WebRendererMode? mappedMode = _webRendererModeMap[stringArgDeprecated(FlutterOptions.kWebRendererFlag)!];
if (mappedMode != null) {
webRenderer = mappedMode;
}
dartDefines = updateDartDefines(dartDefines, webRenderer);
if (argParser.options.containsKey('web-renderer')) {
dartDefines = updateDartDefines(dartDefines, stringArgDeprecated('web-renderer')!);
}
Map<String, Object>? defineConfigJsonMap;
@@ -1208,7 +1192,6 @@ abstract class FlutterCommand extends Command<void> {
dartDefines: dartDefines,
bundleSkSLPath: bundleSkSLPath,
dartExperiments: experiments,
webRenderer: webRenderer,
performanceMeasurementFile: performanceMeasurementFile,
dartDefineConfigJsonMap: defineConfigJsonMap,
packagesPath: packagesPath ?? globals.fs.path.absolute('.dart_tool', 'package_config.json'),
@@ -1299,7 +1282,7 @@ abstract class FlutterCommand extends Command<void> {
/// Updates dart-defines based on [webRenderer].
@visibleForTesting
static List<String> updateDartDefines(List<String> dartDefines, WebRendererMode webRenderer) {
static List<String> updateDartDefines(List<String> dartDefines, String webRenderer) {
final Set<String> dartDefinesSet = dartDefines.toSet();
if (!dartDefines.any((String d) => d.startsWith('FLUTTER_WEB_AUTO_DETECT='))
&& dartDefines.any((String d) => d.startsWith('FLUTTER_WEB_USE_SKIA='))) {

View File

@@ -96,13 +96,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
hide: !verboseHelp,
help: 'Name of a build output within the engine out directory, if you are building Flutter locally.\n'
'Use this to select a specific version of the engine if you have built multiple engine targets.\n'
'This path is relative to "--local-engine-src-path" (see above).');
argParser.addOption('local-web-sdk',
hide: !verboseHelp,
help: 'Name of a build output within the engine out directory, if you are building Flutter locally.\n'
'Use this to select a specific version of the web sdk if you have built multiple engine targets.\n'
'This path is relative to "--local-engine-src-path" (see above).');
'This path is relative to "--local-engine-src-path" or "--local-engine-src-out" (q.v.).');
if (verboseHelp) {
argParser.addSeparator('Options for testing the "flutter" tool itself:');
@@ -222,10 +216,9 @@ class FlutterCommandRunner extends CommandRunner<void> {
// Set up the tooling configuration.
final EngineBuildPaths? engineBuildPaths = await globals.localEngineLocator?.findEnginePath(
engineSourcePath: topLevelResults['local-engine-src-path'] as String?,
localEngine: topLevelResults['local-engine'] as String?,
localWebSdk: topLevelResults['local-web-sdk'] as String?,
packagePath: topLevelResults['packages'] as String?,
topLevelResults['local-engine-src-path'] as String?,
topLevelResults['local-engine'] as String?,
topLevelResults['packages'] as String?,
);
if (engineBuildPaths != null) {
contextOverrides.addAll(<Type, Object?>{

View File

@@ -46,23 +46,17 @@ class LocalEngineLocator {
final UserMessages _userMessages;
/// Returns the engine build path of a local engine if one is located, otherwise `null`.
Future<EngineBuildPaths?> findEnginePath({String? engineSourcePath, String? localEngine, String? localWebSdk, String? packagePath}) async {
Future<EngineBuildPaths?> findEnginePath(String? engineSourcePath, String? localEngine, String? packagePath) async {
engineSourcePath ??= _platform.environment[kFlutterEngineEnvironmentVariableName];
if (engineSourcePath == null) {
if (engineSourcePath == null && localEngine != null) {
try {
if (localEngine != null) {
engineSourcePath = _findEngineSourceByBuildPath(localEngine);
}
if (localWebSdk != null) {
engineSourcePath ??= _findEngineSourceByBuildPath(localWebSdk);
}
engineSourcePath = _findEngineSourceByLocalEngine(localEngine);
engineSourcePath ??= await _findEngineSourceByPackageConfig(packagePath);
} on FileSystemException catch (e) {
_logger.printTrace('Local engine auto-detection file exception: $e');
engineSourcePath = null;
}
// If engineSourcePath is still not set, try to determine it by flutter root.
engineSourcePath ??= _tryEnginePath(
_fileSystem.path.join(_fileSystem.directory(_flutterRoot).parent.path, 'engine', 'src'),
@@ -78,9 +72,9 @@ class LocalEngineLocator {
if (engineSourcePath != null) {
_logger.printTrace('Local engine source at $engineSourcePath');
return _findEngineBuildPath(localEngine, localWebSdk, engineSourcePath);
return _findEngineBuildPath(localEngine, engineSourcePath);
}
if (localEngine != null || localWebSdk != null) {
if (localEngine != null) {
throwToolExit(
_userMessages.runnerNoEngineSrcDir(
kFlutterEnginePackageName,
@@ -92,15 +86,15 @@ class LocalEngineLocator {
return null;
}
String? _findEngineSourceByBuildPath(String buildPath) {
String? _findEngineSourceByLocalEngine(String localEngine) {
// When the local engine is an absolute path to a variant inside the
// out directory, parse the engine source.
// --local-engine /path/to/cache/builder/src/out/host_debug_unopt
if (_fileSystem.path.isAbsolute(buildPath)) {
final Directory buildDirectory = _fileSystem.directory(buildPath);
final Directory outDirectory = buildDirectory.parent;
if (_fileSystem.path.isAbsolute(localEngine)) {
final Directory localEngineDirectory = _fileSystem.directory(localEngine);
final Directory outDirectory = localEngineDirectory.parent;
final Directory srcDirectory = outDirectory.parent;
if (buildDirectory.existsSync() && outDirectory.basename == 'out' && srcDirectory.basename == 'src') {
if (localEngineDirectory.existsSync() && outDirectory.basename == 'out' && srcDirectory.basename == 'src') {
_logger.printTrace('Parsed engine source from local engine as ${srcDirectory.path}.');
return srcDirectory.path;
}
@@ -171,38 +165,26 @@ class LocalEngineLocator {
return 'host_$tmpBasename';
}
EngineBuildPaths _findEngineBuildPath(String? localEngine, String? localWebSdk, String enginePath) {
if (localEngine == null && localWebSdk == null) {
throwToolExit(_userMessages.runnerLocalEngineOrWebSdkRequired, exitCode: 2);
EngineBuildPaths _findEngineBuildPath(String? localEngine, String enginePath) {
if (localEngine == null) {
throwToolExit(_userMessages.runnerLocalEngineRequired, exitCode: 2);
}
String? engineBuildPath;
String? engineHostBuildPath;
if (localEngine != null) {
engineBuildPath = _fileSystem.path.normalize(_fileSystem.path.join(enginePath, 'out', localEngine));
if (!_fileSystem.isDirectorySync(engineBuildPath)) {
throwToolExit(_userMessages.runnerNoEngineBuild(engineBuildPath), exitCode: 2);
}
final String basename = _fileSystem.path.basename(engineBuildPath);
final String hostBasename = _getHostEngineBasename(basename);
engineHostBuildPath = _fileSystem.path.normalize(
_fileSystem.path.join(_fileSystem.path.dirname(engineBuildPath), hostBasename),
);
if (!_fileSystem.isDirectorySync(engineHostBuildPath)) {
throwToolExit(_userMessages.runnerNoEngineBuild(engineHostBuildPath), exitCode: 2);
}
final String engineBuildPath = _fileSystem.path.normalize(_fileSystem.path.join(enginePath, 'out', localEngine));
if (!_fileSystem.isDirectorySync(engineBuildPath)) {
throwToolExit(_userMessages.runnerNoEngineBuild(engineBuildPath), exitCode: 2);
}
String? webSdkPath;
if (localWebSdk != null) {
webSdkPath = _fileSystem.path.normalize(_fileSystem.path.join(enginePath, 'out', localWebSdk));
if (!_fileSystem.isDirectorySync(webSdkPath)) {
throwToolExit(_userMessages.runnerNoWebSdk(webSdkPath), exitCode: 2);
}
final String basename = _fileSystem.path.basename(engineBuildPath);
final String hostBasename = _getHostEngineBasename(basename);
final String engineHostBuildPath = _fileSystem.path.normalize(
_fileSystem.path.join(_fileSystem.path.dirname(engineBuildPath), hostBasename),
);
if (!_fileSystem.isDirectorySync(engineHostBuildPath)) {
throwToolExit(_userMessages.runnerNoEngineBuild(engineHostBuildPath), exitCode: 2);
}
return EngineBuildPaths(targetEngine: engineBuildPath, webSdk: webSdkPath, hostEngine: engineHostBuildPath);
return EngineBuildPaths(targetEngine: engineBuildPath, hostEngine: engineHostBuildPath);
}
String? _tryEnginePath(String enginePath) {