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

Side by Side Diff: lib/src/utils.dart

Issue 1020043002: Replace dart_core.js with actual compiled SDK (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: merge Created 5 years, 9 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
« no previous file with comments | « lib/src/options.dart ('k') | test/codegen/expect/constructors.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Holds a couple utility functions used at various places in the system. 5 /// Holds a couple utility functions used at various places in the system.
6 library dev_compiler.src.utils; 6 library dev_compiler.src.utils;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 if (resourceUri.scheme != 'file') return null; 311 if (resourceUri.scheme != 'file') return null;
312 var filepath = resourceUri.path; 312 var filepath = resourceUri.path;
313 var relativePath = path.relative(filepath, from: path.dirname(entryUri.path)); 313 var relativePath = path.relative(filepath, from: path.dirname(entryUri.path));
314 314
315 // File:/// urls can be for resources in the same project or resources from 315 // File:/// urls can be for resources in the same project or resources from
316 // the dev_compiler package. For now we only support relative paths going 316 // the dev_compiler package. For now we only support relative paths going
317 // further inside the folder where the entrypoint is located, otherwise we 317 // further inside the folder where the entrypoint is located, otherwise we
318 // assume this is a runtime resource from the dev_compiler. 318 // assume this is a runtime resource from the dev_compiler.
319 if (!relativePath.startsWith('..')) return relativePath; 319 if (!relativePath.startsWith('..')) return relativePath;
320 320
321 // Expect the code to live under lib/runtime/ in the dev_compiler's folder. 321 // Since this is a URI path we can assume forward slash and use lastIndexOf.
322 var filename = path.basename(filepath); 322 var runtimePath = '/lib/runtime/';
323 var dir = path.dirname(filepath); 323 var pos = filepath.lastIndexOf(runtimePath);
324 if (path.basename(dir) != 'runtime') return null; 324 if (pos == -1) return null;
325 dir = path.dirname(dir); 325
326 if (path.basename(dir) != 'lib') return null; 326 var filename = filepath.substring(pos + runtimePath.length);
327 dir = path.dirname(dir); 327 var dir = filepath.substring(0, pos);
328
329 // TODO(jmesserly): can we implement this without repeatedly reading pubspec?
330 // It seems like we should know our package's root directory without needing
331 // to search like this.
328 var pubspec = 332 var pubspec =
329 loadYaml(new File(path.join(dir, 'pubspec.yaml')).readAsStringSync()); 333 loadYaml(new File(path.join(dir, 'pubspec.yaml')).readAsStringSync());
330 334
331 // Ensure this is loaded from the dev_compiler package. 335 // Ensure this is loaded from the dev_compiler package.
332 if (pubspec['name'] != 'dev_compiler') return null; 336 if (pubspec['name'] != 'dev_compiler') return null;
333 return path.join('dev_compiler', 'runtime', filename); 337 return path.join('dev_compiler', 'runtime', filename);
334 } 338 }
OLDNEW
« no previous file with comments | « lib/src/options.dart ('k') | test/codegen/expect/constructors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698