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

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

Issue 22962005: Merge pull request #581 from kevmoo/polymer (Closed) Base URL: https://github.com/dart-lang/web-ui.git@polymer
Patch Set: Created 7 years, 4 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/compiler.dart ('k') | lib/src/css_analyzer.dart » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library options; 5 library polymer.src.compiler_options;
6 6
7 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 8
9 class CompilerOptions { 9 class CompilerOptions {
10 /** Report warnings as errors. */ 10 /** Report warnings as errors. */
11 final bool warningsAsErrors; 11 final bool warningsAsErrors;
12 12
13 /** True to show informational messages. The `--verbose` flag. */ 13 /** True to show informational messages. The `--verbose` flag. */
14 final bool verbose; 14 final bool verbose;
15 15
(...skipping 28 matching lines...) Expand all
44 */ 44 */
45 final bool rewriteUrls; 45 final bool rewriteUrls;
46 46
47 /** 47 /**
48 * Whether to print error messages using the json format understood by the 48 * Whether to print error messages using the json format understood by the
49 * Dart editor. 49 * Dart editor.
50 */ 50 */
51 final bool jsonFormat; 51 final bool jsonFormat;
52 52
53 /** Emulate scoped styles using a CSS polyfill. */ 53 /** Emulate scoped styles using a CSS polyfill. */
54 final bool processCss; 54 final bool emulateScopedCss;
55
56 /** Emit debugging information for CSS processing. */
57 final bool debugCss;
58
59 // TODO(terry): Delete this option; temporary for a transition period.
60 /** If true, emit mangled CSS otherwise emits component scoped CSS. **/
61 final bool mangleCss;
62 55
63 /** Use CSS file for CSS Reset. */ 56 /** Use CSS file for CSS Reset. */
64 final String resetCssFile; 57 final String resetCssFile;
65 58
66 /** Whether to analyze the input for warnings without generating any code. */ 59 /** Whether to analyze the input for warnings without generating any code. */
67 final bool analysisOnly; 60 final bool analysisOnly;
68 61
69 bool get hasCssReset => resetCssFile != null;
70
71 // We could make this faster, if it ever matters. 62 // We could make this faster, if it ever matters.
72 factory CompilerOptions() => parse(['']); 63 factory CompilerOptions() => parse(['']);
73 64
74 CompilerOptions.fromArgs(ArgResults args) 65 CompilerOptions.fromArgs(ArgResults args)
75 : warningsAsErrors = args['warnings_as_errors'], 66 : warningsAsErrors = args['warnings_as_errors'],
76 verbose = args['verbose'], 67 verbose = args['verbose'],
77 clean = args['clean'], 68 clean = args['clean'],
78 useColors = args['colors'], 69 useColors = args['colors'],
79 baseDir = args['basedir'], 70 baseDir = args['basedir'],
80 outputDir = args['out'], 71 outputDir = args['out'],
81 packageRoot = args['package-root'], 72 packageRoot = args['package-root'],
82 rewriteUrls = args['rewrite-urls'], 73 rewriteUrls = args['rewrite-urls'],
83 forceMangle = args['unique_output_filenames'], 74 forceMangle = args['unique_output_filenames'],
84 jsonFormat = args['json_format'], 75 jsonFormat = args['json_format'],
85 componentsOnly = args['components_only'], 76 componentsOnly = args['components_only'],
86 processCss = args['css'], 77 emulateScopedCss = args['scoped-css'],
87 debugCss = args['debug_css'],
88 resetCssFile = args['css-reset'], 78 resetCssFile = args['css-reset'],
89 mangleCss = args['css-mangle'],
90 analysisOnly = args['analysis-only'], 79 analysisOnly = args['analysis-only'],
91 inputFile = args.rest.length > 0 ? args.rest[0] : null; 80 inputFile = args.rest.length > 0 ? args.rest[0] : null;
92 81
93 /** 82 /**
94 * Returns the compiler options parsed from [arguments]. Set [checkUsage] to 83 * Returns the compiler options parsed from [arguments]. Set [checkUsage] to
95 * false to suppress checking of correct usage or printing help messages. 84 * false to suppress checking of correct usage or printing help messages.
96 */ 85 */
97 // TODO(sigmund): convert all flags to use dashes instead of underscores 86 // TODO(sigmund): convert all flags to use dashes instead of underscores
98 static CompilerOptions parse(List<String> arguments, 87 static CompilerOptions parse(List<String> arguments,
99 {bool checkUsage: true}) { 88 {bool checkUsage: true}) {
(...skipping 17 matching lines...) Expand all
117 ' different directory', 106 ' different directory',
118 defaultsTo: false, negatable: false) 107 defaultsTo: false, negatable: false)
119 ..addFlag('json_format', 108 ..addFlag('json_format',
120 help: 'Print error messsages in a json format easy to parse by tools,' 109 help: 'Print error messsages in a json format easy to parse by tools,'
121 ' such as the Dart editor', 110 ' such as the Dart editor',
122 defaultsTo: false, negatable: false) 111 defaultsTo: false, negatable: false)
123 ..addFlag('components_only', 112 ..addFlag('components_only',
124 help: 'Generate only the code for component classes, do not generate ' 113 help: 'Generate only the code for component classes, do not generate '
125 'HTML files or the main bootstrap code.', 114 'HTML files or the main bootstrap code.',
126 defaultsTo: false, negatable: false) 115 defaultsTo: false, negatable: false)
127 ..addFlag('css', help: 'Emulate scoped styles with CSS polyfill', 116 ..addFlag('scoped-css', help: 'Emulate scoped styles with CSS polyfill',
128 defaultsTo: true) 117 defaultsTo: false)
129 ..addFlag('debug_css', help: 'Debug information for CSS polyfill',
130 defaultsTo: false, negatable: false)
131 ..addOption('css-reset', abbr: 'r', help: 'CSS file used to reset CSS') 118 ..addOption('css-reset', abbr: 'r', help: 'CSS file used to reset CSS')
132 ..addFlag('css-mangle', help: 'Mangle component\'s CSS', defaultsTo: true,
133 negatable: true)
134 ..addFlag('analysis-only', help: 'Don\'t emit code, just show warnings ' 119 ..addFlag('analysis-only', help: 'Don\'t emit code, just show warnings '
135 'and errors (unset by default)', defaultsTo: false, negatable: false) 120 'and errors (unset by default)', defaultsTo: false, negatable: false)
136 ..addOption('out', abbr: 'o', help: 'Directory where to generate files' 121 ..addOption('out', abbr: 'o', help: 'Directory where to generate files'
137 ' (defaults to the same directory as the source file)') 122 ' (defaults to the same directory as the source file)')
138 ..addOption('basedir', help: 'Base directory where to find all source ' 123 ..addOption('basedir', help: 'Base directory where to find all source '
139 'files (defaults to the source file\'s directory)') 124 'files (defaults to the source file\'s directory)')
140 ..addOption('package-root', help: 'Where to find "package:" imports' 125 ..addOption('package-root', help: 'Where to find "package:" imports'
141 '(defaults to the "packages/" subdirectory next to the source file)') 126 '(defaults to the "packages/" subdirectory next to the source file)')
142 ..addFlag('help', abbr: 'h', help: 'Displays this help message', 127 ..addFlag('help', abbr: 'h', help: 'Displays this help message',
143 defaultsTo: false, negatable: false); 128 defaultsTo: false, negatable: false);
144 try { 129 try {
145 var results = parser.parse(arguments); 130 var results = parser.parse(arguments);
146 if (checkUsage && (results['help'] || results.rest.length == 0)) { 131 if (checkUsage && (results['help'] || results.rest.length == 0)) {
147 showUsage(parser); 132 showUsage(parser);
148 return null; 133 return null;
149 } 134 }
150 return new CompilerOptions.fromArgs(results); 135 return new CompilerOptions.fromArgs(results);
151 } on FormatException catch (e) { 136 } on FormatException catch (e) {
152 print(e.message); 137 print(e.message);
153 showUsage(parser); 138 showUsage(parser);
154 return null; 139 return null;
155 } 140 }
156 } 141 }
157 142
158 static showUsage(parser) { 143 static showUsage(parser) {
159 print('Usage: dwc [options...] input.html'); 144 print('Usage: dwc [options...] input.html');
160 print(parser.getUsage()); 145 print(parser.getUsage());
161 } 146 }
162 } 147 }
OLDNEW
« no previous file with comments | « lib/src/compiler.dart ('k') | lib/src/css_analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698