]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Python/ContextTool.py
Add DebugPort & DebugSupport drivers
[mirror_edk2.git] / Tools / Python / ContextTool.py
CommitLineData
8d4243f1 1#!/usr/bin/env python
2
3b7a53b6 3# Copyright (c) 2007, Intel Corporation
4# All rights reserved. This program and the accompanying materials
5# are licensed and made available under the terms and conditions of the BSD License
6# which accompanies this distribution. The full text of the license may be found at
7# http://opensource.org/licenses/bsd-license.php
8#
9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12"""The EDK II Build System Context Tool Utility maintains Target.txt settings
13in an EDK II Workspace."""
8d4243f1 14
15import wx, os, sys, copy
16from EdkIIWorkspace import *
17
18class ContextToolModel(EdkIIWorkspace):
19 def __init__(self):
20 self.WorkspaceStatus = EdkIIWorkspace.__init__(self)
21 self.Database = {}
22 self.OriginalDatabase = {}
23
24 def LoadTargetTxtFile(self):
25 self.ConvertTextFileToDictionary('Tools/Conf/Target.txt', self.TargetTxtDictionary, '#', '=', True, None)
26 if self.TargetTxtDictionary['ACTIVE_PLATFORM'] == []:
27 self.TargetTxtDictionary['ACTIVE_PLATFORM'] = ['']
28 else:
29 self.TargetTxtDictionary['ACTIVE_PLATFORM'] = [self.TargetTxtDictionary['ACTIVE_PLATFORM'][0]]
30 self.TargetTxtDictionary['TOOL_CHAIN_CONF'] = [self.TargetTxtDictionary['TOOL_CHAIN_CONF'][0]]
31 self.TargetTxtDictionary['MULTIPLE_THREAD'] = [self.TargetTxtDictionary['MULTIPLE_THREAD'][0]]
32 self.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'] = [self.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'][0]]
33 self.TargetTxtDictionary['TARGET'] = list(set(self.TargetTxtDictionary['TARGET']))
34 self.TargetTxtDictionary['TOOL_CHAIN_TAG'] = list(set(self.TargetTxtDictionary['TOOL_CHAIN_TAG']))
35 self.TargetTxtDictionary['TARGET_ARCH'] = list(set(self.TargetTxtDictionary['TARGET_ARCH']))
36 if self.TargetTxtDictionary['TARGET'] == []:
37 self.TargetTxtDictionary['TARGET'] = ['']
38 if self.TargetTxtDictionary['TOOL_CHAIN_TAG'] == []:
39 self.TargetTxtDictionary['TOOL_CHAIN_TAG'] = ['']
40 if self.TargetTxtDictionary['TARGET_ARCH'] == []:
41 self.TargetTxtDictionary['TARGET_ARCH'] = ['']
42 self.TargetTxtDictionary['TARGET'].sort()
43 self.TargetTxtDictionary['TOOL_CHAIN_TAG'].sort()
44 self.TargetTxtDictionary['TARGET_ARCH'].sort()
45 self.OriginalTargetTxtDictionary = copy.deepcopy(self.TargetTxtDictionary)
46
47 def LoadToolsDefTxtFile(self):
48 self.ToolsDefTxtDictionary = {}
49 if self.TargetTxtDictionary['TOOL_CHAIN_CONF'] != ['']:
50 self.ConvertTextFileToDictionary(self.TargetTxtDictionary['TOOL_CHAIN_CONF'][0], self.ToolsDefTxtDictionary, '#', '=', False, None)
51
52 def LoadFrameworkDatabase(self):
53 self.PlatformDatabase = {}
54 Fd = self.XmlParseFile ('Tools/Conf/FrameworkDatabase.db')
55 PlatformList = XmlList (Fd, '/FrameworkDatabase/PlatformList/Filename')
56 for File in PlatformList:
57 FpdFileName = XmlElementData(File)
58 FpdPlatformHeader = self.XmlParseFileSection (FpdFileName, 'PlatformHeader')
59 FpdPlatformDefinitions = self.XmlParseFileSection (FpdFileName,'PlatformDefinitions')
60 PlatformName = XmlElement (FpdPlatformHeader, '/PlatformHeader/PlatformName')
61 PlatformVersion = XmlElement (FpdPlatformHeader, '/PlatformHeader/Version')
62 PlatformUiName = PlatformName + '[' + PlatformVersion + ']'
63 if PlatformUiName not in self.PlatformDatabase:
64 self.PlatformDatabase[PlatformUiName] = {}
65 self.PlatformDatabase[PlatformUiName]['XmlFileName'] = FpdFileName
66 self.PlatformDatabase[PlatformUiName]['SupportedArchitectures'] = set(XmlElement (FpdPlatformDefinitions, '/PlatformSurfaceArea/PlatformDefinitions/SupportedArchitectures').split(' '))
67 self.PlatformDatabase[PlatformUiName]['BuildTargets'] = set(XmlElement (FpdPlatformDefinitions, '/PlatformSurfaceArea/PlatformDefinitions/BuildTargets').split(' '))
68
69 def ComputeToolsDefTxtDatabase(self):
70 self.ToolsDefTxtDatabase = {
71 'TARGET' : [],
72 'TOOL_CHAIN_TAG' : [],
73 'TARGET_ARCH' : []
74 }
75 for Key in dict(self.ToolsDefTxtDictionary):
76 List = Key.split('_')
77 if len(List) != 5:
78 del self.ToolsDefTxtDictionary[Key]
79 elif List[4] == '*':
80 del self.ToolsDefTxtDictionary[Key]
81 else:
82 if List[0] != '*':
83 self.ToolsDefTxtDatabase['TARGET'] += [List[0]]
84 if List[1] != '*':
85 self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG'] += [List[1]]
86 if List[2] != '*':
87 self.ToolsDefTxtDatabase['TARGET_ARCH'] += [List[2]]
88 self.ToolsDefTxtDatabase['TARGET'] = list(set(self.ToolsDefTxtDatabase['TARGET']))
89 self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG'] = list(set(self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG']))
90 self.ToolsDefTxtDatabase['TARGET_ARCH'] = list(set(self.ToolsDefTxtDatabase['TARGET_ARCH']))
91 self.ToolsDefTxtDatabase['TARGET'].sort()
92 self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG'].sort()
93 self.ToolsDefTxtDatabase['TARGET_ARCH'].sort()
94
95 def NewModel(self):
96 self.TargetTxtDictionary = {
97 'ACTIVE_PLATFORM' : [''],
98 'TOOL_CHAIN_CONF' : [''],
99 'MULTIPLE_THREAD' : ['Disable'],
100 'MAX_CONCURRENT_THREAD_NUMBER' : ['2'],
101 'TARGET' : [''],
102 'TOOL_CHAIN_TAG' : [''],
103 'TARGET_ARCH' : ['']
104 }
105
106 def RevertModel(self):
107 self.TargetTxtDictionary = copy.deepcopy(self.OriginalTargetTxtDictionary)
108
109 def RescanModel(self):
110 self.NewModel()
111 self.LoadTargetTxtFile()
112
113 def RefreshModel(self):
114 self.LoadFrameworkDatabase()
115 self.LoadToolsDefTxtFile()
116 self.ComputeToolsDefTxtDatabase()
117
118 if self.Verbose:
119 print self.TargetTxtDictionary
120 print 'ActivePlatform = ', self.TargetTxtDictionary['ACTIVE_PLATFORM'][0]
121 print 'ToolChainConf = ', self.TargetTxtDictionary['TOOL_CHAIN_CONF'][0]
122 print 'MultipleThread = ', self.TargetTxtDictionary['MULTIPLE_THREAD'][0]
123 print 'MaxThreads = ', self.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'][0]
124 print 'TargetSet = ', self.TargetTxtDictionary['TARGET']
125 print 'ToolChainSet = ', self.TargetTxtDictionary['TOOL_CHAIN_TAG']
126 print 'TargetArchSet = ', self.TargetTxtDictionary['TARGET_ARCH']
127 Platforms = self.PlatformDatabase.keys()
128 print 'Possible Settings:'
129 print ' Platforms = ', Platforms
130 print ' TargetSet = ', self.ToolsDefTxtDatabase['TARGET']
131 print ' ToolChainSet = ', self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG']
132 print ' TargetArchSet = ', self.ToolsDefTxtDatabase['TARGET_ARCH']
133 return True
134
135 def ModelModified(self):
136 if self.TargetTxtDictionary != self.OriginalTargetTxtDictionary:
137 return True
138 return False
139
140 def SaveModel(self, Filename='Tools/Conf/Target.txt'):
141 if self.Verbose:
142 for Item in self.TargetTxtDictionary:
143 print Item,'=',self.TargetTxtDictionary[Item]
144 self.ConvertDictionaryToTextFile(Filename, self.TargetTxtDictionary, '#', '=', True, None)
145 self.OriginalTargetTxtDictionary = copy.deepcopy(self.TargetTxtDictionary)
146
147 def CloseModel(self):
148 pass
149
150class Frame(wx.Frame):
151 def __init__(self):
152 wx.Frame.__init__(self,None,-1,'EDK II Build System Context Tool')
153 panel = wx.Panel(self, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL)
154 wx.HelpProvider_Set(wx.SimpleHelpProvider())
155 self.Model = ContextToolModel()
156 if not self.Model.WorkspaceStatus:
157 self.Close()
158 return
159
160 #
161 # Help text
162 #
163 ActivePlatformHelpText = (
164 "Specifies the Platform Name and Platform Version of the platform that will be "
165 "used for build. If set to [Build Directory] and the current directory contains "
166 "an FPD file, then a plaform build on that FPD file will be performed. If set "
167 "to [Build Directory] and there is no FPD file in the current directory, then no "
168 "build will be performed."
169 )
170
171 ToolChainConfHelpText = (
172 "Specifies the name of the file that declares all the tools and flag settings "
173 "required to complete a build. This is typically set to Tools/Conf/tools_def.txt."
174 )
175
176 MultipleThreadHelpText = (
177 "Flag to enable or disable multi-thread builds. If your computer is multi-core "
178 "or contans multiple CPUs, enabling this feature will improve build performance. "
179 "For multi-thread builds, a log will be written to ${BUILD_DIR}/build.log. This "
180 "feature is only for platform builds. Clean, cleanall, and stand-alone module "
181 "builds only use one thread."
182 )
183
184 ThreadsHelpText = (
185 "The number of concurrent threads. The best performance is achieved if this "
186 "value is set to one greater than the number or cores or CPUs in the build system."
187 )
188
189 TargetHelpText = (
190 "Specifies the set of targets to build. If set to All, then all build targets "
191 "are built. Otherwise, the subset of enabled build targets are built. The "
192 "standard build targets are RELEASE and DEBUG, but additional user-defined build "
193 "targets may be declared in the TOOL_CHAIN_CONF file. The DEBUG builds with "
194 "source level debugging enabled. RELEASE builds with source level debugging "
195 "disabled and results in smaller firmware images."
196 )
197
198 ToolChainTagHelpText = (
199 "Specifies the set of tool chains to use during a build. If set to All, then "
200 "all of the supported tools chains are used. Otherwise, only the subset of "
201 "enabled tool chains are used. The TOOL_CHAIN_CONF file declares one or more "
202 "tool chains that may be used."
203 )
204
205 TargetArchHelpText = (
206 "Specifies the set of CPU architectures to build. If set to All, then all the "
207 "CPU architectures supported by the platform FPD file are built. Otherwise, "
208 "only the subset of enabled CPU architectures are built. The standard CPU "
209 "architectures are IA32, X64, IPF, and EBC, but additional CPU architectures "
210 "may be declared in the TOOL_CHAIN_CONF file."
211 )
212
213 #
214 # Status Bar
215 #
216 self.CreateStatusBar()
217
218 #
219 # Build Menus
220 #
221 MenuBar = wx.MenuBar()
222
223 FileMenu = wx.Menu()
224 NewMenuItem = FileMenu.Append(-1, "&New\tCtrl+N", "New target.txt")
225 SaveMenuItem = FileMenu.Append(-1, "&Save\tCtrl+S", "Save target.txt")
226 SaveAsMenuItem = FileMenu.Append(-1, "Save &As...", "Save target.txt as...")
227 RevertMenuItem = FileMenu.Append(-1, "&Revert", "Revert to the original target.txt")
228 ExitMenuItem = FileMenu.Append(-1, "E&xit\tAlt+F4", "Exit ContextTool")
229 MenuBar.Append(FileMenu, "&File")
230 self.Bind(wx.EVT_MENU, self.OnSaveClick, SaveMenuItem)
231 self.Bind(wx.EVT_MENU, self.OnSaveAsClick, SaveAsMenuItem)
232 self.Bind(wx.EVT_MENU, self.OnRevertClick, RevertMenuItem)
233 self.Bind(wx.EVT_MENU, self.OnExitClick, ExitMenuItem)
234
235 ViewMenu = wx.Menu()
236 RefreshMenuItem = ViewMenu.Append (-1, "&Refresh\tF5", "Rescan target.txt")
237 ShowToolBarMenuItem = ViewMenu.AppendCheckItem (-1, "Show &Toolbar", "Shows or hides the toolbar")
238 ShowToolBarMenuItem.Check(True)
239 MenuBar.Append(ViewMenu, "&View")
240 self.Bind(wx.EVT_MENU, self.OnViewRefreshClick, RefreshMenuItem)
241 self.Bind(wx.EVT_MENU, self.OnShowToolBarClick, ShowToolBarMenuItem)
242
243 HelpMenu = wx.Menu()
244 AboutMenuItem = HelpMenu.Append (-1, "&About...", "About")
245 MenuBar.Append(HelpMenu, "&Help")
246 self.Bind(wx.EVT_MENU, self.OnAboutClick, AboutMenuItem)
247
248 self.SetMenuBar (MenuBar)
249
250 #
251 # Build Toolbar
252 #
253 self.ShowToolBar = False
254 self.OnShowToolBarClick(self)
255
256 #
257 # Active Platform Combo Box
258 #
259 ActivePlatformLabel = wx.StaticText(panel, -1, 'ACTIVE_PLATFORM')
260 ActivePlatformLabel.SetHelpText(ActivePlatformHelpText)
261 self.ActivePlatformText = wx.ComboBox(panel,-1, style=wx.CB_DROPDOWN | wx.CB_SORT | wx.CB_READONLY)
262 self.ActivePlatformText.SetHelpText(ActivePlatformHelpText)
263 self.ActivePlatformText.Bind(wx.EVT_TEXT, self.OnActivePlatformClick)
264
265 #
266 # Tool Chain Configuration Text Control and Browse Button for a File Dialog Box
267 #
268 ToolChainConfFileLabel = wx.StaticText(panel, -1, 'TOOL_CHAIN_CONF')
269 ToolChainConfFileLabel.SetHelpText(ToolChainConfHelpText)
270 self.ToolChainConfFileText = wx.TextCtrl(panel, -1, style=wx.TE_PROCESS_ENTER)
271 self.ToolChainConfFileText.Bind(wx.EVT_TEXT_ENTER, self.OnToolChainConfClick)
272 self.ToolChainConfFileText.Bind(wx.EVT_KILL_FOCUS, self.OnToolChainConfClick)
273 self.ToolChainConfFileText.SetHelpText(ToolChainConfHelpText)
274 self.BrowseButton = wx.Button(panel, -1, 'Browse...')
275 self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick)
276
277 #
278 # Multiple Thread enable/disable radio button
279 #
280 MultipleThreadLabel = wx.StaticText(panel, -1, 'MULTIPLE_THREAD')
281 MultipleThreadLabel.SetHelpText(MultipleThreadHelpText)
282 self.MultipleThreadRadioBox = wx.RadioBox(panel, -1, choices=['Enable','Disable'], style=wx.RA_SPECIFY_COLS)
283 self.MultipleThreadRadioBox.Bind(wx.EVT_RADIOBOX, self.OnMultipleThreadRadioBox)
284 self.MultipleThreadRadioBox.SetHelpText(MultipleThreadHelpText)
285
286 #
287 # Thread count spin control
288 #
289 ThreadsLabel = wx.StaticText(panel, -1, 'THREADS')
290 ThreadsLabel.SetHelpText(ThreadsHelpText)
291 self.ThreadsSpinCtrl = wx.SpinCtrl(panel, -1, size=(50, -1), min=2)
292 self.ThreadsSpinCtrl.Bind(wx.EVT_TEXT, self.OnThreadsSpinCtrl)
293 self.ThreadsSpinCtrl.SetHelpText(ThreadsHelpText)
294
295 #
296 # Target, ToolChain, and Arch Check List Boxes
297 #
298 TargetLabel = wx.StaticText(panel, -1, 'TARGET')
299 TargetLabel.SetHelpText(TargetHelpText)
300
301 ToolChainTagLabel = wx.StaticText(panel, -1, 'TOOL_CHAIN_TAG')
302 ToolChainTagLabel.SetHelpText(ToolChainTagHelpText)
303
304 TargetArchLabel = wx.StaticText(panel, -1, 'TARGET_ARCH')
305 TargetArchLabel.SetHelpText(TargetArchHelpText)
306
307 self.TargetCheckListBox = wx.CheckListBox(panel, -1)
308 self.TargetCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnTargetCheckListClick)
309 self.TargetCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnTargetSetFocus)
310 self.TargetCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnTargetKillFocus)
311 self.TargetCheckListBox.SetHelpText(TargetHelpText)
312
313 self.ToolChainTagCheckListBox = wx.CheckListBox(panel, -1)
314 self.ToolChainTagCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnToolChainTagCheckListClick)
315 self.ToolChainTagCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnToolChainTagSetFocus)
316 self.ToolChainTagCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnToolChainTagKillFocus)
317 self.ToolChainTagCheckListBox.SetHelpText(ToolChainTagHelpText)
318
319 self.TargetArchCheckListBox = wx.CheckListBox(panel, -1)
320 self.TargetArchCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnTargetArchCheckListClick)
321 self.TargetArchCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnTargetArchSetFocus)
322 self.TargetArchCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnTargetArchKillFocus)
323 self.TargetArchCheckListBox.SetHelpText(TargetArchHelpText)
324
325 #
326 # Define layout using sizers
327 #
328 self.mainSizer = wx.BoxSizer(wx.VERTICAL)
329
330 flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
331 flexSizer.AddGrowableCol(1)
332 flexSizer.Add(ActivePlatformLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
333 flexSizer.Add(self.ActivePlatformText, 0, wx.EXPAND)
334 flexSizer.Add((0,0), wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
335
336 flexSizer.Add(ToolChainConfFileLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
337 flexSizer.Add(self.ToolChainConfFileText, 0, wx.EXPAND)
338 flexSizer.Add(self.BrowseButton, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
339
340 self.mainSizer.Add (flexSizer, 0, wx.EXPAND | wx.ALL, 10)
341
342 threadsSizer = wx.FlexGridSizer(cols = 5, hgap=5, vgap=5)
343 threadsSizer.Add(MultipleThreadLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
344 threadsSizer.Add(self.MultipleThreadRadioBox, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
345 threadsSizer.Add(ThreadsLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
346 threadsSizer.Add(self.ThreadsSpinCtrl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
347
348 self.mainSizer.Add (threadsSizer, 0, wx.ALL, 10)
349
350 listSizer = wx.FlexGridSizer(rows = 2, cols = 3, hgap=5, vgap=5)
351 listSizer.AddGrowableRow(1)
352 listSizer.AddGrowableCol(0)
353 listSizer.AddGrowableCol(1)
354 listSizer.AddGrowableCol(2)
355 listSizer.Add(TargetLabel, 0, wx.ALIGN_CENTER)
356 listSizer.Add(ToolChainTagLabel, 0, wx.ALIGN_CENTER)
357 listSizer.Add(TargetArchLabel, 0, wx.ALIGN_CENTER)
358 listSizer.Add(self.TargetCheckListBox, 0, wx.ALL | wx.EXPAND)
359 listSizer.Add(self.ToolChainTagCheckListBox, 0, wx.ALL | wx.EXPAND)
360 listSizer.Add(self.TargetArchCheckListBox, 0, wx.ALL | wx.EXPAND)
361
362 self.mainSizer.Add (listSizer, wx.EXPAND | wx.ALL, wx.EXPAND | wx.ALL, 10)
363
364 panel.SetSizer (self.mainSizer)
365
366 self.Model.RescanModel()
367 self.OnRefreshClick(self)
368
369 def OnActivePlatformClick(self, event):
370 Platform = self.ActivePlatformText.GetValue()
371 if Platform == ' [Build Directory]':
372 self.Model.TargetTxtDictionary['ACTIVE_PLATFORM'][0] = ''
373 else:
374 self.Model.TargetTxtDictionary['ACTIVE_PLATFORM'][0] = self.Model.PlatformDatabase[Platform]['XmlFileName']
375
376 def OnToolChainConfClick(self, event):
377 if self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0] != self.ToolChainConfFileText.GetValue():
378 self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0] = self.ToolChainConfFileText.GetValue()
379 self.OnRefreshClick(self)
380
381 def OnBrowseButtonClick(self, event):
382 wildcard = "Text Documents (*.txt)|*.txt|" \
383 "All files (*.*)|*.*"
384 dialog = wx.FileDialog (None, 'Choose a Tool Chain Configuration File', self.Model.WorkspaceFile('Tools/Conf'), '', wildcard, wx.OPEN)
385 if dialog.ShowModal() == wx.ID_OK:
386 print dialog.GetPath()
387 ToolChainConfFile = self.Model.WorkspaceRelativePath(dialog.GetPath())
388 self.ToolChainConfFileText.SetValue(ToolChainConfFile)
389 self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0] = self.ToolChainConfFileText.GetValue()
390 self.OnRefreshClick(self)
391 dialog.Destroy()
392
393 def OnMultipleThreadRadioBox (self, event):
394 self.Model.TargetTxtDictionary['MULTIPLE_THREAD'] = [self.MultipleThreadRadioBox.GetStringSelection()]
395 if self.MultipleThreadRadioBox.GetStringSelection() == 'Disable':
396 self.ThreadsSpinCtrl.Disable()
397 else:
398 self.ThreadsSpinCtrl.Enable()
399
400 def OnThreadsSpinCtrl(self, event):
401 self.Model.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'] = [str(self.ThreadsSpinCtrl.GetValue())]
402
403 def CheckListFocus(self, CheckListBox, Set):
404 Index = 0
405 while Index < CheckListBox.GetCount():
406 CheckListBox.SetSelection(Index, False)
407 Index += 1
408 if Set:
409 CheckListBox.SetSelection(0, True)
410
411 def CheckListClick(self, CheckListBox, Name):
412 if CheckListBox.IsChecked(0):
413 Index = 1
414 while Index < CheckListBox.GetCount():
415 CheckListBox.Check(Index, False)
416 Index += 1
417 if CheckListBox.IsChecked(0):
418 self.Model.TargetTxtDictionary[Name] = ['']
419 else:
420 self.Model.TargetTxtDictionary[Name] = []
421 Index = 1
422 while Index < CheckListBox.GetCount():
423 if CheckListBox.IsChecked(Index):
424 self.Model.TargetTxtDictionary[Name] += [CheckListBox.GetString(Index)]
425 Index += 1
426 if self.Model.TargetTxtDictionary[Name] == []:
427 self.Model.TargetTxtDictionary[Name] = ['']
428
429 def OnTargetCheckListClick(self, event):
430 self.CheckListClick(self.TargetCheckListBox, 'TARGET')
431
432 def OnTargetSetFocus(self, event):
433 self.CheckListFocus(self.TargetCheckListBox, True)
434
435 def OnTargetKillFocus(self, event):
436 self.CheckListFocus(self.TargetCheckListBox, False)
437
438 def OnToolChainTagCheckListClick(self, event):
439 self.CheckListClick(self.ToolChainTagCheckListBox, 'TOOL_CHAIN_TAG')
440
441 def OnToolChainTagSetFocus(self, event):
442 self.CheckListFocus(self.ToolChainTagCheckListBox, True)
443
444 def OnToolChainTagKillFocus(self, event):
445 self.CheckListFocus(self.ToolChainTagCheckListBox, False)
446
447 def OnTargetArchCheckListClick(self, event):
448 self.CheckListClick(self.TargetArchCheckListBox, 'TARGET_ARCH')
449
450 def OnTargetArchSetFocus(self, event):
451 self.CheckListFocus(self.TargetArchCheckListBox, True)
452
453 def OnTargetArchKillFocus(self, event):
454 self.CheckListFocus(self.TargetArchCheckListBox, False)
455
456 def OnRevertClick(self, event):
457 self.Model.RevertModel()
458 self.OnRefreshClick(self)
459
460 def RefreshCheckListBox(self, CheckListBox, Name):
461 CheckListBox.Set(['All'] + self.Model.ToolsDefTxtDatabase[Name])
462 Index = 0
463 MaximumString = ''
464 while Index < CheckListBox.GetCount():
465 String = CheckListBox.GetString(Index)
466 if len(String) > len(MaximumString):
467 MaximumString = String
468 if String in self.Model.TargetTxtDictionary[Name]:
469 CheckListBox.Check(Index, True)
470 else:
471 CheckListBox.Check(Index, False)
472 Index += 1
473 if self.Model.TargetTxtDictionary[Name] == ['']:
474 CheckListBox.Check(0, True)
475 Extents = CheckListBox.GetFullTextExtent (MaximumString)
476 CheckListBox.SetMinSize((Extents[0],(CheckListBox.GetCount()+1) * (Extents[1]+Extents[2])))
477
478 def OnRefreshClick(self, event):
479 self.Model.RefreshModel()
480 Platforms = self.Model.PlatformDatabase.keys()
481 Platforms.sort()
482 self.ActivePlatformText.SetItems([' [Build Directory]'] + Platforms)
483 self.ActivePlatformText.SetValue(' [Build Directory]')
484 for Platform in self.Model.PlatformDatabase:
485 if self.Model.PlatformDatabase[Platform]['XmlFileName'] == self.Model.TargetTxtDictionary['ACTIVE_PLATFORM'][0]:
486 self.ActivePlatformText.SetValue(Platform)
487 if self.ActivePlatformText.GetValue() == ' [Build Directory]':
488 self.Model.TargetTxtDictionary['ACTIVE_PLATFORM'][0] = ''
489 MaximumString = ' [Build Directory]'
490 for String in Platforms:
491 if len(String) > len(MaximumString):
492 MaximumString = String
493 Extents = self.ActivePlatformText.GetFullTextExtent (MaximumString)
494 self.ActivePlatformText.SetMinSize((Extents[0] + 24,-1))
495
496 self.ToolChainConfFileText.SetValue(self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0])
497 Extents = self.ToolChainConfFileText.GetFullTextExtent (self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0])
498 self.ToolChainConfFileText.SetMinSize((Extents[0] + 24,-1))
499
500 self.MultipleThreadRadioBox.SetStringSelection(self.Model.TargetTxtDictionary['MULTIPLE_THREAD'][0])
501 if self.MultipleThreadRadioBox.GetStringSelection() == 'Disable':
502 self.ThreadsSpinCtrl.Disable()
503 self.ThreadsSpinCtrl.SetValue(int(self.Model.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'][0]))
504
505 self.RefreshCheckListBox (self.TargetCheckListBox, 'TARGET')
506 self.RefreshCheckListBox (self.ToolChainTagCheckListBox, 'TOOL_CHAIN_TAG')
507 self.RefreshCheckListBox (self.TargetArchCheckListBox, 'TARGET_ARCH')
508
509 self.mainSizer.SetSizeHints(self)
510 self.mainSizer.Fit(self)
511
512 def OnViewRefreshClick(self, event):
513 self.Model.RescanModel()
514 self.OnRefreshClick(self)
515
516 def AddTool (self, Handler, ArtId, Label, HelpText):
517 Tool = self.ToolBar.AddSimpleTool(
518 -1,
519 wx.ArtProvider.GetBitmap(ArtId, wx.ART_TOOLBAR, self.ToolSize),
520 Label,
521 HelpText
522 )
523 self.Bind(wx.EVT_MENU, Handler, Tool)
524
525 def OnShowToolBarClick(self, event):
526 if self.ShowToolBar:
527 self.ShowToolBar = False
528 self.ToolBar.Destroy()
529 else:
530 self.ShowToolBar = True
531 self.ToolBar = self.CreateToolBar()
532 self.ToolSize = (24,24)
533 self.ToolBar.SetToolBitmapSize(self.ToolSize)
534 self.AddTool (self.OnNewClick, wx.ART_NEW, "New", "New target.txt")
535 self.AddTool (self.OnSaveClick, wx.ART_FILE_SAVE, "Save", "Save target.txt")
536 self.AddTool (self.OnSaveAsClick, wx.ART_FILE_SAVE_AS, "Save As...", "Save target.txt as...")
537 self.AddTool (self.OnRevertClick, wx.ART_UNDO, "Revert", "Revert to original target.txt")
538 self.AddTool (self.OnHelpClick, wx.ART_HELP, "Help", "Context Sensitive Help")
539 self.AddTool (self.OnExitClick, wx.ART_QUIT, "Exit", "Exit Context Tool application")
540 self.ToolBar.Realize()
541
542 def OnNewClick(self, event):
543 self.Model.NewModel()
544 self.OnRefreshClick(self)
545
546 def OnSaveClick(self, event):
547 self.Model.SaveModel()
548
549 def OnSaveAsClick(self, event):
550 wildcard = "Text Documents (*.txt)|*.txt|" \
551 "All files (*.*)|*.*"
552 dialog = wx.FileDialog (None, 'Save As', self.Model.WorkspaceFile('Tools/Conf'), '', wildcard, wx.SAVE | wx.OVERWRITE_PROMPT)
553 if dialog.ShowModal() == wx.ID_OK:
554 TargetTxtFile = self.Model.WorkspaceRelativePath(dialog.GetPath())
555 if TargetTxtFile != '':
556 self.Model.SaveModel(TargetTxtFile)
557 dialog.Destroy()
558
559 def OnExitClick(self, event):
560 if self.Model.ModelModified():
561 dialog = wx.MessageDialog(None, 'The contents have changed.\nDo you want to save changes?', 'EDK II Build System Context Tool', style = wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | wx.ICON_EXCLAMATION)
562 Status = dialog.ShowModal()
563 dialog.Destroy()
564 if Status == wx.ID_YES:
565 self.OnSaveClick (self)
566 elif Status == wx.ID_CANCEL:
567 return
568 self.Model.CloseModel()
569 self.Close()
570
571 def OnHelpClick(self, event):
572 wx.ContextHelp().BeginContextHelp()
573
574 def OnAboutClick(self, event):
575 AboutInfo = wx.AboutDialogInfo()
576 AboutInfo.Name = 'EDK II Build System Context Tool'
577 AboutInfo.Version = '0.3'
578 AboutInfo.Copyright = 'Copyright (c) 2006, Intel Corporation'
579 AboutInfo.Description = """
580 The EDK II Build System Context Tool maintains the target.txt
581 settings in an EDK II Workspace."""
582 AboutInfo.WebSite = ("http://tianocore.org", "Tiano Core home page")
583 AboutInfo.License = """
584 All rights reserved. This program and the accompanying materials are
585 licensed and made available under the terms and conditions of the BSD
586 License which accompanies this distribution. The full text of the
587 license may be found at http://opensource.org/licenses/bsd-license.php
588
589 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
590 BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
591 EITHER EXPRESS OR IMPLIED."""
592 if self.Model.Icon != None:
593 AboutInfo.Icon = self.Model.Icon
594 wx.AboutBox(AboutInfo)
595
596if __name__ == '__main__':
597 app = wx.PySimpleApp()
598 frame = Frame()
599 frame.Show()
600 app.MainLoop()