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