def GetComponent(Lines, KeyValues): (FindBlock, FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, \ FindPcdsDynamicEx) = (False, False, False, False, False, False, False, \ False) ListItem = None LibraryClassItem = [] BuildOption = [] Pcd = [] for Line in Lines: Line = Line[0] # # Ignore !include statement # if Line.upper().find(DataType.TAB_INCLUDE.upper() + ' ') > -1 or \ Line.upper().find(DataType.TAB_DEFINE + ' ') > -1: continue if FindBlock == False: ListItem = Line # # find '{' at line tail # if Line.endswith('{'): FindBlock = True ListItem = CleanString(Line.rsplit('{', 1)[0], \ DataType.TAB_COMMENT_SPLIT) # # Parse a block content # if FindBlock: if Line.find('<LibraryClasses>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (True, False, False, False, False, False, False) continue if Line.find('<BuildOptions>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, True, False, False, False, False, False) continue if Line.find('<PcdsFeatureFlag>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, True, False, False, False, False) continue if Line.find('<PcdsPatchableInModule>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, True, False, False, False) continue if Line.find('<PcdsFixedAtBuild>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, True, False, False) continue if Line.find('<PcdsDynamic>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, True, False) continue if Line.find('<PcdsDynamicEx>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, False, True) continue if Line.endswith('}'): # # find '}' at line tail # KeyValues.append([ListItem, LibraryClassItem, \ BuildOption, Pcd]) (FindBlock, FindLibraryClass, FindBuildOption, \ FindPcdsFeatureFlag, FindPcdsPatchableInModule, \ FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, False, False, False) LibraryClassItem, BuildOption, Pcd = [], [], [] continue if FindBlock: if FindLibraryClass: LibraryClassItem.append(Line) elif FindBuildOption: BuildOption.append(Line) elif FindPcdsFeatureFlag: Pcd.append((DataType.TAB_PCDS_FEATURE_FLAG_NULL, Line)) elif FindPcdsPatchableInModule: Pcd.append((DataType.TAB_PCDS_PATCHABLE_IN_MODULE_NULL, Line)) elif FindPcdsFixedAtBuild: Pcd.append((DataType.TAB_PCDS_FIXED_AT_BUILD_NULL, Line)) elif FindPcdsDynamic: Pcd.append((DataType.TAB_PCDS_DYNAMIC_DEFAULT_NULL, Line)) elif FindPcdsDynamicEx: Pcd.append((DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, Line)) else: KeyValues.append([ListItem, [], [], []]) return True
def GetComponents(Lines, KeyValues, CommentCharacter): if Lines.find(DataType.TAB_SECTION_END) > -1: Lines = Lines.split(DataType.TAB_SECTION_END, 1)[1] (FindBlock, FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, \ FindPcdsDynamicEx) = \ (False, False, False, False, False, False, False, False) ListItem = None LibraryClassItem = [] BuildOption = [] Pcd = [] LineList = Lines.split('\n') for Line in LineList: Line = CleanString(Line, CommentCharacter) if Line is None or Line == '': continue if FindBlock == False: ListItem = Line # # find '{' at line tail # if Line.endswith('{'): FindBlock = True ListItem = CleanString( Line.rsplit('{', 1)[0], CommentCharacter) # # Parse a block content # if FindBlock: if Line.find('<LibraryClasses>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (True, False, False, False, False, False, False) continue if Line.find('<BuildOptions>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, True, False, False, False, False, False) continue if Line.find('<PcdsFeatureFlag>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, True, False, False, False, False) continue if Line.find('<PcdsPatchableInModule>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, True, False, False, False) continue if Line.find('<PcdsFixedAtBuild>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, True, False, False) continue if Line.find('<PcdsDynamic>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, True, False) continue if Line.find('<PcdsDynamicEx>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, False, True) continue if Line.endswith('}'): # # find '}' at line tail # KeyValues.append([ListItem, LibraryClassItem, BuildOption, \ Pcd]) (FindBlock, FindLibraryClass, FindBuildOption, \ FindPcdsFeatureFlag, FindPcdsPatchableInModule, \ FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, False, False, False) LibraryClassItem, BuildOption, Pcd = [], [], [] continue if FindBlock: if FindLibraryClass: LibraryClassItem.append(Line) elif FindBuildOption: BuildOption.append(Line) elif FindPcdsFeatureFlag: Pcd.append((DataType.TAB_PCDS_FEATURE_FLAG, Line)) elif FindPcdsPatchableInModule: Pcd.append((DataType.TAB_PCDS_PATCHABLE_IN_MODULE, Line)) elif FindPcdsFixedAtBuild: Pcd.append((DataType.TAB_PCDS_FIXED_AT_BUILD, Line)) elif FindPcdsDynamic: Pcd.append((DataType.TAB_PCDS_DYNAMIC, Line)) elif FindPcdsDynamicEx: Pcd.append((DataType.TAB_PCDS_DYNAMIC_EX, Line)) else: KeyValues.append([ListItem, [], [], []]) return True
def GetComponents(Lines, KeyValues, CommentCharacter): if Lines.find(DataType.TAB_SECTION_END) > -1: Lines = Lines.split(DataType.TAB_SECTION_END, 1)[1] (FindBlock, FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, FindPcdsDynamic, \ FindPcdsDynamicEx) = \ (False, False, False, False, False, False, False, False) ListItem = None LibraryClassItem = [] BuildOption = [] Pcd = [] LineList = Lines.split('\n') for Line in LineList: Line = CleanString(Line, CommentCharacter) if Line is None or Line == '': continue if FindBlock == False: ListItem = Line # # find '{' at line tail # if Line.endswith('{'): FindBlock = True ListItem = CleanString(Line.rsplit('{', 1)[0], CommentCharacter) # # Parse a block content # if FindBlock: if Line.find('<LibraryClasses>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (True, False, False, False, False, False, False) continue if Line.find('<BuildOptions>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, True, False, False, False, False, False) continue if Line.find('<PcdsFeatureFlag>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, True, False, False, False, False) continue if Line.find('<PcdsPatchableInModule>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, True, False, False, False) continue if Line.find('<PcdsFixedAtBuild>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, True, False, False) continue if Line.find('<PcdsDynamic>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, True, False) continue if Line.find('<PcdsDynamicEx>') != -1: (FindLibraryClass, FindBuildOption, FindPcdsFeatureFlag, \ FindPcdsPatchableInModule, FindPcdsFixedAtBuild, \ FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, False, True) continue if Line.endswith('}'): # # find '}' at line tail # KeyValues.append([ListItem, LibraryClassItem, BuildOption, \ Pcd]) (FindBlock, FindLibraryClass, FindBuildOption, \ FindPcdsFeatureFlag, FindPcdsPatchableInModule, \ FindPcdsFixedAtBuild, FindPcdsDynamic, FindPcdsDynamicEx) = \ (False, False, False, False, False, False, False, False) LibraryClassItem, BuildOption, Pcd = [], [], [] continue if FindBlock: if FindLibraryClass: LibraryClassItem.append(Line) elif FindBuildOption: BuildOption.append(Line) elif FindPcdsFeatureFlag: Pcd.append((DataType.TAB_PCDS_FEATURE_FLAG, Line)) elif FindPcdsPatchableInModule: Pcd.append((DataType.TAB_PCDS_PATCHABLE_IN_MODULE, Line)) elif FindPcdsFixedAtBuild: Pcd.append((DataType.TAB_PCDS_FIXED_AT_BUILD, Line)) elif FindPcdsDynamic: Pcd.append((DataType.TAB_PCDS_DYNAMIC, Line)) elif FindPcdsDynamicEx: Pcd.append((DataType.TAB_PCDS_DYNAMIC_EX, Line)) else: KeyValues.append([ListItem, [], [], []]) return True