Added Support for OPTIONAL property: MULTIPLE_THREAD = enable tag (if not present...
[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
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
577\r
578 readTargetTxtFile();\r
579 boolean haveBuildTargets = readToolDefinitionFile();\r
580 if (!haveBuildTargets) {\r
581 // Lookup Build Targets from the platforms\r
582 readPlatformFileBuildTargets();\r
583 }\r
584 }\r
585\r
586 private void readPlatformFileBuildTargets() {\r
587 Vector<PlatformIdentification> vPlatformId = wt.getAllPlatforms();\r
588 String sBuildTargets = "";\r
589\r
590 // foreach platform, build a list of BuildTargets\r
591 Iterator<PlatformIdentification> iter = vPlatformId.iterator();\r
592 while (iter.hasNext()) {\r
593 PlatformIdentification item = iter.next();\r
594 PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd = GlobalData.openingPlatformList\r
595 .getOpeningPlatformById(\r
596 item)\r
597 .getXmlFpd();\r
598 sBuildTargets += fpd.getPlatformDefinitions().getBuildTargets().toString() + " ";\r
599 }\r
600 String allTargets[] = sBuildTargets.trim().split(" ");\r
601 for (int i = 0; i < allTargets.length; i++) {\r
602 if (!toolsDefTargetNames.contains(allTargets[i])) {\r
603 toolsDefTargetNames += allTargets[i] + " ";\r
604 }\r
605 }\r
606 }\r
607\r
608 private boolean readToolDefinitionFile() {\r
609\r
610 // Parse the tool definition file looking for targets and architectures\r
611 toolsConfFile = null;\r
612 boolean buildTargetsExist = true;\r
613\r
614 if (targetLines[toolDefFileId] != null) {\r
615 String[] result = new String[2];\r
616 targetLines[toolDefFileId].trim();\r
617 result = (targetLines[toolDefFileId]).split("=");\r
618 String resString = (Tools.convertPathToCurrentOsType(result[1])).trim();\r
619 toolsConfFile = workspaceDir.trim() + resString.trim();\r
620 File toolsDefFile = new File(toolsConfFile);\r
621 if (!toolsDefFile.exists()) {\r
622 JOptionPane.showMessageDialog(this, "<html>" + "Tool Definition file, " + toolsConfFile\r
623 + "<br>specified in the target.txt file does not exist!"\r
624 + "<br>Using the default Tool Definition File:<br>"\r
625 + defaultToolsConf);\r
626 toolsConfFile = defaultToolsConf;\r
627 }\r
628 } else {\r
629 toolsConfFile = defaultToolsConf;\r
630 }\r
bf6aed4d 631 String[] toolsDefFields = new String[toolDefFieldCount];\r
632 for (int i = 0; i < toolDefFieldCount; i++)\r
dbf5dd75 633 toolsDefFields[i] = null;\r
634 File toolDefFile = new File(toolsConfFile);\r
635 if (toolDefFile.exists()) {\r
636 try {\r
637 FileReader fileReader = new FileReader(toolDefFile);\r
638 BufferedReader reader = new BufferedReader(fileReader);\r
639 String rLine = null;\r
640 String result[];\r
641 int lineCounter = 0;\r
642 while ((rLine = reader.readLine()) != null) {\r
643\r
644 if (rLine.startsWith("IDENTIFIER")) {\r
645 result = rLine.split("=");\r
646 toolsDefIdentifier = (result[1]).trim();\r
647 } else if ((!rLine.startsWith("#")) && (rLine.contains("="))) {\r
648 result = rLine.split("=");\r
649 toolsDefFields = ((result[0]).trim()).split("_");\r
650 if (toolsDefTargetNames == null) {\r
651 toolsDefTargetNames = (toolsDefFields[toolsDefTargetNameField]).trim() + " ";\r
652 } else if (!toolsDefTargetNames.contains((toolsDefFields[toolsDefTargetNameField]).trim())) {\r
653 toolsDefTargetNames += (toolsDefFields[toolsDefTargetNameField]).trim() + " ";\r
654 }\r
655 if (toolsDefTagNames == null) {\r
656 toolsDefTagNames = (toolsDefFields[toolsDefTagNameField]).trim() + " ";\r
657 } else if (!toolsDefTagNames.contains((toolsDefFields[toolsDefTagNameField]).trim())) {\r
658 toolsDefTagNames += (toolsDefFields[toolsDefTagNameField]).trim() + " ";\r
659 }\r
660 if (toolsDefArchNames == null) {\r
661 toolsDefArchNames = (toolsDefFields[toolsDefArchNameField]).trim() + " ";\r
662 } else if (!toolsDefArchNames.contains((toolsDefFields[toolsDefArchNameField]).trim())) {\r
663 toolsDefArchNames += (toolsDefFields[toolsDefArchNameField]).trim() + " ";\r
664 }\r
665 }\r
666 lineCounter++;\r
667 }\r
668 reader.close();\r
8a11d13a 669 // Only enable Architecture selection based on tool chain installations\r
670 String turnOff = "";\r
671 if (!toolsDefArchNames.contains("EBC"))\r
672 turnOff = "EBC ";\r
673 if (!toolsDefArchNames.contains("PPC"))\r
674 turnOff += "PPC ";\r
675 if (!toolsDefArchNames.contains("IPF"))\r
676 turnOff += "IPF ";\r
677 if (!toolsDefArchNames.contains("X64"))\r
678 turnOff += "X64 ";\r
679 if (!toolsDefArchNames.contains("IA32"))\r
680 turnOff += "X64 ";\r
681 if (!toolsDefArchNames.contains("ARM"))\r
682 turnOff += "ARM ";\r
683 turnOff = turnOff.trim();\r
684 vDisableArchList = stringToVector(turnOff);\r
685\r
dbf5dd75 686 if (!toolsDefTargetNames.matches("[A-Z]+")) {\r
687 toolsDefTargetNames = toolsDefTargetNames.replace("* ", "").trim();\r
688 if (Debug)\r
689 System.out.println("tools_def file does not define build targets: '" + toolsDefTargetNames\r
690 + "'");\r
691 buildTargetsExist = false;\r
692 }\r
693 } catch (IOException e) {\r
694 Log.log(toolsConfFile + " Read Error ", e.getMessage());\r
695 e.printStackTrace();\r
696 }\r
697 }\r
698 return buildTargetsExist;\r
699 }\r
700\r
701 private void readTargetTxtFile() {\r
702 File tFile = new File(targetFile);\r
703\r
704 if (tFile.exists()) {\r
705 try {\r
706 FileReader fileReader = new FileReader(targetFile);\r
707 BufferedReader reader = new BufferedReader(fileReader);\r
708 targetLineNumberMax = 0;\r
709 String rLine = null;\r
710 while ((rLine = reader.readLine()) != null) {\r
711 targetFileContents[targetLineNumberMax] = rLine;\r
712 if (rLine.startsWith("ACTIVE_PLATFORM")) {\r
713 // Only one active platform is permitted!\r
714 targetLines[activePlatformId] = rLine;\r
715 targetLineNumber[activePlatformId] = targetLineNumberMax;\r
716 }\r
717 if ((rLine.startsWith("TARGET" + " ")) || (rLine.startsWith("TARGET" + "\t"))\r
718 || (rLine.startsWith("TARGET="))) {\r
719 // Handle multiple Target Names\r
720 if (rLine.contains(","))\r
721 targetLines[buildTargetId] = rLine.trim().replaceAll(",", " ");\r
722 else\r
723 targetLines[buildTargetId] = rLine.trim();\r
724 targetLineNumber[buildTargetId] = targetLineNumberMax;\r
725 }\r
726 if (rLine.startsWith("TARGET_ARCH")) {\r
727 // Handle multiple Target Architectures\r
728 if (rLine.contains(","))\r
729 targetLines[targetArchId] = rLine.trim().replaceAll(",", " ");\r
730 else\r
731 targetLines[targetArchId] = rLine.trim();\r
732 targetLineNumber[targetArchId] = targetLineNumberMax;\r
733 }\r
734 if (rLine.startsWith("TOOL_CHAIN_CONF")) {\r
735 // Only one file is permitted\r
736 targetLines[toolDefFileId] = rLine.trim();\r
737 targetLineNumber[toolDefFileId] = targetLineNumberMax;\r
738 }\r
739\r
740 if (rLine.startsWith("TOOL_CHAIN_TAG")) {\r
741 // Handle multiple Tool TagNames\r
742 if (rLine.contains(","))\r
743 targetLines[tagNameId] = rLine.trim().replaceAll(",", " ");\r
744 else\r
745 targetLines[tagNameId] = rLine.trim();\r
746 targetLineNumber[tagNameId] = targetLineNumberMax;\r
747 }\r
bf6aed4d 748 \r
749 if (rLine.startsWith("MULTIPLE_THREAD")) {\r
750 // Handle Thread Enable flag\r
751 targetLines[threadEnableId] = rLine.trim();\r
752 targetLineNumber[threadEnableId] = targetLineNumberMax;\r
753 if ((rLine.trim().toLowerCase().contains("enabled")) || (rLine.trim().toLowerCase().contains("true"))) { \r
754 threadEnabled = true;\r
755 } else {\r
756 threadEnabled = false;\r
757 }\r
758 }\r
759 \r
760 if (rLine.startsWith("MAX_CONCURRENT_THREAD_NUMBER")) {\r
761 // Handle Thread Enable flag\r
762 targetLines[threadCountId] = rLine.trim();\r
763 targetLineNumber[threadCountId] = targetLineNumberMax;\r
764 }\r
dbf5dd75 765 targetLineNumberMax++;\r
766 }\r
767 reader.close();\r
768 String archLine[] = new String[2];\r
769 if (targetLines[targetArchId] != null) {\r
770 if (targetLines[targetArchId].contains("=")) {\r
771 if (targetLines[targetArchId].contains(","))\r
772 targetLines[targetArchId] = targetLines[targetArchId].trim().replaceAll(",", " ");\r
773 if (targetLines[targetArchId].length() > 0)\r
774 archLine = targetLines[targetArchId].trim().split("=");\r
775 vArchList = stringToVector(archLine[1]);\r
776 }\r
777 }\r
778\r
bf6aed4d 779 if (targetLines[threadCountId] != null) {\r
780 String tcLine[] = new String[2];\r
781 tcLine = targetLines[threadCountId].trim().split("=");\r
782 threadCount = tcLine[1];\r
783 } else\r
784 threadCount = "";\r
785 \r
dbf5dd75 786 if (Debug == true)\r
bf6aed4d 787 for (int i = 0; i <= maxTargetLines; i++)\r
dbf5dd75 788 System.out.println("targetLines[" + i + "] contains: " + targetLines[i] + " index is: "\r
789 + targetLineNumber[i]);\r
dbf5dd75 790 } catch (IOException e) {\r
791 Log.log(this.targetFile + " Read Error ", e.getMessage());\r
792 e.printStackTrace();\r
793 }\r
794 }\r
795\r
796 }\r
797\r
798 /**\r
799 * This method initializes jContentPane\r
800 * \r
801 * @return javax.swing.JPanel jContentPane\r
802 * \r
803 */\r
804 private JPanel getJContentPane() {\r
805 if (jContentPane == null) {\r
806 jLabelToolsConfigFile = new JLabel();\r
807 jLabelToolsConfigFile.setBounds(new java.awt.Rectangle(labelColumn, toolConfigFileRow, labelWidth,\r
808 oneRowHeight));\r
809 jLabelToolsConfigFile.setText("Tool Chain Definition File");\r
810 jLabelActivePlatform = new JLabel();\r
811 jLabelActivePlatform.setText("Select Active Platform");\r
812 jLabelActivePlatform.setBounds(new java.awt.Rectangle(labelColumn, activePlatformRow, labelWidth,\r
813 oneRowHeight));\r
814 jLabelToolChainTagName = new JLabel();\r
815 jLabelToolChainTagName.setBounds(new java.awt.Rectangle(labelColumn, toolChainTagNameRow, labelWidth,\r
816 oneRowHeight));\r
817 jLabelToolChainTagName.setText("Select Tool Tag Name");\r
818 jLabelBuildTarget = new JLabel();\r
819 jLabelBuildTarget.setBounds(new java.awt.Rectangle(labelColumn, buildTargetRow, labelWidth, oneRowHeight));\r
820 jLabelBuildTarget.setText("Select Build Target");\r
821 jLabelTargetArch = new JLabel();\r
822 jLabelTargetArch.setBounds(new java.awt.Rectangle(labelColumn, targetArchRow, labelWidth, oneRowHeight));\r
823 jLabelTargetArch.setText("Build Architectures");\r
bf6aed4d 824\r
dbf5dd75 825 jArchCheckBox = new ArchCheckBox();\r
826 jArchCheckBox.setBounds(new java.awt.Rectangle(valueColumn, targetArchRow, valueWidth, oneRowHeight));\r
827 jArchCheckBox.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));\r
828\r
bf6aed4d 829 jLabelEnableThreads = new JLabel();\r
830 jLabelEnableThreads.setBounds(new java.awt.Rectangle(labelColumn, threadRow, labelWidth, oneRowHeight));\r
831 jLabelEnableThreads.setText("Enable Compiler Threading");\r
832\r
833 jLabelThreadCount = new JLabel();\r
834 jLabelThreadCount.setBounds(new java.awt.Rectangle(valueColumn + 60, threadRow, labelWidth, oneRowHeight));\r
835 jLabelThreadCount.setText("Number of threads to start");\r
836\r
dbf5dd75 837 jContentPane = new JPanel();\r
838 jContentPane.setLayout(null);\r
839 jContentPane.setPreferredSize(new java.awt.Dimension(dialogWidth - 10, dialogHeight - 10));\r
840\r
841 jContentPane.add(jLabelToolsConfigFile, null);\r
842 jContentPane.add(getJTextFieldToolsConfigFile(), null);\r
843 jContentPane.add(getJButtonBrowse(), null);\r
844\r
845 jContentPane.add(jLabelActivePlatform, null);\r
846 jContentPane.add(getActivePlatform(), null);\r
847\r
848 jContentPane.add(jLabelToolChainTagName, null);\r
849 jContentPane.add(getJScrollPaneTagName(), null);\r
850\r
851 jContentPane.add(jLabelBuildTarget, null);\r
852 jContentPane.add(getJScrollPaneBuildTarget(), null);\r
853\r
854 jContentPane.add(jLabelTargetArch, null);\r
855\r
8a11d13a 856 jArchCheckBox.setDisabledItems(vDisableArchList);\r
dbf5dd75 857 jArchCheckBox.setSelectedItems(vArchList);\r
858 jContentPane.add(jArchCheckBox, null);\r
859\r
bf6aed4d 860 jContentPane.add(jLabelEnableThreads, null);\r
861 jContentPane.add(getCheckBoxEnableThreads(), null);\r
862\r
863 jContentPane.add(jLabelThreadCount, null);\r
864 jContentPane.add(getTextFieldThreadCount(), null);\r
865\r
dbf5dd75 866 jContentPane.add(getJButtonSave(), null);\r
867 jContentPane.add(getJButtonCancel(), null);\r
868 }\r
869 return jContentPane;\r
870 }\r
871\r
872 /*\r
873 * (non-Javadoc)\r
874 * \r
875 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
876 * \r
877 * Override actionPerformed to listen all actions\r
878 * \r
879 */\r
880 public void actionPerformed(ActionEvent arg0) {\r
881\r
882 if (arg0.getSource() == jButtonBrowse) {\r
883 // TODO: Call file browser, starting in $WORKSPACE/Tools/Conf directory\r
884\r
885 }\r
886\r
887 if (arg0.getSource() == jButtonSave) {\r
888 saveTargetFile();\r
889 JOptionPane.showMessageDialog(this, "<html>The target.txt file has been saved!"\r
890 + "<br>A copy of the original file, target.txt.bak has"\r
891 + "<br>also been created.</html>");\r
892 this.exit();\r
893 }\r
894\r
895 if (arg0.getSource() == jButtonCancel) {\r
896 this.exit();\r
897 }\r
bf6aed4d 898 \r
899 if (arg0.getSource() == jCheckBoxEnableThreads) {\r
900 if (jCheckBoxEnableThreads.isSelected() == false) {\r
901 threadCount = "";\r
902 jTextFieldThreadCount.setText(threadCount);\r
903 }\r
904 }\r
dbf5dd75 905 }\r
bf6aed4d 906 \r
dbf5dd75 907\r
908 private void updateActivePlatform() {\r
909 int lineAP;\r
910 if (targetLines[activePlatformId] != null) {\r
911 lineAP = targetLineNumber[activePlatformId];\r
912 } else {\r
913 lineAP = targetLineNumberMax;\r
914 targetLineNumber[activePlatformId] = lineAP;\r
915 targetLineNumberMax++;\r
916 }\r
917 if (jComboBoxActivePlatform.getSelectedItem() == "Do Not Set") {\r
918 targetFileContents[lineAP] = "";\r
919 targetLines[activePlatformId] = "";\r
920 } else {\r
921 targetFileContents[lineAP] = "ACTIVE_PLATFORM = " + jComboBoxActivePlatform.getSelectedItem() + "\r\n";\r
922 targetLines[activePlatformId] = targetFileContents[lineAP];\r
923 }\r
924 if (Debug)\r
925 System.out.println("Active Platform: " + targetFileContents[lineAP]);\r
926 }\r
927\r
928 private void updateToolDefFile() {\r
929 int lineTDF;\r
930 if (targetLines[toolDefFileId] != null) {\r
931 lineTDF = targetLineNumber[toolDefFileId];\r
932 } else {\r
933 lineTDF = targetLineNumberMax;\r
934 targetLineNumber[toolDefFileId] = lineTDF;\r
935 targetLineNumberMax++;\r
936 }\r
937 if (Debug)\r
938 System.out.println("Tool Config File: " + jTextFieldToolsConfigFile.getText());\r
939 if (jTextFieldToolsConfigFile.getText() == null) {\r
bf6aed4d 940 targetFileContents[lineTDF] = "#MT#";\r
dbf5dd75 941 targetLines[toolDefFileId] = "";\r
942 } else {\r
bf6aed4d 943 targetFileContents[lineTDF] = "TOOL_CHAIN_CONF = " + jTextFieldToolsConfigFile.getText();\r
dbf5dd75 944 targetLines[toolDefFileId] = targetFileContents[lineTDF];\r
945 }\r
946 }\r
947\r
948 private void updateToolTagNames() {\r
949 String sTagNames = vectorToString(iCheckBoxListTagName.getAllCheckedItemsString());\r
950 int lineTTN;\r
951\r
952 if (targetLines[tagNameId] != null) {\r
953 lineTTN = targetLineNumber[tagNameId];\r
954 } else {\r
955 lineTTN = targetLineNumberMax;\r
956 targetLineNumber[tagNameId] = lineTTN;\r
957 targetLineNumberMax++;\r
958 }\r
959\r
960 if (Debug)\r
961 System.out.println("Tag Name(s): " + sTagNames);\r
962\r
963 if (sTagNames.length() > 0) {\r
bf6aed4d 964 targetFileContents[lineTTN] = "TOOL_CHAIN_TAG = " + sTagNames;\r
dbf5dd75 965 targetLines[tagNameId] = targetFileContents[lineTTN];\r
966 } else {\r
bf6aed4d 967 targetFileContents[lineTTN] = "#MT#";\r
dbf5dd75 968 targetLines[tagNameId] = "";\r
969 }\r
970 }\r
971\r
972 private void updateBuildTargets() {\r
973 String sBuildTargets = vectorToString(iCheckBoxListBuildTarget.getAllCheckedItemsString());\r
974 int lineBT;\r
975\r
976 if (targetLines[buildTargetId] != null) {\r
977 lineBT = targetLineNumber[buildTargetId];\r
978 } else {\r
979 lineBT = targetLineNumberMax;\r
980 targetLineNumber[buildTargetId] = lineBT;\r
981 targetLineNumberMax++;\r
982 }\r
983 if (Debug)\r
984 System.out.println("Build Target(s): " + sBuildTargets);\r
985 if (sBuildTargets.length() > 0) {\r
bf6aed4d 986 targetFileContents[lineBT] = "TARGET = " + sBuildTargets;\r
dbf5dd75 987 targetLines[buildTargetId] = targetFileContents[lineBT];\r
988 } else {\r
bf6aed4d 989 targetFileContents[lineBT] = "#MT#";\r
dbf5dd75 990 targetLines[buildTargetId] = "";\r
991 }\r
992\r
993 }\r
994\r
995 private void updateArchitectures() {\r
996 String sArchList = jArchCheckBox.getSelectedItemsString().trim();\r
997\r
998 if (Debug)\r
999 System.out.println("Architectures: " + sArchList);\r
1000\r
1001 int lineSA;\r
1002 if (targetLines[targetArchId] != null) {\r
1003 lineSA = targetLineNumber[targetArchId];\r
1004 } else {\r
1005 lineSA = targetLineNumberMax;\r
1006 targetLineNumber[targetArchId] = lineSA;\r
1007 targetLineNumberMax++;\r
1008 }\r
1009 if (sArchList == "") {\r
bf6aed4d 1010 targetFileContents[lineSA] = "#MT#";\r
dbf5dd75 1011 targetLines[targetArchId] = "";\r
1012 } else {\r
bf6aed4d 1013 targetFileContents[lineSA] = "TARGET_ARCH = " + sArchList;\r
dbf5dd75 1014 targetLines[targetArchId] = targetFileContents[lineSA];\r
1015 }\r
1016\r
1017 }\r
1018\r
bf6aed4d 1019 private void updateEnableThreads() {\r
1020 int lineET;\r
1021 if (targetLines[threadEnableId] != null) {\r
1022 lineET = targetLineNumber[threadEnableId];\r
1023 } else {\r
1024 lineET = targetLineNumberMax;\r
1025 targetLineNumber[threadEnableId] = lineET;\r
1026 targetLineNumberMax++;\r
1027 }\r
1028 if (jCheckBoxEnableThreads.isSelected() == true) {\r
1029 targetFileContents[lineET] = "MULTIPLE_THREAD = enabled";\r
1030 targetLines[threadEnableId] = targetFileContents[lineET];\r
1031 } else {\r
1032 targetFileContents[lineET] = "#MT#";\r
1033 targetLines[threadEnableId] = "";\r
1034 }\r
1035 }\r
1036 \r
1037 private void updateThreadCount() {\r
1038 int lineTC;\r
1039\r
1040 if (targetLines[threadCountId] != null) {\r
1041 lineTC = targetLineNumber[threadCountId];\r
1042 } else {\r
1043 lineTC = targetLineNumberMax;\r
1044 targetLineNumber[threadCountId] = lineTC;\r
1045 targetLineNumberMax++;\r
1046 }\r
1047 if (jCheckBoxEnableThreads.isSelected() == true) {\r
1048 // Threading must be enabled\r
1049 if (jTextFieldThreadCount.getText().length() > 0) {\r
1050 // Thread Count must be greater than 0\r
1051 Scanner scan = new Scanner(jTextFieldThreadCount.getText().trim()); \r
1052 if (scan.nextInt() > 0) { \r
1053 targetFileContents[lineTC] = "MAX_CONCURRENT_THREAD_NUMBER = " + jTextFieldThreadCount.getText().trim();\r
1054 targetLines[threadCountId] = targetFileContents[lineTC];\r
1055 } else {\r
1056 Log.wrn("Build Preferences", "Threading Enabled, but thread count is not set, setting to default of 1.");\r
1057 targetFileContents[lineTC] = "MAX_CONCURRENT_THREAD_NUMBER = 1";\r
1058 targetLines[threadCountId] = "MAX_CONCURRENT_THREAD_NUMBER = 1";\r
1059 }\r
1060 } else {\r
1061 Log.wrn("Build Preferences", "Threading Enabled, but thread count is not set, setting to default of 1.");\r
1062 targetFileContents[lineTC] = "MAX_CONCURRENT_THREAD_NUMBER = 1";\r
1063 targetLines[threadCountId] = "MAX_CONCURRENT_THREAD_NUMBER = 1";\r
1064 }\r
1065 } else {\r
1066 // Don't track threads if threading is not enabled\r
1067 targetFileContents[lineTC] = "#MT#";\r
1068 targetLines[threadCountId] = "";\r
1069 threadCount = "";\r
1070 }\r
1071 \r
1072 }\r
dbf5dd75 1073 private String vectorToString(Vector<String> v) {\r
1074 String s = " ";\r
1075 for (int i = 0; i < v.size(); ++i) {\r
1076 s += v.get(i);\r
1077 s += " ";\r
1078 }\r
1079 return s.trim();\r
1080 }\r
1081\r
1082 protected Vector<String> stringToVector(String s) {\r
1083 if (s == null) {\r
1084 return null;\r
1085 }\r
1086 String[] sArray = s.split(" ");\r
1087 Vector<String> v = new Vector<String>();\r
1088 for (int i = 0; i < sArray.length; ++i) {\r
1089 v.add(sArray[i]);\r
1090 }\r
1091 return v;\r
1092 }\r
1093\r
1094 private void saveTargetFile() {\r
1095 updateActivePlatform();\r
1096 updateToolDefFile();\r
1097 updateToolTagNames();\r
1098 updateBuildTargets();\r
1099 updateArchitectures();\r
bf6aed4d 1100 updateEnableThreads();\r
1101 updateThreadCount();\r
dbf5dd75 1102\r
1103 try {\r
1104 copy(targetFile, targetFile + ".bak");\r
1105 FileWriter fileWriter = new FileWriter(targetFile);\r
1106 BufferedWriter writer = new BufferedWriter(fileWriter);\r
1107 for (int i = 0; i < targetLineNumberMax; i++) {\r
bf6aed4d 1108 if (! targetFileContents[i].contains("#MT#"))\r
1109 writer.write(targetFileContents[i] + "\n");\r
dbf5dd75 1110 }\r
1111 writer.close();\r
1112 } catch (IOException e) {\r
1113 Log.err(toolsConfFile + " Write Error ", e.getMessage());\r
1114 e.printStackTrace();\r
1115 }\r
1116 }\r
1117\r
1118 private void copy(String txtFile, String bakFile) throws IOException {\r
1119 File fromFile = new File(txtFile);\r
1120 File toFile = new File(bakFile);\r
1121 FileInputStream fromTxt = null;\r
1122 FileOutputStream toBak = null;\r
1123 try {\r
1124 fromTxt = new FileInputStream(fromFile);\r
1125 toBak = new FileOutputStream(toFile);\r
1126 byte[] buffer = new byte[4096];\r
1127 int bytes_read;\r
1128 while ((bytes_read = fromTxt.read(buffer)) != -1) {\r
1129 toBak.write(buffer, 0, bytes_read);\r
1130 }\r
1131 } finally {\r
1132 if (fromTxt != null)\r
1133 try {\r
1134 fromTxt.close();\r
1135 } catch (IOException e) {\r
1136 Log.err(toolsConfFile + " Read Error ", e.getMessage());\r
1137\r
1138 }\r
1139 if (toBak != null)\r
1140 try {\r
1141 toBak.close();\r
1142 } catch (IOException e) {\r
1143 Log.err(toolsConfFile + ".bak Write Error ", e.getMessage());\r
1144 }\r
1145 }\r
1146 }\r
1147\r
1148 private void exit() {\r
1149 this.setVisible(false);\r
1150 if (bTarget != null) {\r
1151 bTarget.dispose();\r
1152 }\r
1153 }\r
1154}\r