Chromium Code Reviews

Side by Side Diff: frog/frog_options.dart

Issue 8619005: Initial CL to create SDK directory (this will be done as a build step). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « dart.gyp ('k') | frog/reader.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 /** General options used by the compiler. */ 5 /** General options used by the compiler. */
6 FrogOptions options; 6 FrogOptions options;
7 7
8 /** Extracts options from command-line arguments. */ 8 /** Extracts options from command-line arguments. */
9 void parseOptions(String homedir, List<String> args, FileSystem files) { 9 void parseOptions(String homedir, List<String> args, FileSystem files) {
10 assert(options == null); 10 assert(options == null);
11 options = new FrogOptions(homedir, args, files); 11 options = new FrogOptions(homedir, args, files);
12 } 12 }
13 13
14 // TODO(sigmund): make into a generic option parser... 14 // TODO(sigmund): make into a generic option parser...
15 class FrogOptions { 15 class FrogOptions {
16 /** Location of corelib and other special dart libraries. */ 16 /** Location of corelib and other special dart libraries. */
17 String libDir; 17 String libDir;
18 18
19 /* The top-level dart script to compile. */ 19 /* The top-level dart script to compile. */
20 String dartScript; 20 String dartScript;
21 21
22 /** Where to place the generated code. */ 22 /** Where to place the generated code. */
23 String outfile; 23 String outfile;
24 24
25 // TODO(dgrove): fix this. For now, either 'sdk' or 'dev'.
26 final config = 'dev';
27
28
25 // Options that modify behavior significantly 29 // Options that modify behavior significantly
26 bool enableLeg = false; 30 bool enableLeg = false;
27 bool legOnly = false; 31 bool legOnly = false;
28 bool enableAsserts = false; 32 bool enableAsserts = false;
29 bool enableTypeChecks = false; 33 bool enableTypeChecks = false;
30 bool warningsAsErrors = false; 34 bool warningsAsErrors = false;
31 bool verifyImplements = false; // TODO(jimhug): Implement 35 bool verifyImplements = false; // TODO(jimhug): Implement
32 bool compileAll = false; 36 bool compileAll = false;
33 bool forceDynamic = false; 37 bool forceDynamic = false;
34 bool dietParse = false; 38 bool dietParse = false;
35 bool compileOnly = false; 39 bool compileOnly = false;
36 40
37 // Message support 41 // Message support
38 bool throwOnErrors = false; 42 bool throwOnErrors = false;
39 bool throwOnWarnings = false; 43 bool throwOnWarnings = false;
40 bool throwOnFatal = false; 44 bool throwOnFatal = false;
41 bool showInfo = false; 45 bool showInfo = false;
42 bool showWarnings = true; 46 bool showWarnings = true;
43 47
44 /** 48 /**
45 * Options to be used later for passing to the generated code. These are all 49 * Options to be used later for passing to the generated code. These are all
46 * the arguments after the first dart script, if any. 50 * the arguments after the first dart script, if any.
47 */ 51 */
48 List<String> childArgs; 52 List<String> childArgs;
49 53
50 FrogOptions(String homedir, List<String> args, FileSystem files) { 54 FrogOptions(String homedir, List<String> args, FileSystem files) {
51 libDir = homedir + '/lib'; // Default value for --libdir. 55 if (config == 'dev') {
56 libDir = joinPaths(homedir, '/lib'); // Default value for --libdir.
57 } else if (config == 'sdk') {
58 libDir = joinPaths(homedir, '/../lib');
59 } else {
60 world.error('Invalid configuration $config', null);
61 throw('Invalid configuration');
62 }
63
52 bool ignoreUnrecognizedFlags = false; 64 bool ignoreUnrecognizedFlags = false;
53 bool passedLibDir = false; 65 bool passedLibDir = false;
54 childArgs = []; 66 childArgs = [];
55 67
56 // Start from 2 to skip arguments representing the compiler command 68 // Start from 2 to skip arguments representing the compiler command
57 // (node/python followed by frogsh/frog.py). 69 // (node/python followed by frogsh/frog.py).
58 // TODO(jimhug): break on switch cases seems broken? 70 // TODO(jimhug): break on switch cases seems broken?
59 loop: for (int i = 2; i < args.length; i++) { 71 loop: for (int i = 2; i < args.length; i++) {
60 var arg = args[i]; 72 var arg = args[i];
61 73
(...skipping 74 matching lines...)
136 passedLibDir = true; 148 passedLibDir = true;
137 } else { 149 } else {
138 if (!ignoreUnrecognizedFlags) { 150 if (!ignoreUnrecognizedFlags) {
139 print('unrecognized flag: "$arg"'); 151 print('unrecognized flag: "$arg"');
140 } 152 }
141 } 153 }
142 } 154 }
143 } 155 }
144 156
145 // TODO(jimhug): Remove this hack. 157 // TODO(jimhug): Remove this hack.
146 if (!passedLibDir && !files.fileExists(libDir)) { 158 if (!passedLibDir && config == 'dev' && !files.fileExists(libDir)) {
147 // Try locally 159 // Try locally
148 var temp = 'frog/lib'; 160 var temp = 'frog/lib';
149 if (files.fileExists(temp)) { 161 if (files.fileExists(temp)) {
150 libDir = temp; 162 libDir = temp;
151 } else { 163 } else {
152 libDir = 'lib'; 164 libDir = 'lib';
153 } 165 }
154 } 166 }
155 } 167 }
156 } 168 }
OLDNEW
« no previous file with comments | « dart.gyp ('k') | frog/reader.dart » ('j') | no next file with comments »

Powered by Google App Engine