1## @file 2# This file is used to define class objects of INF file [BuildOptions] section. 3# It will consumed by InfParser. 4# 5# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR> 6# 7# This program and the accompanying materials are licensed and made available 8# under the terms and conditions of the BSD License which accompanies this 9# distribution. The full text of the license may be found at 10# http://opensource.org/licenses/bsd-license.php 11# 12# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 15''' 16InfBuildOptionObject 17''' 18 19from Library import GlobalData 20 21from Object.Parser.InfCommonObject import InfSectionCommonDef 22 23class InfBuildOptionItem(): 24 def __init__(self): 25 self.Content = '' 26 self.SupArchList = [] 27 self.AsBuildList = [] 28 29 def SetContent(self, Content): 30 self.Content = Content 31 def GetContent(self): 32 return self.Content 33 34 def SetSupArchList(self, SupArchList): 35 self.SupArchList = SupArchList 36 def GetSupArchList(self): 37 return self.SupArchList 38 39 # 40 # AsBuild Information 41 # 42 def SetAsBuildList(self, AsBuildList): 43 self.AsBuildList = AsBuildList 44 def GetAsBuildList(self): 45 return self.AsBuildList 46 47 48## INF BuildOption section 49# Macro define is not permitted for this section. 50# 51# 52class InfBuildOptionsObject(InfSectionCommonDef): 53 def __init__(self): 54 self.BuildOptions = [] 55 InfSectionCommonDef.__init__(self) 56 ## SetBuildOptions function 57 # 58 # For BuildOptionName, need to validate it's format 59 # For BuildOptionValue, just ignore it. 60 # 61 # @param Arch Indicated which arch of build options belong to. 62 # @param BuildOptCont A list contain BuildOption related information. 63 # The element in the list contain 3 members. 64 # BuildOptionName, BuildOptionValue and IsReplace 65 # flag. 66 # 67 # @return True Build options set/validate successfully 68 # @return False Build options set/validate failed 69 # 70 def SetBuildOptions(self, BuildOptCont, ArchList = None, SectionContent = ''): 71 72 if not GlobalData.gIS_BINARY_INF: 73 74 if SectionContent.strip() != '': 75 InfBuildOptionItemObj = InfBuildOptionItem() 76 InfBuildOptionItemObj.SetContent(SectionContent) 77 InfBuildOptionItemObj.SetSupArchList(ArchList) 78 79 self.BuildOptions.append(InfBuildOptionItemObj) 80 else: 81 # 82 # For AsBuild INF file 83 # 84 if len(BuildOptCont) >= 1: 85 InfBuildOptionItemObj = InfBuildOptionItem() 86 InfBuildOptionItemObj.SetAsBuildList(BuildOptCont) 87 InfBuildOptionItemObj.SetSupArchList(ArchList) 88 self.BuildOptions.append(InfBuildOptionItemObj) 89 90 return True 91 92 def GetBuildOptions(self): 93 return self.BuildOptions