Unverified Commit 8230ef5e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "[web] Add `--local-web-sdk` flag and use precompiled platform kernels...

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

This reverts commit 0e9ee367.
parent 1a460cfb
......@@ -277,22 +277,22 @@ class AndroidGradleBuilder implements AndroidBuilder {
if (!buildInfo.androidGradleDaemon) {
command.add('--no-daemon');
}
final LocalEngineInfo? localEngineInfo = _artifacts.localEngineInfo;
if (localEngineInfo != null) {
if (_artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = _artifacts as LocalEngineArtifacts;
final Directory localEngineRepo = _getLocalEngineRepo(
engineOutPath: localEngineInfo.engineOutPath,
engineOutPath: localEngineArtifacts.engineOutPath,
androidBuildInfo: androidBuildInfo,
fileSystem: _fileSystem,
);
_logger.printTrace(
'Using local engine: ${localEngineInfo.engineOutPath}\n'
'Using local engine: ${localEngineArtifacts.engineOutPath}\n'
'Local Maven repo: ${localEngineRepo.path}'
);
command.add('-Plocal-engine-repo=${localEngineRepo.path}');
command.add('-Plocal-engine-build-mode=${buildInfo.modeName}');
command.add('-Plocal-engine-out=${localEngineInfo.engineOutPath}');
command.add('-Plocal-engine-out=${localEngineArtifacts.engineOutPath}');
command.add('-Ptarget-platform=${_getTargetPlatformByLocalEnginePath(
localEngineInfo.engineOutPath)}');
localEngineArtifacts.engineOutPath)}');
} else if (androidBuildInfo.targetArchs.isNotEmpty) {
final String targetPlatforms = androidBuildInfo
.targetArchs
......@@ -611,20 +611,20 @@ class AndroidGradleBuilder implements AndroidBuilder {
);
}
final LocalEngineInfo? localEngineInfo = _artifacts.localEngineInfo;
if (localEngineInfo != null) {
if (_artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = _artifacts as LocalEngineArtifacts;
final Directory localEngineRepo = _getLocalEngineRepo(
engineOutPath: localEngineInfo.engineOutPath,
engineOutPath: localEngineArtifacts.engineOutPath,
androidBuildInfo: androidBuildInfo,
fileSystem: _fileSystem,
);
_logger.printTrace(
'Using local engine: ${localEngineInfo.engineOutPath}\n'
'Using local engine: ${localEngineArtifacts.engineOutPath}\n'
'Local Maven repo: ${localEngineRepo.path}'
);
command.add('-Plocal-engine-repo=${localEngineRepo.path}');
command.add('-Plocal-engine-build-mode=${buildInfo.modeName}');
command.add('-Plocal-engine-out=${localEngineInfo.engineOutPath}');
command.add('-Plocal-engine-out=${localEngineArtifacts.engineOutPath}');
// Copy the local engine repo in the output directory.
try {
......@@ -639,7 +639,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
);
}
command.add('-Ptarget-platform=${_getTargetPlatformByLocalEnginePath(
localEngineInfo.engineOutPath)}');
localEngineArtifacts.engineOutPath)}');
} else if (androidBuildInfo.targetArchs.isNotEmpty) {
final String targetPlatforms = androidBuildInfo.targetArchs
.map(getPlatformNameForAndroidArch).join(',');
......
......@@ -310,12 +310,10 @@ class UserMessages {
'Unable to detect a Flutter engine build directory in $engineSourcePath.\n'
"Please ensure that $engineSourcePath is a Flutter engine 'src' directory and that "
"you have compiled the engine in that directory, which should produce an 'out' directory";
String get runnerLocalEngineOrWebSdkRequired =>
'You must specify --local-engine or --local-web-sdk if you are using a locally built engine or web sdk.';
String get runnerLocalEngineRequired =>
'You must specify --local-engine if you are using a locally built engine.';
String runnerNoEngineBuild(String engineBuildPath) =>
'No Flutter engine build found at $engineBuildPath.';
String runnerNoWebSdk(String webSdkPath) =>
'No Flutter web sdk found at $webSdkPath.';
String runnerWrongFlutterInstance(String flutterRoot, String currentDir) =>
"Warning: the 'flutter' tool you are currently running is not the one from the current directory:\n"
' running Flutter : $flutterRoot\n'
......
......@@ -13,7 +13,6 @@ import 'base/os.dart';
import 'base/utils.dart';
import 'convert.dart';
import 'globals.dart' as globals;
import 'web/compile.dart';
/// Whether icon font subsetting is enabled by default.
const bool kIconTreeShakerEnabledDefault = true;
......@@ -36,7 +35,6 @@ class BuildInfo {
List<String>? dartDefines,
this.bundleSkSLPath,
List<String>? dartExperiments,
this.webRenderer = WebRendererMode.autoDetect,
required this.treeShakeIcons,
this.performanceMeasurementFile,
this.dartDefineConfigJsonMap,
......@@ -126,9 +124,6 @@ class BuildInfo {
/// A list of Dart experiments.
final List<String> dartExperiments;
/// When compiling to web, which web renderer mode we are using (html, canvaskit, auto)
final WebRendererMode webRenderer;
/// The name of a file where flutter assemble will output performance
/// information in a JSON format.
///
......@@ -611,9 +606,8 @@ List<DarwinArch> defaultIOSArchsForEnvironment(
Artifacts artifacts,
) {
// Handle single-arch local engines.
final LocalEngineInfo? localEngineInfo = artifacts.localEngineInfo;
if (localEngineInfo != null) {
final String localEngineName = localEngineInfo.localEngineName;
if (artifacts is LocalEngineArtifacts) {
final String localEngineName = artifacts.localEngineName;
if (localEngineName.contains('_arm64')) {
return <DarwinArch>[ DarwinArch.arm64 ];
}
......@@ -634,9 +628,8 @@ List<DarwinArch> defaultIOSArchsForEnvironment(
/// The default set of macOS device architectures to build for.
List<DarwinArch> defaultMacOSArchsForEnvironment(Artifacts artifacts) {
// Handle single-arch local engines.
final LocalEngineInfo? localEngineInfo = artifacts.localEngineInfo;
if (localEngineInfo != null) {
if (localEngineInfo.localEngineName.contains('_arm64')) {
if (artifacts is LocalEngineArtifacts) {
if (artifacts.localEngineName.contains('_arm64')) {
return <DarwinArch>[ DarwinArch.arm64 ];
}
return <DarwinArch>[ DarwinArch.x86_64 ];
......@@ -862,17 +855,6 @@ HostPlatform getCurrentHostPlatform() {
return HostPlatform.linux_x64;
}
FileSystemEntity getWebPlatformBinariesDirectory(Artifacts artifacts, WebRendererMode webRenderer) {
switch (webRenderer) {
case WebRendererMode.autoDetect:
return artifacts.getHostArtifact(HostArtifact.webPlatformAutoDillDirectory);
case WebRendererMode.canvaskit:
return artifacts.getHostArtifact(HostArtifact.webPlatformCanvasKitDillDirectory);
case WebRendererMode.html:
return artifacts.getHostArtifact(HostArtifact.webPlatformHtmlDillDirectory);
}
}
/// Returns the top-level build output directory.
String getBuildDirectory([Config? config, FileSystem? fileSystem]) {
// TODO(johnmccutchan): Stop calling this function as part of setting
......
......@@ -18,7 +18,6 @@ import '../../dart/package_map.dart';
import '../../flutter_plugins.dart';
import '../../globals.dart' as globals;
import '../../project.dart';
import '../../web/compile.dart';
import '../../web/file_generators/flutter_js.dart' as flutter_js;
import '../../web/file_generators/flutter_service_worker_js.dart';
import '../../web/file_generators/main_dart.dart' as main_dart;
......@@ -136,9 +135,7 @@ class WebEntrypointTarget extends Target {
/// Compiles a web entry point with dart2js.
class Dart2JSTarget extends Target {
const Dart2JSTarget(this.webRenderer);
final WebRendererMode webRenderer;
const Dart2JSTarget();
@override
String get name => 'dart2js';
......@@ -186,12 +183,12 @@ class Dart2JSTarget extends Target {
final bool sourceMapsEnabled = environment.defines[kSourceMapsEnabled] == 'true';
final bool nativeNullAssertions = environment.defines[kNativeNullAssertions] == 'true';
final Artifacts artifacts = globals.artifacts!;
final String platformBinariesPath = getWebPlatformBinariesDirectory(artifacts, webRenderer).path;
final String librariesSpec = (artifacts.getHostArtifact(HostArtifact.flutterWebSdk) as Directory).childFile('libraries.json').path;
final List<String> sharedCommandOptions = <String>[
artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
'--disable-dart-dev',
artifacts.getHostArtifact(HostArtifact.dart2jsSnapshot).path,
'--platform-binaries=$platformBinariesPath',
'--libraries-spec=$librariesSpec',
...decodeCommaSeparated(environment.defines, kExtraFrontEndOptions),
if (nativeNullAssertions)
'--native-null-assertions',
......@@ -259,16 +256,14 @@ class Dart2JSTarget extends Target {
/// Unpacks the dart2js compilation and resources to a given output directory.
class WebReleaseBundle extends Target {
const WebReleaseBundle(this.webRenderer);
final WebRendererMode webRenderer;
const WebReleaseBundle();
@override
String get name => 'web_release_bundle';
@override
List<Target> get dependencies => <Target>[
Dart2JSTarget(webRenderer),
List<Target> get dependencies => const <Target>[
Dart2JSTarget(),
];
@override
......@@ -446,19 +441,18 @@ class WebBuiltInAssets extends Target {
/// Generate a service worker for a web target.
class WebServiceWorker extends Target {
const WebServiceWorker(this.fileSystem, this.cache, this.webRenderer);
const WebServiceWorker(this.fileSystem, this.cache);
final FileSystem fileSystem;
final Cache cache;
final WebRendererMode webRenderer;
@override
String get name => 'web_service_worker';
@override
List<Target> get dependencies => <Target>[
Dart2JSTarget(webRenderer),
WebReleaseBundle(webRenderer),
const Dart2JSTarget(),
const WebReleaseBundle(),
WebBuiltInAssets(fileSystem, cache),
];
......
......@@ -18,6 +18,7 @@ import '../build_system/targets/deferred_components.dart';
import '../build_system/targets/ios.dart';
import '../build_system/targets/linux.dart';
import '../build_system/targets/macos.dart';
import '../build_system/targets/web.dart';
import '../build_system/targets/windows.dart';
import '../cache.dart';
import '../convert.dart';
......@@ -47,6 +48,8 @@ List<Target> _kDefaultTargets = <Target>[
const ProfileBundleLinuxAssets(TargetPlatform.linux_arm64),
const ReleaseBundleLinuxAssets(TargetPlatform.linux_x64),
const ReleaseBundleLinuxAssets(TargetPlatform.linux_arm64),
// Web targets
WebServiceWorker(globals.fs, globals.cache),
const ReleaseAndroidApplication(),
// This is a one-off rule for bundle and aot compat.
const CopyFlutterBundle(),
......
......@@ -741,8 +741,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
{String? additionalSourceUri}
) async {
final String frontendServer = _artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk,
platform: (targetModel == TargetModel.dartdevc) ? TargetPlatform.web_javascript : null,
Artifact.frontendServerSnapshotForEngineDartSdk
);
final List<String> command = <String>[
_artifacts.getHostArtifact(HostArtifact.engineDartBinary).path,
......
......@@ -170,12 +170,13 @@ Future<List<String>> _xcodeBuildSettingsLines({
final String buildNumber = parsedBuildNumber(manifest: project.manifest, buildInfo: buildInfo) ?? '1';
xcodeBuildSettings.add('FLUTTER_BUILD_NUMBER=$buildNumber');
final LocalEngineInfo? localEngineInfo = globals.artifacts?.localEngineInfo;
if (localEngineInfo != null) {
final String engineOutPath = localEngineInfo.engineOutPath;
final Artifacts? artifacts = globals.artifacts;
if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts;
final String engineOutPath = localEngineArtifacts.engineOutPath;
xcodeBuildSettings.add('FLUTTER_ENGINE=${globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath))}');
final String localEngineName = localEngineInfo.localEngineName;
final String localEngineName = localEngineArtifacts.localEngineName;
xcodeBuildSettings.add('LOCAL_ENGINE=$localEngineName');
// Tell Xcode not to build universal binaries for local engines, which are
......
......@@ -53,11 +53,12 @@ Future<void> buildLinux(
// step.
final Map<String, String> environmentConfig = buildInfo.toEnvironmentConfig();
environmentConfig['FLUTTER_TARGET'] = target;
final LocalEngineInfo? localEngineInfo = globals.artifacts?.localEngineInfo;
if (localEngineInfo != null) {
final String engineOutPath = localEngineInfo.engineOutPath;
final Artifacts? artifacts = globals.artifacts;
if (artifacts is LocalEngineArtifacts) {
final LocalEngineArtifacts localEngineArtifacts = artifacts;
final String engineOutPath = localEngineArtifacts.engineOutPath;
environmentConfig['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
environmentConfig['LOCAL_ENGINE'] = localEngineInfo.localEngineName;
environmentConfig['LOCAL_ENGINE'] = localEngineArtifacts.localEngineName;
}
writeGeneratedCmakeConfig(Cache.flutterRoot!, linuxProject, buildInfo, environmentConfig);
......
......@@ -107,15 +107,15 @@ class FlutterDevice {
// used to file a bug, but the compiler will still start up correctly.
if (targetPlatform == TargetPlatform.web_javascript) {
// TODO(zanderso): consistently provide these flags across platforms.
late String platformDillName;
late HostArtifact platformDillArtifact;
final List<String> extraFrontEndOptions = List<String>.of(buildInfo.extraFrontEndOptions);
if (buildInfo.nullSafetyMode == NullSafetyMode.unsound) {
platformDillName = 'ddc_outline.dill';
platformDillArtifact = HostArtifact.webPlatformKernelDill;
if (!extraFrontEndOptions.contains('--no-sound-null-safety')) {
extraFrontEndOptions.add('--no-sound-null-safety');
}
} else if (buildInfo.nullSafetyMode == NullSafetyMode.sound) {
platformDillName = 'ddc_outline_sound.dill';
platformDillArtifact = HostArtifact.webPlatformSoundKernelDill;
if (!extraFrontEndOptions.contains('--sound-null-safety')) {
extraFrontEndOptions.add('--sound-null-safety');
}
......@@ -123,11 +123,6 @@ class FlutterDevice {
assert(false);
}
final String platformDillPath = globals.fs.path.join(
getWebPlatformBinariesDirectory(globals.artifacts!, buildInfo.webRenderer).path,
platformDillName
);
generator = ResidentCompiler(
globals.artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path,
buildMode: buildInfo.mode,
......@@ -144,7 +139,9 @@ class FlutterDevice {
assumeInitializeFromDillUpToDate: buildInfo.assumeInitializeFromDillUpToDate,
targetModel: TargetModel.dartdevc,
extraFrontEndOptions: extraFrontEndOptions,
platformDill: globals.fs.file(platformDillPath).absolute.uri.toString(),
platformDill: globals.fs.file(globals.artifacts!
.getHostArtifact(platformDillArtifact))
.absolute.uri.toString(),
dartDefines: buildInfo.dartDefines,
librariesSpec: globals.fs.file(globals.artifacts!
.getHostArtifact(HostArtifact.flutterWebLibrariesJson)).uri.toString(),
......
......@@ -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='))) {
......
......@@ -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?>{
......
......@@ -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) {
......
......@@ -50,29 +50,22 @@ class WebTestCompiler {
required BuildInfo buildInfo,
}) async {
LanguageVersion languageVersion = LanguageVersion(2, 8);
late final String platformDillName;
HostArtifact platformDillArtifact = HostArtifact.webPlatformSoundKernelDill;
// TODO(zanderso): to support autodetect this would need to partition the source code into a
// a sound and unsound set and perform separate compilations
// a sound and unsound set and perform separate compilations.
final List<String> extraFrontEndOptions = List<String>.of(buildInfo.extraFrontEndOptions);
if (buildInfo.nullSafetyMode == NullSafetyMode.unsound || buildInfo.nullSafetyMode == NullSafetyMode.autodetect) {
platformDillName = 'ddc_outline.dill';
platformDillArtifact = HostArtifact.webPlatformKernelDill;
if (!extraFrontEndOptions.contains('--no-sound-null-safety')) {
extraFrontEndOptions.add('--no-sound-null-safety');
}
} else if (buildInfo.nullSafetyMode == NullSafetyMode.sound) {
languageVersion = currentLanguageVersion(_fileSystem, Cache.flutterRoot!);
platformDillName = 'ddc_outline_sound.dill';
if (!extraFrontEndOptions.contains('--sound-null-safety')) {
extraFrontEndOptions.add('--sound-null-safety');
}
}
final String platformDillPath = _fileSystem.path.join(
getWebPlatformBinariesDirectory(_artifacts, buildInfo.webRenderer).path,
platformDillName
);
final Directory outputDirectory = _fileSystem.directory(testOutputDir)
..createSync(recursive: true);
final List<File> generatedFiles = <File>[];
......@@ -123,7 +116,9 @@ class WebTestCompiler {
initializeFromDill: cachedKernelPath,
targetModel: TargetModel.dartdevc,
extraFrontEndOptions: extraFrontEndOptions,
platformDill: platformDillPath,
platformDill: _artifacts
.getHostArtifact(platformDillArtifact)
.absolute.uri.toString(),
dartDefines: buildInfo.dartDefines,
librariesSpec: _artifacts.getHostArtifact(HostArtifact.flutterWebLibrariesJson).uri.toString(),
packagesPath: buildInfo.packagesPath,
......
......@@ -48,42 +48,40 @@ Future<void> buildWeb(
final Status status = globals.logger.startProgress('Compiling $target for the Web...');
final Stopwatch sw = Stopwatch()..start();
try {
final BuildResult result = await globals.buildSystem.build(
WebServiceWorker(globals.fs, globals.cache, buildInfo.webRenderer),
Environment(
projectDir: globals.fs.currentDirectory,
outputDir: outputDirectory,
buildDir: flutterProject.directory
.childDirectory('.dart_tool')
.childDirectory('flutter_build'),
defines: <String, String>{
kTargetFile: target,
kHasWebPlugins: hasWebPlugins.toString(),
kCspMode: csp.toString(),
if (baseHref != null)
kBaseHref : baseHref,
kSourceMapsEnabled: sourceMaps.toString(),
kNativeNullAssertions: nativeNullAssertions.toString(),
if (serviceWorkerStrategy != null)
kServiceWorkerStrategy: serviceWorkerStrategy,
if (dart2jsOptimization != null)
kDart2jsOptimization: dart2jsOptimization,
...buildInfo.toBuildSystemEnvironment(),
},
artifacts: globals.artifacts!,
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
cacheDir: globals.cache.getRoot(),
engineVersion: globals.artifacts!.isLocalEngine
? null
: globals.flutterVersion.engineRevision,
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
// Web uses a different Dart plugin registry.
// https://github.com/flutter/flutter/issues/80406
generateDartPluginRegistry: false,
final BuildResult result = await globals.buildSystem.build(WebServiceWorker(globals.fs, globals.cache), Environment(
projectDir: globals.fs.currentDirectory,
outputDir: outputDirectory,
buildDir: flutterProject.directory
.childDirectory('.dart_tool')
.childDirectory('flutter_build'),
defines: <String, String>{
kTargetFile: target,
kHasWebPlugins: hasWebPlugins.toString(),
kCspMode: csp.toString(),
if (baseHref != null)
kBaseHref : baseHref,
kSourceMapsEnabled: sourceMaps.toString(),
kNativeNullAssertions: nativeNullAssertions.toString(),
if (serviceWorkerStrategy != null)
kServiceWorkerStrategy: serviceWorkerStrategy,
if (dart2jsOptimization != null)
kDart2jsOptimization: dart2jsOptimization,
...buildInfo.toBuildSystemEnvironment(),
},
artifacts: globals.artifacts!,
fileSystem: globals.fs,
logger: globals.logger,
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
cacheDir: globals.cache.getRoot(),
engineVersion: globals.artifacts!.isLocalEngine
? null
: globals.flutterVersion.engineRevision,
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
// Web uses a different Dart plugin registry.
// https://github.com/flutter/flutter/issues/80406
generateDartPluginRegistry: false,
));
if (!result.success) {
for (final ExceptionMeasurement measurement in result.exceptions.values) {
......
......@@ -215,11 +215,11 @@ void _writeGeneratedFlutterConfig(
'FLUTTER_TARGET': target,
...buildInfo.toEnvironmentConfig(),
};
final LocalEngineInfo? localEngineInfo = globals.artifacts?.localEngineInfo;
if (localEngineInfo != null) {
final String engineOutPath = localEngineInfo.engineOutPath;
final Artifacts artifacts = globals.artifacts!;
if (artifacts is LocalEngineArtifacts) {
final String engineOutPath = artifacts.engineOutPath;
environment['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
environment['LOCAL_ENGINE'] = localEngineInfo.localEngineName;
environment['LOCAL_ENGINE'] = artifacts.localEngineName;
}
writeGeneratedCmakeConfig(Cache.flutterRoot!, windowsProject, buildInfo, environment);
}
......
......@@ -29,7 +29,6 @@ import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:flutter_tools/src/web/compile.dart';
import 'package:test/fake.dart';
import 'package:vm_service/vm_service.dart';
......@@ -674,35 +673,35 @@ void main() {
});
test('auto web-renderer with no dart-defines', () {
dartDefines = FlutterCommand.updateDartDefines(dartDefines, WebRendererMode.autoDetect);
dartDefines = FlutterCommand.updateDartDefines(dartDefines, 'auto');
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=true']);
});
test('canvaskit web-renderer with no dart-defines', () {
dartDefines = FlutterCommand.updateDartDefines(dartDefines, WebRendererMode.canvaskit);
dartDefines = FlutterCommand.updateDartDefines(dartDefines, 'canvaskit');
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=false','FLUTTER_WEB_USE_SKIA=true']);
});
test('html web-renderer with no dart-defines', () {
dartDefines = FlutterCommand.updateDartDefines(dartDefines, WebRendererMode.html);
dartDefines = FlutterCommand.updateDartDefines(dartDefines, 'html');
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=false','FLUTTER_WEB_USE_SKIA=false']);
});
test('auto web-renderer with existing dart-defines', () {
dartDefines = <String>['FLUTTER_WEB_USE_SKIA=false'];
dartDefines = FlutterCommand.updateDartDefines(dartDefines, WebRendererMode.autoDetect);
dartDefines = FlutterCommand.updateDartDefines(dartDefines, 'auto');
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=true']);
});
test('canvaskit web-renderer with no dart-defines', () {
dartDefines = <String>['FLUTTER_WEB_USE_SKIA=false'];
dartDefines = FlutterCommand.updateDartDefines(dartDefines, WebRendererMode.canvaskit);
dartDefines = FlutterCommand.updateDartDefines(dartDefines, 'canvaskit');
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=false','FLUTTER_WEB_USE_SKIA=true']);
});
test('html web-renderer with no dart-defines', () {
dartDefines = <String>['FLUTTER_WEB_USE_SKIA=true'];
dartDefines = FlutterCommand.updateDartDefines(dartDefines, WebRendererMode.html);
dartDefines = FlutterCommand.updateDartDefines(dartDefines, 'html');
expect(dartDefines, <String>['FLUTTER_WEB_AUTO_DETECT=false','FLUTTER_WEB_USE_SKIA=false']);
});
});
......
......@@ -199,7 +199,7 @@ void main() {
});
group('LocalEngineArtifacts', () {
late Artifacts artifacts;
late LocalEngineArtifacts artifacts;
late Cache cache;
late FileSystem fileSystem;
late Platform platform;
......@@ -217,9 +217,9 @@ void main() {
osUtils: FakeOperatingSystemUtils(),
artifacts: <ArtifactSet>[],
);
artifacts = CachedLocalEngineArtifacts(
artifacts = LocalEngineArtifacts(
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
engineOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
cache: cache,
fileSystem: fileSystem,
platform: platform,
......@@ -435,9 +435,9 @@ void main() {
});
testWithoutContext('Looks up dart.exe on windows platforms', () async {
artifacts = CachedLocalEngineArtifacts(
artifacts = LocalEngineArtifacts(
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
engineOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
cache: cache,
fileSystem: fileSystem,
platform: FakePlatform(operatingSystem: 'windows'),
......@@ -473,9 +473,9 @@ void main() {
});
testWithoutContext('Finds dart-sdk in windows prebuilts', () async {
artifacts = CachedLocalEngineArtifacts(
artifacts = LocalEngineArtifacts(
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
engineOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
cache: cache,
fileSystem: fileSystem,
platform: FakePlatform(operatingSystem: 'windows'),
......@@ -498,9 +498,9 @@ void main() {
});
testWithoutContext('Finds dart-sdk in macos prebuilts', () async {
artifacts = CachedLocalEngineArtifacts(
artifacts = LocalEngineArtifacts(
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
engineOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
cache: cache,
fileSystem: fileSystem,
platform: FakePlatform(operatingSystem: 'macos'),
......
......@@ -33,7 +33,6 @@ import 'package:flutter_tools/src/run_cold.dart';
import 'package:flutter_tools/src/run_hot.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:flutter_tools/src/web/compile.dart' show WebRendererMode;
import 'package:package_config/package_config.dart';
import 'package:test/fake.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
......@@ -1921,28 +1920,6 @@ flutter:
expect(fakeVmServiceHost?.hasRemainingExpectations, false);
}));
testUsingContext('FlutterDevice uses canvaskit platform dill when canvaskit mode is selected', () async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice(targetPlatform: TargetPlatform.web_javascript);
final DefaultResidentCompiler? residentCompiler = (await FlutterDevice.create(
device,
buildInfo: const BuildInfo(
BuildMode.debug,
'',
treeShakeIcons: false,
webRenderer: WebRendererMode.canvaskit,
),
target: null,
platform: FakePlatform(),
)).generator as DefaultResidentCompiler?;
expect(residentCompiler!.platformDill, 'file:///HostArtifact.webPlatformCanvasKitDillDirectory/ddc_outline_sound.dill');
}, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('FlutterDevice uses dartdevc configuration when targeting web', () async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice(targetPlatform: TargetPlatform.web_javascript);
......@@ -1966,7 +1943,7 @@ flutter:
expect(residentCompiler.targetModel, TargetModel.dartdevc);
expect(residentCompiler.sdkRoot,
'${globals.artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path}/');
expect(residentCompiler.platformDill, 'file:///HostArtifact.webPlatformAutoDillDirectory/ddc_outline.dill');
expect(residentCompiler.platformDill, 'file:///HostArtifact.webPlatformKernelDill');
}, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(),
FileSystem: () => MemoryFileSystem.test(),
......@@ -1997,7 +1974,7 @@ flutter:
expect(residentCompiler.targetModel, TargetModel.dartdevc);
expect(residentCompiler.sdkRoot,
'${globals.artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path}/');
expect(residentCompiler.platformDill, 'file:///HostArtifact.webPlatformAutoDillDirectory/ddc_outline_sound.dill');
expect(residentCompiler.platformDill, 'file:///HostArtifact.webPlatformSoundKernelDill');
}, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(),
FileSystem: () => MemoryFileSystem.test(),
......
......@@ -43,7 +43,7 @@ void main() {
);
expect(
await localEngineLocator.findEnginePath(localEngine: 'ios_debug'),
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
matchesEngineBuildPaths(
hostEngine: '/arbitrary/engine/src/out/host_debug',
targetEngine: '/arbitrary/engine/src/out/ios_debug',
......@@ -58,7 +58,7 @@ void main() {
.writeAsStringSync('sky_engine:file:///symlink/src/out/ios_debug/gen/dart-pkg/sky_engine/lib/');
expect(
await localEngineLocator.findEnginePath(localEngine: 'ios_debug'),
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
matchesEngineBuildPaths(
hostEngine: '/symlink/src/out/host_debug',
targetEngine: '/symlink/src/out/ios_debug',
......@@ -84,7 +84,7 @@ void main() {
);
expect(
await localEngineLocator.findEnginePath(engineSourcePath: '$kArbitraryEngineRoot/src', localEngine: 'ios_debug'),
await localEngineLocator.findEnginePath('$kArbitraryEngineRoot/src', 'ios_debug', null),
matchesEngineBuildPaths(
hostEngine: '/arbitrary/engine/src/out/host_debug',
targetEngine: '/arbitrary/engine/src/out/ios_debug',
......@@ -111,7 +111,7 @@ void main() {
);
expect(
await localEngineLocator.findEnginePath(localEngine: localEngine.path),
await localEngineLocator.findEnginePath(null, localEngine.path, null),
matchesEngineBuildPaths(
hostEngine: '/arbitrary/engine/src/out/host_debug',
targetEngine: '/arbitrary/engine/src/out/ios_debug',
......@@ -137,7 +137,7 @@ void main() {
);
expect(
await localEngineLocator.findEnginePath(localEngine: localEngine.path),
await localEngineLocator.findEnginePath(null, localEngine.path, null),
matchesEngineBuildPaths(
hostEngine: '/arbitrary/engine/src/out/host_debug',
targetEngine: '/arbitrary/engine/src/out/host_debug',
......@@ -161,7 +161,7 @@ void main() {
);
await expectToolExitLater(
localEngineLocator.findEnginePath(localEngine: localEngine.path),
localEngineLocator.findEnginePath(null, localEngine.path, null),
contains('No Flutter engine build found at /arbitrary/engine/src/out/host_debug'),
);
});
......@@ -190,7 +190,7 @@ void main() {
);
expect(
await localEngineLocator.findEnginePath(localEngine: 'ios_debug'),
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
matchesEngineBuildPaths(
hostEngine: 'flutter/engine/src/out/host_debug',
targetEngine: 'flutter/engine/src/out/ios_debug',
......@@ -212,7 +212,7 @@ void main() {
);
await expectToolExitLater(
localEngineLocator.findEnginePath(localEngine: '/path/to/nothing'),
localEngineLocator.findEnginePath(null, '/path/to/nothing', null),
contains('Unable to detect local Flutter engine src directory'),
);
});
......@@ -236,7 +236,7 @@ void main() {
);
expect(
await localWasmEngineLocator.findEnginePath(localEngine: localWasmEngine.path),
await localWasmEngineLocator.findEnginePath(null, localWasmEngine.path, null),
matchesEngineBuildPaths(
hostEngine: '/arbitrary/engine/src/out/wasm_whatever',
targetEngine: '/arbitrary/engine/src/out/wasm_whatever',
......@@ -254,7 +254,7 @@ void main() {
);
expect(
await localWebEngineLocator.findEnginePath(localEngine: localWebEngine.path),
await localWebEngineLocator.findEnginePath(null, localWebEngine.path, null),
matchesEngineBuildPaths(
hostEngine: '/arbitrary/engine/src/out/web_whatever',
targetEngine: '/arbitrary/engine/src/out/web_whatever',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment