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 {
/// The location of file generators.
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
......@@ -210,7 +207,6 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [ BuildMod
case Artifact.constFinder:
return 'const_finder.dart.snapshot';
case Artifact.flutterToolsFileGenerators:
case Artifact.canvasKitPath:
return '';
}
}
......@@ -535,7 +531,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators:
case Artifact.canvasKitPath:
return _getHostArtifactPath(artifact, platform, mode);
}
}
......@@ -574,7 +569,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators:
case Artifact.canvasKitPath:
return _getHostArtifactPath(artifact, platform, mode);
}
}
......@@ -625,7 +619,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators:
case Artifact.canvasKitPath:
return _getHostArtifactPath(artifact, platform, mode);
}
}
......@@ -703,8 +696,6 @@ class CachedArtifacts implements Artifacts {
throw StateError('Artifact $artifact not available for platform $platform.');
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
case Artifact.canvasKitPath:
return _fileSystem.path.join(_cache.getWebSdkDirectory().path, 'canvaskit');
}
}
......@@ -974,8 +965,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
return _fileSystem.path.join(_getDartSdkPath(), 'bin', 'snapshots', artifactFileName);
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
case Artifact.canvasKitPath:
return _fileSystem.path.join(localEngineInfo.engineOutPath, 'canvaskit');
}
}
......@@ -1103,8 +1092,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
_getDartSdkPath(), 'bin', 'snapshots',
_artifactToFileName(artifact, _platform, mode),
);
case Artifact.canvasKitPath:
return _fileSystem.path.join(_webSdkPath, 'canvaskit');
case Artifact.genSnapshot:
case Artifact.flutterTester:
case Artifact.flutterFramework:
......
......@@ -516,20 +516,31 @@ class WebBuiltInAssets extends Target {
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
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
Future<void> build(Environment environment) async {
final Directory canvasKitDirectory = globals.fs.directory(
globals.artifacts!.getArtifactPath(
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);
for (final File file in _canvasKitFiles) {
final String relativePath = _filePathRelativeToCanvasKitDirectory(file);
final String targetPath = fileSystem.path.join(environment.outputDir.path, 'canvaskit', relativePath);
file.copySync(targetPath);
}
......
......@@ -420,12 +420,13 @@ class WebAssetServer implements AssetReader {
File file = _resolveDartFile(requestPath);
if (!file.existsSync() && requestPath.startsWith('canvaskit/')) {
final String canvasKitPath = globals.artifacts!.getArtifactPath(
Artifact.canvasKitPath,
platform: TargetPlatform.web_javascript,
final Directory canvasKitDirectory = globals.fs.directory(
globals.fs.path.join(
globals.artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path,
'canvaskit',
)
);
final Uri potential = globals.fs
.directory(canvasKitPath)
final Uri potential = canvasKitDirectory
.uri
.resolve(requestPath.replaceFirst('canvaskit/', ''));
file = globals.fs.file(potential);
......
......@@ -221,9 +221,9 @@ class FlutterWebPlatform extends PlatformPlugin {
));
File _canvasKitFile(String relativePath) {
final String canvasKitPath = _artifacts!.getArtifactPath(
Artifact.canvasKitPath,
platform: TargetPlatform.web_javascript,
final String canvasKitPath = _fileSystem.path.join(
_artifacts!.getHostArtifact(HostArtifact.flutterWebSdk).path,
'canvaskit',
);
final File canvasKitFile = _fileSystem.file(_fileSystem.path.join(
canvasKitPath,
......
......@@ -145,10 +145,6 @@ void main() {
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
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', () {
......@@ -346,10 +342,6 @@ void main() {
artifacts.getHostArtifact(HostArtifact.libtessellator).path,
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', () {
......
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