Skip to content

Commit 7fe8659

Browse files
kevmoocommit-bot@chromium.org
authored andcommitted
dump-info: Use relative paths for library canonicalUri...
...if they are within the working directory Makes output from dump-info more stable, especially with pkg:build Change-Id: I3e6c444a0aa7df55c10e1bdff4b59ef035d2acc3 Reviewed-on: https://dart-review.googlesource.com/53168 Reviewed-by: Harry Terkelsen <[email protected]> Commit-Queue: Kevin Moore <[email protected]>
1 parent dcf4886 commit 7fe8659

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pkg/compiler/lib/src/dump_info.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'dart:convert'
88
show ChunkedConversionSink, JsonEncoder, StringConversionSink;
99

1010
import 'package:dart2js_info/info.dart';
11+
import 'package:path/path.dart' as p;
1112

1213
import '../compiler_new.dart';
1314
import 'common/names.dart';
@@ -77,7 +78,17 @@ class ElementInfoCollector {
7778
libname = '<unnamed>';
7879
}
7980
int size = compiler.dumpInfoTask.sizeOf(lib);
80-
LibraryInfo info = new LibraryInfo(libname, lib.canonicalUri, null, size);
81+
82+
var uri = lib.canonicalUri;
83+
if (Uri.base.isScheme('file') && lib.canonicalUri.isScheme('file')) {
84+
var basePath = p.fromUri(Uri.base);
85+
var libPath = p.fromUri(lib.canonicalUri);
86+
if (p.isWithin(basePath, libPath)) {
87+
uri = p.toUri(p.relative(libPath, from: basePath));
88+
}
89+
}
90+
91+
LibraryInfo info = new LibraryInfo(libname, uri, null, size);
8192
_entityToInfo[lib] = info;
8293

8394
environment.forEachLibraryMember(lib, (MemberEntity member) {

pkg/compiler/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ dependencies:
1919
path: ../../third_party/pkg/dart2js_info
2020
front_end:
2121
path: ../front_end
22+
path:
23+
path: ../../third_party/pkg/path
2224
dependency_overrides:
2325
front_end:
2426
path: ../front_end

0 commit comments

Comments
 (0)