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

Side by Side Diff: pkg/code_transformers/lib/src/dart_sdk.dart

Issue 172633006: Revert "Revert "Adding package:code_transformers for unifying common transformers code"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/code_transformers/lib/resolver.dart ('k') | pkg/code_transformers/lib/src/resolver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library code_transformers.src.dart_sdk;
6
7 import 'dart:convert' as convert;
8 import 'dart:io' show Directory, File, Platform, Process;
9 import 'package:path/path.dart' as path;
10
11
12 /// Attempts to provide the current Dart SDK directory.
13 ///
14 /// Note that this may not be correct when executing outside of `pub`.
15 String get dartSdkDirectory {
16 if (path.split(Platform.executable).length == 1) {
17 // TODO(blois): make this cross-platform.
18 // HACK: A single part, hope it's on the path.
19 var result = Process.runSync('which', ['dart'],
20 stdoutEncoding: convert.UTF8);
21 return path.dirname(path.dirname(result.stdout));
22 }
23 var sdkDir = path.dirname(path.absolute(Platform.executable));
24 // If there's a sub-dir named dart-sdk then we're most likely executing from
25 // a dart enlistment build directory.
26 if (new Directory(path.join(sdkDir, 'dart-sdk')).existsSync()) {
27 return path.join(sdkDir, 'dart-sdk');
28 }
29 // If we can find libraries.dart then it's the root of the SDK.
30 if (new File(path.join(sdkDir, 'lib', '_internal', 'libraries.dart'))
31 .existsSync()) {
32 return sdkDir;
33 }
34
35 var parts = path.split(sdkDir);
36 // If the dart executable is within the sdk dir then get the root.
37 if (parts.contains('dart-sdk')) {
38 return path.joinAll(parts.take(parts.indexOf('dart-sdk') + 1));
39 }
40
41 return sdkDir;
42 }
OLDNEW
« no previous file with comments | « pkg/code_transformers/lib/resolver.dart ('k') | pkg/code_transformers/lib/src/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698