| Index: pkg/kernel/bin/dartk.dart
|
| diff --git a/pkg/kernel/bin/dartk.dart b/pkg/kernel/bin/dartk.dart
|
| index e735f9789e5a18560c3dd1c4cca2a6f8b418486a..f6a6447472e6c781911225381fb20ed4e5f78bb4 100755
|
| --- a/pkg/kernel/bin/dartk.dart
|
| +++ b/pkg/kernel/bin/dartk.dart
|
| @@ -10,6 +10,7 @@ import 'batch_util.dart';
|
|
|
| import 'package:args/args.dart';
|
| import 'package:kernel/analyzer/loader.dart';
|
| +import 'package:kernel/application_root.dart';
|
| import 'package:kernel/verifier.dart';
|
| import 'package:kernel/kernel.dart';
|
| import 'package:kernel/log.dart';
|
| @@ -36,6 +37,11 @@ ArgParser parser = new ArgParser(allowTrailingOptions: true)
|
| ..addOption('packages',
|
| abbr: 'p', help: 'Path to the .packages file or packages folder.')
|
| ..addOption('package-root', help: 'Deprecated alias for --packages')
|
| + ..addOption('app-root',
|
| + help: 'Store library paths relative to the given directory.\n'
|
| + 'If none is given, absolute paths are used.\n'
|
| + 'Application libraries not inside the application root are stored '
|
| + 'using absolute paths')
|
| ..addOption('target',
|
| abbr: 't',
|
| help: 'Tailor the IR to the given target.',
|
| @@ -244,6 +250,13 @@ Future<CompilerOutcome> batchMain(
|
| String packagePath = options['packages'] ?? options['package-root'];
|
| checkIsFileOrDirectoryOrNull(packagePath, 'Package root or .packages');
|
|
|
| + String applicationRootOption = options['app-root'];
|
| + checkIsDirectoryOrNull(applicationRootOption, 'Application root');
|
| + if (applicationRootOption != null) {
|
| + applicationRootOption = new File(applicationRootOption).absolute.path;
|
| + }
|
| + var applicationRoot = new ApplicationRoot(applicationRootOption);
|
| +
|
| // Set up logging.
|
| if (options['verbose']) {
|
| log.onRecord.listen((LogRecord rec) {
|
| @@ -255,9 +268,10 @@ Future<CompilerOutcome> batchMain(
|
| return fail('Exactly one FILE should be given.');
|
| }
|
|
|
| - var file = options.rest.single;
|
| -
|
| + String file = options.rest.single;
|
| checkIsFile(file, option: 'Input file');
|
| + file = new File(file).absolute.path;
|
| + Uri fileUri = new Uri(scheme: 'file', path: file);
|
|
|
| String format = options['format'] ?? defaultFormat();
|
| String outputFile = options['out'] ?? defaultOutput();
|
| @@ -297,16 +311,18 @@ Future<CompilerOutcome> batchMain(
|
| sdk: options['sdk'],
|
| packagePath: packagePath,
|
| customUriMappings: customUriMappings,
|
| - declaredVariables: declaredVariables);
|
| + declaredVariables: declaredVariables,
|
| + applicationRoot: applicationRoot);
|
| String packageDiscoveryPath = batchModeState.isBatchMode ? null : file;
|
| DartLoader loader = await batchModeState.batch.getLoader(
|
| repository, dartOptions,
|
| packageDiscoveryPath: packageDiscoveryPath);
|
| if (options['link']) {
|
| - program = loader.loadProgram(file, target: target);
|
| + program = loader.loadProgram(fileUri, target: target);
|
| } else {
|
| - var library = loader.loadLibrary(file);
|
| - assert(library == repository.getLibrary(file));
|
| + var library = loader.loadLibrary(fileUri);
|
| + assert(library ==
|
| + repository.getLibraryReference(applicationRoot.relativeUri(fileUri)));
|
| program = new Program(repository.libraries);
|
| }
|
| errors = loader.errors;
|
|
|