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