]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/UPT/Object/Parser/InfBuildOptionObject.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Object / Parser / InfBuildOptionObject.py
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 - 2018, Intel Corporation. All rights reserved.<BR>
6 #
7 # SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 '''
10 InfBuildOptionObject
11 '''
12
13 from Library import GlobalData
14
15 from Object.Parser.InfCommonObject import InfSectionCommonDef
16
17 class InfBuildOptionItem():
18 def __init__(self):
19 self.Content = ''
20 self.SupArchList = []
21 self.AsBuildList = []
22
23 def SetContent(self, Content):
24 self.Content = Content
25 def GetContent(self):
26 return self.Content
27
28 def SetSupArchList(self, SupArchList):
29 self.SupArchList = SupArchList
30 def GetSupArchList(self):
31 return self.SupArchList
32
33 #
34 # AsBuild Information
35 #
36 def SetAsBuildList(self, AsBuildList):
37 self.AsBuildList = AsBuildList
38 def GetAsBuildList(self):
39 return self.AsBuildList
40
41
42 ## INF BuildOption section
43 # Macro define is not permitted for this section.
44 #
45 #
46 class InfBuildOptionsObject(InfSectionCommonDef):
47 def __init__(self):
48 self.BuildOptions = []
49 InfSectionCommonDef.__init__(self)
50 ## SetBuildOptions function
51 #
52 # For BuildOptionName, need to validate it's format
53 # For BuildOptionValue, just ignore it.
54 #
55 # @param Arch Indicated which arch of build options belong to.
56 # @param BuildOptCont A list contain BuildOption related information.
57 # The element in the list contain 3 members.
58 # BuildOptionName, BuildOptionValue and IsReplace
59 # flag.
60 #
61 # @return True Build options set/validate successfully
62 # @return False Build options set/validate failed
63 #
64 def SetBuildOptions(self, BuildOptCont, ArchList = None, SectionContent = ''):
65
66 if not GlobalData.gIS_BINARY_INF:
67
68 if SectionContent.strip() != '':
69 InfBuildOptionItemObj = InfBuildOptionItem()
70 InfBuildOptionItemObj.SetContent(SectionContent)
71 InfBuildOptionItemObj.SetSupArchList(ArchList)
72
73 self.BuildOptions.append(InfBuildOptionItemObj)
74 else:
75 #
76 # For AsBuild INF file
77 #
78 if len(BuildOptCont) >= 1:
79 InfBuildOptionItemObj = InfBuildOptionItem()
80 InfBuildOptionItemObj.SetAsBuildList(BuildOptCont)
81 InfBuildOptionItemObj.SetSupArchList(ArchList)
82 self.BuildOptions.append(InfBuildOptionItemObj)
83
84 return True
85
86 def GetBuildOptions(self):
87 return self.BuildOptions