mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[ddc] Add full .dill uri to metadata
Change-Id: I0333b41298c5556d6ce72e339c9eec061b620866 Fixes: https://github.com/dart-lang/sdk/issues/43684 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181861 Reviewed-by: Anna Gringauze <annagrin@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
parent
34bec2f1a5
commit
ab789de75b
3 changed files with 21 additions and 7 deletions
|
@ -380,6 +380,7 @@ Future<CompilerResult> _compile(List<String> args,
|
|||
kernel.BinaryPrinter(sink).writeComponentFile(component);
|
||||
outFiles.add(sink.flush().then((_) => sink.close()));
|
||||
}
|
||||
String fullDillUri;
|
||||
if (argResults['experimental-output-compiled-kernel'] as bool) {
|
||||
if (outPaths.length > 1) {
|
||||
print(
|
||||
|
@ -396,8 +397,8 @@ Future<CompilerResult> _compile(List<String> args,
|
|||
if (identical(compilerState, oldCompilerState)) {
|
||||
compiledLibraries.unbindCanonicalNames();
|
||||
}
|
||||
var sink =
|
||||
File(p.withoutExtension(outPaths.first) + '.full.dill').openWrite();
|
||||
fullDillUri = p.withoutExtension(outPaths.first) + '.full.dill';
|
||||
var sink = File(fullDillUri).openWrite();
|
||||
kernel.BinaryPrinter(sink).writeComponentFile(compiledLibraries);
|
||||
outFiles.add(sink.flush().then((_) => sink.close()));
|
||||
}
|
||||
|
@ -445,6 +446,7 @@ Future<CompilerResult> _compile(List<String> args,
|
|||
emitDebugMetadata: options.emitDebugMetadata,
|
||||
jsUrl: p.toUri(output).toString(),
|
||||
mapUrl: mapUrl,
|
||||
fullDillUri: fullDillUri,
|
||||
customScheme: options.multiRootScheme,
|
||||
multiRootOutputPath: multiRootOutputPath,
|
||||
component: compiledLibraries);
|
||||
|
@ -647,6 +649,7 @@ JSCode jsProgramToCode(js_ast.Program moduleTree, ModuleFormat format,
|
|||
bool emitDebugMetadata = false,
|
||||
String jsUrl,
|
||||
String mapUrl,
|
||||
String fullDillUri,
|
||||
String sourceMapBase,
|
||||
String customScheme,
|
||||
String multiRootOutputPath,
|
||||
|
@ -705,19 +708,20 @@ JSCode jsProgramToCode(js_ast.Program moduleTree, ModuleFormat format,
|
|||
SharedCompiler.metricsLocationID, '$compileTimeStatistics');
|
||||
|
||||
var debugMetadata = emitDebugMetadata
|
||||
? _emitMetadata(moduleTree, component, mapUrl, jsUrl)
|
||||
? _emitMetadata(moduleTree, component, mapUrl, jsUrl, fullDillUri)
|
||||
: null;
|
||||
|
||||
return JSCode(text, builtMap, metadata: debugMetadata);
|
||||
}
|
||||
|
||||
ModuleMetadata _emitMetadata(js_ast.Program program, Component component,
|
||||
String sourceMapUri, String moduleUri) {
|
||||
String sourceMapUri, String moduleUri, String fullDillUri) {
|
||||
var metadata = ModuleMetadata(
|
||||
program.name,
|
||||
loadFunctionName(program.name),
|
||||
sourceMapUri,
|
||||
moduleUri,
|
||||
fullDillUri,
|
||||
component.mode == NonNullableByDefaultCompiledMode.Strong);
|
||||
|
||||
for (var lib in component.libraries) {
|
||||
|
|
|
@ -29,7 +29,7 @@ class ModuleMetadataVersion {
|
|||
///
|
||||
/// TODO(annagrin): create metadata package, make version the same as the
|
||||
/// metadata package version, automate updating with the package update
|
||||
static const ModuleMetadataVersion current = ModuleMetadataVersion(1, 0, 1);
|
||||
static const ModuleMetadataVersion current = ModuleMetadataVersion(1, 0, 2);
|
||||
|
||||
/// Current metadata version created by the reader
|
||||
String get version => '$majorVersion.$minorVersion.$patchVersion';
|
||||
|
@ -124,6 +124,12 @@ class ModuleMetadata {
|
|||
/// Module uri
|
||||
final String moduleUri;
|
||||
|
||||
/// The uri where DDC wrote a full .dill file for this module.
|
||||
///
|
||||
/// Can be `null` if the module was compiled without the option to output the
|
||||
/// .dill fle.
|
||||
final String fullDillUri;
|
||||
|
||||
final Map<String, LibraryMetadata> libraries = {};
|
||||
|
||||
/// True if the module corresponding to this metadata was compiled with sound
|
||||
|
@ -131,7 +137,7 @@ class ModuleMetadata {
|
|||
final bool soundNullSafety;
|
||||
|
||||
ModuleMetadata(this.name, this.closureName, this.sourceMapUri, this.moduleUri,
|
||||
this.soundNullSafety,
|
||||
this.fullDillUri, this.soundNullSafety,
|
||||
{this.version}) {
|
||||
version ??= ModuleMetadataVersion.current.version;
|
||||
}
|
||||
|
@ -157,6 +163,7 @@ class ModuleMetadata {
|
|||
closureName = json['closureName'] as String,
|
||||
sourceMapUri = json['sourceMapUri'] as String,
|
||||
moduleUri = json['moduleUri'] as String,
|
||||
fullDillUri = json['fullDillUri'] as String,
|
||||
soundNullSafety = json['soundNullSafety'] as bool {
|
||||
var fileVersion = json['version'] as String;
|
||||
if (!ModuleMetadataVersion.current.isCompatibleWith(version)) {
|
||||
|
@ -175,6 +182,7 @@ class ModuleMetadata {
|
|||
'closureName': closureName,
|
||||
'sourceMapUri': sourceMapUri,
|
||||
'moduleUri': moduleUri,
|
||||
'fullDillUri': fullDillUri,
|
||||
'libraries': [for (var lib in libraries.values) lib.toJson()],
|
||||
'soundNullSafety': soundNullSafety
|
||||
};
|
||||
|
|
|
@ -114,7 +114,8 @@ void main() {
|
|||
}
|
||||
|
||||
ModuleMetadata createMetadata(String version) => ModuleMetadata(
|
||||
'module', 'closure', 'module.map', 'module.js', true, version: version)
|
||||
'module', 'closure', 'module.map', 'module.js', 'module.full.dill', true,
|
||||
version: version)
|
||||
..addLibrary(LibraryMetadata('library', 'package:library/test.dart',
|
||||
'file:///source/library/lib/test.dart', ['src/test2.dart']));
|
||||
|
||||
|
@ -125,6 +126,7 @@ void testMetadataFields(ModuleMetadata module, String version) {
|
|||
expect(module.closureName, 'closure');
|
||||
expect(module.sourceMapUri, 'module.map');
|
||||
expect(module.moduleUri, 'module.js');
|
||||
expect(module.fullDillUri, 'module.full.dill');
|
||||
expect(module.soundNullSafety, true);
|
||||
|
||||
var libUri = module.libraries.keys.first;
|
||||
|
|
Loading…
Reference in a new issue