diff options
Diffstat (limited to 'Tools/Python')
-rwxr-xr-x | Tools/Python/Calc-Deps.py | 217 | ||||
-rwxr-xr-x | Tools/Python/ContextTool.py | 600 | ||||
-rw-r--r-- | Tools/Python/Doxyfile | 259 | ||||
-rwxr-xr-x | Tools/Python/EdkIIWorkspace.py | 148 | ||||
-rwxr-xr-x | Tools/Python/Fd.py | 582 | ||||
-rwxr-xr-x | Tools/Python/GenMake.py | 114 | ||||
-rwxr-xr-x | Tools/Python/InstallFar.py | 328 | ||||
-rwxr-xr-x | Tools/Python/Install_Python_OSX.sh | 16 | ||||
-rwxr-xr-x | Tools/Python/ListWorkspace.py | 47 | ||||
-rwxr-xr-x | Tools/Python/MkFar.py | 230 | ||||
-rwxr-xr-x | Tools/Python/WorkspaceRoutines.py | 61 | ||||
-rwxr-xr-x | Tools/Python/XmlRoutines.py | 195 | ||||
-rw-r--r-- | Tools/Python/buildgen/AntTasks.py | 84 | ||||
-rw-r--r-- | Tools/Python/buildgen/BuildConfig.py | 185 | ||||
-rw-r--r-- | Tools/Python/buildgen/BuildFile.py | 582 | ||||
-rw-r--r-- | Tools/Python/buildgen/FrameworkElement.py | 523 | ||||
-rw-r--r-- | Tools/Python/buildgen/SurfaceAreaElement.py | 1555 | ||||
-rw-r--r-- | Tools/Python/buildgen/module_build_path.txt | 5 | ||||
-rw-r--r-- | Tools/Python/buildgen/platform_build_path.txt | 5 | ||||
-rw-r--r-- | Tools/Python/far-template | 48 |
20 files changed, 0 insertions, 5784 deletions
diff --git a/Tools/Python/Calc-Deps.py b/Tools/Python/Calc-Deps.py deleted file mode 100755 index b022a907ae..0000000000 --- a/Tools/Python/Calc-Deps.py +++ /dev/null @@ -1,217 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2007, Intel Corporation -# All rights reserved. This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -"""Calculate the dependencies a given module has by looking through the source -code to see what guids and functions are referenced to see which Packages and -Library Classes need to be referenced. """ - -import os, sys, re, getopt, string, glob, xml.dom.minidom, pprint -from XmlRoutines import * - -# Map each function name back to the lib class that declares it. -function_table = {} - -# Map each guid name to a package name. -cname_table = {} - -def inWorkspace(rel_path): - """Treat the given path as relative to the workspace.""" - - # Make sure the user has set the workspace variable: - try: - return os.path.join(os.environ["WORKSPACE"], rel_path ) - except: - print "Oops! You must set the WORKSPACE environment variable to run this script." - sys.exit() - -def getIdentifiers(infiles): - - """Build a set of all the identifiers in this file.""" - - # Start with an empty set. - ids = set() - - for infile in infiles: - - # Open the file - f = open(infile) - - # Create some lexical categories that we will use to filter out - strings=re.compile('L?"[^"]*"') - chars=re.compile("'[^']*'") - hex=re.compile("0[Xx][0-9a-fA-F]*") - keywords = re.compile('for|do|while|if|else|break|int|unsigned|switch|volatile|goto|case|char|long|struct|return|extern') - common = re.compile('VOID|UINTN|UINT32|UINT8|UINT64') - - # Compile a Regular expression to grab all the identifers from the input. - identifier = re.compile('[_a-zA-Z][0-9_a-zA-Z]{3,}') - - for line in f.readlines(): - - # Filter some lexical categories out. - # for filter in [strings, chars, hex, keywords, common]: - for filter in [strings, chars, hex]: - line = re.sub(filter, '', line) - - # Add all the identifiers that we found on this line. - ids = ids.union(set(identifier.findall(line))) - - # Close the file - f.close() - - # Return the set of identifiers. - return ids - - -def search_classes(ids): - - """ Search the set of classes for functions.""" - - # Start with an empty set. - classes = set() - - for id in ids: - try: - # If it is not a "hit" in the table add it to the set. - classes.add(function_table[id]) - except: - # If it is not a "hit" in the table, ignore it. - pass - - return classes - -def search_cnames(ids): - - """Search all the Packages to see if this code uses a Guid from one of them. - Return a set of matching packages.""" - - packages = set() - - for id in ids: - try: - # If it is not a "hit" in the table add it to the set. - packages.add(cname_table[id]) - except: - # If it is not a "hit" in the table, ignore it. - pass - - return packages - -def getSpds(): - - """Open the database and get all the spd files out.""" - - # Open the database - database = xml.dom.minidom.parse(inWorkspace("Tools/Conf/FrameworkDatabase.db")) - - # Get a list of all the packages - for filename in XmlList(database, "/FrameworkDatabase/PackageList/Filename"): - spdFile = XmlElementData(filename) - - # Now open the spd file and build the database of guids. - getCNames(inWorkspace(spdFile)) - getLibClasses(inWorkspace(spdFile)) - -def getCNames(spdFile): - - """Extract all the C_Names from an spd file.""" - - # Begin to parse the XML of the .spd - spd = xml.dom.minidom.parse(spdFile) - - # Get the name of the package - packageName = XmlElement(spd, "PackageSurfaceArea/SpdHeader/PackageName") - packageVersion = XmlElement(spd, "PackageSurfaceArea/SpdHeader/Version") - packageGuid = XmlElement(spd, "PackageSurfaceArea/SpdHeader/GuidValue") - - # Find the C_Name - for cname in XmlList(spd, "/PackageSurfaceArea/GuidDeclarations/Entry/C_Name") + \ - XmlList(spd, "/PackageSurfaceArea/PcdDeclarations/PcdEntry/C_Name") + \ - XmlList(spd, "/PackageSurfaceArea/PpiDeclarations/Entry/C_Name") + \ - XmlList(spd, "/PackageSurfaceArea/ProtocolDeclarations/Entry/C_Name"): - - # Get the text of the <C_Name> tag. - cname_text = XmlElementData(cname) - - # Map the <C_Name> to the <PackageName>. We will use this to lookup every - # identifier in the Input Code. - cname_table[cname_text] = {"name": packageName, "version": packageVersion, "guid": packageGuid} - - - return - -def getLibClasses(spdFile): - - """Extract all the Lib Classes from an spd file.""" - - # Begin to parse the XML of the .spd - spd = xml.dom.minidom.parse(spdFile) - - # Get the guid of the package - packageGuid = XmlElement(spd, "/PackageSurfaceArea/SpdHeader/GuidValue") - - for libClass in XmlList(spd, "/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass"): - className = XmlAttribute(libClass, "Name") - headerfile = XmlElementData(libClass.getElementsByTagName("IncludeHeader")[0]) - - packageRoot=os.path.dirname(spdFile) - - headerfile = os.path.join(packageRoot, headerfile) - - f = open(headerfile) - - # This pattern can pick out function names if the EFI coding - # standard is followed. We could also use dumpbin on library - # instances to get a list of symbols. - functionPattern = re.compile("([_a-zA-Z][_a-zA-Z0-9]*) *\( *"); - - for line in f.readlines(): - m = functionPattern.match(line) - if m: - functionName = m.group(1) - # Map it! - function_table[functionName] = (className, packageGuid) - - f.close() - -def guid(strVal): - """Make a guid number out of a guid hex string.""" - return long(strVal.replace('-',''), 16) - -# This acts like the main() function for the script, unless it is 'import'ed into another -# script. -if __name__ == '__main__': - - # Create a pretty printer for dumping data structures in a readable form. - pp = pprint.PrettyPrinter(indent=2) - - # Process the command line args. - optlist, args = getopt.getopt(sys.argv[1:], 'h', [ 'example-long-arg=', 'testing']) - - """You should pass a file name as a paramter. It should be preprocessed text -of all the .c and .h files in your module, which is cat'ed together into one -large file.""" - - # Scrape out all the things that look like identifiers. - ids = getIdentifiers(args) - - # Read in the spds from the workspace to find the Guids. - getSpds() - - # Debug stuff. - print "Function Table = " - pp.pprint(function_table) - print "CName Table = " - pp.pprint(cname_table) - print "Classes = " - pp.pprint(list(search_classes(ids))) - print "C_Names = " - pp.pprint(list(search_cnames(ids))) diff --git a/Tools/Python/ContextTool.py b/Tools/Python/ContextTool.py deleted file mode 100755 index 0dfd5c65b4..0000000000 --- a/Tools/Python/ContextTool.py +++ /dev/null @@ -1,600 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2007, Intel Corporation -# All rights reserved. This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -"""The EDK II Build System Context Tool Utility maintains Target.txt settings -in an EDK II Workspace.""" - -import wx, os, sys, copy -from EdkIIWorkspace import * - -class ContextToolModel(EdkIIWorkspace): - def __init__(self): - self.WorkspaceStatus = EdkIIWorkspace.__init__(self) - self.Database = {} - self.OriginalDatabase = {} - - def LoadTargetTxtFile(self): - self.ConvertTextFileToDictionary('Tools/Conf/Target.txt', self.TargetTxtDictionary, '#', '=', True, None) - if self.TargetTxtDictionary['ACTIVE_PLATFORM'] == []: - self.TargetTxtDictionary['ACTIVE_PLATFORM'] = [''] - else: - self.TargetTxtDictionary['ACTIVE_PLATFORM'] = [self.TargetTxtDictionary['ACTIVE_PLATFORM'][0]] - self.TargetTxtDictionary['TOOL_CHAIN_CONF'] = [self.TargetTxtDictionary['TOOL_CHAIN_CONF'][0]] - self.TargetTxtDictionary['MULTIPLE_THREAD'] = [self.TargetTxtDictionary['MULTIPLE_THREAD'][0]] - self.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'] = [self.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'][0]] - self.TargetTxtDictionary['TARGET'] = list(set(self.TargetTxtDictionary['TARGET'])) - self.TargetTxtDictionary['TOOL_CHAIN_TAG'] = list(set(self.TargetTxtDictionary['TOOL_CHAIN_TAG'])) - self.TargetTxtDictionary['TARGET_ARCH'] = list(set(self.TargetTxtDictionary['TARGET_ARCH'])) - if self.TargetTxtDictionary['TARGET'] == []: - self.TargetTxtDictionary['TARGET'] = [''] - if self.TargetTxtDictionary['TOOL_CHAIN_TAG'] == []: - self.TargetTxtDictionary['TOOL_CHAIN_TAG'] = [''] - if self.TargetTxtDictionary['TARGET_ARCH'] == []: - self.TargetTxtDictionary['TARGET_ARCH'] = [''] - self.TargetTxtDictionary['TARGET'].sort() - self.TargetTxtDictionary['TOOL_CHAIN_TAG'].sort() - self.TargetTxtDictionary['TARGET_ARCH'].sort() - self.OriginalTargetTxtDictionary = copy.deepcopy(self.TargetTxtDictionary) - - def LoadToolsDefTxtFile(self): - self.ToolsDefTxtDictionary = {} - if self.TargetTxtDictionary['TOOL_CHAIN_CONF'] != ['']: - self.ConvertTextFileToDictionary(self.TargetTxtDictionary['TOOL_CHAIN_CONF'][0], self.ToolsDefTxtDictionary, '#', '=', False, None) - - def LoadFrameworkDatabase(self): - self.PlatformDatabase = {} - Fd = self.XmlParseFile ('Tools/Conf/FrameworkDatabase.db') - PlatformList = XmlList (Fd, '/FrameworkDatabase/PlatformList/Filename') - for File in PlatformList: - FpdFileName = XmlElementData(File) - FpdPlatformHeader = self.XmlParseFileSection (FpdFileName, 'PlatformHeader') - FpdPlatformDefinitions = self.XmlParseFileSection (FpdFileName,'PlatformDefinitions') - PlatformName = XmlElement (FpdPlatformHeader, '/PlatformHeader/PlatformName') - PlatformVersion = XmlElement (FpdPlatformHeader, '/PlatformHeader/Version') - PlatformUiName = PlatformName + '[' + PlatformVersion + ']' - if PlatformUiName not in self.PlatformDatabase: - self.PlatformDatabase[PlatformUiName] = {} - self.PlatformDatabase[PlatformUiName]['XmlFileName'] = FpdFileName - self.PlatformDatabase[PlatformUiName]['SupportedArchitectures'] = set(XmlElement (FpdPlatformDefinitions, '/PlatformSurfaceArea/PlatformDefinitions/SupportedArchitectures').split(' ')) - self.PlatformDatabase[PlatformUiName]['BuildTargets'] = set(XmlElement (FpdPlatformDefinitions, '/PlatformSurfaceArea/PlatformDefinitions/BuildTargets').split(' ')) - - def ComputeToolsDefTxtDatabase(self): - self.ToolsDefTxtDatabase = { - 'TARGET' : [], - 'TOOL_CHAIN_TAG' : [], - 'TARGET_ARCH' : [] - } - for Key in dict(self.ToolsDefTxtDictionary): - List = Key.split('_') - if len(List) != 5: - del self.ToolsDefTxtDictionary[Key] - elif List[4] == '*': - del self.ToolsDefTxtDictionary[Key] - else: - if List[0] != '*': - self.ToolsDefTxtDatabase['TARGET'] += [List[0]] - if List[1] != '*': - self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG'] += [List[1]] - if List[2] != '*': - self.ToolsDefTxtDatabase['TARGET_ARCH'] += [List[2]] - self.ToolsDefTxtDatabase['TARGET'] = list(set(self.ToolsDefTxtDatabase['TARGET'])) - self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG'] = list(set(self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG'])) - self.ToolsDefTxtDatabase['TARGET_ARCH'] = list(set(self.ToolsDefTxtDatabase['TARGET_ARCH'])) - self.ToolsDefTxtDatabase['TARGET'].sort() - self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG'].sort() - self.ToolsDefTxtDatabase['TARGET_ARCH'].sort() - - def NewModel(self): - self.TargetTxtDictionary = { - 'ACTIVE_PLATFORM' : [''], - 'TOOL_CHAIN_CONF' : [''], - 'MULTIPLE_THREAD' : ['Disable'], - 'MAX_CONCURRENT_THREAD_NUMBER' : ['2'], - 'TARGET' : [''], - 'TOOL_CHAIN_TAG' : [''], - 'TARGET_ARCH' : [''] - } - - def RevertModel(self): - self.TargetTxtDictionary = copy.deepcopy(self.OriginalTargetTxtDictionary) - - def RescanModel(self): - self.NewModel() - self.LoadTargetTxtFile() - - def RefreshModel(self): - self.LoadFrameworkDatabase() - self.LoadToolsDefTxtFile() - self.ComputeToolsDefTxtDatabase() - - if self.Verbose: - print self.TargetTxtDictionary - print 'ActivePlatform = ', self.TargetTxtDictionary['ACTIVE_PLATFORM'][0] - print 'ToolChainConf = ', self.TargetTxtDictionary['TOOL_CHAIN_CONF'][0] - print 'MultipleThread = ', self.TargetTxtDictionary['MULTIPLE_THREAD'][0] - print 'MaxThreads = ', self.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'][0] - print 'TargetSet = ', self.TargetTxtDictionary['TARGET'] - print 'ToolChainSet = ', self.TargetTxtDictionary['TOOL_CHAIN_TAG'] - print 'TargetArchSet = ', self.TargetTxtDictionary['TARGET_ARCH'] - Platforms = self.PlatformDatabase.keys() - print 'Possible Settings:' - print ' Platforms = ', Platforms - print ' TargetSet = ', self.ToolsDefTxtDatabase['TARGET'] - print ' ToolChainSet = ', self.ToolsDefTxtDatabase['TOOL_CHAIN_TAG'] - print ' TargetArchSet = ', self.ToolsDefTxtDatabase['TARGET_ARCH'] - return True - - def ModelModified(self): - if self.TargetTxtDictionary != self.OriginalTargetTxtDictionary: - return True - return False - - def SaveModel(self, Filename='Tools/Conf/Target.txt'): - if self.Verbose: - for Item in self.TargetTxtDictionary: - print Item,'=',self.TargetTxtDictionary[Item] - self.ConvertDictionaryToTextFile(Filename, self.TargetTxtDictionary, '#', '=', True, None) - self.OriginalTargetTxtDictionary = copy.deepcopy(self.TargetTxtDictionary) - - def CloseModel(self): - pass - -class Frame(wx.Frame): - def __init__(self): - wx.Frame.__init__(self,None,-1,'EDK II Build System Context Tool') - panel = wx.Panel(self, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL) - wx.HelpProvider_Set(wx.SimpleHelpProvider()) - self.Model = ContextToolModel() - if not self.Model.WorkspaceStatus: - self.Close() - return - - # - # Help text - # - ActivePlatformHelpText = ( - "Specifies the Platform Name and Platform Version of the platform that will be " - "used for build. If set to [Build Directory] and the current directory contains " - "an FPD file, then a plaform build on that FPD file will be performed. If set " - "to [Build Directory] and there is no FPD file in the current directory, then no " - "build will be performed." - ) - - ToolChainConfHelpText = ( - "Specifies the name of the file that declares all the tools and flag settings " - "required to complete a build. This is typically set to Tools/Conf/tools_def.txt." - ) - - MultipleThreadHelpText = ( - "Flag to enable or disable multi-thread builds. If your computer is multi-core " - "or contans multiple CPUs, enabling this feature will improve build performance. " - "For multi-thread builds, a log will be written to ${BUILD_DIR}/build.log. This " - "feature is only for platform builds. Clean, cleanall, and stand-alone module " - "builds only use one thread." - ) - - ThreadsHelpText = ( - "The number of concurrent threads. The best performance is achieved if this " - "value is set to one greater than the number or cores or CPUs in the build system." - ) - - TargetHelpText = ( - "Specifies the set of targets to build. If set to All, then all build targets " - "are built. Otherwise, the subset of enabled build targets are built. The " - "standard build targets are RELEASE and DEBUG, but additional user-defined build " - "targets may be declared in the TOOL_CHAIN_CONF file. The DEBUG builds with " - "source level debugging enabled. RELEASE builds with source level debugging " - "disabled and results in smaller firmware images." - ) - - ToolChainTagHelpText = ( - "Specifies the set of tool chains to use during a build. If set to All, then " - "all of the supported tools chains are used. Otherwise, only the subset of " - "enabled tool chains are used. The TOOL_CHAIN_CONF file declares one or more " - "tool chains that may be used." - ) - - TargetArchHelpText = ( - "Specifies the set of CPU architectures to build. If set to All, then all the " - "CPU architectures supported by the platform FPD file are built. Otherwise, " - "only the subset of enabled CPU architectures are built. The standard CPU " - "architectures are IA32, X64, IPF, and EBC, but additional CPU architectures " - "may be declared in the TOOL_CHAIN_CONF file." - ) - - # - # Status Bar - # - self.CreateStatusBar() - - # - # Build Menus - # - MenuBar = wx.MenuBar() - - FileMenu = wx.Menu() - NewMenuItem = FileMenu.Append(-1, "&New\tCtrl+N", "New target.txt") - SaveMenuItem = FileMenu.Append(-1, "&Save\tCtrl+S", "Save target.txt") - SaveAsMenuItem = FileMenu.Append(-1, "Save &As...", "Save target.txt as...") - RevertMenuItem = FileMenu.Append(-1, "&Revert", "Revert to the original target.txt") - ExitMenuItem = FileMenu.Append(-1, "E&xit\tAlt+F4", "Exit ContextTool") - MenuBar.Append(FileMenu, "&File") - self.Bind(wx.EVT_MENU, self.OnSaveClick, SaveMenuItem) - self.Bind(wx.EVT_MENU, self.OnSaveAsClick, SaveAsMenuItem) - self.Bind(wx.EVT_MENU, self.OnRevertClick, RevertMenuItem) - self.Bind(wx.EVT_MENU, self.OnExitClick, ExitMenuItem) - - ViewMenu = wx.Menu() - RefreshMenuItem = ViewMenu.Append (-1, "&Refresh\tF5", "Rescan target.txt") - ShowToolBarMenuItem = ViewMenu.AppendCheckItem (-1, "Show &Toolbar", "Shows or hides the toolbar") - ShowToolBarMenuItem.Check(True) - MenuBar.Append(ViewMenu, "&View") - self.Bind(wx.EVT_MENU, self.OnViewRefreshClick, RefreshMenuItem) - self.Bind(wx.EVT_MENU, self.OnShowToolBarClick, ShowToolBarMenuItem) - - HelpMenu = wx.Menu() - AboutMenuItem = HelpMenu.Append (-1, "&About...", "About") - MenuBar.Append(HelpMenu, "&Help") - self.Bind(wx.EVT_MENU, self.OnAboutClick, AboutMenuItem) - - self.SetMenuBar (MenuBar) - - # - # Build Toolbar - # - self.ShowToolBar = False - self.OnShowToolBarClick(self) - - # - # Active Platform Combo Box - # - ActivePlatformLabel = wx.StaticText(panel, -1, 'ACTIVE_PLATFORM') - ActivePlatformLabel.SetHelpText(ActivePlatformHelpText) - self.ActivePlatformText = wx.ComboBox(panel,-1, style=wx.CB_DROPDOWN | wx.CB_SORT | wx.CB_READONLY) - self.ActivePlatformText.SetHelpText(ActivePlatformHelpText) - self.ActivePlatformText.Bind(wx.EVT_TEXT, self.OnActivePlatformClick) - - # - # Tool Chain Configuration Text Control and Browse Button for a File Dialog Box - # - ToolChainConfFileLabel = wx.StaticText(panel, -1, 'TOOL_CHAIN_CONF') - ToolChainConfFileLabel.SetHelpText(ToolChainConfHelpText) - self.ToolChainConfFileText = wx.TextCtrl(panel, -1, style=wx.TE_PROCESS_ENTER) - self.ToolChainConfFileText.Bind(wx.EVT_TEXT_ENTER, self.OnToolChainConfClick) - self.ToolChainConfFileText.Bind(wx.EVT_KILL_FOCUS, self.OnToolChainConfClick) - self.ToolChainConfFileText.SetHelpText(ToolChainConfHelpText) - self.BrowseButton = wx.Button(panel, -1, 'Browse...') - self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick) - - # - # Multiple Thread enable/disable radio button - # - MultipleThreadLabel = wx.StaticText(panel, -1, 'MULTIPLE_THREAD') - MultipleThreadLabel.SetHelpText(MultipleThreadHelpText) - self.MultipleThreadRadioBox = wx.RadioBox(panel, -1, choices=['Enable','Disable'], style=wx.RA_SPECIFY_COLS) - self.MultipleThreadRadioBox.Bind(wx.EVT_RADIOBOX, self.OnMultipleThreadRadioBox) - self.MultipleThreadRadioBox.SetHelpText(MultipleThreadHelpText) - - # - # Thread count spin control - # - ThreadsLabel = wx.StaticText(panel, -1, 'THREADS') - ThreadsLabel.SetHelpText(ThreadsHelpText) - self.ThreadsSpinCtrl = wx.SpinCtrl(panel, -1, size=(50, -1), min=2) - self.ThreadsSpinCtrl.Bind(wx.EVT_TEXT, self.OnThreadsSpinCtrl) - self.ThreadsSpinCtrl.SetHelpText(ThreadsHelpText) - - # - # Target, ToolChain, and Arch Check List Boxes - # - TargetLabel = wx.StaticText(panel, -1, 'TARGET') - TargetLabel.SetHelpText(TargetHelpText) - - ToolChainTagLabel = wx.StaticText(panel, -1, 'TOOL_CHAIN_TAG') - ToolChainTagLabel.SetHelpText(ToolChainTagHelpText) - - TargetArchLabel = wx.StaticText(panel, -1, 'TARGET_ARCH') - TargetArchLabel.SetHelpText(TargetArchHelpText) - - self.TargetCheckListBox = wx.CheckListBox(panel, -1) - self.TargetCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnTargetCheckListClick) - self.TargetCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnTargetSetFocus) - self.TargetCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnTargetKillFocus) - self.TargetCheckListBox.SetHelpText(TargetHelpText) - - self.ToolChainTagCheckListBox = wx.CheckListBox(panel, -1) - self.ToolChainTagCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnToolChainTagCheckListClick) - self.ToolChainTagCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnToolChainTagSetFocus) - self.ToolChainTagCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnToolChainTagKillFocus) - self.ToolChainTagCheckListBox.SetHelpText(ToolChainTagHelpText) - - self.TargetArchCheckListBox = wx.CheckListBox(panel, -1) - self.TargetArchCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnTargetArchCheckListClick) - self.TargetArchCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnTargetArchSetFocus) - self.TargetArchCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnTargetArchKillFocus) - self.TargetArchCheckListBox.SetHelpText(TargetArchHelpText) - - # - # Define layout using sizers - # - self.mainSizer = wx.BoxSizer(wx.VERTICAL) - - flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5) - flexSizer.AddGrowableCol(1) - flexSizer.Add(ActivePlatformLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(self.ActivePlatformText, 0, wx.EXPAND) - flexSizer.Add((0,0), wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) - - flexSizer.Add(ToolChainConfFileLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) - flexSizer.Add(self.ToolChainConfFileText, 0, wx.EXPAND) - flexSizer.Add(self.BrowseButton, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) - - self.mainSizer.Add (flexSizer, 0, wx.EXPAND | wx.ALL, 10) - - threadsSizer = wx.FlexGridSizer(cols = 5, hgap=5, vgap=5) - threadsSizer.Add(MultipleThreadLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) - threadsSizer.Add(self.MultipleThreadRadioBox, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) - threadsSizer.Add(ThreadsLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) - threadsSizer.Add(self.ThreadsSpinCtrl, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL) - - self.mainSizer.Add (threadsSizer, 0, wx.ALL, 10) - - listSizer = wx.FlexGridSizer(rows = 2, cols = 3, hgap=5, vgap=5) - listSizer.AddGrowableRow(1) - listSizer.AddGrowableCol(0) - listSizer.AddGrowableCol(1) - listSizer.AddGrowableCol(2) - listSizer.Add(TargetLabel, 0, wx.ALIGN_CENTER) - listSizer.Add(ToolChainTagLabel, 0, wx.ALIGN_CENTER) - listSizer.Add(TargetArchLabel, 0, wx.ALIGN_CENTER) - listSizer.Add(self.TargetCheckListBox, 0, wx.ALL | wx.EXPAND) - listSizer.Add(self.ToolChainTagCheckListBox, 0, wx.ALL | wx.EXPAND) - listSizer.Add(self.TargetArchCheckListBox, 0, wx.ALL | wx.EXPAND) - - self.mainSizer.Add (listSizer, wx.EXPAND | wx.ALL, wx.EXPAND | wx.ALL, 10) - - panel.SetSizer (self.mainSizer) - - self.Model.RescanModel() - self.OnRefreshClick(self) - - def OnActivePlatformClick(self, event): - Platform = self.ActivePlatformText.GetValue() - if Platform == ' [Build Directory]': - self.Model.TargetTxtDictionary['ACTIVE_PLATFORM'][0] = '' - else: - self.Model.TargetTxtDictionary['ACTIVE_PLATFORM'][0] = self.Model.PlatformDatabase[Platform]['XmlFileName'] - - def OnToolChainConfClick(self, event): - if self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0] != self.ToolChainConfFileText.GetValue(): - self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0] = self.ToolChainConfFileText.GetValue() - self.OnRefreshClick(self) - - def OnBrowseButtonClick(self, event): - wildcard = "Text Documents (*.txt)|*.txt|" \ - "All files (*.*)|*.*" - dialog = wx.FileDialog (None, 'Choose a Tool Chain Configuration File', self.Model.WorkspaceFile('Tools/Conf'), '', wildcard, wx.OPEN) - if dialog.ShowModal() == wx.ID_OK: - print dialog.GetPath() - ToolChainConfFile = self.Model.WorkspaceRelativePath(dialog.GetPath()) - self.ToolChainConfFileText.SetValue(ToolChainConfFile) - self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0] = self.ToolChainConfFileText.GetValue() - self.OnRefreshClick(self) - dialog.Destroy() - - def OnMultipleThreadRadioBox (self, event): - self.Model.TargetTxtDictionary['MULTIPLE_THREAD'] = [self.MultipleThreadRadioBox.GetStringSelection()] - if self.MultipleThreadRadioBox.GetStringSelection() == 'Disable': - self.ThreadsSpinCtrl.Disable() - else: - self.ThreadsSpinCtrl.Enable() - - def OnThreadsSpinCtrl(self, event): - self.Model.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'] = [str(self.ThreadsSpinCtrl.GetValue())] - - def CheckListFocus(self, CheckListBox, Set): - Index = 0 - while Index < CheckListBox.GetCount(): - CheckListBox.SetSelection(Index, False) - Index += 1 - if Set: - CheckListBox.SetSelection(0, True) - - def CheckListClick(self, CheckListBox, Name): - if CheckListBox.IsChecked(0): - Index = 1 - while Index < CheckListBox.GetCount(): - CheckListBox.Check(Index, False) - Index += 1 - if CheckListBox.IsChecked(0): - self.Model.TargetTxtDictionary[Name] = [''] - else: - self.Model.TargetTxtDictionary[Name] = [] - Index = 1 - while Index < CheckListBox.GetCount(): - if CheckListBox.IsChecked(Index): - self.Model.TargetTxtDictionary[Name] += [CheckListBox.GetString(Index)] - Index += 1 - if self.Model.TargetTxtDictionary[Name] == []: - self.Model.TargetTxtDictionary[Name] = [''] - - def OnTargetCheckListClick(self, event): - self.CheckListClick(self.TargetCheckListBox, 'TARGET') - - def OnTargetSetFocus(self, event): - self.CheckListFocus(self.TargetCheckListBox, True) - - def OnTargetKillFocus(self, event): - self.CheckListFocus(self.TargetCheckListBox, False) - - def OnToolChainTagCheckListClick(self, event): - self.CheckListClick(self.ToolChainTagCheckListBox, 'TOOL_CHAIN_TAG') - - def OnToolChainTagSetFocus(self, event): - self.CheckListFocus(self.ToolChainTagCheckListBox, True) - - def OnToolChainTagKillFocus(self, event): - self.CheckListFocus(self.ToolChainTagCheckListBox, False) - - def OnTargetArchCheckListClick(self, event): - self.CheckListClick(self.TargetArchCheckListBox, 'TARGET_ARCH') - - def OnTargetArchSetFocus(self, event): - self.CheckListFocus(self.TargetArchCheckListBox, True) - - def OnTargetArchKillFocus(self, event): - self.CheckListFocus(self.TargetArchCheckListBox, False) - - def OnRevertClick(self, event): - self.Model.RevertModel() - self.OnRefreshClick(self) - - def RefreshCheckListBox(self, CheckListBox, Name): - CheckListBox.Set(['All'] + self.Model.ToolsDefTxtDatabase[Name]) - Index = 0 - MaximumString = '' - while Index < CheckListBox.GetCount(): - String = CheckListBox.GetString(Index) - if len(String) > len(MaximumString): - MaximumString = String - if String in self.Model.TargetTxtDictionary[Name]: - CheckListBox.Check(Index, True) - else: - CheckListBox.Check(Index, False) - Index += 1 - if self.Model.TargetTxtDictionary[Name] == ['']: - CheckListBox.Check(0, True) - Extents = CheckListBox.GetFullTextExtent (MaximumString) - CheckListBox.SetMinSize((Extents[0],(CheckListBox.GetCount()+1) * (Extents[1]+Extents[2]))) - - def OnRefreshClick(self, event): - self.Model.RefreshModel() - Platforms = self.Model.PlatformDatabase.keys() - Platforms.sort() - self.ActivePlatformText.SetItems([' [Build Directory]'] + Platforms) - self.ActivePlatformText.SetValue(' [Build Directory]') - for Platform in self.Model.PlatformDatabase: - if self.Model.PlatformDatabase[Platform]['XmlFileName'] == self.Model.TargetTxtDictionary['ACTIVE_PLATFORM'][0]: - self.ActivePlatformText.SetValue(Platform) - if self.ActivePlatformText.GetValue() == ' [Build Directory]': - self.Model.TargetTxtDictionary['ACTIVE_PLATFORM'][0] = '' - MaximumString = ' [Build Directory]' - for String in Platforms: - if len(String) > len(MaximumString): - MaximumString = String - Extents = self.ActivePlatformText.GetFullTextExtent (MaximumString) - self.ActivePlatformText.SetMinSize((Extents[0] + 24,-1)) - - self.ToolChainConfFileText.SetValue(self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0]) - Extents = self.ToolChainConfFileText.GetFullTextExtent (self.Model.TargetTxtDictionary['TOOL_CHAIN_CONF'][0]) - self.ToolChainConfFileText.SetMinSize((Extents[0] + 24,-1)) - - self.MultipleThreadRadioBox.SetStringSelection(self.Model.TargetTxtDictionary['MULTIPLE_THREAD'][0]) - if self.MultipleThreadRadioBox.GetStringSelection() == 'Disable': - self.ThreadsSpinCtrl.Disable() - self.ThreadsSpinCtrl.SetValue(int(self.Model.TargetTxtDictionary['MAX_CONCURRENT_THREAD_NUMBER'][0])) - - self.RefreshCheckListBox (self.TargetCheckListBox, 'TARGET') - self.RefreshCheckListBox (self.ToolChainTagCheckListBox, 'TOOL_CHAIN_TAG') - self.RefreshCheckListBox (self.TargetArchCheckListBox, 'TARGET_ARCH') - - self.mainSizer.SetSizeHints(self) - self.mainSizer.Fit(self) - - def OnViewRefreshClick(self, event): - self.Model.RescanModel() - self.OnRefreshClick(self) - - def AddTool (self, Handler, ArtId, Label, HelpText): - Tool = self.ToolBar.AddSimpleTool( - -1, - wx.ArtProvider.GetBitmap(ArtId, wx.ART_TOOLBAR, self.ToolSize), - Label, - HelpText - ) - self.Bind(wx.EVT_MENU, Handler, Tool) - - def OnShowToolBarClick(self, event): - if self.ShowToolBar: - self.ShowToolBar = False - self.ToolBar.Destroy() - else: - self.ShowToolBar = True - self.ToolBar = self.CreateToolBar() - self.ToolSize = (24,24) - self.ToolBar.SetToolBitmapSize(self.ToolSize) - self.AddTool (self.OnNewClick, wx.ART_NEW, "New", "New target.txt") - self.AddTool (self.OnSaveClick, wx.ART_FILE_SAVE, "Save", "Save target.txt") - self.AddTool (self.OnSaveAsClick, wx.ART_FILE_SAVE_AS, "Save As...", "Save target.txt as...") - self.AddTool (self.OnRevertClick, wx.ART_UNDO, "Revert", "Revert to original target.txt") - self.AddTool (self.OnHelpClick, wx.ART_HELP, "Help", "Context Sensitive Help") - self.AddTool (self.OnExitClick, wx.ART_QUIT, "Exit", "Exit Context Tool application") - self.ToolBar.Realize() - - def OnNewClick(self, event): - self.Model.NewModel() - self.OnRefreshClick(self) - - def OnSaveClick(self, event): - self.Model.SaveModel() - - def OnSaveAsClick(self, event): - wildcard = "Text Documents (*.txt)|*.txt|" \ - "All files (*.*)|*.*" - dialog = wx.FileDialog (None, 'Save As', self.Model.WorkspaceFile('Tools/Conf'), '', wildcard, wx.SAVE | wx.OVERWRITE_PROMPT) - if dialog.ShowModal() == wx.ID_OK: - TargetTxtFile = self.Model.WorkspaceRelativePath(dialog.GetPath()) - if TargetTxtFile != '': - self.Model.SaveModel(TargetTxtFile) - dialog.Destroy() - - def OnExitClick(self, event): - if self.Model.ModelModified(): - 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) - Status = dialog.ShowModal() - dialog.Destroy() - if Status == wx.ID_YES: - self.OnSaveClick (self) - elif Status == wx.ID_CANCEL: - return - self.Model.CloseModel() - self.Close() - - def OnHelpClick(self, event): - wx.ContextHelp().BeginContextHelp() - - def OnAboutClick(self, event): - AboutInfo = wx.AboutDialogInfo() - AboutInfo.Name = 'EDK II Build System Context Tool' - AboutInfo.Version = '0.3' - AboutInfo.Copyright = 'Copyright (c) 2006, Intel Corporation' - AboutInfo.Description = """ - The EDK II Build System Context Tool maintains the target.txt - settings in an EDK II Workspace.""" - AboutInfo.WebSite = ("http://tianocore.org", "Tiano Core home page") - AboutInfo.License = """ - All rights reserved. This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD - License which accompanies this distribution. The full text of the - license may be found at http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" - BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, - EITHER EXPRESS OR IMPLIED.""" - if self.Model.Icon != None: - AboutInfo.Icon = self.Model.Icon - wx.AboutBox(AboutInfo) - -if __name__ == '__main__': - app = wx.PySimpleApp() - frame = Frame() - frame.Show() - app.MainLoop() diff --git a/Tools/Python/Doxyfile b/Tools/Python/Doxyfile deleted file mode 100644 index c9ea39075d..0000000000 --- a/Tools/Python/Doxyfile +++ /dev/null @@ -1,259 +0,0 @@ -# Doxyfile 1.4.5 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = "Python Scripts for EDK II ($Rev$)" -PROJECT_NUMBER = "Revision $(DOXY_PROJ_NUM)" -OUTPUT_DIRECTORY = docs -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = . -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = YES -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 8 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = YES -BUILTIN_STL_SUPPORT = NO -DISTRIBUTE_GROUP_DOC = NO -SUBGROUPING = YES -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 9999 -SHOW_USED_FILES = YES -SHOW_DIRECTORIES = YES -FILE_VERSION_FILTER = -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = YES -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = . -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py -RECURSIVE = NO -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -USE_HTAGS = NO -VERBATIM_HEADERS = NO -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = NO -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = NO -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 1000 -DOT_TRANSPARENT = NO -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = YES diff --git a/Tools/Python/EdkIIWorkspace.py b/Tools/Python/EdkIIWorkspace.py deleted file mode 100755 index 935ffadc09..0000000000 --- a/Tools/Python/EdkIIWorkspace.py +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env python - -# This is the base class for applications that operate on an EDK II Workspace - -import os, sys -from XmlRoutines import * - -class EdkIIWorkspace: - def __init__(self): - """Collect WorkspaceDir from the environment, the Verbose command line flag, and detect an icon bitmap file.""" - if os.environ.get('WORKSPACE') == None: - print 'ERROR: WORKSPACE not defined. Please run EdkSetup from the EDK II install directory.' - return False - - self.WorkspaceDir = os.path.realpath(os.environ.get('WORKSPACE')) - (Drive, Path) = os.path.splitdrive(self.WorkspaceDir) - if Drive == '': - (Drive, CwdPath) = os.path.splitdrive(os.getcwd()) - if Drive != '': - self.WorkspaceDir = Drive + Path - else: - self.WorkspaceDir = Drive.upper() + Path - - try: - self.Icon = wx.Icon(self.WorkspaceFile('tools/Python/TianoCoreOrgLogo.gif'),wx.BITMAP_TYPE_GIF) - except: - self.Icon = None - - self.Verbose = False - for arg in sys.argv: - if arg.lower() == '-v': - self.Verbose = True - - return True - - def WorkspaceRelativePath(self, FileName): - """Convert a full path filename to a workspace relative filename.""" - FileName = os.path.realpath(FileName) - if FileName.find(self.WorkspaceDir) != 0: - return '' - return FileName.replace (self.WorkspaceDir, '').strip('\\').strip('/') - - def WorkspaceFile(self, FileName): - """Convert a workspace relative filename to a full path filename.""" - return os.path.realpath(os.path.join(self.WorkspaceDir,FileName)) - - def XmlParseFile (self, FileName): - """Parse an XML file into a DOM and return the DOM.""" - if self.Verbose: - print FileName - return XmlParseFile (self.WorkspaceFile(FileName)) - - def XmlParseFileSection (self, FileName, SectionTag): - """Parse a section of an XML file into a DOM(Document Object Model) and return the DOM.""" - if self.Verbose: - print FileName - return XmlParseFileSection (self.WorkspaceFile(FileName), SectionTag) - - def XmlSaveFile (self, Dom, FileName): - """Save a DOM(Document Object Model) into an XML file.""" - if self.Verbose: - print FileName - return XmlSaveFile (Dom, self.WorkspaceFile(FileName)) - - def ConvertTextFileToDictionary(self, FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter): - """Convert a workspace relative text file to a dictionary of (name:value) pairs.""" - if self.Verbose: - print FileName - return ConvertTextFileToDictionary(self.WorkspaceFile(FileName), Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter) - - def ConvertDictionaryToTextFile(self, FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter): - """Convert a dictionary of (name:value) pairs to a workspace relative text file.""" - if self.Verbose: - print FileName - return ConvertDictionaryToTextFile(self.WorkspaceFile(FileName), Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter) - -# -# Convert a text file to a dictionary -# -def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter): - """Convert a text file to a dictionary of (name:value) pairs.""" - try: - f = open(FileName,'r') - except: - return False - Keys = [] - for Line in f: - LineList = Line.split(KeySplitCharacter,1) - if len(LineList) >= 2: - Key = LineList[0].split() - if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys: - if ValueSplitFlag: - Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter) - else: - Dictionary[Key[0]] = LineList[1].strip().replace('\\','/') - Keys += [Key[0]] - f.close() - return True - -def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter): - """Convert a dictionary of (name:value) pairs to a text file.""" - try: - f = open(FileName,'r') - Lines = [] - Lines = f.readlines() - f.close() - except: - Lines = [] - Keys = Dictionary.keys() - MaxLength = 0 - for Key in Keys: - if len(Key) > MaxLength: - MaxLength = len(Key) - Index = 0 - for Line in Lines: - LineList = Line.split(KeySplitCharacter,1) - if len(LineList) >= 2: - Key = LineList[0].split() - if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] in Dictionary: - if ValueSplitFlag: - Line = '%-*s %c %s\n' % (MaxLength, Key[0], KeySplitCharacter, ' '.join(Dictionary[Key[0]])) - else: - Line = '%-*s %c %s\n' % (MaxLength, Key[0], KeySplitCharacter, Dictionary[Key[0]]) - Lines.pop(Index) - if Key[0] in Keys: - Lines.insert(Index,Line) - Keys.remove(Key[0]) - Index += 1 - for RemainingKey in Keys: - if ValueSplitFlag: - Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter,' '.join(Dictionary[RemainingKey])) - else: - Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter, Dictionary[RemainingKey]) - Lines.append(Line) - try: - f = open(FileName,'w') - except: - return False - f.writelines(Lines) - f.close() - return True - -# This acts like the main() function for the script, unless it is 'import'ed into another -# script. -if __name__ == '__main__': - - # Nothing to do here. Could do some unit tests. - pass diff --git a/Tools/Python/Fd.py b/Tools/Python/Fd.py deleted file mode 100755 index f8b26059e7..0000000000 --- a/Tools/Python/Fd.py +++ /dev/null @@ -1,582 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2007, Intel Corporation -# All rights reserved. This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -"""An EDK II Build System Framework Database Utility maintains -FrameworkDatabase.db settings in an EDK II Workspace.""" - -import wx, os, sys, copy -from EdkIIWorkspace import * - -class FrameworkDatabaseModel(EdkIIWorkspace): - def __init__(self): - self.WorkspaceStatus = EdkIIWorkspace.__init__(self) - self.Database = {} - self.OriginalDatabase = {} - - def AddFile (self, DirName, FileName, FileType, Enabled): - if DirName != '': - FileName = os.path.join(DirName,FileName) - if FileType == 'Package': - Header = self.XmlParseFileSection (FileName, 'SpdHeader') - Name = XmlElement (Header, '/SpdHeader/PackageName') - Version = XmlElement (Header, '/SpdHeader/Version') - elif FileType == 'Platform': - Header = self.XmlParseFileSection (FileName, 'PlatformHeader') - Name = XmlElement (Header, '/PlatformHeader/PlatformName') - Version = XmlElement (Header, '/PlatformHeader/Version') - else: - return - FileName = FileName.replace('\\','/') - if Name == '' and Version == '': - ValidType = 'Invalid' - OtherType = 'Valid' - UiName = FileName - else: - ValidType = 'Valid' - OtherType = 'Invalid' - UiName = Name + ' [' + Version + ']' - self.Database[FileType][OtherType]['PossibleSettings'].pop(FileName, None) - self.Database[FileType][OtherType]['EnabledSettings'].pop(FileName, None) - self.Database[FileType][ValidType]['PossibleSettings'][FileName] = UiName - if Enabled: - self.Database[FileType][ValidType]['EnabledSettings'][FileName] = UiName - return - - def NewModel(self): - self.Database['Platform'] = {'Valid': {'PossibleSettings':{}, 'EnabledSettings':{}},'Invalid': {'PossibleSettings':{}, 'EnabledSettings':{}}} - self.Database['Package'] = {'Valid': {'PossibleSettings':{}, 'EnabledSettings':{}},'Invalid': {'PossibleSettings':{}, 'EnabledSettings':{}}} - - def RevertModel(self): - self.Database = copy.deepcopy(self.OriginalDatabase) - - def RescanModel(self): - self.NewModel() - self.Fd = self.XmlParseFile ('Tools/Conf/FrameworkDatabase.db') - PackageList = XmlList (self.Fd, '/FrameworkDatabase/PackageList/Filename') - for File in PackageList: - SpdFileName = XmlElementData(File) - self.AddFile ('', SpdFileName, 'Package', True) - PlatformList = XmlList (self.Fd, '/FrameworkDatabase/PlatformList/Filename') - for File in PlatformList: - FpdFileName = XmlElementData(File) - self.AddFile ('', FpdFileName, 'Platform', True) - self.OriginalDatabase = copy.deepcopy(self.Database) - - def RefreshModel(self): - Temp = copy.deepcopy(self.Database) - for FileType in ['Package','Platform']: - for Valid in ['Valid','Invalid']: - for Item in Temp[FileType][Valid]['PossibleSettings']: - self.AddFile('',Item, FileType, Item in Temp[FileType][Valid]['EnabledSettings']) - return True - - def ModelModified(self): - if self.Database['Package']['Valid']['EnabledSettings'] != self.OriginalDatabase['Package']['Valid']['EnabledSettings']: - return True - if self.Database['Package']['Invalid']['EnabledSettings'] != self.OriginalDatabase['Package']['Invalid']['EnabledSettings']: - return True - if self.Database['Platform']['Valid']['EnabledSettings'] != self.OriginalDatabase['Platform']['Valid']['EnabledSettings']: - return True - if self.Database['Platform']['Invalid']['EnabledSettings'] != self.OriginalDatabase['Platform']['Invalid']['EnabledSettings']: - return True - return False - - def SaveModel(self, Filename='Tools/Conf/FrameworkDatabase.db'): - EnabledList = self.Database['Package']['Valid']['EnabledSettings'].keys() - EnabledList += self.Database['Package']['Invalid']['EnabledSettings'].keys() - PackageList = XmlList (self.Fd, '/FrameworkDatabase/PackageList/Filename') - for File in PackageList: - SpdFileName = XmlElementData(File) - if SpdFileName in EnabledList: - EnabledList.remove(SpdFileName) - continue - XmlRemoveElement(File) - - ParentNode = XmlList (self.Fd, '/FrameworkDatabase/PackageList')[0] - for SpdFileName in EnabledList: - XmlAppendChildElement(ParentNode, u'Filename', SpdFileName) - - EnabledList = self.Database['Platform']['Valid']['EnabledSettings'].keys() - EnabledList += self.Database['Platform']['Invalid']['EnabledSettings'].keys() - PlatformList = XmlList (self.Fd, '/FrameworkDatabase/PlatformList/Filename') - for File in PlatformList: - FpdFileName = XmlElementData(File) - if FpdFileName in EnabledList: - EnabledList.remove(FpdFileName) - continue - XmlRemoveElement(File) - - ParentNode = XmlList (self.Fd, '/FrameworkDatabase/PlatformList')[0] - for FpdFileName in EnabledList: - XmlAppendChildElement(ParentNode, u'Filename', FpdFileName) - - self.XmlSaveFile (self.Fd, Filename) - self.OriginalDatabase = copy.deepcopy(self.Database) - - def CloseModel(self): - pass - -class Frame(wx.Frame): - def __init__(self): - wx.Frame.__init__(self,None,-1,'EDK II Build System Framework Database Utility') - panel = wx.Panel(self, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL) - wx.HelpProvider_Set(wx.SimpleHelpProvider()) - - self.Model = FrameworkDatabaseModel() - - # - # Help text - # - PackagesHelpText = ( - "The set of packages that are active in the current WORKSPACE." - ) - - PlatformsHelpText = ( - "The set of platforms that are active in the current WORKSPACE." - ) - - InvalidPackagesHelpText = ( - "The set of packages that are in Framework Database, but not in the current WORKSPACE." - ) - - InvalidPlatformsHelpText = ( - "The set of platforms that are in Framework Database, but not in the current WORKSPACE." - ) - - # - # Status Bar - # - self.StatusBar = self.CreateStatusBar() - - # - # Build Menus - # - MenuBar = wx.MenuBar() - - FileMenu = wx.Menu() - NewMenuItem = FileMenu.Append(-1, "&New\tCtrl+N", "New FrameworkDatabase.db") - SaveMenuItem = FileMenu.Append(-1, "&Save\tCtrl+S", "Save FramdworkDatabase.db") - SaveAsMenuItem = FileMenu.Append(-1, "Save &As...", "Save FrameworkDatabase.db as...") - RevertMenuItem = FileMenu.Append(-1, "&Revert", "Revert to the original FrameworkDatabase.db") - ScanMenuItem = FileMenu.Append(-1, "Scan &WORKSPACE\tCtrl+W", "Scan WORKSPACE for additional packages and platforms") - ScanAndSyncMenuItem = FileMenu.Append(-1, "Scan &WORKSPACE and Sync\tCtrl+W", "Scan WORKSPACE for additional packages and platforms and sync FramdworkDatabase.db") - ExitMenuItem = FileMenu.Append(-1, "E&xit\tAlt+F4", "Exit Framework Database Tool") - MenuBar.Append(FileMenu, "&File") - self.Bind(wx.EVT_MENU, self.OnSaveClick, SaveMenuItem) - self.Bind(wx.EVT_MENU, self.OnSaveAsClick, SaveAsMenuItem) - self.Bind(wx.EVT_MENU, self.OnRevertClick, RevertMenuItem) - self.Bind(wx.EVT_MENU, self.OnScanClick, ScanMenuItem) - self.Bind(wx.EVT_MENU, self.OnScanAndSyncClick, ScanAndSyncMenuItem) - self.Bind(wx.EVT_MENU, self.OnExitClick, ExitMenuItem) - - EditMenu = wx.Menu() - SelectAllPlatformsMenuItem = EditMenu.Append (-1, "Select All Platforms", "Select all platforms") - ClearAllPlatformsMenuItem = EditMenu.Append (-1, "Clear All Platforms", "Clear all platforms") - SelectAllPackagesMenuItem = EditMenu.Append (-1, "Select All Packages", "Select all packages") - ClearAllPackagesMenuItem = EditMenu.Append (-1, "Clear All Packages", "Clear all packages") - SelectAllInvalidPlatformsMenuItem = EditMenu.Append (-1, "Select All Invalid Platforms", "Select all invalid platforms") - ClearAllInvalidPlatformsMenuItem = EditMenu.Append (-1, "Clear All Invalid Platforms", "Clear all invalid platforms") - SelectAllInvalidPackagesMenuItem = EditMenu.Append (-1, "Select All Invalid Packages", "Select all invalid packages") - ClearAllInvalidPackagesMenuItem = EditMenu.Append (-1, "Clear All Invalid Packages", "Clear all invalid packages") - MenuBar.Append(EditMenu, "&Edit") - self.Bind(wx.EVT_MENU, self.OnSelectAllPlatformsClick, SelectAllPlatformsMenuItem) - self.Bind(wx.EVT_MENU, self.OnClearAllPlatformsClick, ClearAllPlatformsMenuItem) - self.Bind(wx.EVT_MENU, self.OnSelectAllPackagesClick, SelectAllPackagesMenuItem) - self.Bind(wx.EVT_MENU, self.OnClearAllPackagesClick, ClearAllPackagesMenuItem) - self.Bind(wx.EVT_MENU, self.OnSelectAllInvalidPlatformsClick, SelectAllInvalidPlatformsMenuItem) - self.Bind(wx.EVT_MENU, self.OnClearAllInvalidPlatformsClick, ClearAllInvalidPlatformsMenuItem) - self.Bind(wx.EVT_MENU, self.OnSelectAllInvalidPackagesClick, SelectAllInvalidPackagesMenuItem) - self.Bind(wx.EVT_MENU, self.OnClearAllInvalidPackagesClick, ClearAllInvalidPackagesMenuItem) - - ViewMenu = wx.Menu() - RefreshMenuItem = ViewMenu.Append (-1, "&Refresh\tF5", "Rescan FrameworkDatabase.db") - ShowToolBarMenuItem = ViewMenu.AppendCheckItem (-1, "Show &Toolbar", "Shows or hides the toolbar") - ShowToolBarMenuItem.Check(True) - MenuBar.Append(ViewMenu, "&View") - self.Bind(wx.EVT_MENU, self.OnViewRefreshClick, RefreshMenuItem) - self.Bind(wx.EVT_MENU, self.OnShowToolBarClick, ShowToolBarMenuItem) - - HelpMenu = wx.Menu() - AboutMenuItem = HelpMenu.Append (-1, "&About...", "About") - MenuBar.Append(HelpMenu, "&Help") - self.Bind(wx.EVT_MENU, self.OnAboutClick, AboutMenuItem) - - self.SetMenuBar (MenuBar) - - # - # Build Toolbar - # - self.ShowToolBar = False - self.OnShowToolBarClick(self) - - # - # Target, ToolChain, and Arch Check List Boxes - # - PackagesLabel = wx.StaticText(panel, -1, 'Packages') - PackagesLabel.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)) - PackagesLabel.SetHelpText(PackagesHelpText) - - PlatformsLabel = wx.StaticText(panel, -1, 'Platforms') - PlatformsLabel.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)) - PlatformsLabel.SetHelpText(PlatformsHelpText) - - # - # Buttons - # - self.SelectAllPackagesButton = wx.Button(panel, -1, 'Select All') - self.ClearAllPackagesButton = wx.Button(panel, -1, 'Clear All') - self.SelectAllPackagesButton.Bind (wx.EVT_BUTTON, self.OnSelectAllPackagesClick) - self.ClearAllPackagesButton.Bind (wx.EVT_BUTTON, self.OnClearAllPackagesClick) - - self.PackagesCheckListBox = wx.CheckListBox(panel, -1) - self.PackagesCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnPackagesCheckListClick) - self.PackagesCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnPackagesSetFocus) - self.PackagesCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnPackagesKillFocus) - self.PackagesCheckListBox.SetHelpText(PackagesHelpText) - - - self.SelectAllPlatformsButton = wx.Button(panel, -1, 'Select All') - self.ClearAllPlatformsButton = wx.Button(panel, -1, 'Clear All') - self.SelectAllPlatformsButton.Bind(wx.EVT_BUTTON, self.OnSelectAllPlatformsClick) - self.ClearAllPlatformsButton.Bind (wx.EVT_BUTTON, self.OnClearAllPlatformsClick) - - self.PlatformsCheckListBox = wx.CheckListBox(panel, -1) - self.PlatformsCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnPlatformsCheckListClick) - self.PlatformsCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnPlatformsSetFocus) - self.PlatformsCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnPlatformsKillFocus) - self.PlatformsCheckListBox.SetHelpText(PlatformsHelpText) - - InvalidPackagesLabel = wx.StaticText(panel, -1, 'Invalid Packages') - InvalidPackagesLabel.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)) - InvalidPackagesLabel.SetHelpText(InvalidPackagesHelpText) - - InvalidPlatformsLabel = wx.StaticText(panel, -1, 'Invalid Platforms') - InvalidPlatformsLabel.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)) - InvalidPlatformsLabel.SetHelpText(InvalidPlatformsHelpText) - - self.SelectAllInvalidPackagesButton = wx.Button(panel, -1, 'Select All') - self.ClearAllInvalidPackagesButton = wx.Button(panel, -1, 'Clear All') - self.SelectAllInvalidPackagesButton.Bind (wx.EVT_BUTTON, self.OnSelectAllInvalidPackagesClick) - self.ClearAllInvalidPackagesButton.Bind (wx.EVT_BUTTON, self.OnClearAllInvalidPackagesClick) - - self.InvalidPackagesCheckListBox = wx.CheckListBox(panel, -1) - self.InvalidPackagesCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnInvalidPackagesCheckListClick) - self.InvalidPackagesCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnInvalidPackagesSetFocus) - self.InvalidPackagesCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnInvalidPackagesKillFocus) - self.InvalidPackagesCheckListBox.SetHelpText(PackagesHelpText) - - self.SelectAllInvalidPlatformsButton = wx.Button(panel, -1, 'Select All') - self.ClearAllInvalidPlatformsButton = wx.Button(panel, -1, 'Clear All') - self.SelectAllInvalidPlatformsButton.Bind(wx.EVT_BUTTON, self.OnSelectAllInvalidPlatformsClick) - self.ClearAllInvalidPlatformsButton.Bind (wx.EVT_BUTTON, self.OnClearAllInvalidPlatformsClick) - - self.InvalidPlatformsCheckListBox = wx.CheckListBox(panel, -1) - self.InvalidPlatformsCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnInvalidPlatformsCheckListClick) - self.InvalidPlatformsCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnInvalidPlatformsSetFocus) - self.InvalidPlatformsCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnInvalidPlatformsKillFocus) - self.InvalidPlatformsCheckListBox.SetHelpText(PlatformsHelpText) - - # - # Define layout using sizers - # - self.mainSizer = wx.BoxSizer(wx.VERTICAL) - - listSizer = wx.GridBagSizer(hgap=5, vgap=5) - listSizer.Add(PackagesLabel, pos=(0,0), span=(1,2), flag=wx.ALIGN_CENTER) - listSizer.Add(PlatformsLabel, pos=(0,2), span=(1,2), flag=wx.ALIGN_CENTER) - listSizer.Add(self.SelectAllPackagesButton, pos=(1,0), flag=wx.ALIGN_CENTER) - listSizer.Add(self.ClearAllPackagesButton, pos=(1,1), flag=wx.ALIGN_CENTER) - listSizer.Add(self.SelectAllPlatformsButton, pos=(1,2), flag=wx.ALIGN_CENTER) - listSizer.Add(self.ClearAllPlatformsButton, pos=(1,3), flag=wx.ALIGN_CENTER) - listSizer.Add(self.PackagesCheckListBox, pos=(2,0), span=(1,2), flag=wx.ALL | wx.EXPAND) - listSizer.Add(self.PlatformsCheckListBox, pos=(2,2), span=(1,2), flag=wx.ALL | wx.EXPAND) - - listSizer.Add(InvalidPackagesLabel, pos=(3,0), span=(1,2), flag=wx.ALIGN_CENTER) - listSizer.Add(InvalidPlatformsLabel, pos=(3,2), span=(1,2), flag=wx.ALIGN_CENTER) - listSizer.Add(self.SelectAllInvalidPackagesButton, pos=(4,0), flag=wx.ALIGN_CENTER) - listSizer.Add(self.ClearAllInvalidPackagesButton, pos=(4,1), flag=wx.ALIGN_CENTER) - listSizer.Add(self.SelectAllInvalidPlatformsButton, pos=(4,2), flag=wx.ALIGN_CENTER) - listSizer.Add(self.ClearAllInvalidPlatformsButton, pos=(4,3), flag=wx.ALIGN_CENTER) - listSizer.Add(self.InvalidPackagesCheckListBox, pos=(5,0), span=(1,2), flag=wx.ALL | wx.EXPAND) - listSizer.Add(self.InvalidPlatformsCheckListBox, pos=(5,2), span=(1,2), flag=wx.ALL | wx.EXPAND) - - listSizer.AddGrowableRow(2) - listSizer.AddGrowableRow(5) - listSizer.AddGrowableCol(0) - listSizer.AddGrowableCol(1) - listSizer.AddGrowableCol(2) - listSizer.AddGrowableCol(3) - - self.mainSizer.Add (listSizer, wx.EXPAND | wx.ALL, wx.EXPAND | wx.ALL, 10) - - panel.SetSizer (self.mainSizer) - - self.OnViewRefreshClick(self) - - def CheckListFocus(self, CheckListBox, Set): - Index = 0 - while Index < CheckListBox.GetCount(): - CheckListBox.SetSelection(Index, False) - Index += 1 - if Set and CheckListBox.GetCount() > 0: - CheckListBox.SetSelection(0, True) - - def CheckListClick(self, CheckListBox, Database): - Index = 0 - Database['EnabledSettings'] = {} - while Index < CheckListBox.GetCount(): - if CheckListBox.IsChecked(Index): - for Item in Database['PossibleSettings']: - if Database['PossibleSettings'][Item] == CheckListBox.GetString(Index): - Database['EnabledSettings'][Item] = Database['PossibleSettings'][Item] - Index += 1 - - def OnPackagesCheckListClick(self, event): - self.CheckListClick(self.PackagesCheckListBox, self.Model.Database['Package']['Valid']) - - def OnPackagesSetFocus(self, event): - self.CheckListFocus(self.PackagesCheckListBox, True) - - def OnPackagesKillFocus(self, event): - self.CheckListFocus(self.PackagesCheckListBox, False) - - def OnPlatformsCheckListClick(self, event): - self.CheckListClick(self.PlatformsCheckListBox, self.Model.Database['Platform']['Valid']) - - def OnPlatformsSetFocus(self, event): - self.CheckListFocus(self.PlatformsCheckListBox, True) - - def OnPlatformsKillFocus(self, event): - self.CheckListFocus(self.PlatformsCheckListBox, False) - - def OnInvalidPackagesCheckListClick(self, event): - self.CheckListClick(self.InvalidPackagesCheckListBox, self.Model.Database['Package']['Invalid']) - - def OnInvalidPackagesSetFocus(self, event): - self.CheckListFocus(self.InvalidPackagesCheckListBox, True) - - def OnInvalidPackagesKillFocus(self, event): - self.CheckListFocus(self.InvalidPackagesCheckListBox, False) - - def OnInvalidPlatformsCheckListClick(self, event): - self.CheckListClick(self.InvalidPlatformsCheckListBox, self.Model.Database['Platform']['Invalid']) - - def OnInvalidPlatformsSetFocus(self, event): - self.CheckListFocus(self.InvalidPlatformsCheckListBox, True) - - def OnInvalidPlatformsKillFocus(self, event): - self.CheckListFocus(self.InvalidPlatformsCheckListBox, False) - - def OnRevertClick(self, event): - self.Model.RevertModel() - self.StatusBar.SetFocus() - self.OnRefreshClick(self) - - def RefreshCheckListBox(self, CheckListBox, SelectAllButton, ClearAllButton, Database): - NameList = [] - for Item in Database['PossibleSettings']: - NameList.append(Database['PossibleSettings'][Item]) - NameList.sort() - CheckListBox.Set(NameList) - Index = 0 - MaximumString = '.' - while Index < CheckListBox.GetCount(): - String = CheckListBox.GetString(Index) - if len(String) > len(MaximumString): - MaximumString = String - Enabled = False - for Item in Database['EnabledSettings']: - if String == Database['EnabledSettings'][Item]: - Enabled = True - if Enabled: - CheckListBox.Check(Index, True) - else: - CheckListBox.Check(Index, False) - Index += 1 - Extents = CheckListBox.GetFullTextExtent (MaximumString) - CheckListBox.SetMinSize((Extents[0] + 30,(CheckListBox.GetCount()+2) * (Extents[1]+Extents[2]))) - if NameList == []: - CheckListBox.Disable() - SelectAllButton.Disable() - ClearAllButton.Disable() - else: - CheckListBox.Enable() - SelectAllButton.Enable() - ClearAllButton.Enable() - - def OnRefreshClick(self, event): - self.Model.RefreshModel() - self.RefreshCheckListBox (self.PackagesCheckListBox, self.SelectAllPackagesButton, self.ClearAllPackagesButton, self.Model.Database['Package']['Valid']) - self.RefreshCheckListBox (self.PlatformsCheckListBox, self.SelectAllPlatformsButton, self.ClearAllPlatformsButton, self.Model.Database['Platform']['Valid']) - self.RefreshCheckListBox (self.InvalidPackagesCheckListBox, self.SelectAllInvalidPackagesButton, self.ClearAllInvalidPackagesButton, self.Model.Database['Package']['Invalid']) - self.RefreshCheckListBox (self.InvalidPlatformsCheckListBox, self.SelectAllInvalidPlatformsButton, self.ClearAllInvalidPlatformsButton, self.Model.Database['Platform']['Invalid']) - self.mainSizer.SetSizeHints(self) - self.mainSizer.Fit(self) - self.Update() - - def OnViewRefreshClick(self, event): - self.Model.RescanModel() - self.StatusBar.SetFocus() - self.OnRefreshClick(self) - - def AddTool (self, Handler, ArtId, Label, HelpText): - Tool = self.ToolBar.AddSimpleTool( - -1, - wx.ArtProvider.GetBitmap(ArtId, wx.ART_TOOLBAR, self.ToolSize), - Label, - HelpText - ) - self.Bind(wx.EVT_MENU, Handler, Tool) - - def OnShowToolBarClick(self, event): - if self.ShowToolBar: - self.ShowToolBar = False - self.ToolBar.Destroy() - else: - self.ShowToolBar = True - self.ToolBar = self.CreateToolBar() - self.ToolSize = (24,24) - self.ToolBar.SetToolBitmapSize(self.ToolSize) - self.AddTool (self.OnNewClick, wx.ART_NEW, "New", "New FrameworkDatabase.db") - self.AddTool (self.OnScanAndSyncClick, wx.ART_HARDDISK, "Scan WORKSPACE and Sync", "Scan WORKSPACE for new Packages and Platforms and sync FrameworkDatabase.db") - self.AddTool (self.OnSaveClick, wx.ART_FILE_SAVE, "Save", "Save FrameworkDatabase.db") - self.AddTool (self.OnSaveAsClick, wx.ART_FILE_SAVE_AS, "Save As...", "Save FrameworkDatabase.db as...") - self.AddTool (self.OnRevertClick, wx.ART_UNDO, "Revert", "Revert to original FrameworkDatabase.db") - self.AddTool (self.OnHelpClick, wx.ART_HELP, "Help", "Context Sensitive Help") - self.AddTool (self.OnExitClick, wx.ART_QUIT, "Exit", "Exit EDK II Build System Framework Database Utility") - self.ToolBar.Realize() - - def OnNewClick(self, event): - self.Model.NewModel() - self.OnRefreshClick(self) - - def ScanDirectory(self, Data, DirName, FilesInDir): - WorkspaceDirName = self.Model.WorkspaceRelativePath(DirName) - self.StatusBar.SetStatusText('Scanning: ' + WorkspaceDirName) - RemoveList = [] - for File in FilesInDir: - if File[0] == '.': - RemoveList.insert(0, File) - for File in RemoveList: - FilesInDir.remove(File) - for File in FilesInDir: - if os.path.splitext(File)[1].lower() == '.spd': - self.Model.AddFile (WorkspaceDirName, File, 'Package', False) - self.OnRefreshClick(self) - if os.path.splitext(File)[1].lower() == '.fpd': - self.Model.AddFile (WorkspaceDirName, File, 'Platform', False) - self.OnRefreshClick(self) - - def OnScanClick(self, event): - os.path.walk(self.Model.WorkspaceFile(''), self.ScanDirectory, None) - self.StatusBar.SetStatusText('Scanning: Complete') - self.StatusBar.SetFocus() - self.OnRefreshClick(self) - - def OnScanAndSyncClick(self, event): - self.OnSelectAllPackagesClick(self) - self.OnSelectAllPlatformsClick(self) - self.OnClearAllInvalidPackagesClick(self) - self.OnClearAllInvalidPlatformsClick(self) - self.OnScanClick(self) - self.OnSelectAllPackagesClick(self) - self.OnSelectAllPlatformsClick(self) - self.OnClearAllInvalidPackagesClick(self) - self.OnClearAllInvalidPlatformsClick(self) - - def OnSelectAllPackagesClick(self, event): - self.Model.Database['Package']['Valid']['EnabledSettings'] = self.Model.Database['Package']['Valid']['PossibleSettings'] - self.OnRefreshClick(self) - - def OnClearAllPackagesClick(self, event): - self.Model.Database['Package']['Valid']['EnabledSettings'] = {} - self.OnRefreshClick(self) - - def OnSelectAllPlatformsClick(self, event): - self.Model.Database['Platform']['Valid']['EnabledSettings'] = self.Model.Database['Platform']['Valid']['PossibleSettings'] - self.OnRefreshClick(self) - - def OnClearAllPlatformsClick(self, event): - self.Model.Database['Platform']['Valid']['EnabledSettings'] = {} - self.OnRefreshClick(self) - - def OnSelectAllInvalidPackagesClick(self, event): - self.Model.Database['Package']['Invalid']['EnabledSettings'] = self.Model.Database['Package']['Invalid']['PossibleSettings'] - self.OnRefreshClick(self) - - def OnClearAllInvalidPackagesClick(self, event): - self.Model.Database['Package']['Invalid']['EnabledSettings'] = {} - self.OnRefreshClick(self) - - def OnSelectAllInvalidPlatformsClick(self, event): - self.Model.Database['Platform']['Invalid']['EnabledSettings'] = self.Model.Database['Platform']['Invalid']['PossibleSettings'] - self.OnRefreshClick(self) - - def OnClearAllInvalidPlatformsClick(self, event): - self.Model.Database['Platform']['Invalid']['EnabledSettings'] = {} - self.OnRefreshClick(self) - - def OnSaveClick(self, event): - self.Model.SaveModel() - - def OnSaveAsClick(self, event): - wildcard = "Text Documents (*.db)|*.db|" \ - "All files (*.*)|*.*" - dialog = wx.FileDialog (None, 'Save As', self.Model.WorkspaceFile('Tools/Conf'), '', wildcard, wx.SAVE | wx.OVERWRITE_PROMPT) - if dialog.ShowModal() == wx.ID_OK: - FrameworkDatabaseDbFile = self.Model.WorkspaceRelativePath(dialog.GetPath()) - if FrameworkDatabaseDbFile != '': - self.Model.SaveModel(FrameworkDatabaseDbFile) - dialog.Destroy() - - def OnExitClick(self, event): - if self.Model.ModelModified(): - dialog = wx.MessageDialog(None, 'The contents have changed.\nDo you want to save changes?', 'EDK II Build System Framework Databsase Utility', style = wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | wx.ICON_EXCLAMATION) - Status = dialog.ShowModal() - dialog.Destroy() - if Status == wx.ID_YES: - self.OnSaveClick (self) - elif Status == wx.ID_CANCEL: - return - self.Model.CloseModel() - self.Close() - - def OnHelpClick(self, event): - wx.ContextHelp().BeginContextHelp() - - def OnAboutClick(self, event): - AboutInfo = wx.AboutDialogInfo() - AboutInfo.Name = 'EDK II Build System Framework Database Utility' - AboutInfo.Version = '0.3' - AboutInfo.Copyright = 'Copyright (c) 2006, Intel Corporation' - AboutInfo.Description = """ - The EDK II Build System Framework Database Utility maintains FrameworkDatabase.db - settings in an EDK II Workspace.""" - AboutInfo.WebSite = ("http://tianocore.org", "Tiano Core home page") - AboutInfo.License = """ - All rights reserved. This program and the accompanying materials are - licensed and made available under the terms and conditions of the BSD - License which accompanies this distribution. The full text of the - license may be found at http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" - BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, - EITHER EXPRESS OR IMPLIED.""" - if self.Model.Icon != None: - AboutInfo.Icon = self.Model.Icon - wx.AboutBox(AboutInfo) - -if __name__ == '__main__': - app = wx.PySimpleApp() - frame = Frame() - frame.Show() - app.MainLoop() - diff --git a/Tools/Python/GenMake.py b/Tools/Python/GenMake.py deleted file mode 100755 index 171a6d79bd..0000000000 --- a/Tools/Python/GenMake.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python - -"""Create GNU Makefiles for the Libraries of the MdePkg.""" - -import os, sys, getopt, string, xml.dom.minidom, shutil -from XmlRoutines import * -from WorkspaceRoutines import * - -Makefile = string.Template("""ARCH = $ARCH - -MAKEROOT ?= ../.. - -VPATH = .. - -$IDENTIFIER - -OBJECTS = $OBJECTS - -include $$(MAKEROOT)/lib.makefile -""") - -def openSpd(spdFile): - - """Open the spdFile and process the msa files it contains.""" - - db = xml.dom.minidom.parse(inWorkspace(spdFile)) - - for arch in ["IA32", "X64"]: - for msaFile in XmlList(db, "/PackageSurfaceArea/MsaFiles/Filename"): - msaFileName = XmlElementData(msaFile) - doLib(msaFileName, arch) - - # Copy the Include tree for the Package - packageDir = os.path.dirname(spdFile) - mkdir(packageDir) - if not os.path.exists(os.path.join(packageDir, "Include")): - print "Exporting the include dir..." - os.system("svn export %s %s" % - (inWorkspace(os.path.join(packageDir, "Include")), - os.path.join(packageDir, "Include"))) - else: - print "Error: The directory '%s' is in the way. Please move it." % os.path.join(packageDir, "Include") - sys.exit() - -def inMde(f): - """Make a path relative to the Mde Pkg root dir.""" - return inWorkspace(os.path.join("MdePkg", f)) - -def doLib(msafile, arch): - - """Create a directory with the sources, AutoGen.h and a makefile.""" - - objects = [] - - msa = xml.dom.minidom.parse(inMde(msafile)) - modName = str(XmlElement(msa, "/ModuleSurfaceArea/MsaHeader/ModuleName")) - base, _ = os.path.splitext(msafile) - msabase = os.path.basename(base) - - suppArch = str(XmlElement(msa, "/ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures")) - if not arch in string.split(suppArch, " "): - return - - # What kind of module is this? - - # Assume it is a driver. - identifier = "DRIVERNAME = %s" % modName - - # Let's see if it claims to produce a library class. - for libClass in XmlList(msa, "/ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass"): - if libClass.getAttribute("Usage") == "ALWAYS_PRODUCED": - # It's a library. - identifier = "LIBNAME = %s" % modName - - mkdir(modName) - - buildDir = os.path.join(modName, "build-%s" % arch ) - mkdir(buildDir) - - for sourceFile in XmlList(msa, "/ModuleSurfaceArea/SourceFiles/Filename"): - - sourceFileName = str(XmlElementData(sourceFile)) - suppArchs = sourceFile.getAttribute("SupArchList").split(" ") - toolchain = sourceFile.getAttribute("ToolChainFamily") - base, ext = os.path.splitext(sourceFileName) - - if (suppArchs == [""] or arch in suppArchs) and toolchain in ["", "GCC"] and ext in [".c", ".h", ".S"]: - if ext in [".c", ".S"]: - obj = str(base+".o") - if obj in objects: - print "Error: The msa file %s is ambiguous. There are mutliple sources that can produce the object file %s. Please fix it." % (msafile, obj) - sys.exit() - else: - objects.append(obj) - sourceDir = os.path.join(modName, os.path.dirname(sourceFileName)) - mkdir(sourceDir) - mkdir(os.path.join(buildDir, os.path.dirname(sourceFileName))) - shutil.copy(inMde(os.path.join(os.path.dirname(msafile), sourceFileName)), - sourceDir) - - # Write a Makefile for this module - f = open(os.path.join(buildDir, "Makefile"), "w") - f.write(Makefile.substitute(ARCH=arch, IDENTIFIER=identifier, OBJECTS=string.join(objects, " "))) - f.close() - - # Right now we are getting the AutoGen.h file from a previous build. We - # could create it from scratch also. - shutil.copy(inWorkspace("Build/Mde/DEBUG_UNIXGCC/%s/MdePkg/Library/%s/%s/DEBUG/AutoGen.h") % (arch, modName, msabase), buildDir) - -# This acts like the main() function for the script, unless it is 'import'ed -# into another script. -if __name__ == '__main__': - - openSpd("MdePkg/MdePkg.spd") diff --git a/Tools/Python/InstallFar.py b/Tools/Python/InstallFar.py deleted file mode 100755 index 7bc03aa0ca..0000000000 --- a/Tools/Python/InstallFar.py +++ /dev/null @@ -1,328 +0,0 @@ -#!/usr/bin/env python - -"""This is a python script that takes user input from the command line and -installs a far (Framework Archive Manifest) file into the workspace.""" - -import os, sys, getopt, string, xml.dom.minidom, zipfile, md5 -from XmlRoutines import * -from WorkspaceRoutines import * - -class Flags: - """Keep track of some command line flags and operating modes.""" - def __init__(self): - self.verbose = False - self.force = False - self.reinstall = False - self.dir = '' - -class Database: - - """This class encapsulates the FrameworkDatabase file for the workspace we - are operating on.""" - - def __init__(self, filename="Tools/Conf/FrameworkDatabase.db"): - - # First try to get a lock file. - self.DBFile = inWorkspace(filename) - self.lockfile = inWorkspace("Tools/Conf/FrameworkDatabase.lock") - if os.path.exists(self.lockfile): - self.itsMyLockFile = False - print "Error: The database file is locked by ", self.lockfile - raise OSError("The Database is locked.") - else: - self.lock = open(self.lockfile, 'w') - self.lock.write("pid "+str(os.getpid())) - self.itsMyLockFile = True - - self.dom = XmlParseFile(inWorkspace(filename)) - - self.installedPackages = {} - self.installedPlatforms = {} - self.installedFars = {} - - for spdfile in XmlList(self.dom, "/FrameworkDatabase/PackageList/Filename"): - filename = str(XmlElementData(spdfile)) - spd = XmlParseFileSection(inWorkspace(filename), "SpdHeader") - self.installedPackages[GetSpdGuidVersion(spd, 1)] = \ - XmlElement(spd, "/SpdHeader/PackageName") - - for fpdfile in XmlList(self.dom, "/FrameworkDatabase/PlatformList/Filename"): - filename = str(XmlElementData(fpdfile)) - fpd = XmlParseFileSection(inWorkspace(filename), "PlatformHeader") - self.installedPlatforms[GetFpdGuidVersion(fpd, 1)] = \ - XmlElement(fpd, "/PlatformHeader/PlatformName") - - for farfile in XmlList(self.dom, "/FrameworkDatabase/FarList/Filename"): - farGuid = Guid(farfile.getAttribute("FarGuid")) - self.installedFars[farGuid] = XmlElementData(farfile) - - self.packageList = XmlNode(self.dom, "/FrameworkDatabase/PackageList") - self.platformList = XmlNode(self.dom, "/FrameworkDatabase/PlatformList") - self.farList = XmlNode(self.dom, "/FrameworkDatabase/FarList") - - def __del__(self): - if self.itsMyLockFile: - self.lock.close() - os.unlink(self.lockfile) - - def HasPackage(self, (guid, version)): - """Return true iff this package is already installed.""" - if version == "": - # Look for the guid. - for (g, v) in self.installedPackages.keys(): - if g == guid: - return True - return self.installedPackages.has_key((guid, version)) - - def HasPlatform(self, (guid, version)): - """Return true iff this platform is already installed.""" - if version == "": - # Look for the guid. - for (g, v) in self.installedPlatforms.keys(): - if g == guid: - return True - return self.installedPlatforms.has_key((guid, version)) - - def HasFar(self, farguid): - """Return true iff this far is already installed.""" - return self.installedFars.has_key(farguid) - - def AddPackage(self, f): - """Put this package in the database""" - XmlAppendChildElement(self.packageList, "Filename", f) - - def AddPlatform(self, f): - """Put this platform in the database""" - XmlAppendChildElement(self.platformList, "Filename", f) - - def AddFar(self, f, guid=""): - """Put this far in the database""" - XmlAppendChildElement(self.farList, "Filename", f, {"FarGuid":guid} ) - - def Write(self): - """Save the Xml tree out to the file.""" - if True: - XmlSaveFile(self.dom, self.DBFile) - else: - f=open(self.DBFile, 'w') - f.write(self.dom.toprettyxml(2*" ")) - f.close() - -def ExtractFile(zip, file, defaultDir="", workspaceLocation="", md5sum=""): - """Unzip a file.""" - if flags.verbose: - print "Extracting ", file - - destFile = os.path.join(inWorkspace(workspaceLocation), str(file)) - destDir = os.path.dirname(destFile) - - mkdir(destDir) - - f = open(destFile, "w") - contents = zip.read(os.path.join(defaultDir,file)) - if md5sum and (md5.md5(contents).hexdigest() != md5sum): - print "Error: The md5 sum does not match on file %s." % file - f.write(contents) - f.close() - -def GetFpdGuidVersion(Dom, strip=0): - - """Get the Guid and version of the fpd from a dom object.""" - - gpath = ["PlatformSurfaceArea", "PlatformHeader", "GuidValue"] - vpath = ["PlatformSurfaceArea", "PlatformHeader", "Version"] - - return Guid(XmlElement(Dom, "/".join(gpath[strip:]))), \ - XmlElement(Dom, "/".join(vpath[strip:])) - -def GetSpdGuidVersion(Dom, strip=0): - - """Get the Guid and version of the spd from a dom object.""" - - gpath = ["PackageSurfaceArea", "SpdHeader", "GuidValue"] - vpath = ["PackageSurfaceArea", "SpdHeader", "Version"] - - return Guid(XmlElement(Dom, "/".join(gpath[strip:]))), \ - XmlElement(Dom, "/".join(vpath[strip:])) - -def InstallFar(farfile, workspaceLocation=""): - - """Unpack the far an install it in the workspace. We need to adhere to the - rules of far handling.""" - - far = zipfile.ZipFile(farfile, "r") - - # Use this list to make sure we get everything from the far. - zipContents = far.namelist() - - manifest = xml.dom.minidom.parseString(far.read("FrameworkArchiveManifest.xml")) - zipContents.remove("FrameworkArchiveManifest.xml") - fdb = Database() - - # First we need to make sure that the far will install cleanly. - - installError = False # Let's hope for the best. - spdDoms = [] - farSpds = [] - - # Check the packages - for farPackage in XmlList(manifest, "/FrameworkArchiveManifest/FarPackageList/FarPackage/FarFilename"): - spdfile = str(XmlElementData(farPackage)) - spd = XmlParseStringSection(far.read(spdfile), "SpdHeader") - packageGV = GetSpdGuidVersion(spd, 1) - if fdb.HasPackage(packageGV): - if not flags.reinstall: - print "Error: This package is already installed: ", spdfile - installError = True - - # Build up a list of the package guid versions that this far is bringing in. - # This is needed to satisfy dependencies of msas that are in the other packages of - # this far. - farSpds.append(packageGV) - - spdDoms.append((spd, spdfile)) - - for spd, spdfile in spdDoms: - # Now we need to get a list of every msa in this spd and check the package dependencies. - for msafile in XmlList(spd, "/PackageSurfaceArea/MsaFiles/Filename"): - msafilePath = str(os.path.join(os.path.dirname(spdfile), XmlElementData(msafile))) - - msa = XmlParseString(far.read(msafilePath)) - - for package in XmlList(msa, "/ModuleSurfaceArea/PackageDependencies/Package"): - guid = Guid(package.getAttribute("PackageGuid")) - version = package.getAttribute("PackageVersion") - - # Does anyone provide this package? - if not fdb.HasPackage((guid, version)) and not (guid, version) in farSpds: - print ("Error: The module %s depends on the package guid %s version %s, which " + \ - "is not installed in the workspace, nor is it provided by this far.") \ - % (msafilePath, guid, version) - installError = True - - # Check the platforms - for farPlatform in XmlList(manifest, "/FrameworkArchiveManifest/FarPlatformList/FarPlatform/FarFilename"): - fpdfile = str(XmlElementData(farPlatform)) - fpd = XmlParseString(far.read(fpdfile)) - if fdb.HasPlatform(GetFpdGuidVersion(fpd, 0)): - if not flags.reinstall: - print "Error: This platform is already installed: ", fpdfile - installError = True - - # Now we need to check that all the Platforms (and modules?) that are - # referenced by this fpd are installed in the workspace or are in this far. - packagesNeeded = set() - - # Go through the dependencies - for dependency in XmlList(fpd, "/PlatformSurfaceArea/FrameworkModules/ModuleSA") + \ - XmlList(fpd, "/PlatformSurfaceArea/FrameworkModules/ModuleSA/Libraries/Instance"): - packagesNeeded.add((Guid(dependency.getAttribute("PackageGuid")), - dependency.getAttribute("PackageVersion"))) - - # Let's see if all the packages are in the workspace - for guid, version in packagesNeeded: - # Does anyone provide this package? - if not fdb.HasPackage((guid, version)) and not (guid, version) in farSpds: - print ("Error: The fpd %s depends on the package guid %s version %s, which " + \ - "is not installed in the workspace, nor is it provided by this far.") \ - % (fpdfile, guid, version) - installError = True - - # Check the fars - thisFarGuid = Guid(XmlElement(manifest, "/FrameworkArchiveManifest/FarHeader/GuidValue")) - if fdb.HasFar(thisFarGuid): - if not flags.reinstall: - print "Error: There is a far with this guid already installed." - installError = True - - # We can not do the install - if installError: - if flags.force: - print "Warning: Ignoring previous errors as you requested." - else: - return False - - # Install the packages - for farPackage in XmlList(manifest, "/FrameworkArchiveManifest/FarPackageList/FarPackage"): - - filename = XmlElement(farPackage, "FarPackage/FarFilename") - if not flags.reinstall: - fdb.AddPackage(filename) - ExtractFile(far, filename, workspaceLocation) - zipContents.remove(filename) - - DefaultPath = XmlElement(farPackage, "FarPackage/DefaultPath") - - for content in XmlList(farPackage, "FarPackage/Contents/FarFilename"): - - filename = XmlElementData(content) - ExtractFile(far, filename, DefaultPath, workspaceLocation, md5sum=content.getAttribute("Md5Sum")) - zipContents.remove(os.path.join(DefaultPath, filename)) - - # Install the platforms - for farPlatform in XmlList(manifest, "/FrameworkArchiveManifest/FarPlatformList/FarPlatform"): - - filename = XmlElement(farPlatform, "FarPlatform/FarFilename") - if not flags.reinstall: - fdb.AddPlatform(filename) - ExtractFile(far, filename, "", workspaceLocation) - zipContents.remove(filename) - - # Install the Contents - for content in XmlList(manifest, "/FrameworkArchiveManifest/Contents/FarFilename"): - - filename = XmlElementData(content) - ExtractFile(far, filename, "", workspaceLocation) - zipContents.remove(filename) - - # What if there are more files in the far? - if not zipContents == []: - print "Warning: There are files in the far that were not expected: ", zipContents - - if not flags.reinstall: - fdb.AddFar(farfile, thisFarGuid) - - # If everything has gone well, we can put the manifest file in a safe place... - farDir = inWorkspace("Tools/Conf/InstalledFars/") - mkdir(farDir) - f=open(os.path.join(farDir, thisFarGuid), 'w') - f.write(far.read("FrameworkArchiveManifest.xml")) - f.close() - - # Write out the new database - if not flags.reinstall: - fdb.Write() - - far.close() - -# This acts like the main() function for the script, unless it is 'import'ed -# into another script. -if __name__ == '__main__': - - flags = Flags() - - # Process the command line args. - optlist, args = getopt.getopt(sys.argv[1:], '?hvfd:', ['directory=', 'help', 'verbose', 'force', 'reinstall']) - - # First pass through the options list. - for o, a in optlist: - if o in ["-h", "-?", "--help"]: - print """ -%s: Install a far (Framework Archive) into the current workspace. -""" % os.path.basename(sys.argv[0]) - - sys.exit() - optlist.remove((o,a)) - if o in ["-v", "--verbose"]: - flags.verbose = True - if o in ["-d", "--directory"]: - flags.dir = a - if o in ["-f", "--force"]: - flags.force = True - if o in ["--reinstall"]: - flags.reinstall = True - - for f in args: - InstallFar(f) - if args == []: - print "Please pass a far filename on the command line." diff --git a/Tools/Python/Install_Python_OSX.sh b/Tools/Python/Install_Python_OSX.sh deleted file mode 100755 index e584171b1e..0000000000 --- a/Tools/Python/Install_Python_OSX.sh +++ /dev/null @@ -1,16 +0,0 @@ -echo "You proxy is currently set to \"$http_proxy\"." -echo "It needs to set in order to download through a firewall." -echo "For example: \"export http_proxy=proxy.company.com:911\"" -set -e -echo "After the download, get ready to enter the root password." -curl -C - --remote-name http://www.python.org/ftp/python/2.4.4/python-2.4.4-macosx2006-10-18.dmg --progress-bar -hdiutil attach python-2.4.4-macosx2006-10-18.dmg -sudo installer -pkg "/Volumes/Univeral MacPython 2.4.4/MacPython.mpkg/" -target / -sudo ln -fs /usr/local/bin/python2.4 /usr/bin/python -hdiutil unmount "/Volumes/Univeral MacPython 2.4.4/" - -# Get the wxpython installer. -curl -C - --remote-name http://superb-west.dl.sourceforge.net/sourceforge/wxpython/wxPython2.8-osx-unicode-2.8.0.1-universal10.4-py2.4.dmg --progress-bar -hdiutil attach wxPython2.8-osx-unicode-2.8.0.1-universal10.4-py2.4.dmg -sudo installer -pkg /Volumes/wxPython2.8-osx-unicode-2.8.0.1-universal10.4-py2.4/wxPython2.8-osx-unicode-universal10.4-py2.4.pkg -target / -hdiutil unmount /Volumes/wxPython2.8-osx-unicode-2.8.0.1-universal10.4-py2.4/ diff --git a/Tools/Python/ListWorkspace.py b/Tools/Python/ListWorkspace.py deleted file mode 100755 index 1a1c9deaef..0000000000 --- a/Tools/Python/ListWorkspace.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python - -"""List the contents of the Framework Database to the screen in a readble -form.""" - -import os, sys, getopt, string, xml.dom.minidom, zipfile, md5 -from XmlRoutines import * -from WorkspaceRoutines import * - -def openDatabase(f): - - print "Dumping the contents of %s workspace database file." % f - - db = xml.dom.minidom.parse(inWorkspace(f)) - - return db - -def showSpds(db): - - print "--------\nPackages\n--------" - - for spdFile in XmlList(db, "/FrameworkDatabase/PackageList/Filename"): - spdFileName = XmlElementData(spdFile) - spd = xml.dom.minidom.parse(inWorkspace(spdFileName)) - spdName = XmlElement(spd, "/PackageSurfaceArea/SpdHeader/PackageName") - - print " %-24s %-10s" % (spdName, spdFileName) - -def showFpds(db): - - print "--------\nPlatforms\n--------" - - for fpdFile in XmlList(db, "/FrameworkDatabase/PlatformList/Filename"): - fpdFileName = XmlElementData(fpdFile) - fpd = xml.dom.minidom.parse(inWorkspace(fpdFileName)) - fpdName = XmlElement(fpd, "/PlatformSurfaceArea/PlatformHeader/PlatformName") - - print " %-24s %-10s" % (fpdName, fpdFileName) - -# This acts like the main() function for the script, unless it is 'import'ed -# into another script. -if __name__ == '__main__': - - db = openDatabase("Tools/Conf/FrameworkDatabase.db") - - showSpds(db) - showFpds(db) diff --git a/Tools/Python/MkFar.py b/Tools/Python/MkFar.py deleted file mode 100755 index 2848b1de65..0000000000 --- a/Tools/Python/MkFar.py +++ /dev/null @@ -1,230 +0,0 @@ -#!/usr/bin/env python - -"""This is a python script that takes user input from the command line and -creates a far (Framework Archive Manifest) file for distribution.""" - -import os, sys, getopt, string, xml.dom.minidom, zipfile, md5 -from XmlRoutines import * -from WorkspaceRoutines import * - -class Far: - """This class is used to collect arbitrarty data from the template file.""" - def __init__(far): - """Assign the default values for the far fields.""" - far.FileName = "output.far" - far.FarName="" - far.Version="" - far.License="" - far.Abstract="" - far.Description="" - far.Copyright="" - far.SpdFiles=[] - far.FpdFiles=[] - far.ExtraFiles=[] - -far = Far() -"""The far object is constructed from the template file the user passed in.""" - -def AddToZip(zip, infile): - - """Add a file to a zip file, provided it is not already there.""" - - if not infile in zip.namelist(): - zip.write(inWorkspace(infile), infile) - -def parseMsa(msaFile, spdDir): - - """Parse an msa file and return a list of all the files that this msa - includes.""" - - filelist = [msaFile] - - msaDir = os.path.dirname(msaFile) - - msa = xml.dom.minidom.parse(inWorkspace(os.path.join(spdDir, msaFile))) - - xmlPaths = [ - "/ModuleSurfaceArea/SourceFiles/Filename", - "/ModuleSurfaceArea/NonProcessedFiles/Filename" ] - - for xmlPath in xmlPaths: - for f in XmlList(msa, xmlPath): - filelist.append(str(os.path.join(msaDir, XmlElementData(f)))) - - return filelist - -def parseSpd(spdFile): - - """Parse an spd file and return a list of all the files that this spd - includes.""" - - files = [] - - spdDir = os.path.dirname(spdFile) - - spd = xml.dom.minidom.parse(inWorkspace(spdFile)) - - # We are currently ignoring these hints. - readonly = XmlElement(spd, "/PackageSurfaceArea/PackageDefinitions/ReadOnly") != "false" - repackage = XmlElement(spd, "/PackageSurfaceArea/PackageDefinitions/RePackage") != "false" - - xmlPaths = [ - "/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass/IncludeHeader", - "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader/IncludeHeader" ] - - # These are covered by the Industry Standard Includes. - # "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader" - - for xmlPath in xmlPaths: - for f in XmlList(spd, xmlPath): - files.append(str(XmlElementData(f))) - - for f in XmlList(spd, "/PackageSurfaceArea/MsaFiles/Filename"): - msaFile = str(XmlElementData(f)) - files += parseMsa(msaFile, spdDir) - - cwd = os.getcwd() - os.chdir(inWorkspace(spdDir)) - for root, dirs, entries in os.walk("Include"): - # Some files need to be skipped. - for r in ["CVS", ".svn"]: - if r in dirs: - dirs.remove(r) - for entry in entries: - files.append(os.path.join(os.path.normpath(root), entry)) - os.chdir(cwd) - - return files - -def makeFarHeader(doc): - - """Create a dom tree for the Far Header. It will use information from the - template file passed on the command line, if present.""" - - header = XmlAppendChildElement(doc.documentElement, "FarHeader") - - XmlAppendChildElement(header, "FarName", far.FarName) - XmlAppendChildElement(header, "GuidValue", genguid()) - XmlAppendChildElement(header, "Version", far.Version) - XmlAppendChildElement(header, "Abstract", far.Abstract) - XmlAppendChildElement(header, "Description", far.Description) - XmlAppendChildElement(header, "Copyright", far.Copyright) - XmlAppendChildElement(header, "License", far.License) - XmlAppendChildElement(header, "Specification", "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052") - - return header - -def getSpdGuidVersion(spdFile): - - """Returns a tuple (guid, version) which is read from the given spdFile.""" - - spd = xml.dom.minidom.parse(inWorkspace(spdFile)) - - return (XmlElement(spd, "/PackageSurfaceArea/SpdHeader/GuidValue"), - XmlElement(spd, "/PackageSurfaceArea/SpdHeader/Version")) - -def makeFar(files, farname): - - """Make a far out of the given filelist and writes it to the file farname.""" - - domImpl = xml.dom.minidom.getDOMImplementation() - man = domImpl.createDocument(None, "FrameworkArchiveManifest", None) - top_element = man.documentElement - - top_element.appendChild(makeFarHeader(man)) - - packList = XmlAppendChildElement(top_element, "FarPackageList") - platList = XmlAppendChildElement(top_element, "FarPlatformList") - contents = XmlAppendChildElement(top_element, "Contents") - XmlAppendChildElement(top_element, "UserExtensions") - - try: - zip = zipfile.ZipFile(farname, "w", zipfile.ZIP_DEFLATED) - except: - zip = zipfile.ZipFile(farname, "w", zipfile.ZIP_STORED) - for infile in set(files): - if not os.path.exists(inWorkspace(infile)): - print "Error: Non-existent file '%s'." % infile - sys.exit() - (_, extension) = os.path.splitext(infile) - if extension == ".spd": - filelist = parseSpd(infile) - spdDir = os.path.dirname(infile) - - (spdGuid, spdVersion) = getSpdGuidVersion(infile) - - package = XmlAppendChildElement(packList, "FarPackage") - XmlAppendChildElement(package, "FarFilename", lean(infile), {"Md5Sum": Md5(inWorkspace(infile))}) - AddToZip(zip, infile) - XmlAppendChildElement(package, "GuidValue", spdGuid) - XmlAppendChildElement(package, "Version", spdVersion) - XmlAppendChildElement(package, "DefaultPath", spdDir) - XmlAppendChildElement(package, "FarPlatformList") - packContents = XmlAppendChildElement(package, "Contents") - XmlAppendChildElement(package, "UserExtensions") - - for spdfile in filelist: - XmlAppendChildElement(packContents, "FarFilename", lean(spdfile), {"Md5Sum": Md5(inWorkspace(os.path.join(spdDir, spdfile)))}) - AddToZip(zip, os.path.join(spdDir,spdfile)) - - elif extension == ".fpd": - - platform = XmlAppendChildElement(platList, "FarPlatform") - XmlAppendChildElement(platform, "FarFilename", lean(infile), {"Md5Sum": Md5(inWorkspace(infile))}) - AddToZip(zip, infile) - - else: - XmlAppendChildElement(contents, "FarFilename", lean(infile), {"Md5Sum": Md5(inWorkspace(infile))}) - AddToZip(zip, infile) - - zip.writestr("FrameworkArchiveManifest.xml", man.toxml('UTF-8')) - zip.close() - return - -# This acts like the main() function for the script, unless it is 'import'ed -# into another script. -if __name__ == '__main__': - - # Create a pretty printer for dumping data structures in a readable form. - # pp = pprint.PrettyPrinter(indent=2) - - # Process the command line args. - optlist, args = getopt.getopt(sys.argv[1:], 'ho:t:v', [ 'template=', 'output=', 'far=', 'help', 'debug', 'verbose', 'version']) - - # First pass through the options list. - for o, a in optlist: - if o in ["-h", "--help"]: - print """ -Pass a list of .spd and .fpd files to be placed into a far for distribution. -You may give the name of the far with a -f or --far option. For example: - - %s --template far-template --far library.far MdePkg/MdePkg.spd - -The file paths of .spd and .fpd are treated as relative to the WORKSPACE -environment variable which must be set to a valid workspace root directory. - -A template file may be passed in with the --template option. This template file -is a text file that allows more contol over the contents of the far. -""" % os.path.basename(sys.argv[0]) - - sys.exit() - optlist.remove((o,a)) - if o in ["-t", "--template"]: - # The template file is processed first, so that command line options can - # override it. - templateName = a - execfile(templateName) - optlist.remove((o,a)) - - # Second pass through the options list. These can override the first pass. - for o, a in optlist: - if o in ["-o", "--far", "--output"]: - far.FileName = a - - # Let's err on the side of caution and not let people blow away data - # accidentally. - if os.path.exists(far.FileName): - print "Error: File %s exists. Not overwriting." % far.FileName - sys.exit() - - makeFar(far.SpdFiles + far.FpdFiles + far.ExtraFiles + args, far.FileName) diff --git a/Tools/Python/WorkspaceRoutines.py b/Tools/Python/WorkspaceRoutines.py deleted file mode 100755 index c75cd57c52..0000000000 --- a/Tools/Python/WorkspaceRoutines.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2007, Intel Corporation -# All rights reserved. This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -import os, sys, re, getopt, string, glob, xml.dom.minidom, pprint, md5, socket, getpass, time, random - -def inWorkspace(rel_path=""): - """Treat the given path as relative to the workspace.""" - - # Make sure the user has set the workspace variable: - try: - return os.path.join(os.environ["WORKSPACE"], rel_path ) - except: - print "Oops! You must set the WORKSPACE environment variable to run this script." - sys.exit() - -def genguid(): - g = md5.md5( - str(random.random()) + - getpass.getuser() + - str(time.time()) + - socket.gethostbyname(socket.gethostname())).hexdigest() - return Guid("%s-%s-%s-%s-%s" % (g[0:8], g[8:12], g[12:16], g[16:20], g[20:])) - -def lean(path): - """Lean the slashes forward""" - - return os.path.normpath(path).replace("\\", "/") - -def mkdir(path): - """Make a directory if it is not there already.""" - - try: - os.makedirs(path) - except: - pass - -def Md5(filename): - - sum = "" - - try: - f=open(filename, "rb") - sum = md5.md5(f.read()).hexdigest() - f.close() - except IOError: - print "Error: Unable to open file: %s" % filename - sys.exit() - - return sum - -def Guid(guidString): - """Convert the guid string into a canonical form suitable for comparison.""" - return string.lower(guidString) diff --git a/Tools/Python/XmlRoutines.py b/Tools/Python/XmlRoutines.py deleted file mode 100755 index 05abb272ad..0000000000 --- a/Tools/Python/XmlRoutines.py +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2007, Intel Corporation -# All rights reserved. This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -"""This is an XML API that uses a syntax similar to XPath, but it is written in -standard python so that no extra python packages are required to use it.""" - -import xml.dom.minidom - -def XmlList(Dom, String): - """Get a list of XML Elements using XPath style syntax.""" - if String == None or String == "" or Dom == None or Dom == "": - return [] - if Dom.nodeType==Dom.DOCUMENT_NODE: - Dom = Dom.documentElement - if String[0] == "/": - String = String[1:] - tagList = String.split('/') - nodes = [Dom] - index = 0 - end = len(tagList) - 1 - while index <= end: - childNodes = [] - for node in nodes: - if node.nodeType == node.ELEMENT_NODE and node.tagName == tagList[index]: - if index < end: - childNodes.extend(node.childNodes) - else: - childNodes.append(node) - nodes = childNodes - childNodes = [] - index += 1 - - return nodes - -def XmlNode (Dom, String): - """Return a single node that matches the String which is XPath style syntax.""" - if String == None or String == "" or Dom == None or Dom == "": - return "" - if Dom.nodeType==Dom.DOCUMENT_NODE: - Dom = Dom.documentElement - if String[0] == "/": - String = String[1:] - tagList = String.split('/') - index = 0 - end = len(tagList) - 1 - childNodes = [Dom] - while index <= end: - for node in childNodes: - if node.nodeType == node.ELEMENT_NODE and node.tagName == tagList[index]: - if index < end: - childNodes = node.childNodes - else: - return node - break - index += 1 - return "" - -def XmlElement (Dom, String): - """Return a single element that matches the String which is XPath style syntax.""" - try: - return XmlNode (Dom, String).firstChild.data.strip() - except: - return '' - -def XmlElementData (Dom): - """Get the text for this element.""" - if Dom == None or Dom == '' or Dom.firstChild == None: - return '' - return Dom.firstChild.data.strip() - -def XmlAttribute (Dom, AttName): - """Return a single attribute named AttName.""" - if Dom == None or Dom == '': - return '' - try: - return Dom.getAttribute(AttName) - except: - return '' - -def XmlTopTag(Dom): - """Return the name of the Root or top tag in the XML tree.""" - return Dom.firstChild.nodeName - -def XmlParseFile (FileName): - """Parse an XML file into a DOM and return the DOM.""" - try: - f = open(FileName, 'r') - Dom = xml.dom.minidom.parse(f) - f.close() - return Dom - except: - return xml.dom.minidom.parseString('<empty/>') - -def XmlParseString (Str): - """Parse an XML string into a DOM and return the DOM.""" - try: - return xml.dom.minidom.parseString(Str) - except: - return xml.dom.minidom.parseString('<empty/>') - -def XmlParseFileSection (FileName, Tag): - """Parse a section of an XML file into a DOM(Document Object Model) and return the DOM.""" - try: - f = open(FileName, 'r') - except: - return xml.dom.minidom.parseString('<empty/>') - Start = '<' + Tag - End = '</' + Tag + '>' - File = '' - while File.find(Start) < 0 or File.find(End) < 0: - Section = f.read(0x1000) - if Section == '': - break - File += Section - f.close() - if File.find(Start) < 0 or File.find(End) < 0: - return xml.dom.minidom.parseString('<empty/>') - File = File[File.find(Start):File.find(End)+len(End)] - try: - return xml.dom.minidom.parseString(File) - except: - return xml.dom.minidom.parseString('<empty/>') - -def XmlParseStringSection (XmlString, Tag): - """Parse a section of an XML string into a DOM(Document Object Model) and return the DOM.""" - Start = '<' + Tag - End = '</' + Tag + '>' - File = XmlString - if File.find(Start) < 0 or File.find(End) < 0: - return xml.dom.minidom.parseString('<empty/>') - File = File[File.find(Start):File.find(End)+len(End)] - try: - return xml.dom.minidom.parseString(File) - except: - return xml.dom.minidom.parseString('<empty/>') - -def XmlSaveFile (Dom, FileName, Encoding='UTF-8'): - """Save a DOM(Document Object Model) into an XML file.""" - try: - f = open(FileName, 'w') - f.write(Dom.toxml(Encoding).replace('"','"').replace('>','>')) - f.close() - return True - except: - return False - -def XmlRemoveElement(Node): - """Remove an element node from DOM(Document Object Model) tree.""" - ParentNode = Node.parentNode - if ParentNode == None: - return False - PreviousSibling = Node.previousSibling - while PreviousSibling != None and PreviousSibling.nodeType == PreviousSibling.TEXT_NODE and PreviousSibling.data.strip() == '': - Temp = PreviousSibling - PreviousSibling = PreviousSibling.previousSibling - ParentNode.removeChild(Temp) - ParentNode.removeChild(Node) - return True - -def XmlAppendChildElement(ParentNode, TagName, ElementText='', AttributeDictionary = {}): - """Add a child element to a DOM(Document Object Model) tree with optional Attributes.""" - TagName = TagName.strip() - if TagName == '': - return None - Depth = 0 - Dom = ParentNode - while Dom != None and Dom.nodeType != Dom.DOCUMENT_NODE: - Dom = Dom.parentNode - Depth += 1 - if Dom == None: - return None - ParentNode.appendChild(Dom.createTextNode('\n%*s' % (Depth * 2, ''))) - ElementNode = Dom.createElement(TagName) - if ElementText != '': - ElementNode.appendChild(Dom.createTextNode(ElementText)) - for Item in AttributeDictionary: - ElementNode.setAttribute(Item, AttributeDictionary[Item]) - ParentNode.appendChild(ElementNode) - return ElementNode - - -# This acts like the main() function for the script, unless it is 'import'ed into another -# script. -if __name__ == '__main__': - - # Nothing to do here. Could do some unit tests. - pass diff --git a/Tools/Python/buildgen/AntTasks.py b/Tools/Python/buildgen/AntTasks.py deleted file mode 100644 index ce694f9b80..0000000000 --- a/Tools/Python/buildgen/AntTasks.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python
-
-# Copyright (c) 2007, Intel Corporation
-# All rights reserved. This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-"""Ant Tasks Dom Element"""
-
-import xml.dom.minidom, os
-
-class AntTask:
- def __init__(self, document, _name, _body=None, **_attributes):
- """Instantiate an Ant task element
- document, _name=task name, _body=task body, **_attributes=task attributes
- """
- self.Document = document
- self.Root = ""
-
- if _name == None or _name == "":
- raise Exception("No Ant task name")
-
- taskElement = self.Document.createElement(_name)
- for name in _attributes:
- taskElement.setAttribute(name, _attributes[name])
-
- if _body != None:
- if isinstance(_body, str):
- text = self.Document.createTextNode(_body)
- taskElement.appendChild(text)
- elif isinstance(_body, list):
- for subtask in _body:
- taskElement.appendChild(subtask)
-
- self.Root = taskElement
-
- def SubTask(self, _name, _body=None, **_attributes):
- """Insert a sub-task into this task"""
- newTask = AntTask(self.Document, _name , _body, **_attributes)
- self.Root.appendChild(newTask.Root)
- return newTask
-
- def AddSubTask(self, subTask):
- """Insert a existing sub-task into this task"""
- self.Root.appendChild(subTask.Root.cloneNode(True))
- return subTask
-
- def Comment(self, string):
- """Generate a XML comment"""
- self.Root.appendChild(self.Document.createComment(string))
-
- def Blankline(self):
- """Generate a blank line"""
- self.Root.appendChild(self.Document.createTextNode(""))
-
-
-class AntBuildFile(AntTask):
- _FileComment = "DO NOT EDIT\nThis file is auto-generated by the build utility\n\nAbstract:\nAuto-generated ANT build file for building Framework modules and platforms\n"
-
- def __init__(self, name, basedir=".", default="all"):
- """Instantiate an Ant build.xml
- name=project name, basedir=project default directory, default=default target of this project
- """
- self.Document = xml.dom.minidom.getDOMImplementation().createDocument(None, "project", None)
- self.Root = self.Document.documentElement
-
- self.Document.insertBefore(self.Document.createComment(self._FileComment), self.Root)
- self.Root.setAttribute("name", name)
- self.Root.setAttribute("basedir", basedir)
- self.Root.setAttribute("default", default)
-
- def Create(self, file):
- """Generate the build.xml using given file path"""
- buildFileDir = os.path.dirname(file)
- if not os.path.exists(buildFileDir):
- os.makedirs(buildFileDir)
-
- f = open(file, "w")
- f.write(self.Document.toprettyxml(2*" ", encoding="UTF-8"))
- f.close()
diff --git a/Tools/Python/buildgen/BuildConfig.py b/Tools/Python/buildgen/BuildConfig.py deleted file mode 100644 index e91bd294a5..0000000000 --- a/Tools/Python/buildgen/BuildConfig.py +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env python
-
-# Copyright (c) 2007, Intel Corporation
-# All rights reserved. This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-"""Tools and build configuration"""
-
-from sets import Set
-
-class Config(dict):
- def __init__(self, file):
- """file (target configuration file)"""
- configFile = open(file)
- while True:
- line = configFile.readline()
- if line == "": break ## no more line
-
- line = line.strip()
- # skip blank line
- if line == "": continue
- # skip comment line
- if line[0] == '#': continue
- # skip invalid line
- if line[0] == '=':
- print "! invalid configuration:", line
- continue
-
- defStrings = line.split('=', 1)
- name = defStrings[0].strip()
- value = defStrings[1].strip()
- self[name] = value
-
- configFile.close()
-
- def __getitem__(self, attr):
- if attr not in self:
- return ""
-
- value = dict.__getitem__(self, attr)
- if value == None:
- value = ""
- return value
-
-class ToolConfig(dict):
- def __init__(self, file):
- """file (tools configuration file path)"""
- self.Targets = Set()
- self.Toolchains = Set()
- self.Archs = Set()
- self.ToolCodes = Set()
- self.Families = Set()
- self.Attributes = Set(["FAMILY", "NAME", "PATH", "FLAGS", "EXT", "DPATH", "SPATH", "LIBPATH", "INCLUDEPATH"])
-
- configFile = open(file)
- while True:
- line = configFile.readline()
- if line == "": break
-
- line = line.strip()
- # skip blank line
- if line == "": continue
- # skip comment line
- if line[0] == '#': continue
- # skip invalid line
- if line[0] == '=':
- print "! invalid definition:", line
- continue
-
- # split the definition at the first "="
- tool_def = line.split('=', 1)
- name = tool_def[0].strip()
- value = tool_def[1].strip()
-
- # the name of a tool definition must have five parts concatenated by "_"
- keys = name.split('_')
- # skip non-definition line
- if len(keys) < 5: continue
-
- keys = (keys[1], keys[0], keys[2], keys[3], keys[4])
- self[keys] = value
-
- ###############################################
- ## statistics
- ###############################################
- if keys[0] != '*': self.Toolchains.add(keys[0])
- if keys[1] != '*': self.Targets.add(keys[1])
- if keys[2] != '*': self.Archs.add(keys[2])
- if keys[3] != '*': self.ToolCodes.add(keys[3])
- if keys[4] == "FAMILY": self.Families.add(value)
- elif keys[4] == '*': raise Exception("No * allowed in ATTRIBUTE field")
-
- configFile.close()
- # expand the "*" in each field
- self.expand()
-
- def __getitem__(self, attrs):
- if len(attrs) != 5:
- return ""
-
- if attrs not in self:
- return ""
-
- value = dict.__getitem__(self, attrs)
- if value == None:
- value = ""
- return value
-
- def expand(self):
- summary = {}
- toolchains = []
- targets = []
- archs = []
- toolcodes = []
- for key in self:
- value = self[key]
- if key[0] == '*':
- toolchains = self.Toolchains
- else:
- toolchains = [key[0]]
-
- for toolchain in toolchains:
- if key[1] == '*':
- targets = self.Targets
- else:
- targets = [key[1]]
-
- for target in targets:
- if key[2] == '*':
- archs = self.Archs
- else:
- archs = [key[2]]
-
- for arch in archs:
- if key[3] == '*':
- toolcodes = self.ToolCodes
- else:
- toolcodes = [key[3]]
-
- for toolcode in toolcodes:
- attribute = key[4]
- summary[(toolchain, target, arch, toolcode, attribute)] = value
- self.clear()
- for toolchain in self.Toolchains:
- for target in self.Targets:
- for arch in self.Archs:
- for toolcode in self.ToolCodes:
- key = (toolchain, target, arch, toolcode, "NAME")
- if key not in summary: continue
- for attr in self.Attributes:
- key = (toolchain, target, arch, toolcode, attr)
- if key not in summary: continue
- self[key] = summary[key]
-
-
- def __str__(self):
- s = ""
- for entry in self:
- s += entry[0] + "_" + entry[1] + "_" + entry[2] + "_" + entry[3] + "_" + entry[4]
- s += " = " + self[entry] + "\n"
- return s
-
-class TargetConfig(Config):
- pass
-
-## for test
-if __name__ == "__main__":
- import os
- if "WORKSPACE" not in os.environ:
- raise "No WORKSPACE given"
- cfg = ToolConfig(os.path.join(os.environ["WORKSPACE"], "Tools", "Conf", "tools_def.txt"))
- tgt = TargetConfig(os.path.join(os.environ["WORKSPACE"], "Tools", "Conf", "target.txt"))
-
- for key in cfg:
- print key,"=",cfg[key]
-
- print
- for name in tgt:
- print name,"=",tgt[name]
-
\ No newline at end of file diff --git a/Tools/Python/buildgen/BuildFile.py b/Tools/Python/buildgen/BuildFile.py deleted file mode 100644 index 9a2aae30b2..0000000000 --- a/Tools/Python/buildgen/BuildFile.py +++ /dev/null @@ -1,582 +0,0 @@ -#!/usr/bin/env python
-
-# Copyright (c) 2007, Intel Corporation
-# All rights reserved. This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-"""Generate build file for given platform"""
-
-import os, sys, copy
-import xml.dom.minidom, pprint
-import FrameworkElement
-
-from SurfaceAreaElement import *
-from XmlRoutines import *
-from AntTasks import *
-from sets import Set
-
-class BuildFile:
- def __init__(self, workspace, platform, toolchain, target):
- if workspace == None or workspace == "":
- raise Exception("No workspace, no build")
- if platform == None or platform == "":
- raise Exception("No platform, no build")
- if toolchain == None or toolchain == "":
- raise Exception("No toolchain, no build")
- if target == None or target == "":
- raise Exception("No target, no build")
-
- self.Workspace = workspace
- self.Platform = platform
- self.Toolchain = toolchain
- self.Target = target
- self.Path = ""
-
- def Generate(self):
- """Generate the build file"""
- pass
-
-# generating build.xml for platform
-class AntPlatformBuildFile(BuildFile):
- def __init__(self, workspace, platform, toolchain, target):
- BuildFile.__init__(self, workspace, platform, toolchain, target)
- # Form the build file path, hard-coded at present. It should be specified by a configuration file
- self.Path = os.path.join(self.Workspace.Path, self.Platform.OutputPath, target + "_" + toolchain, "build.xml")
- print ""
- # Generate a common build option property file in the format of Java's property file
- self.DefaultBuildOptions()
-
- # new a build file object
- self.BuildXml = AntBuildFile(name="platform", basedir=".", default="all")
-
- # generate the top level properties, tasks, etc.
- self.Header()
-
- # generate "prebuild" target
- self.PreBuild()
-
- # generate "libraries" target for building library modules
- self.Libraries()
-
- # generate "modules" target for building non-library modules
- self.Modules()
-
- # generate "fvs" target for building firmware volume. (not supported yet)
-
- # generate "fds" target for building FlashDevice. (not supported yet)
-
- # generate "postbuild" target
- self.PostBuild()
-
- def Generate(self):
- print "Generating platform build file ...", self.Path
- self.BuildXml.Create(self.Path)
-
- def Header(self):
- _topLevel = self.BuildXml
- # import external tasks
- _topLevel.SubTask("taskdef", resource="GenBuild.tasks")
- _topLevel.SubTask("taskdef", resource="frameworktasks.tasks")
- _topLevel.SubTask("taskdef", resource="net/sf/antcontrib/antlib.xml")
-
- # platform wide properties
- _topLevel.Blankline()
- _topLevel.Comment("WORKSPACE wide attributes")
- _topLevel.SubTask("property", environment="env")
- _topLevel.SubTask("property", name="WORKSPACE_DIR", value="${env.WORKSPACE}")
- _topLevel.SubTask("property", name="CONFIG_DIR", value="${WORKSPACE_DIR}/Tools/Conf")
-
- _topLevel.Blankline()
- _topLevel.Comment("Common build attributes")
- _topLevel.SubTask("property", name="THREAD_COUNT", value=self.Workspace.ThreadCount)
- _topLevel.SubTask("property", name="SINGLE_MODULE_BUILD", value="no")
- _topLevel.SubTask("property", name="MODULE_BUILD_TARGET", value="platform_module_build")
-
- _topLevel.Blankline()
- _topLevel.SubTask("property", name="TOOLCHAIN", value=self.Toolchain)
- _topLevel.SubTask("property", name="TARGET", value=self.Target)
-
- _topLevel.Blankline()
- _topLevel.Comment("Platform attributes")
- _topLevel.SubTask("property", name="PLATFORM", value=self.Platform.Name)
- _topLevel.SubTask("property", name="PLATFORM_GUID", value=self.Platform.GuidValue)
- _topLevel.SubTask("property", name="PLATFORM_VERSION", value=self.Platform.Version)
- _topLevel.SubTask("property", name="PLATFORM_RELATIVE_DIR", value=self.Platform.Dir)
- _topLevel.SubTask("property", name="PLATFORM_DIR", value="${WORKSPACE_DIR}/${PLATFORM_RELATIVE_DIR}")
- _topLevel.SubTask("property", name="PLATFORM_OUTPUT_DIR", value=self.Platform.OutputPath)
-
- # user configurable build path for platform
- _topLevel.Blankline()
- _topLevel.Comment("Common path definition for platform build")
- _topLevel.SubTask("property", file="${WORKSPACE_DIR}/Tools/Python/buildgen/platform_build_path.txt")
-
- # common build tasks in the form of Ant macro
- _topLevel.Blankline()
- _topLevel.Comment("Task Macros for Compiling, Assembling, Linking, etc.")
- _topLevel.SubTask("import", file="${CONFIG_DIR}/BuildMacro.xml")
- _topLevel.Blankline()
- _topLevel.SubTask("echo", message="${PLATFORM}-${PLATFORM_VERSION} (${PLATFORM_RELATIVE_DIR})", level="info")
-
- # define the targets execution sequence
- _topLevel.Blankline()
- _topLevel.Comment("Default target")
- _topLevel.SubTask("target", name="all", depends="prebuild, libraries, modules, postbuild")
-
- def PreBuild(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: prebuild ")
-
- # prebuild is defined by user in the fpd file through <UserExtionsion> element,
- # which has attribute "identifier=0" or "identifier=prebuild"
- prebuildTasks = []
- if self.Platform.UserExtensions.has_key("0"):
- prebuildTasks = self.Platform.UserExtensions["0"]
- elif self.Platform.UserExtensions.has_key("postbuild"):
- prebuildTasks = self.Platform.UserExtensions["prebuild"]
-
- _topLevel.SubTask("target", prebuildTasks, name="prebuild")
-
- def Libraries(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: libraries ")
-
- librariesTarget = _topLevel.SubTask("target", name="libraries")
- parallelBuild = librariesTarget.SubTask("parallel", threadCount="${THREAD_COUNT}")
-
- libraryNumber = 0
- for arch in self.Platform.Libraries:
- libraryNumber += len(self.Platform.Libraries[arch])
- libraryIndex = 0
- for arch in self.Platform.Libraries:
- for lib in self.Platform.Libraries[arch]:
- libraryIndex += 1
- print "Generating library build files ... %d%%\r" % int((float(libraryIndex) / float(libraryNumber)) * 100),
- buildFile = AntModuleBuildFile(self.Workspace, self.Platform, lib, self.Toolchain, self.Target, arch)
- buildFile.Generate()
- buildDir = os.path.join("${TARGET_DIR}", arch, lib.Module.Package.SubPath(lib.Module.Dir),
- lib.Module.FileBaseName)
- parallelBuild.SubTask("ant", dir=buildDir,
- #antfile="build.xml",
- inheritAll="true",
- target="${MODULE_BUILD_TARGET}")
- print ""
-
- def Modules(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: modules ")
-
- modulesTarget = _topLevel.SubTask("target", name="modules")
- parallelBuild = modulesTarget.SubTask("parallel", threadCount="${THREAD_COUNT}")
-
- moduleNumber = 0
- for arch in self.Platform.Modules:
- moduleNumber += len(self.Platform.Modules[arch])
-
- moduleIndex = 0
- for arch in self.Platform.Modules:
- for module in self.Platform.Modules[arch]:
- moduleIndex += 1
- print "Generating module build files ... %d%%\r" % int((float(moduleIndex) / float(moduleNumber)) * 100),
-
- buildDir = os.path.join("${TARGET_DIR}", arch, module.Module.Package.SubPath(module.Module.Dir),
- module.Module.FileBaseName)
- parallelBuild.SubTask("ant", dir=buildDir,
- #antfile="build.xml",
- inheritAll="true",
- target="${MODULE_BUILD_TARGET}")
- buildFile = AntModuleBuildFile(self.Workspace, self.Platform, module, self.Toolchain, self.Target, arch)
- buildFile.Generate()
- print ""
-
- def Fvs(self):
- pass
-
- def Fds(self):
- pass
-
- def PostBuild(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: postbuild ")
-
- # postbuild is defined by user in the fpd file through <UserExtionsion> element,
- # which has attribute "identifier=1" or "identifier=postbuild"
- postbuildTasks = []
- if self.Platform.UserExtensions.has_key("1"):
- postbuildTasks = self.Platform.UserExtensions["1"]
- elif self.Platform.UserExtensions.has_key("postbuild"):
- postbuildTasks = self.Platform.UserExtensions["postbuild"]
-
- _topLevel.SubTask("target", postbuildTasks, name="postbuild")
-
- def Clean(self):
- pass
-
- def CleanAll(self):
- pass
-
- def UserExtensions(self):
- pass
-
- def DefaultBuildOptions(self):
- """Generate ${ARCH}_build.opt which contains the default build&tool definitions"""
- tools = self.Workspace.ToolConfig.ToolCodes
- for arch in self.Workspace.ActiveArchs:
- validTools = []
- for tool in tools:
- key = (self.Toolchain, self.Target, arch, tool, "NAME")
- if self.Workspace.ToolConfig[key] == "": continue
- validTools.append(tool)
-
- optFileDir = os.path.join(self.Workspace.Path, self.Platform.OutputPath,
- self.Target + "_" + self.Toolchain)
- optFileName = arch + "_build.opt"
- if not os.path.exists(optFileDir): os.makedirs(optFileDir)
- f = open(os.path.join(optFileDir, optFileName), "w")
-
- for tool in validTools:
- key = (self.Toolchain, self.Target, arch, tool, "FLAGS")
- if key in self.Platform.BuildOptions:
- flag = self.Platform.BuildOptions[key]
- else:
- key = (self.Toolchain, self.Target, arch, tool, "FAMILY")
- family = self.Workspace.ToolConfig[key]
- key = (family, self.Target, arch, tool, "FLAGS")
- if key in self.Platform.BuildOptions:
- flag = self.Platform.BuildOptions[key]
- else:
- flag = ""
- f.write("PLATFORM_%s_FLAGS=%s\n" % (tool, flag))
- f.write("\n")
-
- for tool in validTools:
- key = (self.Toolchain, self.Target, arch, tool, "FLAGS")
- flag = self.Workspace.ToolConfig[key]
- f.write("DEFAULT_%s_FLAGS=%s\n" % (tool, flag))
-
- f.write("\n")
- for tool in validTools:
- for attr in self.Workspace.ToolConfig.Attributes:
- if attr == "FLAGS": continue
- key = (self.Toolchain, self.Target, arch, tool, attr)
- value = self.Workspace.ToolConfig[key]
- if attr == "NAME":
- path = self.Workspace.ToolConfig[(self.Toolchain, self.Target, arch, tool, "PATH")]
- f.write("%s=%s\n" % (tool, os.path.join(path, value)))
- else:
- f.write("%s_%s=%s\n" % (tool, attr, value))
- f.write("%s_FLAGS=${DEFAULT_%s_FLAGS} ${DEFAULT_MODULE_%s_FLAGS} ${PLATFORM_%s_FLAGS} ${MODULE_%s_FLAGS}\n" %
- (tool, tool, tool, tool, tool))
- f.write("\n")
-
- f.close()
-
-class AntModuleBuildFile(BuildFile):
- def __init__(self, workspace, platform, module, toolchain, target, arch):
- BuildFile.__init__(self, workspace, platform, toolchain, target)
- self.Module = module
- self.Arch = arch
- self.Path = os.path.join(self.Workspace.Path, self.Platform.OutputPath,
- target + "_" + toolchain, arch, self.Module.Module.Package.Dir,
- self.Module.Module.Dir, self.Module.Module.FileBaseName, "build.xml")
- self.BuildXml = AntBuildFile(self.Module.Module.Name)
-
- self.SourceFiles = self.GetSourceFiles()
-
- self.Header()
- self.PreBuild()
- self.Libraries()
- self.Sourcefiles()
- self.Sections()
- self.Ffs()
- self.PostBuild()
-
- def Generate(self):
- # print self.Path,"\r",
- self.BuildXml.Create(self.Path)
-
- def Header(self):
- _topLevel = self.BuildXml
- _topLevel.SubTask("taskdef", resource="frameworktasks.tasks")
- _topLevel.SubTask("taskdef", resource="cpptasks.tasks")
- _topLevel.SubTask("taskdef", resource="cpptasks.types")
- _topLevel.SubTask("taskdef", resource="net/sf/antcontrib/antlib.xml")
-
- _topLevel.Blankline()
- _topLevel.Comment(" TODO ")
- _topLevel.SubTask("property", environment="env")
- _topLevel.SubTask("property", name="WORKSPACE_DIR", value="${env.WORKSPACE}")
-
- _topLevel.Blankline()
- _topLevel.Comment("Common build attributes")
- _topLevel.SubTask("property", name="SINGLE_MODULE_BUILD", value="yes")
- _topLevel.SubTask("property", name="MODULE_BUILD_TARGET", value="single_module_build")
- _topLevel.SubTask("property", name="PLATFORM_PREBUILD", value="yes")
- _topLevel.SubTask("property", name="PLATFORM_POSTBUILD", value="no")
-
- _topLevel.Blankline()
- _topLevel.Comment(" TODO ")
- ifTask = _topLevel.SubTask("if")
- ifTask.SubTask("istrue", value="${SINGLE_MODULE_BUILD}")
- thenTask = ifTask.SubTask("then")
- platformBuildFile = os.path.join("${WORKSPACE_DIR}", self.Platform.OutputPath,
- self.Target + "_" + self.Toolchain, "build.xml")
- thenTask.SubTask("import", file=platformBuildFile)
-
- _topLevel.Blankline()
- _topLevel.SubTask("property", name="ARCH", value=self.Arch)
-
- module = self.Module.Module
- package = module.Package
- _topLevel.Blankline()
- _topLevel.SubTask("property", name="PACKAGE", value=package.Name)
- _topLevel.SubTask("property", name="PACKAGE_GUID", value=package.GuidValue)
- _topLevel.SubTask("property", name="PACKAGE_VERSION", value=package.Version)
- _topLevel.SubTask("property", name="PACKAGE_RELATIVE_DIR", value=package.Dir)
- _topLevel.SubTask("property", name="PACKAGE_DIR", value=os.path.join("${WORKSPACE_DIR}","${PACKAGE_RELATIVE_DIR}"))
-
- _topLevel.Blankline()
- _topLevel.SubTask("property", name="MODULE", value=module.Name)
- _topLevel.SubTask("property", name="MODULE_GUID", value=module.GuidValue)
- _topLevel.SubTask("property", name="MODULE_VERSION", value=module.Version)
- _topLevel.SubTask("property", name="MODULE_TYPE", value=module.Type)
- _topLevel.SubTask("property", name="MODULE_FILE_BASE_NAME", value=module.FileBaseName)
- _topLevel.SubTask("property", name="MODULE_RELATIVE_DIR", value=module.Dir)
- _topLevel.SubTask("property", name="MODULE_DIR", value=os.path.join("${PACKAGE_DIR}", "${MODULE_RELATIVE_DIR}"))
- _topLevel.SubTask("property", name="BASE_NAME", value=module.BaseName)
-
- _topLevel.Blankline()
- _topLevel.SubTask("property", file="${WORKSPACE_DIR}/Tools/Python/buildgen/module_build_path.txt")
-
- self._BuildOption()
-
- _topLevel.Blankline()
- _topLevel.SubTask("property", name="ENTRYPOINT", value="_ModuleEntryPoint")
-
- _topLevel.SubTask("property", name="SOURCE_FILES", value="\n ".join(self._GetSourceFileList()))
- _topLevel.SubTask("property", name="LIBS", value="\n ".join(self._GetLibList()))
-
- _topLevel.Blankline()
- _topLevel.SubTask("property", file="${PLATFORM_BUILD_DIR}/%s_build.opt" % self.Arch)
- _topLevel.Blankline()
- _topLevel.SubTask("echo", message="${MODULE}-${MODULE_VERSION} [${ARCH}] from package ${PACKAGE}-${PACKAGE_VERSION} (${MODULE_RELATIVE_DIR})", level="info")
-
- _topLevel.Blankline()
- _topLevel.Comment("Default target")
- _topLevel.SubTask("target", name="all", depends="single_module_build")
- _topLevel.SubTask("target", name="platform_module_build", depends="prebuild, sourcefiles, sections, output, postbuild")
- _topLevel.SubTask("target", name="single_module_build", depends="prebuild, libraries, sourcefiles, sections, output, postbuild")
-
- def _BuildOption(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- baseModule = self.Module.Module
- tools = self.Workspace.ToolConfig.ToolCodes
-
- for tool in tools:
- key = (self.Toolchain, self.Target, self.Arch, tool, "FLAGS")
- flag = ""
- if key in baseModule.BuildOptions:
- flag = baseModule.BuildOptions[key]
- _topLevel.SubTask("property", name="DEFAULT_MODULE_%s_FLAGS" % tool, value=flag)
-
- _topLevel.Blankline()
- for tool in tools:
- key = (self.Toolchain, self.Target, self.Arch, tool, "FLAGS")
- flag = ""
- if key in self.Module.BuildOptions:
- flag = self.Module.BuildOptions[key]
- _topLevel.SubTask("property", name="MODULE_%s_FLAGS" % tool, value=flag)
-
- def PreBuild(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: prebuild ")
-
- prebuildTasks = []
- module = self.Module.Module
- if module.UserExtensions.has_key("0"):
- prebuildTasks = module.UserExtensions["0"]
- elif module.UserExtensions.has_key("postbuild"):
- prebuildTasks = module.UserExtensions["prebuild"]
-
- _topLevel.SubTask("target", prebuildTasks, name="prebuild")
-
-
- def Libraries(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: libraries ")
-
- librariesTarget = _topLevel.SubTask("target", name="libraries")
- parallelBuild = librariesTarget.SubTask("parallel", threadCount="${THREAD_COUNT}")
- for lib in self.Module.Libraries:
- module = lib.Module
- buildDir = os.path.join("${BIN_DIR}", module.Package.SubPath(module.Dir), module.FileBaseName)
- libTask = parallelBuild.SubTask("ant", dir=buildDir,
- inheritAll="false",
- target="${MODULE_BUILD_TARGET}")
- libTask.SubTask("property", name="PLATFORM_PREBUILD", value="false")
- libTask.SubTask("property", name="PLATFORM_POSTBUILD", value="false")
-
- def Sourcefiles(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: sourcefiles ")
- _sourcefilesTarget = _topLevel.SubTask("target", name="sourcefiles")
-
- _incTask = AntTask(self.BuildXml.Document, "EXTRA.INC")
- _incTask.SubTask("includepath", path="${WORKSPACE_DIR}")
- _incTask.SubTask("includepath", path="${MODULE_DIR}")
- _incTask.SubTask("includepath", path=os.path.join("${MODULE_DIR}", self.Arch.capitalize()))
- _incTask.SubTask("includepath", path="${DEST_DIR_DEBUG}")
- if self.Arch in self.Module.Module.IncludePaths:
- for inc in self.Module.Module.IncludePaths[self.Arch]:
- _incTask.SubTask("includepath", path=os.path.join("${WORKSPACE_DIR}", inc))
-
- # init
- if not self.Module.Module.IsBinary:
- _buildTask = _sourcefilesTarget.SubTask("Build_Init")
- _buildTask.AddSubTask(_incTask)
-
- # AutoGen firt
- _buildTask = _sourcefilesTarget.SubTask("Build_AUTOGEN", FILEEXT="c", FILENAME="AutoGen", FILEPATH=".")
- _buildTask.AddSubTask(_incTask)
-
- # uni file follows
- type = "UNI"
- if type in self.SourceFiles:
- for srcpath in self.SourceFiles[type]:
- taskName = "Build_" + type
- fileDir = os.path.dirname(srcpath)
- if fileDir == "": fileDir = "."
- fileBaseName,fileExt = os.path.basename(srcpath).rsplit(".", 1)
- _buildTask = _sourcefilesTarget.SubTask(taskName, FILENAME=fileBaseName, FILEEXT=fileExt, FILEPATH=fileDir)
- _buildTask.AddSubTask(_incTask)
-
- # others: c, vfr, ...
- for type in self.SourceFiles:
- if type == "Unicode": continue
- for srcpath in self.SourceFiles[type]:
- taskName = "Build_" + type
- fileDir = os.path.dirname(srcpath)
- if fileDir == "": fileDir = "."
- fileBaseName,fileExt = os.path.basename(srcpath).rsplit(".", 1)
- _buildTask = _sourcefilesTarget.SubTask(taskName, FILENAME=fileBaseName, FILEEXT=fileExt, FILEPATH=fileDir)
- _buildTask.AddSubTask(_incTask)
-
- def Sections(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: sections ")
- _sectionsTarget = _topLevel.SubTask("target", name="sections")
-
- def Ffs(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: output ")
- _sectionsTarget = _topLevel.SubTask("target", name="output")
-
- def PostBuild(self):
- _topLevel = self.BuildXml
- _topLevel.Blankline()
- _topLevel.Comment(" TARGET: postbuild ")
-
- postbuildTasks = []
- module = self.Module.Module
- if module.UserExtensions.has_key("1"):
- postbuildTasks = module.UserExtensions["1"]
- elif module.UserExtensions.has_key("postbuild"):
- postbuildTasks = module.UserExtensions["postbuild"]
-
- _topLevel.SubTask("target", postbuildTasks, name="postbuild")
-
- def Clean(self):
- pass
-
- def CleanAll(self):
- pass
-
- def UserExtensions(self):
- pass
-
- def GetSourceFiles(self):
- ## check arch, toolchain, family, toolcode, ext
- ## if the arch of source file supports active arch
- ## if the toolchain of source file supports active toolchain
- ## if the toolchain family of source file supports active toolchain family
- ## if the ext of the source file is supported by the toolcode
- module = self.Module.Module
- files = {} # file type -> src
- for type in module.SourceFiles[self.Arch]:
- if not module.IsBuildable(type):
- # print type,"is not buildable"
- continue
-
- if type not in files:
- files[type] = []
- for src in module.SourceFiles[self.Arch][type]:
- if self.Toolchain not in src.Toolchains:
- # print self.Toolchain,"not in ",src.Toolchains
- continue
- if not self.IsCompatible(src.Families, self.Workspace.ActiveFamilies):
- # print src.Families,"not compatible with",self.Workspace.ActiveFamilies
- continue
- toolcode = src.GetToolCode(src.Type)
- if toolcode != "":
- ext = self.Workspace.GetToolDef(self.Toolchain, self.Target, self.Arch, toolcode, "EXT")
- if ext != "" and ext != src.Ext:
- # print ext,"in tools_def.txt is not the same as",src.Ext
- continue
- ## fileFullPath = os.path.join("${MODULE_DIR}", )
- ## print fileFullPath
- files[type].append(src.Path)
-
- return files
-
- def Intersection(self, list1, list2):
- return list(Set(list1) & Set(list2))
-
- def IsCompatible(self, list1, list2):
- return len(self.Intersection(list1, list2)) > 0
-
- def _GetLibList(self):
- libList = []
- for lib in self.Module.Libraries:
- module = lib.Module
- libList.append(os.path.join("${BIN_DIR}", module.Name + ".lib"))
- return libList
-
- def _GetSourceFileList(self):
- srcList = []
- for type in self.SourceFiles:
- srcList.extend(self.SourceFiles[type])
- return srcList
-
-class NmakeFile(BuildFile):
- pass
-
-class GmakeFile(BuildFile):
- pass
-
-# for test
-if __name__ == "__main__":
- workspacePath = os.getenv("WORKSPACE", os.getcwd())
- startTime = time.clock()
- ws = Workspace(workspacePath, [], [])
-
- # generate build.xml
- ap = ws.ActivePlatform
- for target in ws.ActiveTargets:
- ant = AntPlatformBuildFile(ws, ap, ws.ActiveToolchain, target)
- ant.Generate()
-
- print "\n[Finished in %fs]" % (time.clock() - startTime)
diff --git a/Tools/Python/buildgen/FrameworkElement.py b/Tools/Python/buildgen/FrameworkElement.py deleted file mode 100644 index 3be8eaae57..0000000000 --- a/Tools/Python/buildgen/FrameworkElement.py +++ /dev/null @@ -1,523 +0,0 @@ -#!/usr/bin/env python
-
-# Copyright (c) 2007, Intel Corporation
-# All rights reserved. This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-"""Framework Element Classes
-
-TODO
-"""
-
-################################################################################
-##
-## Element class: base class for representing framework elements
-##
-################################################################################
-class Element:
- def __init__(self, **kwargs):
- """(Name, GuidValue, Version, Path, Dir, Archs, Usage, Features, Signature)"""
- ## The path and directory where the information of the element comes from
- self.Path = "."
- self.Dir = "."
-
- ## Element name, guid and version
- self.Name = ""
- self.GuidValue = ""
- self.Version = ""
-
- ## The element supported architecture
- self.Archs = []
-
- ## Indiciate how the element is used
- self.Usage = "ALWAYS_CONSUMED"
-
- ## Indicate what kind of features this element is bound
- self.Features = []
-
- ## Element signature, used to check the its integerity
- self.Signature = 0
-
- def __str__(self):
- return self.Name + "-" + self.Version + " " + " [" + self.GuidValue + "]"
-
- def __eq__(self, other):
- if not isinstance(other, Element):
- return False
-
- if self.GuidValue != other.GuidValue:
- return False
-
- if self.Version != other.Version:
- return False
-
- return True
-
- def __hash__(self):
- return hash(self.GuidValue + self.Version)
-
-################################################################################
-##
-## ToolOption: build tool option
-##
-################################################################################
-class ToolOption(Element):
-
- def __init__(self, **kwargs):
- """Prefix, Value, Tool, Toolchains, Families, Targets"""
- Element.__init__(self)
-
- self.Prefix = "/"
- self.Value = ""
- self.Tool = ""
- self.Toolchains = ""
- self.Families = "MSFT"
- self.Targets = "DEBUG"
-
-################################################################################
-##
-## BuildTool: build tool
-##
-################################################################################
-class BuildTool(Element):
- def __init__(self, **kwargs):
- """Options, Toolchains, Families, Targets"""
- Element.__init__(self)
-
- self.Options = []
- self.Toolchains = []
- self.Families = []
- self.Targets = []
-
-################################################################################
-##
-## SourceFile: files in a module for build
-##
-################################################################################
-class SourceFile(Element):
- def __init__(self, **kwargs):
- """BaseName, Ext, Type, Toolchains, Families, Targets"""
- Element.__init__(self)
-
- self.BaseName = ""
- self.Ext = ""
- self.Type = ""
- self.Toolchains = []
- self.Families = []
- self.Targets = []
-
-################################################################################
-##
-## IncludeFile: header file
-##
-################################################################################
-class IncludeFile(SourceFile):
- def __init__(self, **kwargs):
- """Type, Package, ModuleType"""
- SourceFile.__init__(self)
-
- self.Type = "HeaderFile"
- self.Package = ""
- self.ModuleType = ""
-
-################################################################################
-##
-## IncludePath:
-##
-################################################################################
-class IncludePath(IncludeFile):
- pass
-
-################################################################################
-##
-## LibraryInterface: library class interface
-##
-################################################################################
-class LibraryInterface(Element):
- def __init__(self, **kwargs):
- """Package, FavoriteInstance, Instances, ModuleTypes, Consumers"""
- Element.__init__(self)
-
- self.Package = ""
- self.FavoriteInstance = ""
- self.Instances = []
- self.ModuleTypes = []
- self.Consumers = []
-
- def __eq__(self, other):
- if not isinstance(other, LibraryInterface):
- return False
- return self.Name == other.Name
-
- def __hash__(self):
- return hash(self.Name)
-
-################################################################################
-##
-## LibraryClass: library class
-##
-################################################################################
-class LibraryClass(Element):
- def __init__(self, **kwargs):
- """
- ()
- """
- Element.__init__(self)
-
- self.Interface = ""
- self.FavoriteInstance = ""
-
- def __eq__(self, other):
- if not isinstance(other, LibraryClass):
- return False
- return self.Name == other.Name
-
- def __hash__(self):
- return hash(self.Name)
-
-################################################################################
-##
-## Guid:
-##
-################################################################################
-class Guid(Element):
- def __init__(self, **kwargs):
- """CName, Types, ModuleTypes"""
- Element.__init__(self)
-
- self.CName = ""
- self.Types = []
- self.ModuleTypes= []
-
-################################################################################
-##
-## Protocol:
-##
-################################################################################
-class Protocol(Guid):
- pass
-
-################################################################################
-##
-## ProtocolNotify:
-##
-################################################################################
-class ProtocolNotify(Protocol):
- pass
-
-################################################################################
-##
-## Ppi:
-##
-################################################################################
-class Ppi(Guid):
- pass
-
-################################################################################
-##
-## PpiNotify:
-##
-################################################################################
-class PpiNotify(Ppi):
- pass
-
-################################################################################
-##
-## Extern:
-##
-################################################################################
-class Extern(Element):
- def __init__(self, **kwargs):
- """Specifications, ModuleEntryPoints, ModuleUnloadImages, Constructors, Destructors, DriverBindings, ComponentNames, DriverConfigs, DriverDiags, SetVirtualAddressMapCallBacks, ExitBootServicesCallBacks"""
- Element.__init__(self)
-
- self.Specifications = []
- self.ModuleEntryPoints = []
- self.ModuleUnloadImages = []
- self.Constructors = []
- self.Destructors = []
- self.DriverBindings = []
- self.ComponentNames = []
- self.DriverConfigs = []
- self.DriverDiags = []
- self.SetVirtualAddressMapCallBacks = []
- self.ExitBootServicesCallBacks = []
-
-################################################################################
-##
-## Sku:
-##
-################################################################################
-class Sku(Element):
- def __init__(self, **kwargs):
- """Id, Value"""
- Element.__init__(self)
-
- self.Id = 0
- self.Value = ""
-
-################################################################################
-##
-## Pcd:
-##
-################################################################################
-class Pcd(Element):
- def __init__(self, **kwargs):
- """Types, CName, Value, Token, TokenSpace, DatumType, Sku, ModuleTypes"""
- Element.__init__(self)
-
- self.Types = []
- self.CName = ""
- self.Value = ""
- self.Token = ""
- self.TokenSpace = ""
- self.DatumType = ""
- self.Default = ""
- self.Sku = ""
- self.ModuleTypes= []
-
-################################################################################
-##
-## Module: framework module
-##
-################################################################################
-class Module(Element):
- def __init__(self, **kwargs):
- """Workspace, Package, Type, BaseName, FileBaseName, IsLibrary, PcdIsDriver,
- NeedsFlashMap_h, SourceFiles, IncludePaths, IncludeFiles, NonProcessedFiles,
- LibraryClasses, Guids, Protocols, Ppis, Externs, Pcds,
- UserExtensions, BuildOptions, Environment
- """
- Element.__init__(self)
-
- self.Workspace = ""
- self.Package = ""
- self.Type = ""
- self.BaseName = ""
- self.FileBaseName = ""
- self.IsLibrary = False
- self.IsBinary = False
- self.PcdIsDriver = False
- self.NeedsFlashMap_h = False
- self.SourceFiles = {} # arch -> {file type -> [source file list]}
- self.IncludePaths = {} # arch -> [path list]
- self.IncludeFiles = {}
-
- self.NonProcessedFiles = []
- self.LibraryClasses = {} # arch -> [library class list]
-
- self.Guids = {} # arch -> [guid object list]
- self.Protocols = {} # arch -> []
- self.Ppis = {} # arch -> []
-
- self.Externs = {} # arch -> []
- self.Pcds = {} # arch -> []
-
- self.UserExtensions = {} # identifier -> ...
- self.BuildOptions = {} # (toolchain, target, arch, toolcode, "FLAGS") -> flag
- self.Environment = {}
-
- def __eq__(self, other):
- if not isinstance(other, Module):
- return False
-
- if self.GuidValue != other.GuidValue:
- return False
-
- if self.Version != other.Version:
- return False
-
- if self.Package != other.Package:
- return False
-
- return True
-
- def __hash__(self):
- return hash(self.GuidValue + self.Version + hash(self.Package))
-
-################################################################################
-##
-## PlatformModule: module for build
-##
-################################################################################
-class PlatformModule(Element):
- def __init__(self, **kwargs):
- """Workspace, Platform, Module, Libraries, Pcds, FfsLayouts, FvBindings
- BuildOptions, BuildType, BuildFile, BuildPath, Sections, FfsFile, Environment
- """
- Element.__init__(self)
- self.Workspace = ""
- self.Platform = ""
- self.Module = ""
- self.Libraries = []
- self.Pcds = []
- self.FfsLayouts = []
- self.FvBindings = []
- self.BuildOptions = {}
-
- self.BuildType = "efi" ## efi or lib
- self.BuildFile = "build.xml"
- self.BuildPath = "${MODULE_BUILD_DIR}"
- self.Sections = []
- self.FfsFile = ""
-
- self.Environment = {} # name/value pairs
-
- def __eq__(self, other):
- if not isinstance(other, PlatformModule):
- if not isinstance(other, Module):
- return False
- elif self.Module != other:
- return False
- elif self.Module != other.Module:
- return False
-
- return True
-
- def __hash__(self):
- return hash(self.Module)
-
-################################################################################
-##
-## Package: framework package
-##
-################################################################################
-class Package(Element):
- def __init__(self, **kwargs):
- """Workspace, ReadOnly, Repackage, Modules, PackageIncludes, StandardIncludes,
- LibraryInterfaces, Guids, Protocols, Ppis, Pcds, Environment
- """
- Element.__init__(self)
-
- self.Workspace = ""
- self.ReadOnly = True
- self.Repackage = True
- self.Modules = []
- self.PackageIncludes = {} # module type -> [include file list]
- self.StandardIncludes = []
- self.LibraryInterfaces = {} # class name -> include file
- self.Guids = {} # cname -> guid object
- self.Protocols = {} # cname -> protocol object
- self.Ppis = {} # cname -> ppi object
- self.Pcds = {} # token -> pcd object
-
- self.Environment = {}
-
-################################################################################
-##
-## PackageDependency:
-##
-################################################################################
-class PackageDependency(Element):
- def __init__(self, **kwargs):
- """Package"""
- Element.__init__(self)
-
- self.Package = ""
-
-################################################################################
-##
-## Platform:
-##
-################################################################################
-class Platform(Element):
- def __init__(self, **kwargs):
- """Targets, OutputPath, Images, Modules, DynamicPcds, Fvs, Libraries
- BuildFile, BuildPath, BuildOptions, UserExtensions
- """
- Element.__init__(self)
-
- self.Targets = []
- self.OutputPath = ""
- self.Images = []
- self.Modules = {} # arch -> [module list]
- self.DynamicPcds = []
- self.FfsLayouts = {}
- self.Fvs = {}
-
- self.Libraries = {} # arch -> [library instance]
- self.BuildFile = "build.xml"
- self.BuildPath = "${PLATFORM_BUILD_DIR}"
- self.BuildOptions = {}
- self.UserExtensions = {}
-
- self.Environment = {} # name/value pairs
-
-################################################################################
-##
-## Workspace:
-##
-################################################################################
-class Workspace(Element):
- def __init__(self, **kwargs):
- """Packages, Platforms, Fars, Modules, PlatformIndex, PackageIndex"""
- Element.__init__(self)
-
- self.Packages = []
- self.Platforms = []
- self.Fars = []
- self.Modules = []
-
- ## "GUID" : {guid : {version : platform}}
- ## "PATH" : {path : platform}
- ## "NAME" : {name : [platform]}
- self.PlatformXref = {
- "GUID" : {},
- "PATH" : {},
- "NAME" : {},
- }
- ## "GUID" : {guid : {version : package}}
- ## "PATH" : {path : package}
- ## "NAME" : {name : package}
- self.PackageXref = {
- "GUID" : {},
- "PATH" : {},
- "NAME" : {},
- }
- ## "GUID" : {guid : {version : [module]}}
- ## "PATH" : {path : module}
- ## "NAME" : {name : module}
- self.ModuleXref = {
- "GUID" : {},
- "PATH" : {},
- "NAME" : {},
- }
- ## "NAME" : {name : [library interface]}
- ## "PATH" : {path : library interface}
- self.LibraryInterfaceXref = {
- "PATH" : {},
- "NAME" : {},
- }
- ## TODO
- self.FarIndex = {}
-
- # from target.txt
- self.TargetConfig = {}
- # from tools_def.txt
- self.ToolConfig = {}
-
- self.ActivePlatform = ""
- self.ActiveToolchain = ""
- self.ActiveFamilies = []
- self.ActiveModules = []
- self.ActiveTargets = []
- self.ActiveArchs = []
-
- self.IndividualModuleBuild = False
- self.MultiThreadBuild = False
- self.ThreadCount = "2"
-
- self.Environment = {}
-
-################################################################################
-##
-## For test:
-##
-################################################################################
-if __name__ == "__main__":
- pass
diff --git a/Tools/Python/buildgen/SurfaceAreaElement.py b/Tools/Python/buildgen/SurfaceAreaElement.py deleted file mode 100644 index ec84582b11..0000000000 --- a/Tools/Python/buildgen/SurfaceAreaElement.py +++ /dev/null @@ -1,1555 +0,0 @@ -#!/usr/bin/env python
-
-# Copyright (c) 2007, Intel Corporation
-# All rights reserved. This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-"""Framework SurfaceArea Elemments"""
-#
-# TODO: FFS layout, Flash, FV, PCD
-#
-import os, sys, re, getopt, string, glob, xml.dom.minidom, pprint, time, copy, shelve, pickle
-from XmlRoutines import *
-import FrameworkElement
-import BuildConfig
-
-################################################################################
-##
-## Convert given list to a string in the format like: [a, b, c]
-##
-################################################################################
-def ListString(lst):
- return "[%s]" % ",".join(lst)
-
-class SurfaceAreaElement:
- """Base class for Surface Area XML element"""
- _ModuleTypes = ('BASE', 'SEC', 'PEI_CORE', 'PEIM', 'DXE_CORE', 'DXE_DRIVER',
- 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'DXE_SMM_DRIVER',
- 'TOOL', 'UEFI_DRIVER', 'UEFI_APPLICATION', 'USER_DEFINED')
- _GuidTypes = ('DATA_HUB_RECORD', 'EFI_EVENT', 'EFI_SYSTEM_CONFIGURATION_TABLE',
- 'EFI_VARIABLE', 'GUID', 'HII_PACKAGE_LIST', 'HOB', 'TOKEN_SPACE_GUID')
- _Archs = ('EBC', 'IA32', 'X64', 'IPF', 'ARM', 'PPC')
- _Usages = ('ALWAYS_CONSUMED', 'SOMETIMES_CONSUMED', 'ALWAYS_PRODUCED',
- 'SOMETIMES_PRODUCED', 'TO_START', 'BY_START', 'PRIVATE')
- _FileTypes = {
- ".c" : "CCode",
- ".C" : "CCode",
- ".cpp" : "CCode",
- ".Cpp" : "CCode",
- ".CPP" : "CCode",
- ".h" : "CHeader",
- ".H" : "CHeader",
- ".asm" : "ASM",
- ".Asm" : "Assembly",
- ".ASM" : "Assembly",
- ".s" : "IpfAssembly",
- ".S" : "GccAssembly",
- ".uni" : "UNI",
- ".Uni" : "Unicode",
- ".UNI" : "Unicode",
- ".vfr" : "VFR",
- ".Vfr" : "VFR",
- ".VFR" : "VFR",
- ".dxs" : "DPX",
- ".Dxs" : "DPX",
- ".DXS" : "DPX",
- ".fv" : "FirmwareVolume",
- ".Fv" : "FirmwareVolume",
- ".FV" : "FirmwareVolume",
- ".efi" : "EFI",
- ".Efi" : "EFI",
- ".EFI" : "EFI",
- ".SEC" : "FFS",
- ".PEI" : "FFS",
- ".DXE" : "FFS",
- ".APP" : "FFS",
- ".FYI" : "FFS",
- ".FFS" : "FFS",
- ".bmp" : "BMP",
- ".i" : "PPCode",
- ".asl" : "ASL",
- ".Asl" : "ASL",
- ".ASL" : "ASL",
- }
- _ToolMapping = {
- "CCode" : "CC",
- "CHeader" : "",
- "ASM" : "ASM",
- "Assembly" : "ASM",
- "IpfAssembly" : "ASM",
- "GccAssembly" : "ASM",
- "UNI" : "",
- "Unicode" : "",
- "VFR" : "",
- "DPX" : "",
- "FirmwareVolume" : "",
- "EFI" : "",
- "FFS" : "",
- "PPCode" : "PP",
- "BMP" : "",
- }
-
- _BuildableFileTypes = ("CCode", "ASM", "Assembly", "IpfAssembly", "GccAssembly", "UNI", "Unicode", "VFR", "DPX", "EFI")
-
- def __init__(self, workspace, owner=None, dom=None, parse=True, postprocess=True):
- self._Workspace = workspace
-
- if owner == None: self._Owner = ""
- else: self._Owner = owner
-
- if dom == None: self._Root = ""
- else: self._Root = dom
-
- self._Elements = {}
-
- if parse: self.Parse()
- if postprocess: self.Postprocess()
-
- def Parse(self):
- """Parse the XML element in DOM form"""
- pass
-
- def Postprocess(self):
- """Re-organize the original information form XML DOM into a format which can be used directly"""
- pass
-
- def GetArchList(self, dom):
- """Parse the SupArchList attribute. If not spcified, return all ARCH supported"""
- archs = XmlAttribute(dom, "SupArchList").split()
- if archs == []:
- if self._Owner.Archs != []:
- archs = self._Owner.Archs
- elif self._Workspace.ActiveArchs != []:
- archs = self._Workspace.ActiveArchs
- elif self._Workspace.ActivePlatform != "" and self._Workspace.ActivePlatform.Archs != []:
- archs = self._Workspace.ActivePlatform.Archs
- else:
- archs = self._Archs
- return archs
-
- def GetModuleTypeList(self, dom):
- """Parse the SupModuleList attribute. If not specified, return all supported module types"""
- moduleTypes = XmlAttribute(dom, "SupModuleList").split()
- if moduleTypes == []:
- moduleTypes = self._ModuleTypes
- return moduleTypes
-
- def GetGuidTypeList(self, dom):
- """Parse GuidTypeList attribute. Default to GUID if not specified"""
- guidTypes = XmlAttribute(dom, "GuidTypeList")
- if guidTypes == []:
- guidTypes = ["GUID"]
- return guidTypes
-
- def GetFeatureList(self, dom):
- """Parse FeatureFlag attribute"""
- return XmlAttribute(dom, "FeatureFlag").split()
-
- def GetToolchainTagList(self, dom):
- """Parse TagName attribute. Return all defined toolchains defined in tools_def.txt if not given"""
- toolchainTagString = XmlAttribute(dom, "TagName")
- if toolchainTagString == "":
- return self._Workspace.ToolConfig.Toolchains
- return toolchainTagString.split()
-
- def GetToolchainFamilyList(self, dom):
- """Parse ToolChainFamily attribute. Return all defined toolchain families in tools_def.txt if not given"""
- familyString = XmlAttribute(dom, "ToolChainFamily")
- if familyString != "":
- return familyString.split()
- return self._Workspace.ToolConfig.Families
-
- def GetTargetList(self, dom):
- """Parse BuildTargets attribute. Return all build targets defined in tools_def.txt if not given"""
- targetList = XmlAttribute(dom, "BuildTargets").split()
- if targetList == []:
- targetList = self._Workspace.ToolConfig.Targets
- return targetList
-
- def GetUsage(self, dom):
- """Parse Usage attribute. Default to ALWAYS_CONSUMED if not given"""
- usageString = XmlAttribute(dom, "Usage")
- if usageString == "":
- return "ALWAYS_CONSUMED"
- return usageString
-
- def GetBuildOptionList(self, dom):
- """Parse Options/Option element. Return a options dictionay with keys as (toolchain, target, arch, toolcode, attr)"""
- optionList = XmlList(dom, "/Options/Option")
- buildOptions = {}
- for option in optionList:
- targets = self.GetTargetList(option)
- toolchainFamilies = self.GetToolchainFamilyList(option)
- toolchainTags = self.GetToolchainTagList(option)
- toolcode = XmlAttribute(option, "ToolCode")
- archs = self.GetArchList(option)
- flag = XmlElementData(option)
- # print flag
-
- toolchains = []
- if toolchainTags != []:
- toolchains = toolchainTags
- elif toolchainFamilies != []:
- toolchains = toolchainFamilies
- else:
- raise Exception("No toolchain specified for a build option: " + self._Owner.Name)
-
- if targets == []: targets = self._Workspace.ActiveTargets
- if archs == []: archs = self._Workspace.ActiveArchs
-
- for toolchain in toolchains:
- for target in targets:
- for arch in archs:
- buildOptions[(toolchain, target, arch, toolcode, "FLAGS")] = flag
- return buildOptions
-
- def GetFvBindingList(self, dom):
- """Parse FvBinding element. If not specified, return NULL FV"""
- fvBindingList = XmlElementData(dom).split()
- if fvBindingList == []:
- fvBindingList = ["NULL"]
- return fvBindingList
-
- def IsBuildable(self, type):
- """Test if a file with the type can be built by a tool"""
- return type in self._BuildableFileTypes
-
- def GetToolCode(self, type):
- """Get the toolcode which must be used to build files with the type"""
- toolcode = ""
- if type in self._ToolMapping:
- toolcode = self._ToolMapping[type]
- return toolcode
-
- def GetBoolean(self, dom):
- """Transate true/false in string form to python's True/False value"""
- boolString = XmlElementData(dom).upper()
- if boolString == "" or boolString == "FALSE" or boolString == "NO":
- return False
- else:
- return True
-
-class LibraryDeclaration(FrameworkElement.LibraryInterface, SurfaceAreaElement):
- def __init__(self, workspace, package, dom):
- FrameworkElement.LibraryInterface.__init__(self)
- self.Package = package
- SurfaceAreaElement.__init__(self, workspace, package, dom)
-
- def Parse(self):
- dom = self._Root
- self.Name = XmlAttribute(dom, "Name")
- self.Path = os.path.normpath(XmlElementData(XmlNode(dom, "/LibraryClass/IncludeHeader")))
- self.Dir = os.path.dirname(self.Path)
-
- attribute = XmlAttribute(dom, "RecommendedInstanceGuid")
- if attribute is not '':
- self.FavoriteIntance = FrameworkElement.Module()
- self.FavoriteIntance.Guid = attribute
-
- attribute = XmlAttribute(dom, "RecommendedInstanceVersion")
- if attribute is not '':
- if self.FavoriteIntance == "":
- raise "No GUID for the recommened library instance"
- self.FavoriteIntance.Version = attribute
-
- self.Archs = self.GetArchList(dom)
- self.ModuleTypes = self.GetModuleTypeList(dom)
-
-class LibraryClass(FrameworkElement.LibraryClass, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.LibraryClass.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
-
- self.Name = XmlElementData(XmlNode(dom, "/LibraryClass/Keyword"))
- self.Usage = self.GetUsage(dom)
- self.Features = self.GetFeatureList(dom)
- self.Archs = self.GetArchList(dom)
-
- attribute = XmlAttribute(dom, "RecommendedInstanceGuid")
- if attribute is not '':
- self.FavoriteIntance = FrameworkElement.Module()
- self.FavoriteIntance.Guid = attribute
-
- attribute = XmlAttribute(dom, "RecommendedInstanceVersion")
- if attribute is not '':
- if self.FavoriteIntance == "":
- self.FavoriteIntance = FrameworkElement.Module()
- self.FavoriteIntance.Version = attribute
-
-class SourceFile(FrameworkElement.SourceFile, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.SourceFile.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
- self.Path = os.path.normpath(XmlElementData(dom))
- self.Dir = os.path.dirname(self.Path)
- self.Type = self.GetFileType()
- self.Toolchains = self.GetToolchainTagList(dom)
- self.Families = self.GetToolchainFamilyList(dom)
- self.Archs = self.GetArchList(dom)
- self.Features = self.GetFeatureList(dom)
-
- def GetFileType(self):
- type = XmlAttribute(self._Root, "ToolCode")
- if type == "":
- fileName = os.path.basename(self.Path)
- self.BaseName,self.Ext = os.path.splitext(fileName)
- if self.Ext in self._FileTypes:
- type = self._FileTypes[self.Ext]
- else:
- type = ""
- return type
-
-class PackageDependency(FrameworkElement.PackageDependency, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.PackageDependency.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
- self.GuidValue = XmlAttribute(dom, "PackageGuid").upper()
- self.Version = XmlAttribute(dom, "PackageVersion")
- self.Archs = self.GetArchList(dom)
- self.Features = self.GetFeatureList(dom)
-
- def Postprocess(self):
- self.Package = self._Workspace.GetPackage(self.GuidValue, self.Version)
- if self.Package == "": raise "No package with GUID=" + self.GuidValue + "VERSION=" + self.Version
-
-class Protocol(FrameworkElement.Protocol, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.Protocol.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
- self.CName = XmlElementData(XmlNode(dom, "/Protocol/ProtocolCName"))
- self.Usage = self.GetUsage(dom)
- self.Archs = self.GetArchList(dom)
- self.Features = self.GetFeatureList(dom)
-
- def Postprocess(self):
- for pd in self._Owner._Elements["PackageDependencies"]:
- if self.CName not in pd.Package.Protocols: continue
- self.GuidValue = pd.Package.Protocols[self.CName]
-
-class ProtocolNotify(FrameworkElement.ProtocolNotify, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.ProtocolNotify.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
-
- self.CName = XmlElementData(XmlNode(dom, "/ProtocolNotify/ProtocolCName"))
- self.Usage = self.GetUsage(dom)
- self.Archs = self.GetArchList(dom)
- self.Features = self.GetFeatureList(dom)
-
- def Postprocess(self):
- for pd in self._Owner._Elements["PackageDependencies"]:
- if self.CName not in pd.Package.Protocols: continue
- self.GuidValue = pd.Package.Protocols[self.CName]
-
-class Ppi(FrameworkElement.Ppi, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.Ppi.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
- self.CName = XmlElementData(XmlNode(dom, "/Ppi/PpiCName"))
- self.Usage = self.GetUsage(dom)
- self.Archs = self.GetArchList(dom)
- self.Features = self.GetFeatureList(dom)
-
- def Postprocess(self):
- for pd in self._Owner._Elements["PackageDependencies"]:
- if self.CName not in pd.Package.Ppis: continue
- self.GuidValue = pd.Package.Ppis[self.CName]
-
-class PpiNotify(FrameworkElement.PpiNotify, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.PpiNotify.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
- self.CName = XmlElementData(XmlNode(dom, "/PpiNotify/PpiCName"))
- self.Usage = self.GetUsage(dom)
- self.Archs = self.GetArchList(dom)
- self.Features = self.GetFeatureList(dom)
-
- def Postprocess(self):
- for pd in self._Owner._Elements["PackageDependencies"]:
- if self.CName not in pd.Package.Ppis: continue
- self.GuidValue = pd.Package.Ppis[self.CName]
-
-class Guid(FrameworkElement.Guid, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.Guid.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
- self.CName = XmlElementData(XmlNode(dom, "/GuidCNames/GuidCName"))
- self.Usage = self.GetUsage(dom)
- self.Archs = self.GetArchList(dom)
- self.Features = self.GetFeatureList(dom)
-
- def Postprocess(self):
- for pd in self._Owner._Elements["PackageDependencies"]:
- if self.CName not in pd.Package.Guids: continue
- self.GuidValue = pd.Package.Guids[self.CName]
-
-class Extern(FrameworkElement.Extern, SurfaceAreaElement):
- def __init__(self, workspace, module, dom):
- FrameworkElement.Extern.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, module, dom)
-
- def Parse(self):
- dom = self._Root
- self.Archs = self.GetArchList(dom)
- self.Features = self.GetFeatureList(dom)
-
- extern = XmlNode(dom, "/Extern/ModuleEntryPoint")
- if extern is not None and extern is not '':
- self.ModuleEntryPoints.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/ModuleUnloadImage")
- if extern is not None and extern is not '':
- self.ModuleUnloadImages.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/Constructor")
- if extern is not None and extern is not '':
- self.Constructors.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/Destructor")
- if extern is not None and extern is not '':
- self.Destructors.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/DriverBinding")
- if extern is not None and extern is not '':
- self.DriverBindings.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/ComponentName")
- if extern is not None and extern is not '':
- self.ComponentNames.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/DriverConfig")
- if extern is not None and extern is not '':
- self.DriverConfigs.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/DriverDiag")
- if extern is not None and extern is not '':
- self.DriverDiags.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/SetVirtualAddressMapCallBacks")
- if extern is not None and extern is not '':
- self.SetVirtualAddressMapCallBacks.append(XmlElementData(extern))
-
- extern = XmlNode(dom, "/Extern/ExitBootServicesCallBack")
- if extern is not None and extern is not '':
- self.ExitBootServicesCallBacks.append(XmlElementData(extern))
-
-class IndustryStdHeader(FrameworkElement.IncludeFile, SurfaceAreaElement):
- def __init__(self, workspace, package, dom):
- FrameworkElement.IncludeFile.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, package, dom)
-
- def Parse(self):
- dom = self._Root
- self.Path = os.path.normpath(XmlElementData(XmlNode(dom, "/IndustryStdHeader/IncludeHeader")))
- self.Dir = os.path.dirname(self.Path)
- self.Archs = self.GetArchList(dom)
- self.ModuleTypes = self.GetModuleTypeList(dom)
-
-class PackageHeader(FrameworkElement.IncludeFile, SurfaceAreaElement):
- def __init__(self, workspace, package, dom):
- FrameworkElement.IncludeFile.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, package, dom)
-
- def Parse(self):
- dom = self._Root
- self.Path = os.path.normpath(XmlElementData(dom))
- self.Dir = os.path.dirname(self.Path)
- self.ModuleType = XmlAttribute(dom, "ModuleType")
-
-class GuidDeclaration(FrameworkElement.Guid, SurfaceAreaElement):
- def __init__(self, workspace, package, dom):
- FrameworkElement.Guid.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, package, dom)
-
- def Parse(self):
- dom = self._Root
- self.CName = XmlElementData(XmlNode(dom, "/Entry/C_Name"))
- self.GuidValue = XmlElementData(XmlNode(dom, "/Entry/GuidValue")).upper()
- self.Name = XmlAttribute(dom, "Name")
- self.Types = self.GetGuidTypeList(dom)
- self.Archs = self.GetArchList(dom)
- self.ModuleTypes = self.GetModuleTypeList(dom)
-
- def Postprocess(self):
- pass
-
-class ProtocolDeclaration(GuidDeclaration, SurfaceAreaElement):
- pass
-
-class PpiDeclaration(GuidDeclaration, SurfaceAreaElement):
- pass
-
-class PcdDeclaration(FrameworkElement.Pcd, SurfaceAreaElement):
- def __init__(self, workspace, package, dom):
- FrameworkElement.Pcd.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, package, dom)
-
- def Parse(self):
- dom = self._Root
- self.Types = XmlElementData(XmlNode(dom, "/PcdEntry/ValidUsage")).split()
- self.CName = XmlElementData(XmlNode(dom, "/PcdEntry/C_Name"))
- self.Token = XmlElementData(XmlNode(dom, "/PcdEntry/Token"))
- self.TokenSpace = XmlElementData(XmlNode(dom, "/PcdEntry/TokenSpaceGuidCName"))
- self.DatumType = XmlElementData(XmlNode(dom, "/PcdEntry/DatumType"))
- self.Default = XmlElementData(XmlNode(dom, "/PcdEntry/DefaultValue"))
- self.Archs = self.GetArchList(dom)
- self.ModuleTypes= self.GetModuleTypeList(dom)
-
-class LibraryInstance(FrameworkElement.PlatformModule, SurfaceAreaElement):
- def __init__(self, workspace, platformModule, dom):
- FrameworkElement.PlatformModule.__init__(self)
- SurfaceAreaElement.__init__(self, workspace, platformModule, dom)
-
- def Parse(self):
- dom = self._Root
- self.GuidValue = XmlAttribute(dom, "ModuleGuid").upper()
- self.Version = XmlAttribute(dom, "ModuleVersion")
- self._Elements["PackageGuid"] = XmlAttribute(dom, "PackageGuid").upper()
- self._Elements["PackageVersion"] = XmlAttribute(dom, "PackageVersion")
-
- def Postprocess(self):
- self.Module = self._Workspace.GetModule(self.GuidValue, self.Version,
- self._Elements["PackageGuid"], self._Elements["PackageVersion"])
- self.Platform = self._Owner.Platform
- self.Archs = self._Owner.Archs
- self.Pcds = self._Owner.Pcds
- self.BuildType = "lib"
-
-class PlatformModule(FrameworkElement.PlatformModule, SurfaceAreaElement):
- def __init__(self, workspace, platform, dom):
- FrameworkElement.PlatformModule.__init__(self)
- self.Platform = platform
- SurfaceAreaElement.__init__(self, workspace, platform, dom)
-
- def Parse(self):
- dom = self._Root
- self.GuidValue = XmlAttribute(dom, "ModuleGuid").upper()
- self.Version = XmlAttribute(dom, "ModuleVersion")
- self.Archs = self.GetArchList(dom)
-
- self._Elements["PackageGuid"] = XmlAttribute(dom, "PackageGuid").upper()
- self._Elements["PackageVersion"] = XmlAttribute(dom, "PackageVersion")
-
- libraryList = XmlList(dom, "/ModuleSA/Libraries/Instance")
- for lib in libraryList:
- self.Libraries.append(LibraryInstance(self._Workspace, self, lib))
-
- dom = XmlNode(dom, "/ModuleSA/ModuleSaBuildOptions")
- self.FvBindings = self.GetFvBindingList(XmlNode(dom, "/ModuleSaBuildOptions/FvBinding"))
- self.FfsLayouts = XmlElementData(XmlNode(dom, "/ModuleSaBuildOptions/FfsFormatKey")).split()
- self.BuildOptions = self.GetBuildOptionList(XmlNode(dom, "/ModuleSaBuildOptions/Options"))
-
- def Postprocess(self):
- self.Module = self._Workspace.GetModule(self.GuidValue, self.Version,
- self._Elements["PackageGuid"], self._Elements["PackageVersion"])
- if self.Module == "":
- raise Exception("No module found: \n\t\tGUID=%s \n\t\tVERSION=%s \n\t\tPACKAGE_GUID=%s \n\t\tPACKAGE_VERSION=%s" % (
- self.GuidValue, self.Version, self._Elements["PackageGuid"], self._Elements["PackageVersion"]))
-
-## def SetupEnvironment(self):
-## self.Environment = {
-## "ARCH" : "",
-## "MODULE_BUILD_TARGET" : "",
-## "SINGLE_MODULE_BUILD" : "",
-## "PLATFORM_PREBUILD" : "",
-## "PLATFORM_POSTBUILD" : "",
-## "LIBS" : "",
-## "SOURCE_FILES" : "",
-## "ENTRYPOINT" : "_ModuleEntryPoint",
-## } # name/value pairs
-## self.Environment["MODULE_BUILD_TARGET"] = "platform_module_build"
-
-class ModuleSurfaceArea(FrameworkElement.Module, SurfaceAreaElement):
- def __init__(self, workspace, package, path):
- FrameworkElement.Module.__init__(self)
-
- self.Path = os.path.normpath(path)
- self.Dir = os.path.dirname(self.Path)
- self.FileBaseName,_ext = os.path.splitext(os.path.basename(self.Path))
- self.Package = package
- SurfaceAreaElement.__init__(self, workspace, package)
-
- def _MsaHeader(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- self.Name = XmlElementData(XmlNode(dom, "/MsaHeader/ModuleName"))
- self.Type = XmlElementData(XmlNode(dom, "/MsaHeader/ModuleType"))
- self.GuidValue = XmlElementData(XmlNode(dom, "/MsaHeader/GuidValue")).upper()
- self.Version = XmlElementData(XmlNode(dom, "/MsaHeader/Version"))
-
- def _ModuleDefinitions(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- self.Archs = XmlElementData(XmlNode(dom, "/ModuleDefinitions/SupportedArchitectures")).split()
- self.IsBinary = self.GetBoolean(XmlNode(dom, "/ModuleDefinitions/BinaryModule"))
- self.BaseName = XmlElementData(XmlNode(dom, "/ModuleDefinitions/OutputFileBasename"))
-
- def _LibraryClassDefinitions(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- lcList = []
- for lc in XmlList(dom, "/LibraryClassDefinitions/LibraryClass"):
- lcList.append(LibraryClass(self._Workspace, self, lc))
- self._Elements["LibraryClassDefinitions"] = lcList
-
- def _SourceFiles(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- srcList = []
- for f in XmlList(dom, "/SourceFiles/Filename"):
- srcList.append(SourceFile(self._Workspace, self, f))
- self._Elements["SourceFiles"] = srcList
-
- def _NonProcessedFiles(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- for f in XmlList(dom, "/NonProcessedFiles/Filename"):
- self.NonProcessedFiles.append(SourceFile(self._Workspace, self, f))
-
- def _PackageDependencies(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- pdList = []
- for pkg in XmlList(dom, "/PackageDependencies/Package"):
- pdList.append(PackageDependency(self._Workspace, self, pkg))
- self._Elements["PackageDependencies"] = pdList
-
- def _Protocols(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
-
- protocolList = []
- for p in XmlList(dom, "/Protocols/Protocol"):
- protocolList.append(Protocol(self._Workspace, self, p))
- for p in XmlList(dom, "/Protocols/ProtocolNotify"):
- protocolList.append(ProtocolNotify(self._Workspace, self, p))
-
- self._Elements["Protocols"] = protocolList
-
- def _Ppis(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
-
- ppiList = []
- for p in XmlList(dom, "/PPIs/Ppi"):
- ppiList.append(Ppi(self._Workspace, self, p))
- for p in XmlList(dom, "/PPIs/PpiNotify"):
- ppiList.append(PpiNotify(self._Workspace, self, p))
-
- self._Elements["PPIs"] = ppiList
-
- def _Guids(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- guidList = []
- for g in XmlList(dom, "/Guids/GuidCNames"):
- guidList.append(Guid(self._Workspace, self, g))
- self._Elements["Guids"] = guidList
-
- def _Externs(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- self.PcdIsDriver = self.GetBoolean(XmlNode(dom, "/Externs/PcdIsDriver"))
- self.NeedsFlashMap_h = self.GetBoolean(XmlNode(dom, "/Externs/TianoR8FlashMap_h"))
-
- externList = []
- specs = FrameworkElement.Extern()
- specs.Archs = self._Archs
- externList.append(specs)
- for spec in XmlList(dom, "/Externs/Specification"):
- specs.Specifications.append(XmlElementData(spec))
- for ext in XmlList(dom, "/Externs/Extern"):
- externList.append(Extern(self._Workspace, self, ext))
- self._Elements["Externs"] = externList
-
- def _ModuleBuildOptions(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- self.BuildOptions = self.GetBuildOptionList(XmlNode(dom, "/ModuleBuildOptions/Options"))
-
- def _UserExtensions(self, xpath):
- domList = XmlList(self._Root, xpath)
- if domList == []: return
- for extension in domList:
- userId = XmlAttribute(extension, "UserID")
- identifier = XmlAttribute(extension, "Identifier")
- if userId == '' or identifier == '':
- raise Exception("No UserId or Identifier specified")
- if userId != "TianoCore": continue
- if identifier not in self.UserExtensions:
- self.UserExtensions[identifier] = []
-
- contentList = self.UserExtensions[identifier]
- for node in extension.childNodes:
- #print node.nodeType
- contentList.append(node.cloneNode(True))
-
- def Parse(self):
- fileFullPath = self._Workspace.SubPath(os.path.dirname(self.Package.Path), self.Path)
- self._Root = xml.dom.minidom.parse(fileFullPath)
- assert self._Root.documentElement.tagName == "ModuleSurfaceArea"
-
- # print " Parsing...",self.Path
- self._MsaHeader("/ModuleSurfaceArea/MsaHeader")
- self._ModuleDefinitions("/ModuleSurfaceArea/ModuleDefinitions")
- self._PackageDependencies("/ModuleSurfaceArea/PackageDependencies")
- self._LibraryClassDefinitions("/ModuleSurfaceArea/LibraryClassDefinitions")
- self._SourceFiles("/ModuleSurfaceArea/SourceFiles")
- self._NonProcessedFiles("/ModuleSurfaceArea/NonProcessedFiles")
- self._Protocols("/ModuleSurfaceArea/Protocols")
- self._Ppis("/ModuleSurfaceArea/Ppis")
- self._Guids("/ModuleSurfaceArea/Guids")
- self._Externs("/ModuleSurfaceArea/Externs")
- self._ModuleBuildOptions("/ModuleSurfaceArea/ModuleBuildOptions")
- self._UserExtensions("/ModuleSurfaceArea/UserExtensions")
-
- def Postprocess(self):
- # resolve package dependency
- if self._Elements.has_key("PackageDependencies"):
- for pd in self._Elements["PackageDependencies"]:
- package = pd.Package
- if self.Type not in package.PackageIncludes:
- print "! Module type %s is not supported in the package %s" % (self.Type, package.Name)
-
- for arch in pd.Archs:
- if arch not in self.IncludePaths:
- self.IncludePaths[arch] = []
- self.IncludePaths[arch].append(package.SubPath("Include"))
- self.IncludePaths[arch].append(package.SubPath("Include", arch.capitalize()))
-
- if arch not in self.IncludeFiles:
- self.IncludeFiles[arch] = []
- if self.Type in package.PackageIncludes:
- for path in package.PackageIncludes[self.Type]:
- self.IncludeFiles[arch].append(package.SubPath(path))
-
- # resolve library class
- if self._Elements.has_key("LibraryClassDefinitions"):
- for lc in self._Elements["LibraryClassDefinitions"]:
- lc.Interface = self.GetLibraryInterface(lc.Name)
- if "ALWAYS_PRODUCED" in lc.Usage:
- self.IsLibrary = True
- lc.Interface.Instances.append(self)
- else:
- lc.Interface.Consumers.append(self)
-
- for arch in lc.Archs:
- if arch not in self.LibraryClasses:
- self.LibraryClasses[arch] = []
- self.LibraryClasses[arch].append(lc)
-
- # expand source files
- if self._Elements.has_key("SourceFiles"):
- for src in self._Elements["SourceFiles"]:
- for arch in src.Archs:
- if arch not in self.SourceFiles:
- self.SourceFiles[arch] = {}
- if src.Type not in self.SourceFiles[arch]:
- self.SourceFiles[arch][src.Type] = []
- self.SourceFiles[arch][src.Type].append(src)
-
- # expand guids
- if self._Elements.has_key("Guids"):
- for guid in self._Elements["Guids"]:
- for arch in guid.Archs:
- if arch not in self.Guids:
- self.Guids[arch] = []
- self.Guids[arch].append(guid)
-
- # expand protocol
- if self._Elements.has_key("Protocols"):
- for protocol in self._Elements["Protocols"]:
- for arch in protocol.Archs:
- if arch not in self.Protocols:
- self.Protocols[arch] = []
- self.Protocols[arch].append(protocol)
-
- # expand ppi
- if self._Elements.has_key("PPIs"):
- for ppi in self._Elements["PPIs"]:
- for arch in ppi.Archs:
- if arch not in self.Ppis:
- self.Ppis[arch] = []
- self.Ppis[arch].append(ppi)
-
- # expand extern
- if self._Elements.has_key("Externs"):
- for extern in self._Elements["Externs"]:
- for arch in extern.Archs:
- if arch not in self.Externs:
- self.Externs[arch] = []
- self.Externs[arch].append(extern)
-
- def GetLibraryInterface(self, name):
- if name in self.Package.LibraryInterfaces:
- return self.Package.LibraryInterfaces[name]
- for pd in self._Elements["PackageDependencies"]:
- if name in pd.Package.LibraryInterfaces:
- return pd.Package.LibraryInterfaces[name]
- return ""
-## def SetupEnvironment(self):
-## self.Environment["MODULE"] = self.Name
-## self.Environment["MODULE_GUID"] = self.GuidValue
-## self.Environment["MODULE_VERSION"] = self.Version
-## self.Environment["MODULE_TYPE"] = self.Type
-## self.Environment["MODULE_FILE_BASE_NAME"] = os.path.basename(self.Path).split(".")[0]
-## self.Environment["MODULE_RELATIVE_DIR"] = os.path.dirname(self.Path)
-## self.Environment["BASE_NAME"] = self.OutputName
-
-class Workspace(FrameworkElement.Workspace, SurfaceAreaElement):
- _Db = "Tools/Conf/FrameworkDatabase.db"
- _Target = "Tools/Conf/Target.txt"
- _PlatformBuildPath = "Tools/Conf/platform_build_path.txt"
- _ModuleBuildPath = "Tools/Conf/module_build_path.txt"
-
- def __init__(self, path, fpdList=None, msaList=None):
- FrameworkElement.Workspace.__init__(self)
- SurfaceAreaElement.__init__(self, self, None, None, False, False)
- self.Path = os.path.normpath(path)
- self.Dir = os.path.dirname(self.Path)
- self._Elements["PlatformList"] = fpdList
- self._Elements["ModuleList"] = msaList
- self.Parse()
- self.Postprocess()
-
- def _FdbHeader(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- self.Name = XmlElementData(XmlNode(dom, "/FdbHeader/DatabaseName"))
- self.GuidValue = XmlElementData(XmlNode(dom, "/FdbHeader/GuidValue")).upper()
- self.Version = XmlElementData(XmlNode(dom, "/FdbHeader/Version"))
-
- def _PackageList(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
-
- fileList = XmlList(dom, "/PackageList/Filename")
- packages = []
- for f in fileList:
- packages.append(os.path.normpath(XmlElementData(f)))
- self._Elements["PackageList"] = packages
-
- def _PlatformList(self, xpath):
- if len(self._Elements["PlatformList"]) > 0:
- return
-
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
-
- fileList = XmlList(dom, "/PlatformList/Filename")
- platforms = []
- for f in fileList:
- platforms.append(os.path.normpath(XmlElementData(f)))
- self._Elements["PlatformList"] = platforms
-
- def _FarList(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
-
- fileList = XmlList(dom, "/FarList/Filename")
- fars = []
- for f in fileList:
- fars.append(os.path.normpath(XmlElementData(f)))
- self._Elements["FarList"] = fars
-
- def ParseWorkspaceDatabase(self):
- # parse frameworkdatabase.db
- self._Root = xml.dom.minidom.parse(self.SubPath(self._Db))
- assert self._Root.documentElement.tagName == "FrameworkDatabase"
-
- self._FdbHeader("/FrameworkDatabase/FdbHeader")
- self._PackageList("/FrameworkDatabase/PackageList")
- self._PlatformList("/FrameworkDatabase/PlatformList")
- self._FarList("/FrameworkDatabase/FarList")
-
- def ParseConfig(self):
- # parse target.txt
- self.ParseTargetConfig()
- # parse tools_def.txt
- self.ParseToolConfig()
- # parse platform/module_build_path.txt
-
- # active toolchain
- # print self.TargetConfig
- self.ActiveToolchain = self.TargetConfig["TOOL_CHAIN_TAG"]
- if self.ActiveToolchain not in self.ToolConfig.Toolchains:
- raise "Not supported tool chain tag %s" % self.ActiveToolchain
-
- # active toolchain family
- self.ActiveFamilies = []
- for key in self.ToolConfig:
- if self.ActiveToolchain in key and "FAMILY" in key:
- family = self.ToolConfig[key]
- if family not in self.ActiveFamilies:
- self.ActiveFamilies.append(family)
-
-
- def ParsePackage(self, packagePaths=None):
- if packagePaths == None:
- return
-
- for packagePath in packagePaths:
- self.Packages.append(PackageSurfaceArea(self, packagePath))
-
- def ParsePlatform(self, platformPaths=None):
- # Only one active platform is allowed
- activePlatformPath = ""
- if self.TargetConfig["ACTIVE_PLATFORM"] == "":
- if platformPaths != None and len(platformPaths) == 1:
- activePlatformPath = platformPaths[0]
- else:
- raise Exception("No active platform specified or implied!")
- else:
- activePlatformPath = os.path.normpath(self.TargetConfig["ACTIVE_PLATFORM"])
-
- self.ActivePlatform = PlatformSurfaceArea(self, activePlatformPath)
- self.Platforms.append(self.ActivePlatform)
-
- def ParseTargetConfig(self):
- self.TargetConfig = BuildConfig.TargetConfig(self.SubPath(self._Target))
- # print self.TargetConfig
-
- def ParseToolConfig(self):
- self.ToolConfig = BuildConfig.ToolConfig(self.SubPath(self.TargetConfig["TOOL_CHAIN_CONF"]))
-
- def GetModule(self, guid, version, packageGuid, packageVersion):
- moduleGuidIndex = self.ModuleXref["GUID"]
- if guid not in moduleGuidIndex:
- print "! No module has GUID=" + guid
- return ""
-
- moduleVersionList = moduleGuidIndex[guid]
- # print moduleVersionList
- moduleList = []
- module = ""
- if version != "":
- if version in moduleVersionList:
- moduleList = moduleVersionList[version]
- else:
- return ""
- else:
- ## no version given, return the first one
- version = "0.0"
- for ver in moduleVersionList:
- if ver > version: version = ver
- moduleList = moduleVersionList[version]
-
- if packageGuid == "":
- ## if no package GUID given, just return the latest one
- version = "0.0"
- for m in moduleList:
- if m.Package.Version > version:
- version = m.Package.Version
- module = m
- else:
- version = "0.0"
- for m in moduleList:
- if m.Package.GuidValue != packageGuid: continue
- if packageVersion == "":
- ## if no version given, just return the latest
- if m.Package.Version > version:
- version = m.Package.Version
- module = m
- elif packageVersion == m.Package.Version:
- module = m
- break;
-
- return module
-
- def GetModuleByPath(self, path):
- ownerPackage = ""
- ownerPackageFullPath = ""
- for package in self.Packages:
- ownerPackageFullPath = self.SubPath(package.Path)
- if path.startswith(packageFullPath): break
-
- if ownerPackage == "":
- return ""
-
- for module in ownerPackage.Modules:
- moduleFullPath = os.path.join(ownerPackageFullPath, module.Path)
- if moduleFullPath == path:
- return module
-
- return ""
-
- def GetPackage(self, guid, version):
- packageGuidIndex = self.PackageXref["GUID"]
- if guid not in packageGuidIndex:
- # raise Exception("No package has GUID=" + guid)
- return ""
-
- packageList = packageGuidIndex[guid]
- package = ""
- if version != "":
- if version in packageList:
- package = packageList[version]
- else:
- ## no version given, return the latest one
- version = "0.0"
- for ver in packageList:
- if ver > version: version = ver
- package = packageList[version]
-
- return package
-
- def GetPlatform(self, guid, version):
- pass
-
- def GetPlatformByPath(self, path):
- for platform in self.Platforms:
- platformFullPath = self.SubPath(platform.Path)
- if platformFullPath == path:
- return platform
- return ""
-
- def GetLibraryInterface(self, name, package):
- if name not in self.LibraryInterfaceXref["NAME"]:
- return ""
- liList = self.LibraryInterfaceXref["NAME"][name]
- for li in liList:
- if li.Package == package:
- return li
- return ""
-
- def SubPath(self, *relativePathList):
- return os.path.normpath(os.path.join(self.Path, *relativePathList))
-
- def SetupCrossRef(self):
- ##
- ## setup platform cross reference as nest-dict
- ## guid -> {version -> platform}
- ##
- ## platformList = self.Platforms
- ## for p in platformList:
- ## guid = p.GuidValue
- ## version = p.Version
- ## if guid not in self.PlatformIndex:
- ## self.PlatformIndex[guid] = {}
- ## if version in self.PlatformIndex[guid]:
- ## raise Exception("Duplicate platform")
- ## self.PlatformIndex[guid][version] = p
-
- ##
- ## setup package cross reference as nest-dict
- ## guid -> {version -> package}
- ## name -> [package list]
- ## path -> package
- ##
- packageList = self.Packages
- for p in packageList:
- guid = p.GuidValue
- version = p.Version
- packageGuidIndex = self.PackageXref["GUID"]
- if guid not in packageGuidIndex:
- packageGuidIndex[guid] = {}
- if version in packageGuidIndex[guid]:
- raise Exception("Duplicate package: %s-%s [%s]" % p.Name, version, guid)
- packageGuidIndex[guid][version] = p
-
- packageNameIndex = self.PackageXref["NAME"]
- name = p.Name
- if name not in packageNameIndex:
- packageNameIndex[name] = []
- packageNameIndex[name].append(p)
-
- packagePathIndex = self.PackageXref["PATH"]
- path = p.Path
- if path in packagePathIndex:
- raise Exception("Duplicate package: %s %s" % p.Name, p.Path)
- packagePathIndex[path] = p.Path
-
- ##
- ## setup library class cross reference as
- ## library class name -> library class object
- ##
- for lcname in p.LibraryInterfaces:
- if lcname not in self.LibraryInterfaceXref["NAME"]:
- # raise Exception("Duplicate library class: %s in package %s" % (lcname, name))
- self.LibraryInterfaceXref["NAME"][lcname] = []
- lcInterface = p.LibraryInterfaces[lcname]
- self.LibraryInterfaceXref["NAME"][lcname].append(lcInterface)
-
- lcHeader = p.SubPath(lcInterface.Path)
- if lcHeader not in self.LibraryInterfaceXref["PATH"]:
- # raise Exception("Duplicate library class interface: %s in package %s" % (lcInterface, name))
- self.LibraryInterfaceXref["PATH"][lcHeader] = []
- self.LibraryInterfaceXref["PATH"][lcHeader].append(lcInterface)
-
- ##
- ## setup package cross reference as nest-dict
- ## guid -> {version -> [module list]}
- ## name -> [module list]
- ## path -> module
- for p in packageList:
- p.ParseMsaFile()
-
- moduleList = p.Modules
- for m in moduleList:
- name = m.Name
- path = m.Path
- guid = m.GuidValue
- version = m.Version
- moduleGuidIndex = self.ModuleXref["GUID"]
- if guid not in moduleGuidIndex:
- moduleGuidIndex[guid] = {}
- else:
- print "! Duplicate module GUID found:", guid, p.SubPath(path)
- dm = moduleGuidIndex[guid].values()[0][0]
- print " ", dm.GuidValue,\
- dm.Package.SubPath(dm.Path)
-
- if version not in moduleGuidIndex[guid]:
- moduleGuidIndex[guid][version] = []
- if m in moduleGuidIndex[guid][version]:
- raise Exception("Duplicate modules in the same package: %s-%s [%s]" % (name, version, guid))
- moduleGuidIndex[guid][version].append(m)
-
- modulePathIndex = self.ModuleXref["PATH"]
- path = p.SubPath(m.Path)
- if path in modulePathIndex:
- raise Exception("Duplicate modules in the same package: %s %s" % (name, path))
- modulePathIndex[path] = m
-
- moduleNameIndex = self.ModuleXref["NAME"]
- if name not in moduleNameIndex:
- moduleNameIndex[name] = []
- moduleNameIndex[name].append(m)
-
- def GetToolDef(self, toolchain, target, arch, toolcode, attr):
- return self.ToolConfig[(toolchain, target, arch, toolcode, attr)]
-
- def Parse(self):
- self.ParseConfig()
- self.ParseWorkspaceDatabase()
-
- def SetupBuild(self):
- # active archs
- self.ActiveArchs = self.TargetConfig["TARGET_ARCH"].split()
- if self.ActiveArchs == []:
- self.ActiveArchs = self.ActivePlatform.Archs
-
- # active targets
- self.ActiveTargets = self.TargetConfig["TARGET"].split()
- if self.ActiveTargets == []:
- self.ActiveTargets = self.ActivePlatform.Targets
-
-
- # active modules
- for msa in self._Elements["ModuleList"]:
- module = self.GetModuleByPath(msa)
- if module == "":
- raise Exception(msa + " is not in any package!")
- self.ActiveModules.append(module)
- self.IndividualModuleBuild = True
- if self.TargetConfig["MULTIPLE_THREAD"].upper() == "ENABLE":
- self.MultiThreadBuild = True
- if "MAX_CONCURRENT_THREAD_NUMBER" in self.TargetConfig:
- self.ThreadCount = self.TargetConfig["MAX_CONCURRENT_THREAD_NUMBER"]
- else:
- self.ThreadCount = "1"
-
- def Postprocess(self):
- self.ParsePackage(self._Elements["PackageList"])
- self.SetupCrossRef()
- self.ParsePlatform(self._Elements["PlatformList"])
- self.SetupBuild()
-
-## def SetupEnvironment(self):
-## config = BuildConfig.Config(self.SubPath(self._PlatformBuildPath))
-## for name in config:
-## self.Environment[name] = config[name]
-##
-## config = BuildConfig.Config(self.SubPath(self._ModuleBuildPath))
-## for name in config:
-## self.Environment[name] = config[name]
-##
-## multiThread = self.TargetConfig["MULTIPLE_THREAD"].upper()
-## threadNumber = self.TargetConfig["MAX_CONCURRENT_THREAD_NUMBER"]
-## if multiThread == "" or multiThread == "FALSE":
-## self.Environment["MULTIPLE_THREAD"] = False
-## self.Environment["MAX_CONCURRENT_THREAD_NUMBER"] = 1
-## else:
-## self.Environment["MULTIPLE_THREAD"] = True
-## if threadNumber != "":
-## self.Environment["MAX_CONCURRENT_THREAD_NUMBER"] = threadNumber
-## else:
-## self.Environment["MAX_CONCURRENT_THREAD_NUMBER"] = 2
-
-class PackageSurfaceArea(FrameworkElement.Package, SurfaceAreaElement):
- def __init__(self, workspace, path):
- FrameworkElement.Package.__init__(self)
-
- self.Path = os.path.normpath(path)
- self.Dir = os.path.dirname(self.Path)
- SurfaceAreaElement.__init__(self, workspace, workspace, None, True, True)
-
- def _SpdHeader(self, xpath):
- dom = XmlNode(self._Root, xpath)
- self.Name = XmlElementData(XmlNode(dom, "/SpdHeader/PackageName"))
- self.GuidValue = XmlElementData(XmlNode(dom, "/SpdHeader/GuidValue")).upper()
- self.Version = XmlElementData(XmlNode(dom, "/SpdHeader/Version"))
-
- def _PackageDefinitions(self, xpath):
- dom = XmlNode(self._Root, xpath)
- self.ReadOnly = XmlElementData(XmlNode(dom, "/PackageDefinitions/ReadOnly"))
- self.Repackage = XmlElementData(XmlNode(dom, "/PackageDefinitions/RePackage"))
-
- def _LibraryClassDeclarations(self, xpath):
- dom = XmlNode(self._Root, xpath)
- lcdList = XmlList(dom, "/LibraryClassDeclarations/LibraryClass")
- lcds = []
- for lc in lcdList:
- lcds.append(LibraryDeclaration(self._Workspace, self, lc))
- self._Elements["LibraryClassDeclarations"] = lcds
-
- def _IndustryStdIncludes(self, xpath):
- dom = XmlNode(self._Root, xpath)
- headerList = XmlList(dom, "/IndustryStdIncludes/IndustryStdHeader")
- headers = []
- for h in headerList:
- headers.append(IndustryStdHeader(self._Workspace, self, h))
- self._Elements["IndustryStdIncludes"] = headers
-
- def _MsaFiles(self, xpath):
- dom = XmlNode(self._Root, xpath)
- msaFileList = XmlList(dom, "/MsaFiles/Filename")
- msaFiles = []
- for msa in msaFileList:
- filePath = os.path.normpath(XmlElementData(msa))
- msaFiles.append(filePath)
- self._Elements["MsaFiles"] = msaFiles
-
- def _PackageHeaders(self, xpath):
- dom = XmlNode(self._Root, xpath)
- headerList = XmlList(dom, "/PackageHeaders/IncludePkgHeader")
- headers = []
- for h in headerList:
- headers.append(PackageHeader(self._Workspace, self, h))
- self._Elements["PackageHeaders"] = headers
-
- def _GuidDeclarations(self, xpath):
- dom = XmlNode(self._Root, xpath)
- guidList = XmlList(dom, "/GuidDeclarations/Entry")
- guids = []
- for guid in guidList:
- guids.append(GuidDeclaration(self._Workspace, self, guid))
- self._Elements["GuidDeclarations"] = guids
-
- def _ProtocolDeclarations(self, xpath):
- dom = XmlNode(self._Root, xpath)
- protocolList = XmlList(dom, "/ProtocolDeclarations/Entry")
- protocols = []
- for p in protocolList:
- protocols.append(ProtocolDeclaration(self._Workspace, self, p))
- self._Elements["ProtocolDeclarations"] = protocols
-
- def _PpiDeclarations(self, xpath):
- dom = XmlNode(self._Root, xpath)
- ppiList = XmlList(dom, "/PpiDeclarations/Entry")
- ppis = []
- for p in ppiList:
- ppis.append(PpiDeclaration(self._Workspace, self, p))
- self._Elements["PpiDeclarations"] = ppis
-
- def _PcdDeclarations(self, xpath):
- dom = XmlNode(self._Root, xpath)
- pcdList = XmlList(dom, "/PcdDeclarations/PcdEntry")
- pcds = []
- for p in pcdList:
- pcds.append(PcdDeclaration(self._Workspace, self, p))
- self._Elements["PcdDeclarations"] = pcds
-
- def SubPath(self, *relativePathList):
- return os.path.normpath(os.path.join(self.Dir, *relativePathList))
-
- def Parse(self):
- self._Root = xml.dom.minidom.parse(self._Workspace.SubPath(self.Path))
- assert self._Root.documentElement.tagName == "PackageSurfaceArea"
-
- # print "Parsing...",self.Path
- self._SpdHeader("/PackageSurfaceArea/SpdHeader")
- self._PackageDefinitions("/PackageSurfaceArea/PackageDefinitions")
- self._LibraryClassDeclarations("/PackageSurfaceArea/LibraryClassDeclarations")
- self._IndustryStdIncludes("/PackageSurfaceArea/IndustryStdIncludes")
- self._MsaFiles("/PackageSurfaceArea/MsaFiles")
- self._PackageHeaders("/PackageSurfaceArea/PackageHeaders")
- self._GuidDeclarations("/PackageSurfaceArea/GuidDeclarations")
- self._ProtocolDeclarations("/PackageSurfaceArea/ProtocolDeclarations")
- self._PpiDeclarations("/PackageSurfaceArea/PpiDeclarations")
- self._PcdDeclarations("/PackageSurfaceArea/PcdDeclarations")
-
- def Postprocess(self):
- # setup guid, protocol, ppi
- for guid in self._Elements["GuidDeclarations"]:
- if guid.CName in self.Guids:
- print "! Duplicate GUID CName (%s) in package %s" % (guid.CName, self.Path)
- self.Guids[guid.CName] = guid
-
- for protocol in self._Elements["ProtocolDeclarations"]:
- if protocol.CName in self.Protocols:
- print "! Duplicate Protocol CName (%s) in package %s" % (protocol.CName, self.Path)
- self.Protocols[protocol.CName] = protocol
-
- for ppi in self._Elements["PpiDeclarations"]:
- if ppi.CName in self.Ppis:
- print "! Duplicate PPI CName (%s) in package (%s)" % (ppi.CName, self.Path)
- self.Ppis[ppi.CName] = ppi
-
- # package header
- for inc in self._Elements["PackageHeaders"]:
- if inc.ModuleType not in self.PackageIncludes:
- self.PackageIncludes[inc.ModuleType] = []
- self.PackageIncludes[inc.ModuleType].append(inc.Path)
-
- # library class
- for lcd in self._Elements["LibraryClassDeclarations"]:
- if lcd.Name in self.LibraryInterfaces:
- raise "Duplicate library class: " + lcd.Name
- self.LibraryInterfaces[lcd.Name] = lcd
-
- # parse mas files
- # self.ParseMsaFile()
- # resolve RecommendedInstance
-
- def ParseMsaFile(self):
- for msaFilePath in self._Elements["MsaFiles"]:
- self.Modules.append(ModuleSurfaceArea(self._Workspace, self, msaFilePath))
-
-class PlatformSurfaceArea(FrameworkElement.Platform, SurfaceAreaElement):
- def __init__(self, workspace, path):
- FrameworkElement.Platform.__init__(self)
-
- self.Path = os.path.normpath(path)
- self.Dir = os.path.dirname(self.Path)
- SurfaceAreaElement.__init__(self, workspace)
-
- def _PlatformHeader(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- self.Name = XmlElementData(XmlNode(dom, "/PlatformHeader/PlatformName"))
- self.GuidValue = XmlElementData(XmlNode(dom, "/PlatformHeader/GuidValue")).upper()
- self.Version = XmlElementData(XmlNode(dom, "/PlatformHeader/Version"))
-
- def _PlatformDefinitions(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- self.Archs = XmlElementData(XmlNode(dom, "/PlatformDefinitions/SupportedArchitectures")).split()
- if self.Archs == []:
- raise Exception("No ARCH specified in platform " + self.Path)
- self.Targets = XmlElementData(XmlNode(dom, "/PlatformDefinitions/BuildTargets")).split()
- self.OutputPath = os.path.normpath(XmlElementData(XmlNode(dom, "/PlatformDefinitions/OutputDirectory")))
-
- def _Flash(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
-
- def _FrameworkModules(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- moduleList = XmlList(dom, "/FrameworkModules/ModuleSA")
- modules = []
- for m in moduleList:
- modules.append(PlatformModule(self._Workspace, self, m))
- self._Elements["FrameworkModules"] = modules
-
- def _DynamicPcdBuildDefinitions(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
-
- def _BuildOptions(self, xpath):
- dom = XmlNode(self._Root, xpath)
- if dom == '': return
- self.BuildOptions = self.GetBuildOptionList(XmlNode(dom, "/BuildOptions/Options"))
- # print self.BuildOptions
-
- def _UserExtensions(self, xpath):
- domList = XmlList(self._Root, xpath)
- if domList == []: return
- for extension in domList:
- userId = XmlAttribute(extension, "UserID")
- identifier = XmlAttribute(extension, "Identifier")
-
- if userId == '' or identifier == '':
- raise Exception("No UserId or Identifier specified")
- if userId != "TianoCore": continue
- if identifier not in self.UserExtensions:
- self.UserExtensions[identifier] = []
-
- contentList = self.UserExtensions[identifier]
- for node in extension.childNodes:
- # print node.nodeType
- contentList.append(node.cloneNode(True))
-
- def Parse(self):
- self._Root = xml.dom.minidom.parse(self._Workspace.SubPath(self.Path))
- assert self._Root.documentElement.tagName == "PlatformSurfaceArea"
-
- self._PlatformHeader("/PlatformSurfaceArea/PlatformHeader")
- self._PlatformDefinitions("/PlatformSurfaceArea/PlatformDefinitions")
- self._Flash("/PlatformSurfaceArea/Flash")
- self._FrameworkModules("/PlatformSurfaceArea/FrameworkModules")
- self._DynamicPcdBuildDefinitions("/PlatformSurfaceArea/DynamicPcdBuildDefinitions")
- self._BuildOptions("/PlatformSurfaceArea/BuildOptions")
- self._UserExtensions("/PlatformSurfaceArea/UserExtensions")
-
- def Postprocess(self):
- # summarize all library modules for build
- for module in self._Elements["FrameworkModules"]:
- for arch in module.Archs:
- if arch not in self.Modules:
- self.Modules[arch] = []
- self.Modules[arch].append(module)
-
- if arch not in self.Libraries:
- self.Libraries[arch] = []
- for li in module.Libraries:
- if li in self.Libraries[arch]: continue
- self.Libraries[arch].append(li)
-
- # FV
- for fvName in module.FvBindings:
- if fvName not in self.Fvs:
- self.Fvs[fvName] = []
- self.Fvs[fvName].append(module)
- # build options
- # user extension
-
-## def SetupEnvironment(self):
-## self.Environment["PLATFORM"] = self.Name
-## self.Environment["PLATFORM_GUID"] = self.GuidValue
-## self.Environment["PLATFORM_VERSION"] = self.Version
-## self.Environment["PLATFORM_RELATIVE_DIR"] = self.Path
-## self.Environment["PLATFORM_OUTPUT_DIR"] = self.OutputPath
-
-def PrintWorkspace(ws):
- print "\nPlatforms:\n"
- for guid in ws.PlatformXref["GUID"]:
- for ver in ws.PlatformXref["GUID"][guid]:
- platform = ws.PlatformXref["GUID"][guid][ver]
- print " %s %s-%s" % (guid, platform.Name, ver)
- for pm in platform.Modules:
- print " %-40s %-10s <%s-%s>" % (pm.Module.Name+"-"+pm.Module.Version,
- ListString(pm.Archs), pm.Module.Package.Name,
- pm.Module.Package.Version)
- for li in pm.Libraries:
- print " %-47s <%s-%s>" % (li.Module.Name+"-"+li.Module.Version,
- li.Module.Package.Name, li.Module.Package.Version)
- print ""
-
- print "\nPackages:\n"
- for guid in ws.PackageXref["GUID"]:
- for ver in ws.PackageXref["GUID"][guid]:
- print " %s %s-%s" % (guid, ws.PackageXref["GUID"][guid][ver].Name, ver)
-
- print "\nModules:\n"
- for guid in ws.ModuleXref["GUID"]:
- for ver in ws.ModuleXref["GUID"][guid]:
- for module in ws.ModuleXref["GUID"][guid][ver]:
- print " %s %-40s [%s-%s]" % (guid, module.Name+"-"+ver, module.Package.Name, module.Package.Version)
- print " Depending on packages:"
- for arch in module.IncludePaths:
- print " ", arch, ":"
- for path in module.IncludePaths[arch]:
- print " ", path
- print "\n"
-
- for arch in module.IncludeFiles:
- print " ", arch, ":"
- for path in module.IncludeFiles[arch]:
- print " ", path
- print "\n"
-
- print " Source files:"
- for arch in module.SourceFiles:
- print " ", arch, ":"
- for type in module.SourceFiles[arch]:
- for src in module.SourceFiles[arch][type]:
- print " %-40s (%s)" % (src.Path, src.Type)
- print "\n"
- print "\nLibrary Classes:"
- for name in ws.LibraryInterfaceXref["NAME"]:
- lcList = ws.LibraryInterfaceXref["NAME"][name]
- for lc in lcList:
- pkgPath = os.path.dirname(lc.Package.Path)
- print "\n [%s] <%s>" % (lc.Name, pkgPath + os.path.sep + lc.Path)
-
- print " Produced By:"
- for li in lc.Instances:
- print " %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))
-
- print " Consumed By:"
- for li in lc.Consumers:
- print " %-40s <%s>" % (li.Name+"-"+li.Version, li.Package.SubPath(li.Path))
-
- print "\nActive Platform:"
- for arch in ws.ActivePlatform.Libraries:
- print " Library Instances (%s) (%d libraries)" % (arch , len(ws.ActivePlatform.Libraries[arch]))
- for li in ws.ActivePlatform.Libraries[arch]:
- print " %s-%s (%s-%s)" % (li.Module.Name, li.Module.Version,
- li.Module.Package.Name, li.Module.Package.Version)
-
- for arch in ws.ActivePlatform.Modules:
- print " Driver Modules (%s) (%d modules)" % (arch, len(ws.ActivePlatform.Modules[arch]))
- for m in ws.ActivePlatform.Modules[arch]:
- print " %s-%s (%s-%s)" % (m.Module.Name, m.Module.Version,
- m.Module.Package.Name, m.Module.Package.Version)
-
- for fv in ws.ActivePlatform.Fvs:
- print
- print " Firmware Volume (%s) (%d modules)" % (fv, len(ws.ActivePlatform.Fvs[fv]))
- for m in ws.ActivePlatform.Fvs[fv]:
- print " %s-%s (%s-%s)" % (m.Module.Name, m.Module.Version,
- m.Module.Package.Name, m.Module.Package.Version)
-
-# for test
-if __name__ == "__main__":
- # os.environ["WORKSPACE"]
- workspacePath = os.getenv("WORKSPACE", os.getcwd())
- saFile = ""
- if len(sys.argv) <= 1:
- saFile = os.path.join(workspacePath, "Tools/Conf/FrameworkDatabase.db")
- else:
- saFile = sys.argv[1]
-
- print "Parsing ... %s\n" % saFile
-
- startTime = time.clock()
- sa = Workspace(workspacePath, [], [])
- # sa = PackageSurfaceArea(saFile)
- # sa = PlatformSurfaceArea(saFile)
- # sa = ModuleSurfaceArea(saFile)
- # print sa
-
- PrintWorkspace(sa)
- print "\n[Finished in %fs]" % (time.clock() - startTime)
-
diff --git a/Tools/Python/buildgen/module_build_path.txt b/Tools/Python/buildgen/module_build_path.txt deleted file mode 100644 index e5c8ed103d..0000000000 --- a/Tools/Python/buildgen/module_build_path.txt +++ /dev/null @@ -1,5 +0,0 @@ -BIN_DIR=${PLATFORM_BUILD_DIR}/${ARCH}
-MODULE_BUILD_DIR=${BIN_DIR}/${PACKAGE_RELATIVE_DIR}/${MODULE_RELATIVE_DIR}/${MODULE_FILE_BASE_NAME}
-DEST_DIR_OUTPUT=${MODULE_BUILD_DIR}/OUTPUT
-DEST_DIR_DEBUG=${MODULE_BUILD_DIR}/DEBUG
-
diff --git a/Tools/Python/buildgen/platform_build_path.txt b/Tools/Python/buildgen/platform_build_path.txt deleted file mode 100644 index 1218ac0ff8..0000000000 --- a/Tools/Python/buildgen/platform_build_path.txt +++ /dev/null @@ -1,5 +0,0 @@ -BUILD_DIR=${WORKSPACE_DIR}/${PLATFORM_OUTPUT_DIR}
-PLATFORM_BUILD_DIR=${BUILD_DIR}/${TARGET}_${TOOLCHAIN}
-TARGET_DIR=${PLATFORM_BUILD_DIR}
-FV_DIR=${TARGET_DIR}/FV
-
diff --git a/Tools/Python/far-template b/Tools/Python/far-template deleted file mode 100644 index 62a54d5a87..0000000000 --- a/Tools/Python/far-template +++ /dev/null @@ -1,48 +0,0 @@ -# This file is a template to be used in creating a Framework Archive Manifest. -# Each entry can be assigned to a string, which is quoted, or to a string that -# spans mutliple lines, which is triple quoted. Lists of strings are placed -# inside of square brackets. -# This file should be passed as a command line argument to the MkFar.py script. -# It is used to help the user control how the far is created. - -# The filename to give the new far. -far.FileName = "my.far" - -# The user readable name to give the far. -far.FarName = "My Far" - -# The version of the far. -far.Version = "0.3" - -# The license terms of the far. -far.License="""This program and the accompanying materials are licensed and made -available under the terms and conditions of the BSD License which accompanies -this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER -THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF -ANY KIND, EITHER EXPRESS OR IMPLIED.""" - -# Short description. -far.Abstract = "Its a good far." - -# Long description. -far.Description="""This Package provides headers and libraries that conform to -my wishes.""" - -# Copyright string to be placed inside the far. -far.Copyright="Copyright (c) 2006, My Corporation." - -# A list of workspace-relative paths to the .spd files that should be -# placed inside this far. -far.SpdFiles=[] - -# A list of workspace-relative paths to the .fpd files that should be -# placed inside this far. -far.FpdFiles=[] - -# A list of workspace-relative paths to the extra files that should be -# placed inside this far. Extra files are ones that are not part of -# an spd or msa or fpd. -far.ExtraFiles=["tools_def_for_this_package.template", "setup.sh"] - -# vim:syntax=python |