Unverified Commit 515027a9 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] allow configuring libraries spec path for the web compilation (#51590)

parent 47911e85
...@@ -40,6 +40,7 @@ enum Artifact { ...@@ -40,6 +40,7 @@ enum Artifact {
kernelWorkerSnapshot, kernelWorkerSnapshot,
/// The root of the web implementation of the dart SDK. /// The root of the web implementation of the dart SDK.
flutterWebSdk, flutterWebSdk,
flutterWebLibrariesJson,
/// The summary dill for the dartdevc target. /// The summary dill for the dartdevc target.
webPlatformKernelDill, webPlatformKernelDill,
iosDeploy, iosDeploy,
...@@ -134,6 +135,8 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo ...@@ -134,6 +135,8 @@ String _artifactToFileName(Artifact artifact, [ TargetPlatform platform, BuildMo
return 'font-subset$exe'; return 'font-subset$exe';
case Artifact.constFinder: case Artifact.constFinder:
return 'const_finder.dart.snapshot'; return 'const_finder.dart.snapshot';
case Artifact.flutterWebLibrariesJson:
return 'libraries.json';
} }
assert(false, 'Invalid artifact $artifact.'); assert(false, 'Invalid artifact $artifact.');
return null; return null;
...@@ -333,6 +336,8 @@ class CachedArtifacts extends Artifacts { ...@@ -333,6 +336,8 @@ class CachedArtifacts extends Artifacts {
return _getFlutterPatchedSdkPath(mode); return _getFlutterPatchedSdkPath(mode);
case Artifact.flutterWebSdk: case Artifact.flutterWebSdk:
return _getFlutterWebSdkPath(); return _getFlutterWebSdkPath();
case Artifact.flutterWebLibrariesJson:
return _fileSystem.path.join(_getFlutterWebSdkPath(), _artifactToFileName(artifact));
case Artifact.webPlatformKernelDill: case Artifact.webPlatformKernelDill:
return _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', _artifactToFileName(artifact)); return _fileSystem.path.join(_getFlutterWebSdkPath(), 'kernel', _artifactToFileName(artifact));
case Artifact.dart2jsSnapshot: case Artifact.dart2jsSnapshot:
...@@ -536,6 +541,8 @@ class LocalEngineArtifacts extends Artifacts { ...@@ -536,6 +541,8 @@ class LocalEngineArtifacts extends Artifacts {
return _fileSystem.path.join(_hostEngineOutPath, artifactFileName); return _fileSystem.path.join(_hostEngineOutPath, artifactFileName);
case Artifact.constFinder: case Artifact.constFinder:
return _fileSystem.path.join(_hostEngineOutPath, 'gen', artifactFileName); return _fileSystem.path.join(_hostEngineOutPath, 'gen', artifactFileName);
case Artifact.flutterWebLibrariesJson:
return _fileSystem.path.join(_getFlutterWebSdkPath(), artifactFileName);
} }
assert(false, 'Invalid artifact $artifact.'); assert(false, 'Invalid artifact $artifact.');
return null; return null;
......
...@@ -462,6 +462,7 @@ abstract class ResidentCompiler { ...@@ -462,6 +462,7 @@ abstract class ResidentCompiler {
List<String> experimentalFlags, List<String> experimentalFlags,
String platformDill, String platformDill,
List<String> dartDefines, List<String> dartDefines,
String librariesSpec,
}) = DefaultResidentCompiler; }) = DefaultResidentCompiler;
// TODO(jonahwilliams): find a better way to configure additional file system // TODO(jonahwilliams): find a better way to configure additional file system
...@@ -526,6 +527,7 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -526,6 +527,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
this.experimentalFlags, this.experimentalFlags,
this.platformDill, this.platformDill,
List<String> dartDefines, List<String> dartDefines,
this.librariesSpec,
}) : assert(sdkRoot != null), }) : assert(sdkRoot != null),
_stdoutHandler = StdoutHandler(consumer: compilerMessageConsumer), _stdoutHandler = StdoutHandler(consumer: compilerMessageConsumer),
dartDefines = dartDefines ?? const <String>[], dartDefines = dartDefines ?? const <String>[],
...@@ -542,6 +544,7 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -542,6 +544,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
final bool unsafePackageSerialization; final bool unsafePackageSerialization;
final List<String> experimentalFlags; final List<String> experimentalFlags;
final List<String> dartDefines; final List<String> dartDefines;
final String librariesSpec;
@override @override
void addFileSystemRoot(String root) { void addFileSystemRoot(String root) {
...@@ -664,6 +667,10 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -664,6 +667,10 @@ class DefaultResidentCompiler implements ResidentCompiler {
'--output-dill', '--output-dill',
outputPath, outputPath,
], ],
if (librariesSpec != null) ...<String>[
'--libraries-spec',
librariesSpec,
],
if (packagesFilePath != null) ...<String>[ if (packagesFilePath != null) ...<String>[
'--packages', '--packages',
packagesFilePath, packagesFilePath,
......
...@@ -94,6 +94,8 @@ class FlutterDevice { ...@@ -94,6 +94,8 @@ class FlutterDevice {
.getArtifactPath(Artifact.webPlatformKernelDill, mode: buildMode)) .getArtifactPath(Artifact.webPlatformKernelDill, mode: buildMode))
.absolute.uri.toString(), .absolute.uri.toString(),
dartDefines: dartDefines, dartDefines: dartDefines,
librariesSpec: globals.fs.file(globals.artifacts
.getArtifactPath(Artifact.flutterWebLibrariesJson)).uri.toString()
); );
} else { } else {
generator = ResidentCompiler( generator = ResidentCompiler(
......
...@@ -688,6 +688,9 @@ void main() { ...@@ -688,6 +688,9 @@ void main() {
trackWidgetCreation: true, trackWidgetCreation: true,
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler;
expect(residentCompiler.librariesSpec,
globals.fs.file(globals.artifacts.getArtifactPath(Artifact.flutterWebLibrariesJson))
.uri.toString());
expect(residentCompiler.targetModel, TargetModel.dartdevc); expect(residentCompiler.targetModel, TargetModel.dartdevc);
expect(residentCompiler.sdkRoot, expect(residentCompiler.sdkRoot,
globals.artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: BuildMode.debug) + '/'); globals.artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: BuildMode.debug) + '/');
......
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