|
18 | 18 | import com.google.common.base.Preconditions; |
19 | 19 | import com.google.common.base.Strings; |
20 | 20 | import com.google.common.collect.Lists; |
| 21 | +import com.google.common.io.Files; |
21 | 22 | import com.google.common.io.Resources; |
22 | 23 | import com.google.devtools.j2objc.util.SourceVersion; |
23 | 24 | import com.google.devtools.j2objc.util.Version; |
24 | | - |
25 | 25 | import java.io.BufferedReader; |
26 | 26 | import java.io.File; |
27 | 27 | import java.io.FileReader; |
28 | 28 | import java.io.IOException; |
29 | 29 | import java.net.URL; |
| 30 | +import java.nio.charset.Charset; |
30 | 31 | import java.util.List; |
31 | 32 | import java.util.Properties; |
32 | 33 |
|
@@ -153,12 +154,29 @@ public static void version() { |
153 | 154 |
|
154 | 155 | public static Options parse(String[] args) throws IOException { |
155 | 156 | Options options = new Options(); |
| 157 | + processArgs(args, options); |
| 158 | + return options; |
| 159 | + } |
| 160 | + |
| 161 | + private static void processArgsFile(String filename, Options options) throws IOException { |
| 162 | + if (filename.isEmpty()) { |
| 163 | + usage("no @ file specified"); |
| 164 | + } |
| 165 | + File f = new File(filename); |
| 166 | + String fileArgs = Files.asCharSource(f, Charset.forName(options.fileEncoding())).read(); |
| 167 | + // Simple split on any whitespace, quoted values aren't supported. |
| 168 | + processArgs(fileArgs.split("\\s+"), options); |
| 169 | + } |
| 170 | + |
| 171 | + private static void processArgs(String[] args, Options options) throws IOException { |
156 | 172 | boolean printArgs = false; |
157 | 173 |
|
158 | 174 | int nArg = 0; |
159 | 175 | while (nArg < args.length) { |
160 | 176 | String arg = args[nArg]; |
161 | | - if (arg.equals("-sourcepath")) { |
| 177 | + if (arg.startsWith("@")) { |
| 178 | + processArgsFile(arg.substring(1), options); |
| 179 | + } else if (arg.equals("-sourcepath")) { |
162 | 180 | if (++nArg == args.length) { |
163 | 181 | usage("-sourcepath requires an argument"); |
164 | 182 | } |
@@ -227,7 +245,5 @@ public static Options parse(String[] args) throws IOException { |
227 | 245 | System.err.print("tree_shaker "); |
228 | 246 | System.err.println(String.join(" ", args)); |
229 | 247 | } |
230 | | - |
231 | | - return options; |
232 | 248 | } |
233 | 249 | } |
0 commit comments