]>
Commit | Line | Data |
---|---|---|
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 | |
f15e1359 | 160 | if(ParseParameter.npflag == true) {\r |
f337986f | 161 | bw.write(ParseParameter.curpstr);\r |
f15e1359 | 162 | }else{\r |
163 | bw.write(textLine);\r | |
2c71f6e5 | 164 | }\r |
f15e1359 | 165 | bw.newLine();\r |
166 | pflag = false;\r | |
2c71f6e5 | 167 | continue;\r |
168 | }\r | |
f15e1359 | 169 | if(ParseParameter.npflag == true) {\r |
f337986f | 170 | bw.write(ParseParameter.curpstr);\r |
2c71f6e5 | 171 | } else {\r |
172 | bw.write(textLine);\r | |
173 | }\r | |
174 | bw.newLine();\r | |
175 | pflag = false;\r | |
c74c7a43 | 176 | }\r |
c74c7a43 | 177 | } else if (textLine.indexOf("TARGET_ARCH") != -1) {\r |
2c71f6e5 | 178 | if(aflag == true){\r |
179 | if(textLine.trim().charAt(0) == '#'){\r | |
f15e1359 | 180 | if(ParseParameter.naflag == true) {\r |
f337986f | 181 | bw.write(ParseParameter.curastr);\r |
f15e1359 | 182 | }else{\r |
183 | bw.write(textLine);\r | |
2c71f6e5 | 184 | }\r |
f15e1359 | 185 | bw.newLine();\r |
186 | aflag = false;\r | |
2c71f6e5 | 187 | continue;\r |
188 | }\r | |
f15e1359 | 189 | if(ParseParameter.naflag == true) {\r |
f337986f | 190 | bw.write(ParseParameter.curastr);\r |
2c71f6e5 | 191 | } else {\r |
192 | bw.write(textLine);\r | |
193 | }\r | |
194 | bw.newLine();\r | |
195 | aflag = false;\r | |
c74c7a43 | 196 | }\r |
c74c7a43 | 197 | } else if (textLine.indexOf("TARGET") != -1) {\r |
2c71f6e5 | 198 | if(tflag == true){\r |
199 | if(textLine.trim().charAt(0) == '#'){\r | |
f15e1359 | 200 | if(ParseParameter.ntflag == true) {\r |
f337986f | 201 | bw.write(ParseParameter.curtstr);\r |
f15e1359 | 202 | }else{\r |
203 | bw.write(textLine);\r | |
2c71f6e5 | 204 | }\r |
f15e1359 | 205 | bw.newLine();\r |
206 | tflag = false;\r | |
2c71f6e5 | 207 | continue;\r |
208 | }\r | |
f15e1359 | 209 | if(ParseParameter.ntflag == true) {\r |
f337986f | 210 | bw.write(ParseParameter.curtstr);\r |
2c71f6e5 | 211 | } else {\r |
212 | bw.write(textLine);\r | |
213 | }\r | |
214 | bw.newLine();\r | |
215 | tflag = false;\r | |
c74c7a43 | 216 | }\r |
c74c7a43 | 217 | } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {\r |
2c71f6e5 | 218 | if(cflag == true){\r |
219 | if(textLine.trim().charAt(0) == '#'){\r | |
f15e1359 | 220 | if(ParseParameter.ncflag == true) {\r |
f337986f | 221 | bw.write(ParseParameter.curcstr);\r |
f15e1359 | 222 | }else{\r |
223 | bw.write(textLine);\r | |
2c71f6e5 | 224 | }\r |
f15e1359 | 225 | bw.newLine();\r |
226 | cflag = false;\r | |
2c71f6e5 | 227 | continue;\r |
228 | }\r | |
f15e1359 | 229 | if(ParseParameter.ncflag == true) {\r |
f337986f | 230 | bw.write(ParseParameter.curcstr);\r |
2c71f6e5 | 231 | } else {\r |
232 | bw.write(textLine);\r | |
233 | }\r | |
234 | bw.newLine();\r | |
235 | cflag = false;\r | |
c74c7a43 | 236 | }\r |
c74c7a43 | 237 | } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {\r |
2c71f6e5 | 238 | if(nflag == true){\r |
239 | if(textLine.trim().charAt(0) == '#'){\r | |
f15e1359 | 240 | if(ParseParameter.nnflag == true) {\r |
f337986f | 241 | bw.write(ParseParameter.curnstr);\r |
f15e1359 | 242 | }else{\r |
243 | bw.write(textLine);\r | |
2c71f6e5 | 244 | }\r |
f15e1359 | 245 | bw.newLine();\r |
246 | nflag = false;\r | |
2c71f6e5 | 247 | continue;\r |
248 | }\r | |
f15e1359 | 249 | if(ParseParameter.nnflag == true) {\r |
f337986f | 250 | bw.write(ParseParameter.curnstr);\r |
2c71f6e5 | 251 | } else {\r |
252 | bw.write(textLine);\r | |
253 | }\r | |
254 | bw.newLine();\r | |
255 | nflag = false;\r | |
256 | }\r | |
257 | } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {\r | |
258 | if(mflag == true){\r | |
259 | if(textLine.trim().charAt(0) == '#'){\r | |
f15e1359 | 260 | if(ParseParameter.nmflag == true) {\r |
f337986f | 261 | bw.write(ParseParameter.curmstr);\r |
f15e1359 | 262 | }else{\r |
263 | bw.write(textLine);\r | |
2c71f6e5 | 264 | }\r |
f15e1359 | 265 | bw.newLine();\r |
266 | mflag = false;\r | |
2c71f6e5 | 267 | continue;\r |
268 | }\r | |
f15e1359 | 269 | if(ParseParameter.nmflag == true) {\r |
f337986f | 270 | bw.write(ParseParameter.curmstr);\r |
2c71f6e5 | 271 | } else {\r |
272 | bw.write(textLine);\r | |
273 | }\r | |
274 | bw.newLine();\r | |
275 | mflag = false;\r | |
276 | }\r | |
277 | }else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {\r | |
278 | if(meflag == true){\r | |
279 | if(textLine.trim().charAt(0) == '#'){\r | |
f15e1359 | 280 | if(ParseParameter.nmeflag == true) {\r |
f337986f | 281 | bw.write(ParseParameter.curmestr);\r |
f15e1359 | 282 | }else{\r |
283 | bw.write(textLine);\r | |
2c71f6e5 | 284 | }\r |
f15e1359 | 285 | bw.newLine();\r |
286 | meflag = false;\r | |
2c71f6e5 | 287 | continue;\r |
288 | }\r | |
f15e1359 | 289 | if(ParseParameter.nmeflag == true) {\r |
f337986f | 290 | bw.write(ParseParameter.curmestr);\r |
2c71f6e5 | 291 | } else {\r |
292 | bw.write(textLine);\r | |
293 | }\r | |
294 | bw.newLine();\r | |
295 | meflag = false;\r | |
c74c7a43 | 296 | }\r |
c74c7a43 | 297 | }\r |
298 | }\r | |
299 | }\r | |
2c71f6e5 | 300 | //\r |
301 | //user maybe delete the line *ACTIVE_PLATFORM*=*\r | |
302 | //\r | |
f15e1359 | 303 | if( (pflag == true) && (ParseParameter.npflag == true) ){\r |
f337986f | 304 | bw.write(ParseParameter.curpstr);\r |
2c71f6e5 | 305 | bw.newLine();\r |
f15e1359 | 306 | } else if ( (tflag == true) && (ParseParameter.ntflag == true) ){\r |
f337986f | 307 | bw.write(ParseParameter.curtstr);\r |
2c71f6e5 | 308 | bw.newLine();\r |
f15e1359 | 309 | } else if ( (aflag == true) && (ParseParameter.naflag == true) ){\r |
f337986f | 310 | bw.write(ParseParameter.curastr);\r |
2c71f6e5 | 311 | bw.newLine();\r |
f15e1359 | 312 | } else if ( (cflag == true) && (ParseParameter.ncflag == true) ){\r |
f337986f | 313 | bw.write(ParseParameter.curcstr);\r |
2c71f6e5 | 314 | bw.newLine();\r |
f15e1359 | 315 | } else if ( (nflag == true) && (ParseParameter.nnflag == true) ){\r |
f337986f | 316 | bw.write(ParseParameter.curnstr);\r |
2c71f6e5 | 317 | bw.newLine();\r |
f15e1359 | 318 | } else if ( (meflag == true) && (ParseParameter.nmeflag == true) ){\r |
f337986f | 319 | bw.write(ParseParameter.curmestr);\r |
2c71f6e5 | 320 | bw.newLine();\r |
f15e1359 | 321 | } else if ( (mflag == true) && (ParseParameter.nmflag == true) ){\r |
f337986f | 322 | bw.write(ParseParameter.curmstr);\r |
2c71f6e5 | 323 | bw.newLine();\r |
324 | }\r | |
c74c7a43 | 325 | } catch (IOException e) {\r |
326 | System.out.println("\n# read or write file error!");\r | |
327 | return false;\r | |
328 | }\r | |
329 | \r | |
330 | try {\r | |
331 | br.close();\r | |
332 | bw.close();\r | |
333 | } catch (IOException e) {\r | |
334 | System.out\r | |
335 | .println("\n# close BufferedReader&BufferedWriter error");\r | |
336 | return false;\r | |
337 | }\r | |
338 | \r | |
339 | if (Fd.delete() == false) {\r | |
340 | System.out.println("\n# delete file failed !");\r | |
341 | return false;\r | |
342 | }\r | |
343 | if (TempFd.renameTo(Fd) == false) {\r | |
344 | System.out.println("\n# rename file failed !");\r | |
345 | return false;\r | |
346 | }\r | |
347 | \r | |
348 | return true;\r | |
349 | }\r | |
f337986f | 350 | \r |
351 | /**\r | |
352 | * read the file and output the lines which include setting\r | |
353 | * @param File fd : the File of the target file\r | |
354 | * @return String: the current setting\r | |
355 | **/\r | |
356 | public static boolean readFile() {\r | |
357 | \r | |
358 | BufferedReader br = null;\r | |
359 | String textLine = null;\r | |
360 | \r | |
361 | try {\r | |
362 | br = new BufferedReader(new FileReader(Fd));\r | |
363 | } catch (FileNotFoundException e) {\r | |
364 | System.out\r | |
365 | .println("\n# create the BufferedReader failed, because can't find the file:target.txt!");\r | |
366 | return false;\r | |
367 | }\r | |
368 | try {\r | |
369 | while ((textLine = br.readLine()) != null) {\r | |
370 | //\r | |
371 | // the line is composed of Space\r | |
372 | //\r | |
373 | if (textLine.trim().compareToIgnoreCase("") == 0) {\r | |
374 | continue;\r | |
375 | } \r | |
376 | //\r | |
377 | // the line starts with "#"\r | |
378 | //\r | |
379 | else if ((textLine.trim().charAt(0) == '#')){\r | |
380 | continue;\r | |
381 | } else {\r | |
382 | if (textLine.indexOf("ACTIVE_PLATFORM") != -1) {\r | |
383 | ParseParameter.curpstr = textLine;\r | |
384 | ParseParameter.plength = textLine.indexOf('=');\r | |
385 | } else if (textLine.indexOf("TARGET_ARCH") != -1) {\r | |
386 | ParseParameter.curastr = textLine;\r | |
387 | ParseParameter.alength = textLine.indexOf('=');\r | |
388 | } else if (textLine.indexOf("TARGET") != -1) {\r | |
389 | ParseParameter.curtstr = textLine;\r | |
390 | ParseParameter.tlength = textLine.indexOf('=');\r | |
391 | } else if (textLine.indexOf("TOOL_CHAIN_CONF") != -1) {\r | |
392 | ParseParameter.curcstr = textLine;\r | |
393 | ParseParameter.clength = textLine.indexOf('=');\r | |
394 | } else if (textLine.indexOf("TOOL_CHAIN_TAG") != -1) {\r | |
395 | ParseParameter.curnstr = textLine;\r | |
396 | ParseParameter.nlength = textLine.indexOf('=');\r | |
397 | } else if (textLine.indexOf("MAX_CONCURRENT_THREAD_NUMBER") != -1) {\r | |
398 | ParseParameter.curmstr = textLine;\r | |
399 | ParseParameter.mlength = textLine.indexOf('=');\r | |
400 | } else if (textLine.indexOf("MULTIPLE_THREAD") != -1) {\r | |
401 | ParseParameter.curmestr = textLine;\r | |
402 | ParseParameter.melength = textLine.indexOf('=');\r | |
403 | }\r | |
404 | }\r | |
405 | }\r | |
406 | } catch (IOException e) {\r | |
407 | System.out.println("\n# read file error!");\r | |
408 | return false;\r | |
409 | }\r | |
410 | \r | |
411 | try {\r | |
412 | br.close();\r | |
413 | } catch (IOException e) {\r | |
414 | System.out\r | |
415 | .println("\n# close BufferedReader error");\r | |
416 | return false;\r | |
417 | }\r | |
418 | return true;\r | |
419 | }\r | |
420 | \r | |
421 | private static String convertStr(String str){\r | |
422 | String convertStr = null;\r | |
423 | \r | |
424 | if( str.compareTo("-p") == 0 ){\r | |
425 | convertStr = "ACTIVE_PLATFORM";\r | |
426 | }else if( str.compareTo("-a") == 0){\r | |
427 | convertStr = "TARGET_ARCH";\r | |
428 | }else if( str.compareTo("-t") == 0){\r | |
429 | convertStr = "TARGET";\r | |
430 | }else if( str.compareTo("-c") == 0){\r | |
431 | convertStr = "TOOL_CHAIN_CONF";\r | |
432 | }else if( str.compareTo("-n") == 0){\r | |
433 | convertStr = "TOOL_CHAIN_TAG";\r | |
434 | }else if( str.compareTo("-m") == 0){\r | |
435 | convertStr = "MAX_CONCURRENT_THREAD_NUMBER";\r | |
436 | }\r | |
437 | \r | |
438 | return convertStr;\r | |
439 | }\r | |
440 | \r | |
c74c7a43 | 441 | \r |
442 | /**\r | |
443 | * according to user's input args, write the file directly\r | |
444 | * @param File fd : the File of the target file\r | |
445 | * @return true or false\r | |
446 | **/\r | |
447 | private static boolean writeFile(File fd) {\r | |
448 | \r | |
449 | if (fd.canWrite() != true)\r | |
450 | return false;\r | |
451 | \r | |
452 | FileOutputStream outputFile = null;\r | |
453 | try {\r | |
454 | outputFile = new FileOutputStream(fd);\r | |
455 | } catch (FileNotFoundException e) {\r | |
456 | System.out\r | |
457 | .println("\n# can't find the file when open the output stream !");\r | |
458 | return false;\r | |
459 | }\r | |
460 | FileChannel outputChannel = outputFile.getChannel();\r | |
461 | \r | |
2c71f6e5 | 462 | ByteBuffer[] buffers = new ByteBuffer[7];\r |
c74c7a43 | 463 | buffers[0] = ByteBuffer.allocate(ParseParameter.pstr.toString().length());\r |
464 | buffers[1] = ByteBuffer.allocate(ParseParameter.tstr.toString().length());\r | |
465 | buffers[2] = ByteBuffer.allocate(ParseParameter.astr.toString().length());\r | |
466 | buffers[3] = ByteBuffer.allocate(ParseParameter.cstr.toString().length());\r | |
467 | buffers[4] = ByteBuffer.allocate(ParseParameter.nstr.toString().length());\r | |
2c71f6e5 | 468 | buffers[5] = ByteBuffer.allocate(ParseParameter.mestr.toString().length());\r |
469 | buffers[6] = ByteBuffer.allocate(ParseParameter.mstr.toString().length());\r | |
c74c7a43 | 470 | \r |
471 | buffers[0].put(ParseParameter.pstr.toString().getBytes()).flip();\r | |
472 | buffers[1].put(ParseParameter.tstr.toString().getBytes()).flip();\r | |
473 | buffers[2].put(ParseParameter.astr.toString().getBytes()).flip();\r | |
474 | buffers[3].put(ParseParameter.cstr.toString().getBytes()).flip();\r | |
475 | buffers[4].put(ParseParameter.nstr.toString().getBytes()).flip();\r | |
2c71f6e5 | 476 | buffers[5].put(ParseParameter.mestr.toString().getBytes()).flip();\r |
477 | buffers[6].put(ParseParameter.mstr.toString().getBytes()).flip();\r | |
c74c7a43 | 478 | \r |
479 | try {\r | |
480 | ByteBuffer bufofCP = ByteBuffer.allocate(Copyright.length());\r | |
481 | bufofCP.put(Copyright.getBytes()).flip();\r | |
482 | outputChannel.write(bufofCP);\r | |
483 | \r | |
484 | ByteBuffer bufofFI = ByteBuffer.allocate(Fileinfo.length());\r | |
485 | bufofFI.put(Fileinfo.getBytes()).flip();\r | |
486 | outputChannel.write(bufofFI);\r | |
487 | \r | |
488 | ByteBuffer buffer0 = ByteBuffer.allocate(pusage.length());\r | |
489 | buffer0.put(pusage.getBytes()).flip();\r | |
490 | outputChannel.write(buffer0);\r | |
491 | outputChannel.write(buffers[0]);\r | |
492 | \r | |
493 | ByteBuffer buffer1 = ByteBuffer.allocate(tusage.length());\r | |
494 | buffer1.put(tusage.getBytes()).flip();\r | |
495 | outputChannel.write(buffer1);\r | |
496 | outputChannel.write(buffers[1]);\r | |
497 | \r | |
498 | ByteBuffer buffer2 = ByteBuffer.allocate(ausage.length());\r | |
499 | buffer2.put(ausage.getBytes()).flip();\r | |
500 | outputChannel.write(buffer2);\r | |
501 | outputChannel.write(buffers[2]);\r | |
502 | \r | |
503 | ByteBuffer buffer3 = ByteBuffer.allocate(cusage.length());\r | |
504 | buffer3.put(cusage.getBytes()).flip();\r | |
505 | outputChannel.write(buffer3);\r | |
506 | outputChannel.write(buffers[3]);\r | |
507 | \r | |
508 | ByteBuffer buffer4 = ByteBuffer.allocate(nusage.length());\r | |
509 | buffer4.put(nusage.getBytes()).flip();\r | |
510 | outputChannel.write(buffer4);\r | |
511 | outputChannel.write(buffers[4]);\r | |
512 | \r | |
2c71f6e5 | 513 | ByteBuffer buffer5 = ByteBuffer.allocate(meusage.length());\r |
514 | buffer4.put(meusage.getBytes()).flip();\r | |
515 | outputChannel.write(buffer5);\r | |
516 | outputChannel.write(buffers[5]);\r | |
517 | \r | |
518 | ByteBuffer buffer6 = ByteBuffer.allocate(musage.length());\r | |
519 | buffer4.put(musage.getBytes()).flip();\r | |
520 | outputChannel.write(buffer6);\r | |
521 | outputChannel.write(buffers[6]);\r | |
522 | \r | |
c74c7a43 | 523 | outputFile.close();\r |
524 | } catch (IOException e) {\r | |
525 | System.out.println("\n# The operations of file failed !");\r | |
526 | return false;\r | |
527 | }\r | |
528 | return true;\r | |
529 | }\r | |
530 | \r | |
531 | ///\r | |
532 | /// point to target.txttmp, a temp file, which is created and deleted during the tool's runtime.\r | |
533 | ///\r | |
534 | private static File TempFd;\r | |
535 | \r | |
536 | ///\r | |
537 | /// point to target.txt.\r | |
538 | ///\r | |
539 | private static File Fd;\r | |
2c71f6e5 | 540 | \r |
541 | ///\r | |
542 | /// when the flag is true, the corresponding str should be add at the end of file.\r | |
543 | ///\r | |
544 | private static boolean pflag = true;\r | |
545 | private static boolean tflag = true;\r | |
546 | private static boolean aflag = true;\r | |
547 | private static boolean cflag = true;\r | |
548 | private static boolean nflag = true;\r | |
549 | private static boolean mflag = true;\r | |
550 | private static boolean meflag = true;\r | |
c74c7a43 | 551 | \r |
552 | private static final String Copyright = "#\n"\r | |
553 | + "# Copyright (c) 2006, Intel Corporation\n"\r | |
554 | + "#\n"\r | |
555 | + "# All rights reserved. This program and the accompanying materials\n"\r | |
556 | + "# are licensed and made available under the terms and conditions of the BSD License\n"\r | |
557 | + "# which accompanies this distribution. The full text of the license may be found at\n"\r | |
558 | + "# http://opensource.org/licenses/bsd-license.php\n"\r | |
559 | + "\n"\r | |
560 | + "# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS,\n"\r | |
561 | + "# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\n";\r | |
562 | \r | |
563 | private static final String Fileinfo = "#\n"\r | |
564 | + "# Filename: target.template\n"\r | |
565 | + "#\n"\r | |
566 | + "# ALL Paths are Relative to WORKSPACE\n"\r | |
567 | + "\n"\r | |
568 | + "# Separate multiple LIST entries with a SINGLE SPACE character, do not use comma characters.\n"\r | |
569 | + "# Un-set an option by either commenting out the line, or not setting a value.\n";\r | |
570 | \r | |
571 | private static final String pusage = "#\n"\r | |
572 | + "# PROPERTY Type Use Description\n"\r | |
573 | + "# ---------------- -------- -------- -----------------------------------------------------------\n"\r | |
574 | + "# ACTIVE_PLATFORM Filename Recommended Specify the WORKSPACE relative Path and Filename\n"\r | |
575 | + "# of the platform FPD file that will be used for the build\n"\r | |
576 | + "# This line is required if and only if the current working\n"\r | |
577 | + "# directory does not contain one or more FPD files.\n";\r | |
578 | \r | |
579 | private static final String tusage = "\n\n"\r | |
580 | + "# TARGET List Optional Zero or more of the following: DEBUG, RELEASE, \n"\r | |
581 | + "# UserDefined; separated by a space character. \n"\r | |
582 | + "# If the line is missing or no value is specified, all\n"\r | |
583 | + "# valid targets specified in the FPD file will attempt \n"\r | |
584 | + "# to be built. The following line will build all platform\n"\r | |
585 | + "# targets.\n";\r | |
586 | \r | |
587 | private static final String ausage = "\n\n"\r | |
588 | + "# TARGET_ARCH List Optional What kind of architecture is the binary being target for.\n"\r | |
589 | + "# One, or more, of the following, IA32, IA64, X64, EBC or ARM.\n"\r | |
590 | + "# Multiple values can be specified on a single line, using \n"\r | |
591 | + "# space charaters to separate the values. These are used \n"\r | |
592 | + "# during the parsing of an FPD file, restricting the build\n"\r | |
593 | + "# output target(s.)\n"\r | |
594 | + "# The Build Target ARCH is determined by a logical AND of:\n"\r | |
595 | + "# FPD BuildOptions: <SupportedArchitectures> tag\n"\r | |
596 | + "# If not specified, then all valid architectures specified \n"\r | |
597 | + "# in the FPD file, for which tools are available, will be \n"\r | |
598 | + "# built.\n";\r | |
599 | \r | |
600 | private static final String cusage = "\n\n"\r | |
601 | + "# TOOL_DEFINITION_FILE Filename Optional Specify the name of the filename to use for specifying \n"\r | |
602 | + "# the tools to use for the build. If not specified, \n"\r | |
603 | + "# tools_def.txt will be used for the build. This file \n"\r | |
604 | + "# MUST be located in the WORKSPACE/Tools/Conf directory.\n";\r | |
605 | \r | |
606 | private static final String nusage = "\n\n"\r | |
607 | + "# TAGNAME List Optional Specify the name(s) of the tools_def.txt TagName to use.\n"\r | |
608 | + "# If not specified, all applicable TagName tools will be \n"\r | |
609 | + "# used for the build. The list uses space character separation.\n";\r | |
2c71f6e5 | 610 | \r |
611 | private static final String musage = "\n\n"\r | |
612 | + "# MULTIPLE_THREAD FLAG Optional Flag to enable multi-thread build. If not specified, default\n"\r | |
613 | + "# is \"Disable\". If your computer is multi-core or multiple CPUs,\n" \r | |
614 | + "# enabling this feature will bring much benefit. For multi-thread\n" \r | |
615 | + "# built, the log will write to ${BUILD_DIR}/build.log.\n" \r | |
616 | + "# This feature is only for PLATFORM build, and clean, cleanall or\n"\r | |
617 | + "# stand-alone module build is still using the normal way.\n";\r | |
618 | private static final String meusage = "\n\n"\r | |
619 | + "# MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Default is 2. Recommend to\n" \r | |
620 | + "# set this value to one more than the number of your compurter\n"\r | |
621 | + "# cores or CPUs.\n";\r | |
c74c7a43 | 622 | }\r |