-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dsc.py
93 lines (79 loc) · 3.02 KB
/
Dsc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
## @file
# This file is used to check format of comments
#
# Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
from collections import OrderedDict
import CommonDataClass.DataClass as DC
class DscElement(object):
def __init__(self):
self.key = ""
self.value = ""
self.settings = dict()
self.lineNo = 0
self.owner = "" # included dsc/inc
self.condition = dict()
self.seprator = "="
self.level = 1
self.tab_spa = " "
def __str__(self):
return "%s%s %s %s" % (self.tab_spa*self.level, self.key,self.seprator,self.value)
class DscSection(object):
def __init__(self, name):
self.sec_head = name
self.macros = dict()
self.arch = "COMMON"
self.filter1 = "COMMON"
self.filter2 = "COMMON"
self.data = []
def __str__(self):
sec_strlst = []
filter_str = ""
if self.filter2.upper() != "COMMON":
filter_str = ".".join(self.arch.upper(),self.filter1.upper(),self.filter2.upper())
elif self.filter1.upper() != "COMMON":
filter_str = ".".join(self.arch.upper(),self.filter1.upper())
elif self.arch.upper() != "COMMON":
filter_str = self.arch.upper()
else:
filter_str = ""
if filter_str:
sec_head_str = "[%s.%s]" % (self.sec_head,filter_str)
else:
sec_head_str = "[%s]" % self.sec_head
sec_strlst.append(sec_head_str)
for key in self.macros:
sec_head_str.append(" DEFINE %s = %s" % (key, self.macros[key]))
def mark_owners(self):
pass
class Dsc(object):
def __init__(self, dsc_path, ext_macros, ext_pcds):
self.dscfile = dsc_path
self.ext_macros = ext_macros
self.ext_pcds = ext_pcds
self.defines = DscSection("Defines")
self.buildoptions = DscSection("BuildOptions")
self.skuids = DscSection("SkuIds")
self.libraryclasses = DscSection("LibraryClasses")
self.defaulstore = DscSection("DefaultStores")
self.packages = DscSection("Packages")
self.ffpcd = DscSection("PcdsFeatureFlag")
self.fixedpcd = DscSection("PcdsFixedAtBuild")
self.components = DscSection("Components")
self.patchpcd = DscSection("PcdspatchableInModule")
self.dyndefaultpcd = DscSection("PcdsDynamicDefault")
self.dynexdefaultpcd = DscSection("PcdsDynamicExDefault")
self.dynhiipcd = DscSection("PcdsDynamicHii")
self.dynexhiipcd = DscSection("PcdsDynamicExHii")
self.dynvpdpcd = DscSection("PcdsDynamicVpd")
self.dynexvpdpcd = DscSection("PcdsDynamicExVpd")
self.inital_dsc()
def get_property(self,name):
return self.defines.data.get(name,"")
def inital_dsc(self):
pass
def format_dsc(self):
pass
def format_json(self):
pass