Support for google3 locations in 'packageRoot' and KernelCompilationService.
Change-Id: I90910bc3c966f648ade107d10d4c7f593c67c7a4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/242162 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Bot
parent
460c2115e7
commit
76387a9c5b
@@ -36,11 +36,7 @@ class KernelCompilationService {
|
||||
}
|
||||
|
||||
final executablePath = io.Platform.resolvedExecutable;
|
||||
final binPath = package_path.dirname(executablePath);
|
||||
final sdkPath = package_path.dirname(binPath);
|
||||
|
||||
final frontEndSnapshotPath = package_path.join(
|
||||
binPath, 'snapshots', 'frontend_server.dart.snapshot');
|
||||
final sdkPaths = _computeSdkPaths();
|
||||
|
||||
final socketCompleter = Completer<io.Socket>();
|
||||
final serverSocket = await _loopbackServerSocket();
|
||||
@@ -52,7 +48,7 @@ class KernelCompilationService {
|
||||
final addressStr = '$host:${serverSocket.port}';
|
||||
|
||||
final process = await io.Process.start(executablePath, [
|
||||
frontEndSnapshotPath,
|
||||
sdkPaths.frontEndSnapshot,
|
||||
'--binary-protocol-address=$addressStr',
|
||||
]);
|
||||
|
||||
@@ -66,8 +62,7 @@ class KernelCompilationService {
|
||||
final requestChannel = RequestChannel(socket);
|
||||
|
||||
// Put the platform dill.
|
||||
final platformDillPath = package_path.join(
|
||||
sdkPath, 'lib', '_internal', 'vm_platform_strong.dill');
|
||||
final platformDillPath = sdkPaths.platformDill;
|
||||
final platformDillBytes = io.File(platformDillPath).readAsBytesSync();
|
||||
await requestChannel.sendRequest<void>('dill.put', {
|
||||
'uri': 'dill:vm',
|
||||
@@ -149,6 +144,30 @@ class KernelCompilationService {
|
||||
});
|
||||
}
|
||||
|
||||
static _SdkPaths _computeSdkPaths() {
|
||||
// Check for google3.
|
||||
final runFiles = io.Platform.environment['RUNFILES'];
|
||||
if (runFiles != null) {
|
||||
final frontServerPath = io.Platform.environment['FRONTEND_SERVER_PATH']!;
|
||||
final platformDillPath = io.Platform.environment['PLATFORM_DILL_PATH']!;
|
||||
return _SdkPaths(
|
||||
frontEndSnapshot: package_path.join(runFiles, frontServerPath),
|
||||
platformDill: package_path.join(runFiles, platformDillPath),
|
||||
);
|
||||
}
|
||||
|
||||
final executablePath = io.Platform.resolvedExecutable;
|
||||
final binPath = package_path.dirname(executablePath);
|
||||
final sdkPath = package_path.dirname(binPath);
|
||||
|
||||
return _SdkPaths(
|
||||
frontEndSnapshot: package_path.join(
|
||||
binPath, 'snapshots', 'frontend_server.dart.snapshot'),
|
||||
platformDill: package_path.join(
|
||||
sdkPath, 'lib', '_internal', 'vm_platform_strong.dill'),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<io.ServerSocket> _loopbackServerSocket() async {
|
||||
try {
|
||||
return await io.ServerSocket.bind(io.InternetAddress.loopbackIPv6, 0);
|
||||
@@ -199,3 +218,13 @@ class _Lock {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _SdkPaths {
|
||||
final String frontEndSnapshot;
|
||||
final String platformDill;
|
||||
|
||||
_SdkPaths({
|
||||
required this.frontEndSnapshot,
|
||||
required this.platformDill,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,5 +25,13 @@ String get packageRoot {
|
||||
if (pkgIndex != -1) {
|
||||
return pathos.joinAll(parts.sublist(0, pkgIndex + 1)) + pathos.separator;
|
||||
}
|
||||
// Try google3 environment. We expect that all packages that will be
|
||||
// accessed via this root are configured in the BUILD file, and located
|
||||
// inside this single root.
|
||||
final runFiles = Platform.environment['RUNFILES'];
|
||||
final analyzerPackagesRoot = Platform.environment['ANALYZER_PACKAGES_ROOT'];
|
||||
if (runFiles != null && analyzerPackagesRoot != null) {
|
||||
return pathos.join(runFiles, analyzerPackagesRoot);
|
||||
}
|
||||
throw StateError('Unable to find sdk/pkg/ in $scriptPath');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user