Unverified Commit 37d4e7d6 authored by Jackson Gardner's avatar Jackson Gardner Committed by GitHub

Always use the canvaskit path from the web sdk. (#123915)

Always use the canvaskit path from the web sdk.
parent 842873c2
...@@ -66,9 +66,6 @@ enum Artifact { ...@@ -66,9 +66,6 @@ enum Artifact {
/// The location of file generators. /// The location of file generators.
flutterToolsFileGenerators, flutterToolsFileGenerators,
/// The path to the CanvasKit files built by the flutter engine.
canvasKitPath,
} }
/// A subset of [Artifact]s that are platform and build mode independent /// A subset of [Artifact]s that are platform and build mode independent
...@@ -210,7 +207,6 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod ...@@ -210,7 +207,6 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod
case Artifact.constFinder: case Artifact.constFinder:
return 'const_finder.dart.snapshot'; return 'const_finder.dart.snapshot';
case Artifact.flutterToolsFileGenerators: case Artifact.flutterToolsFileGenerators:
case Artifact.canvasKitPath:
return ''; return '';
} }
} }
...@@ -535,7 +531,6 @@ class CachedArtifacts implements Artifacts { ...@@ -535,7 +531,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper: case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath: case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators: case Artifact.flutterToolsFileGenerators:
case Artifact.canvasKitPath:
return _getHostArtifactPath(artifact, platform, mode); return _getHostArtifactPath(artifact, platform, mode);
} }
} }
...@@ -574,7 +569,6 @@ class CachedArtifacts implements Artifacts { ...@@ -574,7 +569,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper: case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath: case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators: case Artifact.flutterToolsFileGenerators:
case Artifact.canvasKitPath:
return _getHostArtifactPath(artifact, platform, mode); return _getHostArtifactPath(artifact, platform, mode);
} }
} }
...@@ -625,7 +619,6 @@ class CachedArtifacts implements Artifacts { ...@@ -625,7 +619,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper: case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath: case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators: case Artifact.flutterToolsFileGenerators:
case Artifact.canvasKitPath:
return _getHostArtifactPath(artifact, platform, mode); return _getHostArtifactPath(artifact, platform, mode);
} }
} }
...@@ -703,8 +696,6 @@ class CachedArtifacts implements Artifacts { ...@@ -703,8 +696,6 @@ class CachedArtifacts implements Artifacts {
throw StateError('Artifact $artifact not available for platform $platform.'); throw StateError('Artifact $artifact not available for platform $platform.');
case Artifact.flutterToolsFileGenerators: case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath(); return _getFileGeneratorsPath();
case Artifact.canvasKitPath:
return _fileSystem.path.join(_cache.getWebSdkDirectory().path, 'canvaskit');
} }
} }
...@@ -974,8 +965,6 @@ class CachedLocalEngineArtifacts implements Artifacts { ...@@ -974,8 +965,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
return _fileSystem.path.join(_getDartSdkPath(), 'bin', 'snapshots', artifactFileName); return _fileSystem.path.join(_getDartSdkPath(), 'bin', 'snapshots', artifactFileName);
case Artifact.flutterToolsFileGenerators: case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath(); return _getFileGeneratorsPath();
case Artifact.canvasKitPath:
return _fileSystem.path.join(localEngineInfo.engineOutPath, 'canvaskit');
} }
} }
...@@ -1103,8 +1092,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts { ...@@ -1103,8 +1092,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
_getDartSdkPath(), 'bin', 'snapshots', _getDartSdkPath(), 'bin', 'snapshots',
_artifactToFileName(artifact, _platform, mode), _artifactToFileName(artifact, _platform, mode),
); );
case Artifact.canvasKitPath:
return _fileSystem.path.join(_webSdkPath, 'canvaskit');
case Artifact.genSnapshot: case Artifact.genSnapshot:
case Artifact.flutterTester: case Artifact.flutterTester:
case Artifact.flutterFramework: case Artifact.flutterFramework:
......
...@@ -516,20 +516,31 @@ class WebBuiltInAssets extends Target { ...@@ -516,20 +516,31 @@ class WebBuiltInAssets extends Target {
Source.hostArtifact(HostArtifact.flutterWebSdk), Source.hostArtifact(HostArtifact.flutterWebSdk),
]; ];
Directory get _canvasKitDirectory =>
globals.fs.directory(
fileSystem.path.join(
globals.artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path,
'canvaskit',
)
);
List<File> get _canvasKitFiles => _canvasKitDirectory.listSync(recursive: true).whereType<File>().toList();
String _filePathRelativeToCanvasKitDirectory(File file) =>
fileSystem.path.relative(file.path, from: _canvasKitDirectory.path);
@override @override
List<Source> get outputs => const <Source>[]; List<Source> get outputs => <Source>[
if (isWasm) const Source.pattern('{BUILD_DIR}/main.dart.js'),
const Source.pattern('{BUILD_DIR}/flutter.js'),
for (final File file in _canvasKitFiles)
Source.pattern('{BUILD_DIR}/canvaskit/${_filePathRelativeToCanvasKitDirectory(file)}'),
];
@override @override
Future<void> build(Environment environment) async { Future<void> build(Environment environment) async {
final Directory canvasKitDirectory = globals.fs.directory( for (final File file in _canvasKitFiles) {
globals.artifacts!.getArtifactPath( final String relativePath = _filePathRelativeToCanvasKitDirectory(file);
Artifact.canvasKitPath,
platform: TargetPlatform.web_javascript,
),
);
for (final File file in canvasKitDirectory.listSync(recursive: true).whereType<File>()) {
final String relativePath = fileSystem.path.relative(file.path, from: canvasKitDirectory.path);
final String targetPath = fileSystem.path.join(environment.outputDir.path, 'canvaskit', relativePath); final String targetPath = fileSystem.path.join(environment.outputDir.path, 'canvaskit', relativePath);
file.copySync(targetPath); file.copySync(targetPath);
} }
......
...@@ -420,12 +420,13 @@ class WebAssetServer implements AssetReader { ...@@ -420,12 +420,13 @@ class WebAssetServer implements AssetReader {
File file = _resolveDartFile(requestPath); File file = _resolveDartFile(requestPath);
if (!file.existsSync() && requestPath.startsWith('canvaskit/')) { if (!file.existsSync() && requestPath.startsWith('canvaskit/')) {
final String canvasKitPath = globals.artifacts!.getArtifactPath( final Directory canvasKitDirectory = globals.fs.directory(
Artifact.canvasKitPath, globals.fs.path.join(
platform: TargetPlatform.web_javascript, globals.artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path,
'canvaskit',
)
); );
final Uri potential = globals.fs final Uri potential = canvasKitDirectory
.directory(canvasKitPath)
.uri .uri
.resolve(requestPath.replaceFirst('canvaskit/', '')); .resolve(requestPath.replaceFirst('canvaskit/', ''));
file = globals.fs.file(potential); file = globals.fs.file(potential);
......
...@@ -221,9 +221,9 @@ class FlutterWebPlatform extends PlatformPlugin { ...@@ -221,9 +221,9 @@ class FlutterWebPlatform extends PlatformPlugin {
)); ));
File _canvasKitFile(String relativePath) { File _canvasKitFile(String relativePath) {
final String canvasKitPath = _artifacts!.getArtifactPath( final String canvasKitPath = _fileSystem.path.join(
Artifact.canvasKitPath, _artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path,
platform: TargetPlatform.web_javascript, 'canvaskit',
); );
final File canvasKitFile = _fileSystem.file(_fileSystem.path.join( final File canvasKitFile = _fileSystem.file(_fileSystem.path.join(
canvasKitPath, canvasKitPath,
......
...@@ -145,10 +145,6 @@ void main() { ...@@ -145,10 +145,6 @@ void main() {
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
fileSystem.path.join('root', 'bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'frontend_server.dart.snapshot') fileSystem.path.join('root', 'bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'frontend_server.dart.snapshot')
); );
expect(
artifacts.getArtifactPath(Artifact.canvasKitPath),
fileSystem.path.join('root', 'bin', 'cache', 'flutter_web_sdk', 'canvaskit'),
);
}); });
testWithoutContext('precompiled web artifact paths are correct', () { testWithoutContext('precompiled web artifact paths are correct', () {
...@@ -346,10 +342,6 @@ void main() { ...@@ -346,10 +342,6 @@ void main() {
artifacts.getHostArtifact(HostArtifact.libtessellator).path, artifacts.getHostArtifact(HostArtifact.libtessellator).path,
fileSystem.path.join('/out', 'host_debug_unopt', 'libtessellator.so'), fileSystem.path.join('/out', 'host_debug_unopt', 'libtessellator.so'),
); );
expect(
artifacts.getArtifactPath(Artifact.canvasKitPath, platform: TargetPlatform.web_javascript),
fileSystem.path.join('/out', 'wasm_release', 'canvaskit'),
);
}); });
testWithoutContext('falls back to bundled impeller artifacts if the files do not exist in the local engine', () { testWithoutContext('falls back to bundled impeller artifacts if the files do not exist in the local engine', () {
......
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