OLD | NEW |
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 leg_apiimpl; | 5 library leg_apiimpl; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 | 9 |
10 import 'package:package_config/packages.dart'; | 10 import 'package:package_config/packages.dart'; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 hasOption(options, Flags.useContentSecurityPolicy), | 117 hasOption(options, Flags.useContentSecurityPolicy), |
118 useStartupEmitter: hasOption(options, Flags.fastStartup), | 118 useStartupEmitter: hasOption(options, Flags.fastStartup), |
119 hasIncrementalSupport: | 119 hasIncrementalSupport: |
120 forceIncrementalSupport || | 120 forceIncrementalSupport || |
121 hasOption(options, Flags.incrementalSupport), | 121 hasOption(options, Flags.incrementalSupport), |
122 diagnosticOptions: new DiagnosticOptions( | 122 diagnosticOptions: new DiagnosticOptions( |
123 suppressWarnings: hasOption(options, Flags.suppressWarnings), | 123 suppressWarnings: hasOption(options, Flags.suppressWarnings), |
124 fatalWarnings: hasOption(options, Flags.fatalWarnings), | 124 fatalWarnings: hasOption(options, Flags.fatalWarnings), |
125 suppressHints: hasOption(options, Flags.suppressHints), | 125 suppressHints: hasOption(options, Flags.suppressHints), |
126 terseDiagnostics: hasOption(options, Flags.terse), | 126 terseDiagnostics: hasOption(options, Flags.terse), |
127 showPackageWarnings: | 127 shownPackageWarnings: extractOptionalCsvOption( |
128 hasOption(options, Flags.showPackageWarnings)), | 128 options, Flags.showPackageWarnings)), |
129 enableExperimentalMirrors: | 129 enableExperimentalMirrors: |
130 hasOption(options, Flags.enableExperimentalMirrors), | 130 hasOption(options, Flags.enableExperimentalMirrors), |
131 enableAssertMessage: | 131 enableAssertMessage: |
132 hasOption(options, Flags.enableAssertMessage), | 132 hasOption(options, Flags.enableAssertMessage), |
133 generateCodeWithCompileTimeErrors: | 133 generateCodeWithCompileTimeErrors: |
134 hasOption(options, Flags.generateCodeWithCompileTimeErrors), | 134 hasOption(options, Flags.generateCodeWithCompileTimeErrors), |
135 testMode: hasOption(options, Flags.testMode), | 135 testMode: hasOption(options, Flags.testMode), |
136 allowNativeExtensions: | 136 allowNativeExtensions: |
137 hasOption(options, Flags.allowNativeExtensions)) { | 137 hasOption(options, Flags.allowNativeExtensions)) { |
138 tasks.addAll([ | 138 tasks.addAll([ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // CSV: Comma separated values. | 182 // CSV: Comma separated values. |
183 static List<String> extractCsvOption(List<String> options, String prefix) { | 183 static List<String> extractCsvOption(List<String> options, String prefix) { |
184 for (String option in options) { | 184 for (String option in options) { |
185 if (option.startsWith(prefix)) { | 185 if (option.startsWith(prefix)) { |
186 return option.substring(prefix.length).split(','); | 186 return option.substring(prefix.length).split(','); |
187 } | 187 } |
188 } | 188 } |
189 return const <String>[]; | 189 return const <String>[]; |
190 } | 190 } |
191 | 191 |
| 192 /// Extract list of comma separated values provided for [flag]. Returns an |
| 193 /// empty list if [option] contain [flag] without arguments. Returns `null` if |
| 194 /// [option] doesn't contain [flag] with or without arguments. |
| 195 static List<String> extractOptionalCsvOption( |
| 196 List<String> options, String flag) { |
| 197 String prefix = '$flag='; |
| 198 for (String option in options) { |
| 199 if (option == flag) { |
| 200 return const <String>[]; |
| 201 } |
| 202 if (option.startsWith(flag)) { |
| 203 return option.substring(prefix.length).split(','); |
| 204 } |
| 205 } |
| 206 return null; |
| 207 } |
| 208 |
192 static Uri resolvePlatformConfig(Uri libraryRoot, | 209 static Uri resolvePlatformConfig(Uri libraryRoot, |
193 List<String> options) { | 210 List<String> options) { |
194 String platformConfigPath = | 211 String platformConfigPath = |
195 extractStringOption(options, "--platform-config=", null); | 212 extractStringOption(options, "--platform-config=", null); |
196 if (platformConfigPath != null) { | 213 if (platformConfigPath != null) { |
197 return libraryRoot.resolve(platformConfigPath); | 214 return libraryRoot.resolve(platformConfigPath); |
198 } else if (hasOption(options, '--output-type=dart')) { | 215 } else if (hasOption(options, '--output-type=dart')) { |
199 return libraryRoot.resolve(_dart2dartPlatform); | 216 return libraryRoot.resolve(_dart2dartPlatform); |
200 } else { | 217 } else { |
201 Iterable<String> categories = extractCsvOption(options, '--categories='); | 218 Iterable<String> categories = extractCsvOption(options, '--categories='); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 Uri lookupLibraryUri(String libraryName) { | 580 Uri lookupLibraryUri(String libraryName) { |
564 assert(invariant(NO_LOCATION_SPANNABLE, | 581 assert(invariant(NO_LOCATION_SPANNABLE, |
565 sdkLibraries != null, message: "setupSdk() has not been run")); | 582 sdkLibraries != null, message: "setupSdk() has not been run")); |
566 return sdkLibraries[libraryName]; | 583 return sdkLibraries[libraryName]; |
567 } | 584 } |
568 | 585 |
569 Uri resolvePatchUri(String libraryName) { | 586 Uri resolvePatchUri(String libraryName) { |
570 return backend.resolvePatchUri(libraryName, platformConfigUri); | 587 return backend.resolvePatchUri(libraryName, platformConfigUri); |
571 } | 588 } |
572 } | 589 } |
OLD | NEW |