987912ad |
1 | /** @file\r |
2 | File is TargetFile class which is used to generate the new target.txt. \r |
3 | \r |
4 | Copyright (c) 2006, Intel Corporation\r |
5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r |
8 | http://opensource.org/licenses/bsd-license.php\r |
9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
12 | **/\r |
c74c7a43 |
13 | package org.tianocore.context;\r |
14 | \r |
15 | import java.io.BufferedReader;\r |
16 | import java.io.BufferedWriter;\r |
17 | import java.io.File;\r |
18 | import java.io.FileNotFoundException;\r |
19 | import java.io.FileOutputStream;\r |
20 | import java.io.FileReader;\r |
21 | import java.io.FileWriter;\r |
22 | import java.io.IOException;\r |
23 | import java.nio.ByteBuffer;\r |
24 | import java.nio.channels.FileChannel;\r |
25 | \r |
26 | public class TargetFile {\r |
27 | \r |
28 | /** \r |
29 | * check the validity of path and file\r |
30 | * @param String filename : the name of target file\r |
31 | * @return true or false\r |
32 | **/\r |
f337986f |
33 | public static boolean setFile(String filename) {\r |
c74c7a43 |
34 | \r |
35 | String workspacePath = System.getenv("WORKSPACE");\r |
36 | \r |
37 | Fd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename);\r |
38 | \r |
39 | if (Fd.exists() == true) {\r |
40 | if (createTempFile(filename + "tmp") == false) {\r |
41 | return false;\r |
42 | }\r |
43 | if (readwriteFile() == false) {\r |
44 | return false;\r |
45 | }\r |
46 | return true;\r |
47 | } else {\r |
48 | try {\r |
49 | Fd.createNewFile();\r |
50 | } catch (IOException e) {\r |
51 | System.out.printf("%n%s", "Create the file:target.txt failed!");\r |
52 | return false;\r |
53 | }\r |
54 | }\r |
55 | TargetFile.writeFile(Fd);\r |
56 | return true;\r |
57 | }\r |
f337986f |
58 | \r |
59 | \r |
60 | /** \r |
61 | * validate the filename\r |
62 | * @param String filename : the name of target file\r |
63 | * \r |
64 | * @return true or false\r |
65 | **/\r |
66 | public static boolean validateFilename(String filename) {\r |
67 | \r |
68 | String workspacePath = System.getenv("WORKSPACE");\r |
69 | \r |
70 | Fd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename);\r |
71 | \r |
72 | if (Fd.exists() == true && Fd.canRead() == true)\r |
73 | return true;\r |
74 | else\r |
75 | return false;\r |
76 | }\r |
77 | \r |
c74c7a43 |
78 | \r |
79 | /**\r |
80 | * create a empty temp file, which is located at the same directory with target file\r |
81 | * @param String filename : the name of target temp file\r |
82 | * @return true or false\r |
83 | **/\r |
f337986f |
84 | public static boolean createTempFile(String filename) {\r |
c74c7a43 |
85 | \r |
86 | String workspacePath = System.getenv("WORKSPACE");\r |
87 | \r |
f337986f |
88 | TempFd = new File(workspacePath + File.separator + "Tools" + File.separator + "Conf" + File.separator + filename + "tmp");\r |
c74c7a43 |
89 | \r |
90 | if (TempFd.exists() == true) {\r |
91 | if (TempFd.delete() == false) {\r |
92 | System.out.println("\n# delete file failed !");\r |
93 | return false;\r |
94 | }\r |
95 | }\r |
96 | try {\r |
97 | TempFd.createNewFile();\r |
98 | } catch (IOException e) {\r |
99 | System.out.printf("%n%s",\r |
100 | "Create the temp file:target.txttmp failed!");\r |
101 | return false;\r |
102 | }\r |
103 | \r |
104 | return true;\r |
105 | }\r |
106 | \r |
107 | /**\r |
108 | * read from target.txt and write to target.txttmp, del target.txt, rename\r |
109 | * @param no paremeter\r |
110 | * @return true or false\r |
111 | **/\r |
f337986f |
112 | public static boolean readwriteFile() {\r |
c74c7a43 |
113 | \r |
114 | if (Fd.canRead() != true)\r |
115 | return false;\r |
116 | \r |
117 | BufferedReader br = null;\r |
118 | BufferedWriter bw = null;\r |
119 | String textLine = null;\r |
120 | \r |
121 | try {\r |
122 | br = new BufferedReader(new FileReader(Fd));\r |
123 | } catch (FileNotFoundException e) {\r |
124 | System.out\r |
125 | .println("\n# create the BufferedReader failed, because can't find the file:target.txt!");\r |
126 | return false;\r |
127 | }\r |
128 | try {\r |
129 | bw = new BufferedWriter(new FileWriter(TempFd));\r |
130 | } catch (IOException e) {\r |
131 | System.out.println("\n# create the BufferedWriter failed!");\r |
132 | return false;\r |
133 | }\r |
134 | \r |
135 | //\r |
136 | //TARGET_ARCH must be in front of TARGET!!! according to the target.txt\r |
137 | //\r |
138 | try {\r |
139 | while ((textLine = br.readLine()) != null) {\r |
2c71f6e5 |
140 | //\r |
141 | // the line is composed of Space\r |
142 | //\r |
c74c7a43 |
143 | if (textLine.trim().compareToIgnoreCase("") == 0) {\r |
144 | bw.write(textLine);\r |
145 | bw.newLine();\r |
2c71f6e5 |
146 | } \r |
147 | //\r |
148 | // the line starts with "#", and no "="\r |
149 | //\r |
150 | else if ((textLine.trim().charAt(0) == '#') && (textLine.indexOf("=") == -1)){\r |
c74c7a43 |
151 | bw.write(textLine);\r |
152 | bw.newLine();\r |
153 | } else {\r |
2c71f6e5 |
154 | //\r |
155 | //modify at the first time, and there should be *ACTIVE_PLATFORM*=* in the line\r |
156 | //\r |
c74c7a43 |
157 | if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {\r |
2c71f6e5 |
158 | if(pflag == true){\r |
159 | if(textLine.trim().charAt(0) == '#'){\r |
f337986f |
160 | if(ParseParameter.curpstr.length() >= ParseParameter.plength) {\r |
161 | bw.write(ParseParameter.curpstr);\r |
2c71f6e5 |
162 | bw.newLine();\r |
163 | pflag = false;\r |
164 | }\r |
165 | continue;\r |
166 | }\r |
f337986f |
167 | if(ParseParameter.curpstr.length() >= ParseParameter.plength) {\r |
168 | bw.write(ParseParameter.curpstr);\r |
2c71f6e5 |
169 | } else {\r |
170 | bw.write(textLine);\r |
171 | }\r |
172 | bw.newLine();\r |
173 | pflag = false;\r |
c74c7a43 |
174 | }\r |
c74c7a43 |
175 | } else if (textLine.indexOf("TARGET_ARCH") != -1) {\r |
2c71f6e5 |
176 | if(aflag == true){\r |
177 | if(textLine.trim().charAt(0) == '#'){\r |
f337986f |
178 | if(ParseParameter.curastr.length() >= ParseParameter.alength) {\r |
179 | bw.write(ParseParameter.curastr);\r |
2c71f6e5 |
180 | bw.newLine();\r |
181 | aflag = false;\r |
182 | }\r |
183 | continue;\r |
184 | }\r |
f337986f |
185 | if(ParseParameter.curastr.length() >= ParseParameter.alength) {\r |
186 | bw.write(ParseParameter.curastr);\r |
2c71f6e5 |
187 | } else {\r |
188 | bw.write(textLine);\r |
189 | }\r |
190 | bw.newLine();\r |
191 | aflag = false;\r |
c74c7a43 |
192 | }\r |
c74c7a43 |
193 | } else if (textLine.indexOf("TARGET") != -1) {\r |
2c71f6e5 |
194 | if(tflag == true){\r |
195 | if(textLine.trim().charAt(0) == '#'){\r |
f337986f |
196 | if(ParseParameter.curtstr.length() >= ParseParameter.tlength) {\r |
197 | bw.write(ParseParameter.curtstr);\r |
2c71f6e5 |
198 | bw.newLine();\r |
199 | tflag = false;\r |
200 | }\r |
201 | continue;\r |
202 | }\r |
f337986f |
203 | if(ParseParameter.curtstr.length() >= ParseParameter.tlength) {\r |
204 | bw.write(ParseParameter.curtstr);\r |
2c71f6e5 |
205 | } else {\r |
206 | bw.write(textLine);\r |
207 | }\r |
208 | bw.newLine();\r |
209 | tflag = false;\r |
c74c7a43 |
210 | }\r |
c74c7a43 |
211 | } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {\r |
2c71f6e5 |
212 | if(cflag == true){\r |
213 | if(textLine.trim().charAt(0) == '#'){\r |
f337986f |
214 | if(ParseParameter.curcstr.length() >= ParseParameter.clength) {\r |
215 | bw.write(ParseParameter.curcstr);\r |
2c71f6e5 |
216 | bw.newLine();\r |
217 | cflag = false;\r |
218 | }\r |
219 | continue;\r |
220 | }\r |
f337986f |
221 | if(ParseParameter.curcstr.length() >= ParseParameter.clength) {\r |
222 | bw.write(ParseParameter.curcstr);\r |
2c71f6e5 |
223 | } else {\r |
224 | bw.write(textLine);\r |
225 | }\r |
226 | bw.newLine();\r |
227 | cflag = false;\r |
c74c7a43 |
228 | }\r |
c74c7a43 |
229 | } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {\r |
2c71f6e5 |
230 | if(nflag == true){\r |
231 | if(textLine.trim().charAt(0) == '#'){\r |
f337986f |
232 | if(ParseParameter.curnstr.length() >= ParseParameter.nlength) {\r |
233 | bw.write(ParseParameter.curnstr);\r |
2c71f6e5 |
234 | bw.newLine();\r |
235 | nflag = false;\r |
236 | }\r |
237 | continue;\r |
238 | }\r |
f337986f |
239 | if(ParseParameter.curnstr.length() >= ParseParameter.nlength) {\r |
240 | bw.write(ParseParameter.curnstr);\r |
2c71f6e5 |
241 | } else {\r |
242 | bw.write(textLine);\r |
243 | }\r |
244 | bw.newLine();\r |
245 | nflag = false;\r |
246 | }\r |
247 | } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {\r |
248 | if(mflag == true){\r |
249 | if(textLine.trim().charAt(0) == '#'){\r |
f337986f |
250 | if(ParseParameter.curmstr.length() >= ParseParameter.mlength) {\r |
251 | bw.write(ParseParameter.curmstr);\r |
2c71f6e5 |
252 | bw.newLine();\r |
253 | mflag = false;\r |
254 | }\r |
255 | continue;\r |
256 | }\r |
f337986f |
257 | if(ParseParameter.curmstr.length() >= ParseParameter.mlength) {\r |
258 | bw.write(ParseParameter.curmstr);\r |
2c71f6e5 |
259 | } else {\r |
260 | bw.write(textLine);\r |
261 | }\r |
262 | bw.newLine();\r |
263 | mflag = false;\r |
264 | }\r |
265 | }else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {\r |
266 | if(meflag == true){\r |
267 | if(textLine.trim().charAt(0) == '#'){\r |
f337986f |
268 | if(ParseParameter.curmestr.length() >= ParseParameter.melength) {\r |
269 | bw.write(ParseParameter.curmestr);\r |
2c71f6e5 |
270 | bw.newLine();\r |
271 | meflag = false;\r |
272 | }\r |
273 | continue;\r |
274 | }\r |
f337986f |
275 | if(ParseParameter.curmestr.length() >= ParseParameter.melength) {\r |
276 | bw.write(ParseParameter.curmestr);\r |
2c71f6e5 |
277 | } else {\r |
278 | bw.write(textLine);\r |
279 | }\r |
280 | bw.newLine();\r |
281 | meflag = false;\r |
c74c7a43 |
282 | }\r |
c74c7a43 |
283 | }\r |
284 | }\r |
285 | }\r |
2c71f6e5 |
286 | //\r |
287 | //user maybe delete the line *ACTIVE_PLATFORM*=*\r |
288 | //\r |
f337986f |
289 | if( (pflag == true) && (ParseParameter.curpstr.length() >= ParseParameter.plength) ){\r |
290 | bw.write(ParseParameter.curpstr);\r |
2c71f6e5 |
291 | bw.newLine();\r |
f337986f |
292 | } else if ( (tflag == true) && (ParseParameter.curtstr.length() >= ParseParameter.tlength) ){\r |
293 | bw.write(ParseParameter.curtstr);\r |
2c71f6e5 |
294 | bw.newLine();\r |
f337986f |
295 | } else if ( (aflag == true) && (ParseParameter.curastr.length() >= ParseParameter.alength) ){\r |
296 | bw.write(ParseParameter.curastr);\r |
2c71f6e5 |
297 | bw.newLine();\r |
f337986f |
298 | } else if ( (cflag == true) && (ParseParameter.curcstr.length() >= ParseParameter.clength) ){\r |
299 | bw.write(ParseParameter.curcstr);\r |
2c71f6e5 |
300 | bw.newLine();\r |
f337986f |
301 | } else if ( (nflag == true) && (ParseParameter.curnstr.length() >= ParseParameter.nlength) ){\r |
302 | bw.write(ParseParameter.curnstr);\r |
2c71f6e5 |
303 | bw.newLine();\r |
f337986f |
304 | } else if ( (meflag == true) && (ParseParameter.curmestr.length() >= ParseParameter.melength) ){\r |
305 | bw.write(ParseParameter.curmestr);\r |
2c71f6e5 |
306 | bw.newLine();\r |
f337986f |
307 | } else if ( (mflag == true) && (ParseParameter.curmstr.length() >= ParseParameter.mlength) ){\r |
308 | bw.write(ParseParameter.curmstr);\r |
2c71f6e5 |
309 | bw.newLine();\r |
310 | }\r |
c74c7a43 |
311 | } catch (IOException e) {\r |
312 | System.out.println("\n# read or write file error!");\r |
313 | return false;\r |
314 | }\r |
315 | \r |
316 | try {\r |
317 | br.close();\r |
318 | bw.close();\r |
319 | } catch (IOException e) {\r |
320 | System.out\r |
321 | .println("\n# close BufferedReader&BufferedWriter error");\r |
322 | return false;\r |
323 | }\r |
324 | \r |
325 | if (Fd.delete() == false) {\r |
326 | System.out.println("\n# delete file failed !");\r |
327 | return false;\r |
328 | }\r |
329 | if (TempFd.renameTo(Fd) == false) {\r |
330 | System.out.println("\n# rename file failed !");\r |
331 | return false;\r |
332 | }\r |
333 | \r |
334 | return true;\r |
335 | }\r |
f337986f |
336 | \r |
337 | /**\r |
338 | * read the file and output the lines which include setting\r |
339 | * @param File fd : the File of the target file\r |
340 | * @return String: the current setting\r |
341 | **/\r |
342 | public static boolean readFile() {\r |
343 | \r |
344 | BufferedReader br = null;\r |
345 | String textLine = null;\r |
346 | \r |
347 | try {\r |
348 | br = new BufferedReader(new FileReader(Fd));\r |
349 | } catch (FileNotFoundException e) {\r |
350 | System.out\r |
351 | .println("\n# create the BufferedReader failed, because can't find the file:target.txt!");\r |
352 | return false;\r |
353 | }\r |
354 | try {\r |
355 | while ((textLine = br.readLine()) != null) {\r |
356 | //\r |
357 | // the line is composed of Space\r |
358 | //\r |
359 | if (textLine.trim().compareToIgnoreCase("") == 0) {\r |
360 | continue;\r |
361 | } \r |
362 | //\r |
363 | // the line starts with "#"\r |
364 | //\r |
365 | else if ((textLine.trim().charAt(0) == '#')){\r |
366 | continue;\r |
367 | } else {\r |
368 | if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {\r |
369 | ParseParameter.curpstr = textLine;\r |
370 | ParseParameter.plength = textLine.indexOf('=');\r |
371 | } else if (textLine.indexOf("TARGET_ARCH") != -1) {\r |
372 | ParseParameter.curastr = textLine;\r |
373 | ParseParameter.alength = textLine.indexOf('=');\r |
374 | } else if (textLine.indexOf("TARGET") != -1) {\r |
375 | ParseParameter.curtstr = textLine;\r |
376 | ParseParameter.tlength = textLine.indexOf('=');\r |
377 | } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {\r |
378 | ParseParameter.curcstr = textLine;\r |
379 | ParseParameter.clength = textLine.indexOf('=');\r |
380 | } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {\r |
381 | ParseParameter.curnstr = textLine;\r |
382 | ParseParameter.nlength = textLine.indexOf('=');\r |
383 | } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {\r |
384 | ParseParameter.curmstr = textLine;\r |
385 | ParseParameter.mlength = textLine.indexOf('=');\r |
386 | } else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {\r |
387 | ParseParameter.curmestr = textLine;\r |
388 | ParseParameter.melength = textLine.indexOf('=');\r |
389 | }\r |
390 | }\r |
391 | }\r |
392 | } catch (IOException e) {\r |
393 | System.out.println("\n# read file error!");\r |
394 | return false;\r |
395 | }\r |
396 | \r |
397 | try {\r |
398 | br.close();\r |
399 | } catch (IOException e) {\r |
400 | System.out\r |
401 | .println("\n# close BufferedReader error");\r |
402 | return false;\r |
403 | }\r |
404 | return true;\r |
405 | }\r |
406 | \r |
407 | private static String convertStr(String str){\r |
408 | String convertStr = null;\r |
409 | \r |
410 | if( str.compareTo("-p") == 0 ){\r |
411 | convertStr = "ACTIVE_PLATFORM";\r |
412 | }else if( str.compareTo("-a") == 0){\r |
413 | convertStr = "TARGET_ARCH";\r |
414 | }else if( str.compareTo("-t") == 0){\r |
415 | convertStr = "TARGET";\r |
416 | }else if( str.compareTo("-c") == 0){\r |
417 | convertStr = "TOOL_CHAIN_CONF";\r |
418 | }else if( str.compareTo("-n") == 0){\r |
419 | convertStr = "TOOL_CHAIN_TAG";\r |
420 | }else if( str.compareTo("-m") == 0){\r |
421 | convertStr = "MAX_CONCURRENT_THREAD_NUMBER";\r |
422 | }\r |
423 | \r |
424 | return convertStr;\r |
425 | }\r |
426 | \r |
c74c7a43 |
427 | \r |
428 | /**\r |
429 | * according to user's input args, write the file directly\r |
430 | * @param File fd : the File of the target file\r |
431 | * @return true or false\r |
432 | **/\r |
433 | private static boolean writeFile(File fd) {\r |
434 | \r |
435 | if (fd.canWrite() != true)\r |
436 | return false;\r |
437 | \r |
438 | FileOutputStream outputFile = null;\r |
439 | try {\r |
440 | outputFile = new FileOutputStream(fd);\r |
441 | } catch (FileNotFoundException e) {\r |
442 | System.out\r |
443 | .println("\n# can't find the file when open the output stream !");\r |
444 | return false;\r |
445 | }\r |
446 | FileChannel outputChannel = outputFile.getChannel();\r |
447 | \r |
2c71f6e5 |
448 | ByteBuffer[] buffers = new ByteBuffer[7];\r |
c74c7a43 |
449 | buffers[0] = ByteBuffer.allocate(ParseParameter.pstr.toString().length());\r |
450 | buffers[1] = ByteBuffer.allocate(ParseParameter.tstr.toString().length());\r |
451 | buffers[2] = ByteBuffer.allocate(ParseParameter.astr.toString().length());\r |
452 | buffers[3] = ByteBuffer.allocate(ParseParameter.cstr.toString().length());\r |
453 | buffers[4] = ByteBuffer.allocate(ParseParameter.nstr.toString().length());\r |
2c71f6e5 |
454 | buffers[5] = ByteBuffer.allocate(ParseParameter.mestr.toString().length());\r |
455 | buffers[6] = ByteBuffer.allocate(ParseParameter.mstr.toString().length());\r |
c74c7a43 |
456 | \r |
457 | buffers[0].put(ParseParameter.pstr.toString().getBytes()).flip();\r |
458 | buffers[1].put(ParseParameter.tstr.toString().getBytes()).flip();\r |
459 | buffers[2].put(ParseParameter.astr.toString().getBytes()).flip();\r |
460 | buffers[3].put(ParseParameter.cstr.toString().getBytes()).flip();\r |
461 | buffers[4].put(ParseParameter.nstr.toString().getBytes()).flip();\r |
2c71f6e5 |
462 | buffers[5].put(ParseParameter.mestr.toString().getBytes()).flip();\r |
463 | buffers[6].put(ParseParameter.mstr.toString().getBytes()).flip();\r |
c74c7a43 |
464 | \r |
465 | try {\r |
466 | ByteBuffer bufofCP = ByteBuffer.allocate(Copyright.length());\r |
467 | bufofCP.put(Copyright.getBytes()).flip();\r |
468 | outputChannel.write(bufofCP);\r |
469 | \r |
470 | ByteBuffer bufofFI = ByteBuffer.allocate(Fileinfo.length());\r |
471 | bufofFI.put(Fileinfo.getBytes()).flip();\r |
472 | outputChannel.write(bufofFI);\r |
473 | \r |
474 | ByteBuffer buffer0 = ByteBuffer.allocate(pusage.length());\r |
475 | buffer0.put(pusage.getBytes()).flip();\r |
476 | outputChannel.write(buffer0);\r |
477 | outputChannel.write(buffers[0]);\r |
478 | \r |
479 | ByteBuffer buffer1 = ByteBuffer.allocate(tusage.length());\r |
480 | buffer1.put(tusage.getBytes()).flip();\r |
481 | outputChannel.write(buffer1);\r |
482 | outputChannel.write(buffers[1]);\r |
483 | \r |
484 | ByteBuffer buffer2 = ByteBuffer.allocate(ausage.length());\r |
485 | buffer2.put(ausage.getBytes()).flip();\r |
486 | outputChannel.write(buffer2);\r |
487 | outputChannel.write(buffers[2]);\r |
488 | \r |
489 | ByteBuffer buffer3 = ByteBuffer.allocate(cusage.length());\r |
490 | buffer3.put(cusage.getBytes()).flip();\r |
491 | outputChannel.write(buffer3);\r |
492 | outputChannel.write(buffers[3]);\r |
493 | \r |
494 | ByteBuffer buffer4 = ByteBuffer.allocate(nusage.length());\r |
495 | buffer4.put(nusage.getBytes()).flip();\r |
496 | outputChannel.write(buffer4);\r |
497 | outputChannel.write(buffers[4]);\r |
498 | \r |
2c71f6e5 |
499 | ByteBuffer buffer5 = ByteBuffer.allocate(meusage.length());\r |
500 | buffer4.put(meusage.getBytes()).flip();\r |
501 | outputChannel.write(buffer5);\r |
502 | outputChannel.write(buffers[5]);\r |
503 | \r |
504 | ByteBuffer buffer6 = ByteBuffer.allocate(musage.length());\r |
505 | buffer4.put(musage.getBytes()).flip();\r |
506 | outputChannel.write(buffer6);\r |
507 | outputChannel.write(buffers[6]);\r |
508 | \r |
c74c7a43 |
509 | outputFile.close();\r |
510 | } catch (IOException e) {\r |
511 | System.out.println("\n# The operations of file failed !");\r |
512 | return false;\r |
513 | }\r |
514 | return true;\r |
515 | }\r |
516 | \r |
517 | ///\r |
518 | /// point to target.txttmp, a temp file, which is created and deleted during the tool's runtime.\r |
519 | ///\r |
520 | private static File TempFd;\r |
521 | \r |
522 | ///\r |
523 | /// point to target.txt.\r |
524 | ///\r |
525 | private static File Fd;\r |
2c71f6e5 |
526 | \r |
527 | ///\r |
528 | /// when the flag is true, the corresponding str should be add at the end of file.\r |
529 | ///\r |
530 | private static boolean pflag = true;\r |
531 | private static boolean tflag = true;\r |
532 | private static boolean aflag = true;\r |
533 | private static boolean cflag = true;\r |
534 | private static boolean nflag = true;\r |
535 | private static boolean mflag = true;\r |
536 | private static boolean meflag = true;\r |
c74c7a43 |
537 | \r |
538 | private static final String Copyright = "#\n"\r |
539 | + "# Copyright (c) 2006, Intel Corporation\n"\r |
540 | + "#\n"\r |
541 | + "# All rights reserved. This program and the accompanying materials\n"\r |
542 | + "# are licensed and made available under the terms and conditions of the BSD License\n"\r |
543 | + "# which accompanies this distribution. The full text of the license may be found at\n"\r |
544 | + "# http://opensource.org/licenses/bsd-license.php\n"\r |
545 | + "\n"\r |
546 | + "# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS,\n"\r |
547 | + "# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\n";\r |
548 | \r |
549 | private static final String Fileinfo = "#\n"\r |
550 | + "# Filename: target.template\n"\r |
551 | + "#\n"\r |
552 | + "# ALL Paths are Relative to WORKSPACE\n"\r |
553 | + "\n"\r |
554 | + "# Separate multiple LIST entries with a SINGLE SPACE character, do not use comma characters.\n"\r |
555 | + "# Un-set an option by either commenting out the line, or not setting a value.\n";\r |
556 | \r |
557 | private static final String pusage = "#\n"\r |
558 | + "# PROPERTY Type Use Description\n"\r |
559 | + "# ---------------- -------- -------- -----------------------------------------------------------\n"\r |
560 | + "# ACTIVE_PLATFORM Filename Recommended Specify the WORKSPACE relative Path and Filename\n"\r |
561 | + "# of the platform FPD file that will be used for the build\n"\r |
562 | + "# This line is required if and only if the current working\n"\r |
563 | + "# directory does not contain one or more FPD files.\n";\r |
564 | \r |
565 | private static final String tusage = "\n\n"\r |
566 | + "# TARGET List Optional Zero or more of the following: DEBUG, RELEASE, \n"\r |
567 | + "# UserDefined; separated by a space character. \n"\r |
568 | + "# If the line is missing or no value is specified, all\n"\r |
569 | + "# valid targets specified in the FPD file will attempt \n"\r |
570 | + "# to be built. The following line will build all platform\n"\r |
571 | + "# targets.\n";\r |
572 | \r |
573 | private static final String ausage = "\n\n"\r |
574 | + "# TARGET_ARCH List Optional What kind of architecture is the binary being target for.\n"\r |
575 | + "# One, or more, of the following, IA32, IA64, X64, EBC or ARM.\n"\r |
576 | + "# Multiple values can be specified on a single line, using \n"\r |
577 | + "# space charaters to separate the values. These are used \n"\r |
578 | + "# during the parsing of an FPD file, restricting the build\n"\r |
579 | + "# output target(s.)\n"\r |
580 | + "# The Build Target ARCH is determined by a logical AND of:\n"\r |
581 | + "# FPD BuildOptions: <SupportedArchitectures> tag\n"\r |
582 | + "# If not specified, then all valid architectures specified \n"\r |
583 | + "# in the FPD file, for which tools are available, will be \n"\r |
584 | + "# built.\n";\r |
585 | \r |
586 | private static final String cusage = "\n\n"\r |
587 | + "# TOOL_DEFINITION_FILE Filename Optional Specify the name of the filename to use for specifying \n"\r |
588 | + "# the tools to use for the build. If not specified, \n"\r |
589 | + "# tools_def.txt will be used for the build. This file \n"\r |
590 | + "# MUST be located in the WORKSPACE/Tools/Conf directory.\n";\r |
591 | \r |
592 | private static final String nusage = "\n\n"\r |
593 | + "# TAGNAME List Optional Specify the name(s) of the tools_def.txt TagName to use.\n"\r |
594 | + "# If not specified, all applicable TagName tools will be \n"\r |
595 | + "# used for the build. The list uses space character separation.\n";\r |
2c71f6e5 |
596 | \r |
597 | private static final String musage = "\n\n"\r |
598 | + "# MULTIPLE_THREAD FLAG Optional Flag to enable multi-thread build. If not specified, default\n"\r |
599 | + "# is \"Disable\". If your computer is multi-core or multiple CPUs,\n" \r |
600 | + "# enabling this feature will bring much benefit. For multi-thread\n" \r |
601 | + "# built, the log will write to ${BUILD_DIR}/build.log.\n" \r |
602 | + "# This feature is only for PLATFORM build, and clean, cleanall or\n"\r |
603 | + "# stand-alone module build is still using the normal way.\n";\r |
604 | private static final String meusage = "\n\n"\r |
605 | + "# MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Default is 2. Recommend to\n" \r |
606 | + "# set this value to one more than the number of your compurter\n"\r |
607 | + "# cores or CPUs.\n";\r |
c74c7a43 |
608 | }\r |