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

Unified Diff: pkg/analyzer/lib/src/util/sdk.dart

Issue 2844883005: Use the dart:io Platform.resolvedExecutable API to locate the Dart SDK. (Closed)
Patch Set: 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
« no previous file with comments | « pkg/analyzer/lib/src/lint/analysis.dart ('k') | pkg/analyzer_cli/lib/src/options.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/util/sdk.dart
diff --git a/pkg/analyzer/lib/src/util/sdk.dart b/pkg/analyzer/lib/src/util/sdk.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8e8494eb02a3550d57767643819431069c11fde2
--- /dev/null
+++ b/pkg/analyzer/lib/src/util/sdk.dart
@@ -0,0 +1,32 @@
+// 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 file.
+
+import 'dart:io';
+
+import 'package:path/path.dart' as path;
+
+String getSdkPath([List<String> args]) {
+ // Look for --dart-sdk on the command line.
+ if (args != null) {
+ int index = args.indexOf('--dart-sdk');
+
+ if (index != -1 && (index + 1 < args.length)) {
+ return args[index + 1];
+ }
+
+ for (String arg in args) {
+ if (arg.startsWith('--dart-sdk=')) {
+ return arg.substring('--dart-sdk='.length);
+ }
+ }
+ }
+
+ // Look in env['DART_SDK']
+ if (Platform.environment['DART_SDK'] != null) {
+ return Platform.environment['DART_SDK'];
+ }
+
+ // Use Platform.resolvedExecutable.
+ return path.dirname(path.dirname(Platform.resolvedExecutable));
+}
« no previous file with comments | « pkg/analyzer/lib/src/lint/analysis.dart ('k') | pkg/analyzer_cli/lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698