Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1237)

Unified Diff: pkg/front_end/lib/src/fasta/patched_sdk_location.dart

Issue 2828583003: remove dependencies to analyzer from lib/src/fasta (Closed)
Patch Set: add copyright Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/patched_sdk_location.dart
diff --git a/pkg/front_end/lib/src/fasta/patched_sdk_location.dart b/pkg/front_end/lib/src/fasta/patched_sdk_location.dart
new file mode 100644
index 0000000000000000000000000000000000000000..67f849f8b236e2ea55a2751708e8cc4d92c307ef
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/patched_sdk_location.dart
@@ -0,0 +1,56 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE.md file.
+
+/// Utility for locating the patched_sdk. This is temporarily used to run fasta
+/// until patching support is added.
+library front_end.src.fasta.patched_sdk_location;
Siggi Cherem (dart-lang) 2017/04/19 20:46:18 I extracted this code out of kernel_chain in the p
ahe 2017/04/20 09:24:50 As for the library name, I'd prefer to shorten "fr
ahe 2017/04/20 09:24:50 Agreed, but I think it should be moved to the test
Siggi Cherem (dart-lang) 2017/04/21 04:29:23 Done.
Siggi Cherem (dart-lang) 2017/04/21 04:29:23 Done.
+
+import 'dart:async';
+import 'dart:io' show File, Platform;
+
+import 'environment_variable.dart' show EnvironmentVariable;
ahe 2017/04/20 09:24:50 We should now be able to move this to testing as w
Siggi Cherem (dart-lang) 2017/04/21 04:29:22 Done.
+
+Future<Uri> computePatchedSdk() async {
+ String config = await testConfigVariable.value;
+ String path;
+ switch (Platform.operatingSystem) {
+ case "linux":
+ path = "out/$config/patched_sdk";
+ break;
+
+ case "macos":
+ path = "xcodebuild/$config/patched_sdk";
+ break;
+
+ case "windows":
+ path = "build/$config/patched_sdk";
+ break;
+
+ default:
+ throw "Unsupported operating system: '${Platform.operatingSystem}'.";
+ }
+ Uri sdk = Uri.base.resolve("$path/");
+ const String asyncDart = "lib/async/async.dart";
+ if (!await fileExists(sdk, asyncDart)) {
+ throw "Couldn't find '$asyncDart' in '$sdk'.";
+ }
+ const String asyncSources = "lib/async/async_sources.gypi";
+ if (await fileExists(sdk, asyncSources)) {
+ throw "Found '$asyncSources' in '$sdk', so it isn't a patched SDK.";
+ }
+ return sdk;
+}
+
+Uri computeDartVm(Uri patchedSdk) {
+ return patchedSdk.resolve(Platform.isWindows ? "../dart.exe" : "../dart");
+}
+
+Future<bool> fileExists(Uri base, String path) async {
+ return await new File.fromUri(base.resolve(path)).exists();
+}
+
+final EnvironmentVariable testConfigVariable = new EnvironmentVariable(
+ "DART_CONFIGURATION",
+ "It should be something like 'ReleaseX64', depending on which"
+ " configuration you're testing.");

Powered by Google App Engine
This is Rietveld 408576698