]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/toolchain/Preferences.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / toolchain / Preferences.java
CommitLineData
dbf5dd75 1/** @file\r
2 <<The file is used to update the Build Preferences file, target.txt>>\r
3 \r
4 <<The program will use target.txt, the tools config file specified in that file,\r
5 or it will use the default tools_def.txt file, and it will also scan the \r
6 FrameworkDatabase.db file for certain parameters. >>\r
7 \r
8 Copyright (c) 2006, Intel Corporation\r
9 All rights reserved. This program and the accompanying materials\r
10 are licensed and made available under the terms and conditions of the BSD License\r
11 which accompanies this distribution. The full text of the license may be found at\r
12 http://opensource.org/licenses/bsd-license.php\r
13 \r
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
16 \r
17 Package Name: Tools\r
18 Module Name: FrameworkWizard\r
19 \r
20 **/\r
21\r
22package org.tianocore.frameworkwizard.toolchain;\r
23\r
24import java.awt.event.ActionEvent;\r
25import java.io.*;\r
26import java.util.Vector;\r
27import java.util.Iterator;\r
bf6aed4d 28import java.util.Scanner;\r
dbf5dd75 29\r
30import javax.swing.*;\r
bf6aed4d 31import javax.swing.JScrollPane;\r
dbf5dd75 32import javax.swing.JTextField;\r
33import javax.swing.JFrame;\r
34\r
35import org.tianocore.frameworkwizard.common.GlobalData;\r
36import org.tianocore.frameworkwizard.common.Tools;\r
37import org.tianocore.frameworkwizard.common.Log;\r
38import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r
39import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.*;\r
40import org.tianocore.frameworkwizard.common.ui.IFrame;\r
41import org.tianocore.frameworkwizard.workspace.Workspace;\r
42import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
43import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
44import org.tianocore.PlatformSurfaceAreaDocument;\r
45\r
46/**\r
47 * The class is used to update the target.txt file.\r
48 * \r
49 * It extends IDialog\r
50 * \r
51 */\r
52public class Preferences extends IFrame {\r
53\r
54 // /\r
55 // / Define class Serial Version UID\r
56 // /\r
57 private static final long serialVersionUID = -4777906991966638888L;\r
58\r
59 private final boolean Debug = false;\r
60\r
61 //\r
62 // Define class members\r
63 //\r
64 private final int oneRowHeight = 20;\r
65\r
66 private final int twoRowHeight = 40;\r
67\r
68 private final int threeRowHeight = 60;\r
69\r
70 private final int sepHeight = 6;\r
71\r
72 private final int rowOne = 12;\r
73\r
74 private final int rowTwo = rowOne + oneRowHeight + sepHeight;\r
75\r
76 private final int rowThree = rowTwo + oneRowHeight + sepHeight;\r
77\r
78 private final int rowFour = rowThree + threeRowHeight + sepHeight;\r
79\r
80 private final int rowFive = rowFour + threeRowHeight + sepHeight;\r
81\r
bf6aed4d 82 private final int rowSix = rowFive + oneRowHeight + sepHeight;\r
83\r
84 private final int buttonRow = rowSix + oneRowHeight + sepHeight + sepHeight;\r
dbf5dd75 85\r
86 private final int dialogHeight = buttonRow + twoRowHeight + twoRowHeight;\r
87\r
88 private final int dialogWidth = 540;\r
89\r
90 private final int lastButtonXLoc = 430;\r
91\r
92 private final int next2LastButtonLoc = 329;\r
93\r
94 /*\r
95 * Define the contents for this dialog box\r
96 */\r
97 private static Preferences bTarget = null;\r
98\r
99 private WorkspaceTools wt = new WorkspaceTools();\r
100\r
101 private JFrame frame;\r
102\r
bf6aed4d 103 private final int activePlatformId = 0;\r
104\r
105 private final int buildTargetId = 1;\r
106\r
107 private final int targetArchId = 2;\r
108\r
109 private final int toolDefFileId = 3;\r
110\r
111 private final int tagNameId = 4;\r
112\r
113 private final int threadEnableId = 5;\r
114\r
115 private final int threadCountId = 6;\r
116\r
117 private final int maxTargetLines = threadCountId + 1;\r
118\r
dbf5dd75 119 private JPanel jContentPane = null;\r
120\r
121 private JLabel jLabelToolsConfigFile = null;\r
122\r
123 private JTextField jTextFieldToolsConfigFile = null;\r
124\r
125 private final int toolConfigFileRow = rowOne;\r
126\r
dbf5dd75 127 private JLabel jLabelActivePlatform = null;\r
128\r
129 private JComboBox jComboBoxActivePlatform = null;\r
130\r
dbf5dd75 131 private final int activePlatformRow = rowTwo;\r
132\r
133 private JLabel jLabelToolChainTagName = null;\r
134\r
135 private JScrollPane jScrollPaneTagName = null;\r
136\r
137 private ICheckBoxList iCheckBoxListTagName = null;\r
138\r
139 private final int toolChainTagNameRow = rowThree;\r
140\r
dbf5dd75 141 private JLabel jLabelBuildTarget = null;\r
142\r
143 private JScrollPane jScrollPaneBuildTarget = null;\r
144\r
145 private ICheckBoxList iCheckBoxListBuildTarget = null;\r
146\r
147 private final int buildTargetRow = rowFour;\r
148\r
dbf5dd75 149 private JLabel jLabelTargetArch = null;\r
150\r
151 private ArchCheckBox jArchCheckBox = null;\r
152\r
153 private final int targetArchRow = rowFive;\r
154\r
bf6aed4d 155 private JLabel jLabelEnableThreads = null;\r
156\r
157 private JLabel jLabelThreadCount = null;\r
158\r
159 private final int threadRow = rowSix;\r
160\r
161 private JCheckBox jCheckBoxEnableThreads = null;\r
162\r
163 private JTextField jTextFieldThreadCount = null;\r
164 \r
165 private String threadCount;\r
166 \r
167 private boolean threadEnabled = false;\r
dbf5dd75 168\r
169 private JButton jButtonBrowse = null;\r
170\r
171 private JButton jButtonSave = null;\r
172\r
173 private JButton jButtonCancel = null;\r
174\r
175 private final int labelColumn = 12;\r
176\r
177 private final int labelWidth = 155;\r
178\r
179 private final int valueColumn = 168;\r
180\r
181 private final int valueWidth = 352;\r
182\r
183 private final int valueWidthShort = 260;\r
184\r
185 private final int buttonWidth = 90;\r
186\r
187 private String workspaceDir = Workspace.getCurrentWorkspace() + System.getProperty("file.separator");\r
188\r
189 private String toolsDir = Workspace.getCurrentWorkspace() + System.getProperty("file.separator") + "Tools"\r
190 + System.getProperty("file.separator") + "Conf";\r
191\r
192 private String defaultToolsConf = toolsDir + System.getProperty("file.separator") + "tools_def.txt";\r
193\r
194 private String targetFile = toolsDir + System.getProperty("file.separator") + "target.txt";\r
195\r
196 private String[] targetFileContents = new String[500];\r
197\r
198 // private String[] toolsConfContents;\r
199\r
bf6aed4d 200 private String[] targetLines = new String[maxTargetLines];\r
dbf5dd75 201\r
bf6aed4d 202 private int targetLineNumber[] = new int[maxTargetLines];\r
dbf5dd75 203\r
204 private String toolsConfFile;\r
205\r
206 private String toolsDefTargetNames = null;\r
207\r
208 private final int toolsDefTargetNameField = 0;\r
209\r
210 private String toolsDefTagNames = null;\r
211\r
212 private final int toolsDefTagNameField = 1;\r
213\r
214 private String toolsDefArchNames = null;\r
215\r
216 private final int toolsDefArchNameField = 2;\r
217\r
218 private String toolsDefIdentifier = null;\r
219\r
220 private int targetLineNumberMax;\r
bf6aed4d 221 \r
222 private final int toolDefFieldCount = 5;\r
dbf5dd75 223\r
224 private Vector<String> vArchList = null;\r
225\r
8a11d13a 226 private Vector<String> vDisableArchList = null;\r
52ee46a6 227 \r
dbf5dd75 228 //\r
229 // Not used by UI\r
230 //\r
231 // private Preferences id = null;\r
232\r
233 // private EnumerationData ed = new EnumerationData();\r
234\r
235 /**\r
236 This method initializes jTextFieldToolsConfigFile \r
237 \r
238 @return javax.swing.JTextField jTextFieldToolsConfigFile\r
239 **/\r
240 private JTextField getJTextFieldToolsConfigFile() {\r
241 if (jTextFieldToolsConfigFile == null) {\r
242 if (targetLines[toolDefFileId] != null) {\r
243 String sLine[] = targetLines[toolDefFileId].trim().split("=");\r
244 jTextFieldToolsConfigFile = new JTextField(sLine[1].trim());\r
245 } else\r
246 jTextFieldToolsConfigFile = new JTextField();\r
247\r
248 jTextFieldToolsConfigFile.setBounds(new java.awt.Rectangle(valueColumn, toolConfigFileRow, valueWidthShort,\r
249 oneRowHeight));\r
250 jTextFieldToolsConfigFile.setPreferredSize(new java.awt.Dimension(valueWidthShort, oneRowHeight));\r
251 jTextFieldToolsConfigFile\r
252 .setToolTipText("<html>"\r
253 + "Specify the name of the filename to use for specifying"\r
254 + "<br>the tools to use for the build. If not specified,"\r
255 + "<br>tools_def.txt will be used for the build. This file"\r
256 + "<br>MUST be located in the WORKSPACE/Tools/Conf directory.</html>");\r
257\r
258 }\r
259 return jTextFieldToolsConfigFile;\r
260 }\r
261\r
262 /**\r
263 * This method initializes jComboBoxActivePlatform\r
264 * \r
265 * @return javax.swing.JComboBox jComboBoxActivePlatform\r
266 * \r
267 */\r
268 private JComboBox getActivePlatform() {\r
269 Vector<PlatformIdentification> vPlatformId = wt.getAllPlatforms();\r
270\r
271 if (jComboBoxActivePlatform == null) {\r
272 jComboBoxActivePlatform = new JComboBox();\r
273 jComboBoxActivePlatform.setBounds(new java.awt.Rectangle(valueColumn, activePlatformRow, valueWidth,\r
274 oneRowHeight));\r
275 jComboBoxActivePlatform.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));\r
8a11d13a 276 jComboBoxActivePlatform\r
277 .setToolTipText("<html>Select &quot;Do Not Set&quot; if you want to build a platform"\r
dbf5dd75 278 + "<br>from the directory where the FPD file exists,"\r
279 + "<br>otherwise scroll down to select the platform.</html>");\r
280\r
281 /*\r
282 * Generate the data, selecting what is in target.txt\r
283 */\r
284 jComboBoxActivePlatform.addItem("Do Not Set");\r
285 Iterator<PlatformIdentification> iter = vPlatformId.iterator();\r
286 while (iter.hasNext()) {\r
287 PlatformIdentification item = iter.next();\r
288 String path = item.getPath().trim();\r
289 String str = path.substring(workspaceDir.length(), path.length());\r
290 str.replace(System.getProperty("file.separator"), "/");\r
291 jComboBoxActivePlatform.addItem(str.trim());\r
292 }\r
293 if (targetLines[activePlatformId] == null)\r
294 jComboBoxActivePlatform.setSelectedItem("Do Not Set");\r
295 else\r
296 jComboBoxActivePlatform.setSelectedItem(targetLines[activePlatformId]);\r
297 }\r
298 return jComboBoxActivePlatform;\r
299 }\r
300\r
301 /**\r
302 * This method initializes jScrollPaneTagName\r
303 * \r
304 * @return javax.swing.JScrollPane jScrollPaneTagName\r
305 * \r
306 */\r
307 private JScrollPane getJScrollPaneTagName() {\r
308\r
309 if (jScrollPaneTagName == null) {\r
310 jScrollPaneTagName = new JScrollPane();\r
311 jScrollPaneTagName.setBounds(new java.awt.Rectangle(valueColumn, toolChainTagNameRow, valueWidth,\r
312 threeRowHeight));\r
313 jScrollPaneTagName.setPreferredSize(new java.awt.Dimension(valueWidth, threeRowHeight));\r
314 jScrollPaneTagName.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
315 jScrollPaneTagName.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);\r
316 jScrollPaneTagName.setViewportView(getICheckBoxListTagName());\r
317 jScrollPaneTagName.setToolTipText("<html>"\r
318 + "Specify the TagName(s) from the tool configuration file to use"\r
319 + "<br>for your builds. If not specified, all applicable TagName"\r
320 + " <br>tools will be used for the build.</html>");\r
321 jScrollPaneTagName.setVisible(true);\r
322\r
323 }\r
324 return jScrollPaneTagName;\r
325 }\r
326\r
327 private ICheckBoxList getICheckBoxListTagName() {\r
328 if (iCheckBoxListTagName == null) {\r
329 iCheckBoxListTagName = new ICheckBoxList();\r
8a11d13a 330\r
dbf5dd75 331 if (toolsDefTagNames != null) {\r
332 toolsDefTagNames.trim();\r
333 String aTagNames[] = toolsDefTagNames.trim().split(" ");\r
334 Vector<String> vTags = new Vector<String>();\r
335 for (int i = 0; i < aTagNames.length; i++) {\r
336 vTags.add(aTagNames[i]);\r
337 }\r
338 iCheckBoxListTagName.setAllItems(vTags);\r
339 } else {\r
340 Vector<String> defaultTags = stringToVector("MYTOOLS");\r
341 iCheckBoxListTagName.setAllItems(defaultTags);\r
342 }\r
8a11d13a 343\r
dbf5dd75 344 iCheckBoxListTagName.setAllItemsUnchecked();\r
345 iCheckBoxListTagName.setToolTipText("<html>"\r
346 + "Specify the TagName(s) from the tool configuration file to use"\r
347 + "<br>for your builds. If not specified, all applicable TagName"\r
348 + " <br>tools will be used for the build.</html>");\r
349 Vector<String> vSelectedTags = new Vector<String>();\r
350 if (targetLines[tagNameId] != null) {\r
351 targetLines[tagNameId].trim();\r
352 String targetTags[] = targetLines[tagNameId].trim().split(" ");\r
353 for (int j = 0; j < targetTags.length; j++)\r
354 vSelectedTags.add(targetTags[j]);\r
355 iCheckBoxListTagName.initCheckedItem(true, vSelectedTags);\r
356 }\r
357 }\r
358 return iCheckBoxListTagName;\r
359 }\r
360\r
361 /**\r
362 * This method initializes jScrollPaneBuildTarget\r
363 * \r
364 * @return javax.swing.JComboBox jScrollPaneBuildTarget\r
365 * \r
366 */\r
367 private JScrollPane getJScrollPaneBuildTarget() {\r
368 if (jScrollPaneBuildTarget == null) {\r
369 jScrollPaneBuildTarget = new JScrollPane();\r
370 jScrollPaneBuildTarget.setBounds(new java.awt.Rectangle(valueColumn, buildTargetRow, valueWidth,\r
371 threeRowHeight));\r
372 jScrollPaneBuildTarget.setPreferredSize(new java.awt.Dimension(valueWidth, threeRowHeight));\r
373 jScrollPaneBuildTarget.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
374 jScrollPaneBuildTarget.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);\r
375 jScrollPaneBuildTarget.setViewportView(getICheckBoxListBuildTarget());\r
376 jScrollPaneBuildTarget.setVisible(true);\r
377 jScrollPaneBuildTarget.setToolTipText("<html>"\r
378 + "Select the TARGET Names that you want to build, such as<BR>"\r
379 + "BUILD or BUILD and RELEASE"\r
380 + "<br>If you do not set any of these, all available targets"\r
381 + "<br>will be built.</html>");\r
382\r
383 }\r
384 return jScrollPaneBuildTarget;\r
385 }\r
386\r
bf6aed4d 387 private JCheckBox getCheckBoxEnableThreads() {\r
388 if (jCheckBoxEnableThreads == null) {\r
389 jCheckBoxEnableThreads = new JCheckBox();\r
390 jCheckBoxEnableThreads.setBounds(valueColumn, threadRow, 20, oneRowHeight);\r
391 jCheckBoxEnableThreads.setToolTipText("Select this if you want to enable parallel compilation.");\r
392 jCheckBoxEnableThreads.setSelected(threadEnabled);\r
393 jCheckBoxEnableThreads.addActionListener(this);\r
394 \r
395 }\r
396 return jCheckBoxEnableThreads;\r
397 }\r
398\r
399 private JTextField getTextFieldThreadCount() {\r
400 if (jTextFieldThreadCount == null) {\r
401 jTextFieldThreadCount = new JTextField();\r
402 jTextFieldThreadCount.setBounds(valueColumn + 215, threadRow, 30, oneRowHeight);\r
403 if (threadCount.length() > 0)\r
404 jTextFieldThreadCount.setText(threadCount);\r
405 jTextFieldThreadCount.setToolTipText("<html>Recommended setting is N+1,<br> where N is the number of physical processors or cores in the system</html>");\r
406 // If CheckBoxEnableThreads is selected, then enable editing\r
407\r
408 }\r
409 return jTextFieldThreadCount;\r
410 }\r
411\r
dbf5dd75 412 private ICheckBoxList getICheckBoxListBuildTarget() {\r
413 if (iCheckBoxListBuildTarget == null) {\r
8a11d13a 414\r
dbf5dd75 415 String aBuildTargets[] = toolsDefTargetNames.trim().split(" ");\r
416 Vector<String> vBuildTargets = new Vector<String>();\r
417 for (int i = 0; i < aBuildTargets.length; i++) {\r
418 vBuildTargets.add(aBuildTargets[i]);\r
419 }\r
420 iCheckBoxListBuildTarget = new ICheckBoxList();\r
421 iCheckBoxListBuildTarget.setAllItems(vBuildTargets);\r
422 iCheckBoxListBuildTarget.setAllItemsUnchecked();\r
423 iCheckBoxListBuildTarget.setToolTipText("<html>"\r
424 + "Select the TARGET Names that you want to build, such as<BR>"\r
425 + "BUILD or BUILD and RELEASE"\r
426 + "<br>If you do not set any of these, all available targets"\r
427 + "<br>will be built.</html>");\r
428\r
429 Vector<String> vSelectedTags = new Vector<String>();\r
430 if (targetLines[buildTargetId] != null) {\r
431 targetLines[buildTargetId].trim();\r
432 String targetTags[] = targetLines[buildTargetId].trim().split(" ");\r
433 for (int j = 0; j < targetTags.length; j++)\r
434 vSelectedTags.add(targetTags[j]);\r
435 iCheckBoxListBuildTarget.initCheckedItem(true, vSelectedTags);\r
436 }\r
437 }\r
438 return iCheckBoxListBuildTarget;\r
439 }\r
440\r
441 /**\r
442 This method initializes jButtonBrowse \r
443 \r
444 @return javax.swing.JButton \r
445 **/\r
446 private JButton getJButtonBrowse() {\r
447 if (jButtonBrowse == null) {\r
448 jButtonBrowse = new JButton();\r
449 jButtonBrowse\r
450 .setBounds(new java.awt.Rectangle(lastButtonXLoc, toolConfigFileRow, buttonWidth, oneRowHeight));\r
451 jButtonBrowse.setText("Browse");\r
452 jButtonBrowse.setPreferredSize(new java.awt.Dimension(buttonWidth, oneRowHeight));\r
453 jButtonBrowse.addActionListener(new AbstractAction() {\r
454 /**\r
455 * \r
456 */\r
457 private static final long serialVersionUID = 1L;\r
458\r
459 public void actionPerformed(ActionEvent e) {\r
460 //\r
461 // Select files from current workspace\r
462 //\r
463 String dirPrefix = toolsDir + System.getProperty("file.separator");\r
464 JFileChooser chooser = new JFileChooser(dirPrefix);\r
465 File theFile = null;\r
466 // String headerDest = null;\r
467\r
468 chooser.setMultiSelectionEnabled(false);\r
469 chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);\r
470 int retval = chooser.showOpenDialog(frame);\r
471 if (retval == JFileChooser.APPROVE_OPTION) {\r
472\r
473 theFile = chooser.getSelectedFile();\r
474 String file = theFile.getPath();\r
475 if (!file.startsWith(dirPrefix)) {\r
476 JOptionPane.showMessageDialog(frame, "You can only select files in the Tools"\r
477 + System.getProperty("file.separator")\r
478 + "Conf directory!");\r
479\r
480 return;\r
481 }\r
482\r
483 jTextFieldToolsConfigFile.setText("Tools/Conf/" + theFile.getName());\r
484 } else {\r
485 return;\r
486 }\r
487 }\r
488 });\r
489 }\r
490 return jButtonBrowse;\r
491 }\r
492\r
493 /**\r
494 * This method initializes jButtonOk\r
495 * \r
496 * @return javax.swing.JButton\r
497 * \r
498 */\r
499 private JButton getJButtonSave() {\r
500 if (jButtonSave == null) {\r
501 jButtonSave = new JButton();\r
502 jButtonSave.setBounds(new java.awt.Rectangle(next2LastButtonLoc, buttonRow, buttonWidth, oneRowHeight));\r
503 jButtonSave.setText("Save");\r
504 jButtonSave.addActionListener(this);\r
505 }\r
506 return jButtonSave;\r
507 }\r
508\r
509 /**\r
510 * This method initializes jButtonCancel\r
511 * \r
512 * @return javax.swing.JButton\r
513 * \r
514 */\r
515 private JButton getJButtonCancel() {\r
516 if (jButtonCancel == null) {\r
517 jButtonCancel = new JButton();\r
518 jButtonCancel.setBounds(new java.awt.Rectangle(lastButtonXLoc, buttonRow, buttonWidth, oneRowHeight));\r
519 jButtonCancel.setText("Cancel");\r
520 jButtonCancel.addActionListener(this);\r
521 }\r
522 return jButtonCancel;\r
523 }\r
524\r
525 public static void main(String[] args) {\r
526 // TODO Auto-generated method stub\r
527\r
528 }\r
529\r
530 public static Preferences getInstance() {\r
531 if (bTarget == null) {\r
532 bTarget = new Preferences();\r
533 }\r
534 return bTarget;\r
535 }\r
536\r
537 /**\r
538 * This is the default constructor\r
539 */\r
540 public Preferences() {\r
541 super();\r
542 init();\r
543 }\r
544\r
545 /**\r
546 * This method initializes this\r
547 * \r
548 */\r
549 private void init() {\r
550\r
bf6aed4d 551 for (int i = 0; i < maxTargetLines; i++) {\r
dbf5dd75 552 targetLines[i] = null;\r
553 targetLineNumber[i] = -1;\r
554 }\r
555 initReadFiles();\r
556 this.setSize(dialogWidth, dialogHeight);\r
557 this.setContentPane(getJContentPane());\r
558 this.setTitle("Build Preferences [" + toolsDefIdentifier + "]");\r
559 this.setDefaultCloseOperation(IFrame.EXIT_ON_CLOSE);\r
560 this.centerWindow();\r
561 this.setVisible(true);\r
562 }\r
563\r
564 /**\r
565 * This method initializes this Fill values to all fields if these values are\r
566 * not empty\r
567 * \r
568 * @param initReadFiles\r
569 * \r
570 */\r
571 private void initReadFiles() {\r
572 /*\r
573 * TODO\r
574 * Read Current target.txt file first\r
575 * Read TOOL_CHAIN_CONF file if specified, otherwise use tools_def.txt\r
576 */\r
dbf5dd75 577 readTargetTxtFile();\r
578 boolean haveBuildTargets = readToolDefinitionFile();\r
579 if (!haveBuildTargets) {\r
580 // Lookup Build Targets from the platforms\r
581 readPlatformFileBuildTargets();\r
582 }\r
583 }\r
584\r
585 private void readPlatformFileBuildTargets() {\r
586 Vector<PlatformIdentification> vPlatformId = wt.getAllPlatforms();\r
587 String sBuildTargets = "";\r
588\r
589 // foreach platform, build a list of BuildTargets\r
590 Iterator<PlatformIdentification> iter = vPlatformId.iterator();\r
591 while (iter.hasNext()) {\r
592 PlatformIdentification item = iter.next();\r
593 PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd = GlobalData.openingPlatformList\r
594 .getOpeningPlatformById(\r
595 item)\r
596 .getXmlFpd();\r
597 sBuildTargets += fpd.getPlatformDefinitions().getBuildTargets().toString() + " ";\r
598 }\r
599 String allTargets[] = sBuildTargets.trim().split(" ");\r
600 for (int i = 0; i < allTargets.length; i++) {\r
601 if (!toolsDefTargetNames.contains(allTargets[i])) {\r
602 toolsDefTargetNames += allTargets[i] + " ";\r
603 }\r
604 }\r
605 }\r
606\r
607 private boolean readToolDefinitionFile() {\r
608\r
609 // Parse the tool definition file looking for targets and architectures\r
610 toolsConfFile = null;\r
611 boolean buildTargetsExist = true;\r
612\r
613 if (targetLines[toolDefFileId] != null) {\r
614 String[] result = new String[2];\r
615 targetLines[toolDefFileId].trim();\r
616 result = (targetLines[toolDefFileId]).split("=");\r
617 String resString = (Tools.convertPathToCurrentOsType(result[1])).trim();\r
618 toolsConfFile = workspaceDir.trim() + resString.trim();\r
619 File toolsDefFile = new File(toolsConfFile);\r
620 if (!toolsDefFile.exists()) {\r
621 JOptionPane.showMessageDialog(this, "<html>" + "Tool Definition file, " + toolsConfFile\r
622 + "<br>specified in the target.txt file does not exist!"\r
623 + "<br>Using the default Tool Definition File:<br>"\r
624 + defaultToolsConf);\r
625 toolsConfFile = defaultToolsConf;\r
626 }\r
627 } else {\r
628 toolsConfFile = defaultToolsConf;\r
629 }\r
bf6aed4d 630 String[] toolsDefFields = new String[toolDefFieldCount];\r
631 for (int i = 0; i < toolDefFieldCount; i++)\r
dbf5dd75 632 toolsDefFields[i] = null;\r
633 File toolDefFile = new File(toolsConfFile);\r
634 if (toolDefFile.exists()) {\r
635 try {\r
636 FileReader fileReader = new FileReader(toolDefFile);\r
637 BufferedReader reader = new BufferedReader(fileReader);\r
638 String rLine = null;\r
639 String result[];\r
640 int lineCounter = 0;\r
641 while ((rLine = reader.readLine()) != null) {\r
642\r
643 if (rLine.startsWith("IDENTIFIER")) {\r
644 result = rLine.split("=");\r
645 toolsDefIdentifier = (result[1]).trim();\r
646 } else if ((!rLine.startsWith("#")) && (rLine.contains("="))) {\r
647 result = rLine.split("=");\r
648 toolsDefFields = ((result[0]).trim()).split("_");\r
649 if (toolsDefTargetNames == null) {\r
650 toolsDefTargetNames = (toolsDefFields[toolsDefTargetNameField]).trim() + " ";\r
651 } else if (!toolsDefTargetNames.contains((toolsDefFields[toolsDefTargetNameField]).trim())) {\r
652 toolsDefTargetNames += (toolsDefFields[toolsDefTargetNameField]).trim() + " ";\r
653 }\r
654 if (toolsDefTagNames == null) {\r
655 toolsDefTagNames = (toolsDefFields[toolsDefTagNameField]).trim() + " ";\r
656 } else if (!toolsDefTagNames.contains((toolsDefFields[toolsDefTagNameField]).trim())) {\r
657 toolsDefTagNames += (toolsDefFields[toolsDefTagNameField]).trim() + " ";\r
658 }\r
659 if (toolsDefArchNames == null) {\r
660 toolsDefArchNames = (toolsDefFields[toolsDefArchNameField]).trim() + " ";\r
661 } else if (!toolsDefArchNames.contains((toolsDefFields[toolsDefArchNameField]).trim())) {\r
662 toolsDefArchNames += (toolsDefFields[toolsDefArchNameField]).trim() + " ";\r
663 }\r
664 }\r
665 lineCounter++;\r
666 }\r
667 reader.close();\r
8a11d13a 668 // Only enable Architecture selection based on tool chain installations\r
669 String turnOff = "";\r
670 if (!toolsDefArchNames.contains("EBC"))\r
671 turnOff = "EBC ";\r
672 if (!toolsDefArchNames.contains("PPC"))\r
673 turnOff += "PPC ";\r
674 if (!toolsDefArchNames.contains("IPF"))\r
675 turnOff += "IPF ";\r
676 if (!toolsDefArchNames.contains("X64"))\r
677 turnOff += "X64 ";\r
678 if (!toolsDefArchNames.contains("IA32"))\r
679 turnOff += "X64 ";\r
680 if (!toolsDefArchNames.contains("ARM"))\r
681 turnOff += "ARM ";\r
682 turnOff = turnOff.trim();\r
683 vDisableArchList = stringToVector(turnOff);\r
684\r
dbf5dd75 685 if (!toolsDefTargetNames.matches("[A-Z]+")) {\r
686 toolsDefTargetNames = toolsDefTargetNames.replace("* ", "").trim();\r
687 if (Debug)\r
688 System.out.println("tools_def file does not define build targets: '" + toolsDefTargetNames\r
689 + "'");\r
690 buildTargetsExist = false;\r
691 }\r
692 } catch (IOException e) {\r
693 Log.log(toolsConfFile + " Read Error ", e.getMessage());\r
694 e.printStackTrace();\r
695 }\r
696 }\r
697 return buildTargetsExist;\r
698 }\r
699\r
700 private void readTargetTxtFile() {\r
701 File tFile = new File(targetFile);\r
702\r
703 if (tFile.exists()) {\r
704 try {\r
705 FileReader fileReader = new FileReader(targetFile);\r
706 BufferedReader reader = new BufferedReader(fileReader);\r
707 targetLineNumberMax = 0;\r
708 String rLine = null;\r
709 while ((rLine = reader.readLine()) != null) {\r
710 targetFileContents[targetLineNumberMax] = rLine;\r
711 if (rLine.startsWith("ACTIVE_PLATFORM")) {\r
712 // Only one active platform is permitted!\r
713 targetLines[activePlatformId] = rLine;\r
714 targetLineNumber[activePlatformId] = targetLineNumberMax;\r
715 }\r
716 if ((rLine.startsWith("TARGET" + " ")) || (rLine.startsWith("TARGET" + "\t"))\r
717 || (rLine.startsWith("TARGET="))) {\r
718 // Handle multiple Target Names\r
719 if (rLine.contains(","))\r
720 targetLines[buildTargetId] = rLine.trim().replaceAll(",", " ");\r
721 else\r
722 targetLines[buildTargetId] = rLine.trim();\r
723 targetLineNumber[buildTargetId] = targetLineNumberMax;\r
724 }\r
725 if (rLine.startsWith("TARGET_ARCH")) {\r
726 // Handle multiple Target Architectures\r
727 if (rLine.contains(","))\r
728 targetLines[targetArchId] = rLine.trim().replaceAll(",", " ");\r
729 else\r
730 targetLines[targetArchId] = rLine.trim();\r
731 targetLineNumber[targetArchId] = targetLineNumberMax;\r
732 }\r
733 if (rLine.startsWith("TOOL_CHAIN_CONF")) {\r
734 // Only one file is permitted\r
735 targetLines[toolDefFileId] = rLine.trim();\r
736 targetLineNumber[toolDefFileId] = targetLineNumberMax;\r
737 }\r
738\r
739 if (rLine.startsWith("TOOL_CHAIN_TAG")) {\r
740 // Handle multiple Tool TagNames\r
741 if (rLine.contains(","))\r
742 targetLines[tagNameId] = rLine.trim().replaceAll(",", " ");\r
743 else\r
744 targetLines[tagNameId] = rLine.trim();\r
745 targetLineNumber[tagNameId] = targetLineNumberMax;\r
746 }\r
bf6aed4d 747 \r
748 if (rLine.startsWith("MULTIPLE_THREAD")) {\r
749 // Handle Thread Enable flag\r
750 targetLines[threadEnableId] = rLine.trim();\r
751 targetLineNumber[threadEnableId] = targetLineNumberMax;\r
752 if ((rLine.trim().toLowerCase().contains("enabled")) || (rLine.trim().toLowerCase().contains("true"))) { \r
753 threadEnabled = true;\r
754 } else {\r
755 threadEnabled = false;\r
756 }\r
757 }\r
758 \r
759 if (rLine.startsWith("MAX_CONCURRENT_THREAD_NUMBER")) {\r
760 // Handle Thread Enable flag\r
761 targetLines[threadCountId] = rLine.trim();\r
762 targetLineNumber[threadCountId] = targetLineNumberMax;\r
763 }\r
dbf5dd75 764 targetLineNumberMax++;\r
765 }\r
766 reader.close();\r
767 String archLine[] = new String[2];\r
768 if (targetLines[targetArchId] != null) {\r
769 if (targetLines[targetArchId].contains("=")) {\r
770 if (targetLines[targetArchId].contains(","))\r
771 targetLines[targetArchId] = targetLines[targetArchId].trim().replaceAll(",", " ");\r
772 if (targetLines[targetArchId].length() > 0)\r
773 archLine = targetLines[targetArchId].trim().split("=");\r
774 vArchList = stringToVector(archLine[1]);\r
775 }\r
776 }\r
777\r
bf6aed4d 778 if (targetLines[threadCountId] != null) {\r
779 String tcLine[] = new String[2];\r
780 tcLine = targetLines[threadCountId].trim().split("=");\r
781 threadCount = tcLine[1];\r
782 } else\r
783 threadCount = "";\r
784 \r
dbf5dd75 785 if (Debug == true)\r
bf6aed4d 786 for (int i = 0; i <= maxTargetLines; i++)\r
dbf5dd75 787 System.out.println("targetLines[" + i + "] contains: " + targetLines[i] + " index is: "\r
788 + targetLineNumber[i]);\r
dbf5dd75 789 } catch (IOException e) {\r
790 Log.log(this.targetFile + " Read Error ", e.getMessage());\r
791 e.printStackTrace();\r
792 }\r
793 }\r
794\r
795 }\r
796\r
797 /**\r
798 * This method initializes jContentPane\r
799 * \r
800 * @return javax.swing.JPanel jContentPane\r
801 * \r
802 */\r
803 private JPanel getJContentPane() {\r
804 if (jContentPane == null) {\r
805 jLabelToolsConfigFile = new JLabel();\r
806 jLabelToolsConfigFile.setBounds(new java.awt.Rectangle(labelColumn, toolConfigFileRow, labelWidth,\r
807 oneRowHeight));\r
808 jLabelToolsConfigFile.setText("Tool Chain Definition File");\r
809 jLabelActivePlatform = new JLabel();\r
810 jLabelActivePlatform.setText("Select Active Platform");\r
811 jLabelActivePlatform.setBounds(new java.awt.Rectangle(labelColumn, activePlatformRow, labelWidth,\r
812 oneRowHeight));\r
813 jLabelToolChainTagName = new JLabel();\r
814 jLabelToolChainTagName.setBounds(new java.awt.Rectangle(labelColumn, toolChainTagNameRow, labelWidth,\r
815 oneRowHeight));\r
816 jLabelToolChainTagName.setText("Select Tool Tag Name");\r
817 jLabelBuildTarget = new JLabel();\r
818 jLabelBuildTarget.setBounds(new java.awt.Rectangle(labelColumn, buildTargetRow, labelWidth, oneRowHeight));\r
819 jLabelBuildTarget.setText("Select Build Target");\r
820 jLabelTargetArch = new JLabel();\r
821 jLabelTargetArch.setBounds(new java.awt.Rectangle(labelColumn, targetArchRow, labelWidth, oneRowHeight));\r
822 jLabelTargetArch.setText("Build Architectures");\r
bf6aed4d 823\r
dbf5dd75 824 jArchCheckBox = new ArchCheckBox();\r
825 jArchCheckBox.setBounds(new java.awt.Rectangle(valueColumn, targetArchRow, valueWidth, oneRowHeight));\r
826 jArchCheckBox.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));\r
827\r
bf6aed4d 828 jLabelEnableThreads = new JLabel();\r
829 jLabelEnableThreads.setBounds(new java.awt.Rectangle(labelColumn, threadRow, labelWidth, oneRowHeight));\r
830 jLabelEnableThreads.setText("Enable Compiler Threading");\r
831\r
832 jLabelThreadCount = new JLabel();\r
833 jLabelThreadCount.setBounds(new java.awt.Rectangle(valueColumn + 60, threadRow, labelWidth, oneRowHeight));\r
834 jLabelThreadCount.setText("Number of threads to start");\r
835\r
dbf5dd75 836 jContentPane = new JPanel();\r
837 jContentPane.setLayout(null);\r
838 jContentPane.setPreferredSize(new java.awt.Dimension(dialogWidth - 10, dialogHeight - 10));\r
839\r
840 jContentPane.add(jLabelToolsConfigFile, null);\r
841 jContentPane.add(getJTextFieldToolsConfigFile(), null);\r
842 jContentPane.add(getJButtonBrowse(), null);\r
843\r
844 jContentPane.add(jLabelActivePlatform, null);\r
845 jContentPane.add(getActivePlatform(), null);\r
846\r
847 jContentPane.add(jLabelToolChainTagName, null);\r
848 jContentPane.add(getJScrollPaneTagName(), null);\r
849\r
850 jContentPane.add(jLabelBuildTarget, null);\r
851 jContentPane.add(getJScrollPaneBuildTarget(), null);\r
852\r
853 jContentPane.add(jLabelTargetArch, null);\r
854\r
8a11d13a 855 jArchCheckBox.setDisabledItems(vDisableArchList);\r
dbf5dd75 856 jArchCheckBox.setSelectedItems(vArchList);\r
857 jContentPane.add(jArchCheckBox, null);\r
858\r
bf6aed4d 859 jContentPane.add(jLabelEnableThreads, null);\r
860 jContentPane.add(getCheckBoxEnableThreads(), null);\r
861\r
862 jContentPane.add(jLabelThreadCount, null);\r
863 jContentPane.add(getTextFieldThreadCount(), null);\r
864\r
dbf5dd75 865 jContentPane.add(getJButtonSave(), null);\r
866 jContentPane.add(getJButtonCancel(), null);\r
867 }\r
868 return jContentPane;\r
869 }\r
870\r
871 /*\r
872 * (non-Javadoc)\r
873 * \r
874 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
875 * \r
876 * Override actionPerformed to listen all actions\r
877 * \r
878 */\r
879 public void actionPerformed(ActionEvent arg0) {\r
880\r
881 if (arg0.getSource() == jButtonBrowse) {\r
882 // TODO: Call file browser, starting in $WORKSPACE/Tools/Conf directory\r
883\r
884 }\r
885\r
886 if (arg0.getSource() == jButtonSave) {\r
887 saveTargetFile();\r
888 JOptionPane.showMessageDialog(this, "<html>The target.txt file has been saved!"\r
889 + "<br>A copy of the original file, target.txt.bak has"\r
890 + "<br>also been created.</html>");\r
891 this.exit();\r
892 }\r
893\r
894 if (arg0.getSource() == jButtonCancel) {\r
895 this.exit();\r
896 }\r
bf6aed4d 897 \r
898 if (arg0.getSource() == jCheckBoxEnableThreads) {\r
899 if (jCheckBoxEnableThreads.isSelected() == false) {\r
900 threadCount = "";\r
901 jTextFieldThreadCount.setText(threadCount);\r
902 }\r
903 }\r
dbf5dd75 904 }\r
bf6aed4d 905 \r
dbf5dd75 906\r
907 private void updateActivePlatform() {\r
908 int lineAP;\r
909 if (targetLines[activePlatformId] != null) {\r
910 lineAP = targetLineNumber[activePlatformId];\r
911 } else {\r
912 lineAP = targetLineNumberMax;\r
913 targetLineNumber[activePlatformId] = lineAP;\r
914 targetLineNumberMax++;\r
915 }\r
916 if (jComboBoxActivePlatform.getSelectedItem() == "Do Not Set") {\r
917 targetFileContents[lineAP] = "";\r
918 targetLines[activePlatformId] = "";\r
919 } else {\r
920 targetFileContents[lineAP] = "ACTIVE_PLATFORM = " + jComboBoxActivePlatform.getSelectedItem() + "\r\n";\r
921 targetLines[activePlatformId] = targetFileContents[lineAP];\r
922 }\r
923 if (Debug)\r
924 System.out.println("Active Platform: " + targetFileContents[lineAP]);\r
925 }\r
926\r
927 private void updateToolDefFile() {\r
928 int lineTDF;\r
929 if (targetLines[toolDefFileId] != null) {\r
930 lineTDF = targetLineNumber[toolDefFileId];\r
931 } else {\r
932 lineTDF = targetLineNumberMax;\r
933 targetLineNumber[toolDefFileId] = lineTDF;\r
934 targetLineNumberMax++;\r
935 }\r
936 if (Debug)\r
937 System.out.println("Tool Config File: " + jTextFieldToolsConfigFile.getText());\r
938 if (jTextFieldToolsConfigFile.getText() == null) {\r
bf6aed4d 939 targetFileContents[lineTDF] = "#MT#";\r
dbf5dd75 940 targetLines[toolDefFileId] = "";\r
941 } else {\r
bf6aed4d 942 targetFileContents[lineTDF] = "TOOL_CHAIN_CONF = " + jTextFieldToolsConfigFile.getText();\r
dbf5dd75 943 targetLines[toolDefFileId] = targetFileContents[lineTDF];\r
944 }\r
945 }\r
946\r
947 private void updateToolTagNames() {\r
948 String sTagNames = vectorToString(iCheckBoxListTagName.getAllCheckedItemsString());\r
949 int lineTTN;\r
950\r
951 if (targetLines[tagNameId] != null) {\r
952 lineTTN = targetLineNumber[tagNameId];\r
953 } else {\r
954 lineTTN = targetLineNumberMax;\r
955 targetLineNumber[tagNameId] = lineTTN;\r
956 targetLineNumberMax++;\r
957 }\r
958\r
959 if (Debug)\r
960 System.out.println("Tag Name(s): " + sTagNames);\r
961\r
962 if (sTagNames.length() > 0) {\r
bf6aed4d 963 targetFileContents[lineTTN] = "TOOL_CHAIN_TAG = " + sTagNames;\r
dbf5dd75 964 targetLines[tagNameId] = targetFileContents[lineTTN];\r
965 } else {\r
bf6aed4d 966 targetFileContents[lineTTN] = "#MT#";\r
dbf5dd75 967 targetLines[tagNameId] = "";\r
968 }\r
969 }\r
970\r
971 private void updateBuildTargets() {\r
972 String sBuildTargets = vectorToString(iCheckBoxListBuildTarget.getAllCheckedItemsString());\r
973 int lineBT;\r
974\r
975 if (targetLines[buildTargetId] != null) {\r
976 lineBT = targetLineNumber[buildTargetId];\r
977 } else {\r
978 lineBT = targetLineNumberMax;\r
979 targetLineNumber[buildTargetId] = lineBT;\r
980 targetLineNumberMax++;\r
981 }\r
982 if (Debug)\r
983 System.out.println("Build Target(s): " + sBuildTargets);\r
984 if (sBuildTargets.length() > 0) {\r
bf6aed4d 985 targetFileContents[lineBT] = "TARGET = " + sBuildTargets;\r
dbf5dd75 986 targetLines[buildTargetId] = targetFileContents[lineBT];\r
987 } else {\r
bf6aed4d 988 targetFileContents[lineBT] = "#MT#";\r
dbf5dd75 989 targetLines[buildTargetId] = "";\r
990 }\r
991\r
992 }\r
993\r
994 private void updateArchitectures() {\r
995 String sArchList = jArchCheckBox.getSelectedItemsString().trim();\r
996\r
997 if (Debug)\r
998 System.out.println("Architectures: " + sArchList);\r
999\r
1000 int lineSA;\r
1001 if (targetLines[targetArchId] != null) {\r
1002 lineSA = targetLineNumber[targetArchId];\r
1003 } else {\r
1004 lineSA = targetLineNumberMax;\r
1005 targetLineNumber[targetArchId] = lineSA;\r
1006 targetLineNumberMax++;\r
1007 }\r
1008 if (sArchList == "") {\r
bf6aed4d 1009 targetFileContents[lineSA] = "#MT#";\r
dbf5dd75 1010 targetLines[targetArchId] = "";\r
1011 } else {\r
bf6aed4d 1012 targetFileContents[lineSA] = "TARGET_ARCH = " + sArchList;\r
dbf5dd75 1013 targetLines[targetArchId] = targetFileContents[lineSA];\r
1014 }\r
1015\r
1016 }\r
1017\r
bf6aed4d 1018 private void updateEnableThreads() {\r
1019 int lineET;\r
1020 if (targetLines[threadEnableId] != null) {\r
1021 lineET = targetLineNumber[threadEnableId];\r
1022 } else {\r
1023 lineET = targetLineNumberMax;\r
1024 targetLineNumber[threadEnableId] = lineET;\r
1025 targetLineNumberMax++;\r
1026 }\r
1027 if (jCheckBoxEnableThreads.isSelected() == true) {\r
1028 targetFileContents[lineET] = "MULTIPLE_THREAD = enabled";\r
1029 targetLines[threadEnableId] = targetFileContents[lineET];\r
1030 } else {\r
1031 targetFileContents[lineET] = "#MT#";\r
1032 targetLines[threadEnableId] = "";\r
1033 }\r
1034 }\r
1035 \r
1036 private void updateThreadCount() {\r
1037 int lineTC;\r
1038\r
1039 if (targetLines[threadCountId] != null) {\r
1040 lineTC = targetLineNumber[threadCountId];\r
1041 } else {\r
1042 lineTC = targetLineNumberMax;\r
1043 targetLineNumber[threadCountId] = lineTC;\r
1044 targetLineNumberMax++;\r
1045 }\r
1046 if (jCheckBoxEnableThreads.isSelected() == true) {\r
1047 // Threading must be enabled\r
1048 if (jTextFieldThreadCount.getText().length() > 0) {\r
1049 // Thread Count must be greater than 0\r
1050 Scanner scan = new Scanner(jTextFieldThreadCount.getText().trim()); \r
1051 if (scan.nextInt() > 0) { \r
1052 targetFileContents[lineTC] = "MAX_CONCURRENT_THREAD_NUMBER = " + jTextFieldThreadCount.getText().trim();\r
1053 targetLines[threadCountId] = targetFileContents[lineTC];\r
1054 } else {\r
1055 Log.wrn("Build Preferences", "Threading Enabled, but thread count is not set, setting to default of 1.");\r
1056 targetFileContents[lineTC] = "MAX_CONCURRENT_THREAD_NUMBER = 1";\r
1057 targetLines[threadCountId] = "MAX_CONCURRENT_THREAD_NUMBER = 1";\r
1058 }\r
1059 } else {\r
1060 Log.wrn("Build Preferences", "Threading Enabled, but thread count is not set, setting to default of 1.");\r
1061 targetFileContents[lineTC] = "MAX_CONCURRENT_THREAD_NUMBER = 1";\r
1062 targetLines[threadCountId] = "MAX_CONCURRENT_THREAD_NUMBER = 1";\r
1063 }\r
1064 } else {\r
1065 // Don't track threads if threading is not enabled\r
1066 targetFileContents[lineTC] = "#MT#";\r
1067 targetLines[threadCountId] = "";\r
1068 threadCount = "";\r
1069 }\r
1070 \r
1071 }\r
dbf5dd75 1072 private String vectorToString(Vector<String> v) {\r
1073 String s = " ";\r
1074 for (int i = 0; i < v.size(); ++i) {\r
1075 s += v.get(i);\r
1076 s += " ";\r
1077 }\r
1078 return s.trim();\r
1079 }\r
1080\r
1081 protected Vector<String> stringToVector(String s) {\r
1082 if (s == null) {\r
1083 return null;\r
1084 }\r
1085 String[] sArray = s.split(" ");\r
1086 Vector<String> v = new Vector<String>();\r
1087 for (int i = 0; i < sArray.length; ++i) {\r
1088 v.add(sArray[i]);\r
1089 }\r
1090 return v;\r
1091 }\r
1092\r
1093 private void saveTargetFile() {\r
1094 updateActivePlatform();\r
1095 updateToolDefFile();\r
1096 updateToolTagNames();\r
1097 updateBuildTargets();\r
1098 updateArchitectures();\r
bf6aed4d 1099 updateEnableThreads();\r
1100 updateThreadCount();\r
dbf5dd75 1101\r
1102 try {\r
1103 copy(targetFile, targetFile + ".bak");\r
1104 FileWriter fileWriter = new FileWriter(targetFile);\r
1105 BufferedWriter writer = new BufferedWriter(fileWriter);\r
1106 for (int i = 0; i < targetLineNumberMax; i++) {\r
bf6aed4d 1107 if (! targetFileContents[i].contains("#MT#"))\r
1108 writer.write(targetFileContents[i] + "\n");\r
dbf5dd75 1109 }\r
1110 writer.close();\r
1111 } catch (IOException e) {\r
1112 Log.err(toolsConfFile + " Write Error ", e.getMessage());\r
1113 e.printStackTrace();\r
1114 }\r
1115 }\r
1116\r
1117 private void copy(String txtFile, String bakFile) throws IOException {\r
1118 File fromFile = new File(txtFile);\r
1119 File toFile = new File(bakFile);\r
1120 FileInputStream fromTxt = null;\r
1121 FileOutputStream toBak = null;\r
1122 try {\r
1123 fromTxt = new FileInputStream(fromFile);\r
1124 toBak = new FileOutputStream(toFile);\r
1125 byte[] buffer = new byte[4096];\r
1126 int bytes_read;\r
1127 while ((bytes_read = fromTxt.read(buffer)) != -1) {\r
1128 toBak.write(buffer, 0, bytes_read);\r
1129 }\r
1130 } finally {\r
1131 if (fromTxt != null)\r
1132 try {\r
1133 fromTxt.close();\r
1134 } catch (IOException e) {\r
1135 Log.err(toolsConfFile + " Read Error ", e.getMessage());\r
1136\r
1137 }\r
1138 if (toBak != null)\r
1139 try {\r
1140 toBak.close();\r
1141 } catch (IOException e) {\r
1142 Log.err(toolsConfFile + ".bak Write Error ", e.getMessage());\r
1143 }\r
1144 }\r
1145 }\r
1146\r
1147 private void exit() {\r
1148 this.setVisible(false);\r
1149 if (bTarget != null) {\r
1150 bTarget.dispose();\r
1151 }\r
1152 }\r
1153}\r