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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/command.dart

Issue 2553973004: remove DDC --build-root option (Closed)
Patch Set: merge Created 4 years 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 | « no previous file | no next file » | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:io'; 5 import 'dart:io';
6 import 'package:analyzer/src/generated/source.dart' show Source; 6 import 'package:analyzer/src/generated/source.dart' show Source;
7 import 'package:analyzer/src/summary/package_bundle_reader.dart' 7 import 'package:analyzer/src/summary/package_bundle_reader.dart'
8 show InSummarySource; 8 show InSummarySource;
9 import 'package:args/args.dart' show ArgParser, ArgResults; 9 import 'package:args/args.dart' show ArgParser, ArgResults;
10 import 'package:args/command_runner.dart' show UsageException; 10 import 'package:args/command_runner.dart' show UsageException;
11 import 'package:path/path.dart' as path; 11 import 'package:path/path.dart' as path;
12 12
13 import '../analyzer/context.dart' show AnalyzerOptions, parseDeclaredVariables; 13 import '../analyzer/context.dart' show AnalyzerOptions, parseDeclaredVariables;
14 import 'compiler.dart' show BuildUnit, CompilerOptions, ModuleCompiler; 14 import 'compiler.dart' show BuildUnit, CompilerOptions, ModuleCompiler;
15 import 'module_builder.dart'; 15 import 'module_builder.dart';
16 16
17 final ArgParser _argParser = () { 17 final ArgParser _argParser = () {
18 var argParser = new ArgParser(allowTrailingOptions: true) 18 var argParser = new ArgParser(allowTrailingOptions: true)
19 ..addFlag('help', abbr: 'h', help: 'Display this message.') 19 ..addFlag('help', abbr: 'h', help: 'Display this message.')
20 ..addOption('out', 20 ..addOption('out',
21 abbr: 'o', allowMultiple: true, help: 'Output file (required).') 21 abbr: 'o', allowMultiple: true, help: 'Output file (required).')
22 ..addOption('module-root', 22 ..addOption('module-root',
23 help: 'Root module directory.\n' 23 help: 'Root module directory.\n'
24 'Generated module paths are relative to this root.') 24 'Generated module paths are relative to this root.')
25 ..addOption('library-root', 25 ..addOption('library-root',
26 help: 'Root of source files.\n' 26 help: 'Root of source files.\n'
27 'Generated library names are relative to this root.') 27 'Generated library names are relative to this root.');
28 ..addOption('build-root',
29 help: 'Deprecated in favor of --library-root', hide: true);
30 addModuleFormatOptions(argParser, allowMultiple: true); 28 addModuleFormatOptions(argParser, allowMultiple: true);
31 AnalyzerOptions.addArguments(argParser); 29 AnalyzerOptions.addArguments(argParser);
32 CompilerOptions.addArguments(argParser); 30 CompilerOptions.addArguments(argParser);
33 return argParser; 31 return argParser;
34 }(); 32 }();
35 33
36 /// Runs a single compile for dartdevc. 34 /// Runs a single compile for dartdevc.
37 /// 35 ///
38 /// This handles argument parsing, usage, error handling. 36 /// This handles argument parsing, usage, error handling.
39 /// See bin/dartdevc.dart for the actual entry point, which includes Bazel 37 /// See bin/dartdevc.dart for the actual entry point, which includes Bazel
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } else if (outPaths.length != moduleFormats.length) { 116 } else if (outPaths.length != moduleFormats.length) {
119 _usageException('Number of output files (${outPaths.length}) must match ' 117 _usageException('Number of output files (${outPaths.length}) must match '
120 'number of module formats (${moduleFormats.length}).'); 118 'number of module formats (${moduleFormats.length}).');
121 } 119 }
122 120
123 // TODO(jmesserly): for now the first one is special. This will go away once 121 // TODO(jmesserly): for now the first one is special. This will go away once
124 // we've removed the "root" and "module name" variables. 122 // we've removed the "root" and "module name" variables.
125 var firstOutPath = outPaths[0]; 123 var firstOutPath = outPaths[0];
126 124
127 var libraryRoot = argResults['library-root'] as String; 125 var libraryRoot = argResults['library-root'] as String;
128 libraryRoot ??= argResults['build-root'] as String;
129 if (libraryRoot != null) { 126 if (libraryRoot != null) {
130 libraryRoot = path.absolute(libraryRoot); 127 libraryRoot = path.absolute(libraryRoot);
131 } else { 128 } else {
132 libraryRoot = Directory.current.path; 129 libraryRoot = Directory.current.path;
133 } 130 }
134 var moduleRoot = argResults['module-root'] as String; 131 var moduleRoot = argResults['module-root'] as String;
135 String modulePath; 132 String modulePath;
136 if (moduleRoot != null) { 133 if (moduleRoot != null) {
137 moduleRoot = path.absolute(moduleRoot); 134 moduleRoot = path.absolute(moduleRoot);
138 if (!path.isWithin(moduleRoot, firstOutPath)) { 135 if (!path.isWithin(moduleRoot, firstOutPath)) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 '\n\n${_argParser.usage}'; 203 '\n\n${_argParser.usage}';
207 204
208 void _usageException(String message) { 205 void _usageException(String message) {
209 throw new UsageException(message, _usageMessage); 206 throw new UsageException(message, _usageMessage);
210 } 207 }
211 208
212 /// Thrown when the input source code has errors. 209 /// Thrown when the input source code has errors.
213 class CompileErrorException implements Exception { 210 class CompileErrorException implements Exception {
214 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; 211 toString() => '\nPlease fix all errors before compiling (warnings are okay).';
215 } 212 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698