summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/Common/DscClassObject.py
blob: 428f1686b6d98567612a844f8cebd10cdf2e9006 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
## @file
# This file is used to define each component of DSC file
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution.  The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#

##
# Import Modules
#
import os
import EdkLogger as EdkLogger
import Database
from String import *
from Parsing import *
from DataType import *
from Identification import *
from Dictionary import *
from CommonDataClass.PlatformClass import *
from CommonDataClass.CommonClass import SkuInfoClass
from BuildToolError import *
from Misc import sdict
import GlobalData
from Table.TableDsc import TableDsc

#
# Global variable
#
Section = {TAB_UNKNOWN.upper() : MODEL_UNKNOWN,
           TAB_DSC_DEFINES.upper() : MODEL_META_DATA_HEADER,
           TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BUILD_OPTION,
           TAB_SKUIDS.upper() : MODEL_EFI_SKU_ID,
           TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_INSTANCE,
           TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS,
           TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT_BUILD,
           TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABLE_IN_MODULE,
           TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_FLAG,
           TAB_PCDS_DYNAMIC_EX_NULL.upper() : MODEL_PCD_DYNAMIC_EX,
           TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL.upper() :  MODEL_PCD_DYNAMIC_EX_DEFAULT,
           TAB_PCDS_DYNAMIC_EX_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_EX_VPD,
           TAB_PCDS_DYNAMIC_EX_HII_NULL.upper() : MODEL_PCD_DYNAMIC_EX_HII,
           TAB_PCDS_DYNAMIC_NULL.upper() : MODEL_PCD_DYNAMIC,
           TAB_PCDS_DYNAMIC_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_DEFAULT,
           TAB_PCDS_DYNAMIC_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_VPD,
           TAB_PCDS_DYNAMIC_HII_NULL.upper() : MODEL_PCD_DYNAMIC_HII,
           TAB_COMPONENTS.upper() : MODEL_META_DATA_COMPONENT,
           TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION
           }

## DscObject
#
# This class defined basic Dsc object which is used by inheriting
#
# @param object:       Inherited from object class
#
class DscObject(object):
    def __init__(self):
        object.__init__()

## Dsc
#
# This class defined the structure used in Dsc object
#
# @param DscObject:         Inherited from InfObject class
# @param Ffilename:         Input value for Ffilename of Inf file, default is None
# @param IsMergeAllArches:  Input value for IsMergeAllArches
#                           True is to merge all arches
#                           Fales is not to merge all arches
#                           default is False
# @param IsToPlatform:      Input value for IsToPlatform
#                           True is to transfer to ModuleObject automatically
#                           False is not to transfer to ModuleObject automatically
#                           default is False
# @param WorkspaceDir:      Input value for current workspace directory, default is None
#
# @var _NullClassIndex:     To store value for _NullClassIndex, default is 0
# @var Identification:      To store value for Identification, it is a structure as Identification
# @var Defines:             To store value for Defines, it is a structure as DscDefines
# @var Contents:            To store value for Contents, it is a structure as DscContents
# @var UserExtensions:      To store value for UserExtensions
# @var Platform:            To store value for Platform, it is a structure as PlatformClass
# @var WorkspaceDir:        To store value for WorkspaceDir
# @var KeyList:             To store value for KeyList, a list for all Keys used in Dec
#
class Dsc(DscObject):
    _NullClassIndex = 0

    def __init__(self, Filename = None, IsToDatabase = False, IsToPlatform = False, WorkspaceDir = None, Database = None):
        self.Identification = Identification()
        self.Platform = PlatformClass()
        self.UserExtensions = ''
        self.WorkspaceDir = WorkspaceDir
        self.IsToDatabase = IsToDatabase

        self.Cur = Database.Cur
        self.TblFile = Database.TblFile
        self.TblDsc = Database.TblDsc


        self.KeyList = [
            TAB_SKUIDS, TAB_LIBRARIES, TAB_LIBRARY_CLASSES, TAB_BUILD_OPTIONS, TAB_PCDS_FIXED_AT_BUILD_NULL, \
            TAB_PCDS_PATCHABLE_IN_MODULE_NULL, TAB_PCDS_FEATURE_FLAG_NULL, \
            TAB_PCDS_DYNAMIC_DEFAULT_NULL, TAB_PCDS_DYNAMIC_HII_NULL, TAB_PCDS_DYNAMIC_VPD_NULL, \
            TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, TAB_PCDS_DYNAMIC_EX_HII_NULL, TAB_PCDS_DYNAMIC_EX_VPD_NULL, \
            TAB_COMPONENTS, TAB_DSC_DEFINES
        ]

        self.PcdToken = {}

        #
        # Upper all KEYs to ignore case sensitive when parsing
        #
        self.KeyList = map(lambda c: c.upper(), self.KeyList)

        #
        # Init RecordSet
        #
#        self.RecordSet = {}
#        for Key in self.KeyList:
#            self.RecordSet[Section[Key]] = []

        #
        # Load Dsc file if filename is not None
        #
        if Filename != None:
            self.LoadDscFile(Filename)

        #
        # Transfer to Platform Object if IsToPlatform is True
        #
        if IsToPlatform:
            self.DscToPlatform()

    ## Transfer to Platform Object
    #
    # Transfer all contents of an Inf file to a standard Module Object
    #
    def DscToPlatform(self):
        #
        # Init global information for the file
        #
        ContainerFile = self.Identification.FileFullPath

        #
        # Generate Platform Header
        #
        self.GenPlatformHeader(ContainerFile)

        #
        # Generate BuildOptions
        #
        self.GenBuildOptions(ContainerFile)

        #
        # Generate SkuInfos
        #
        self.GenSkuInfos(ContainerFile)

        #
        # Generate Libraries
        #
        self.GenLibraries(ContainerFile)

        #
        # Generate LibraryClasses
        #
        self.GenLibraryClasses(ContainerFile)

        #
        # Generate Pcds
        #
        self.GenPcds(DataType.TAB_PCDS_FIXED_AT_BUILD, ContainerFile)
        self.GenPcds(DataType.TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile)
        self.GenFeatureFlagPcds(DataType.TAB_PCDS_FEATURE_FLAG, ContainerFile)
        self.GenDynamicDefaultPcds(DataType.TAB_PCDS_DYNAMIC_DEFAULT, ContainerFile)
        self.GenDynamicDefaultPcds(DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT, ContainerFile)
        self.GenDynamicHiiPcds(DataType.TAB_PCDS_DYNAMIC_HII, ContainerFile)
        self.GenDynamicHiiPcds(DataType.TAB_PCDS_DYNAMIC_EX_HII, ContainerFile)
        self.GenDynamicVpdPcds(DataType.TAB_PCDS_DYNAMIC_VPD, ContainerFile)
        self.GenDynamicVpdPcds(DataType.TAB_PCDS_DYNAMIC_EX_VPD, ContainerFile)

        #
        # Generate Components
        #
        self.GenComponents(ContainerFile)

        #
        # Update to database
        #
        if self.IsToDatabase:
            for Key in self.PcdToken.keys():
                SqlCommand = """update %s set Value2 = '%s' where ID = %s""" % (self.TblDsc.Table, ".".join((self.PcdToken[Key][0], self.PcdToken[Key][1])), Key)
                self.TblDsc.Exec(SqlCommand)
    #End of DscToPlatform

    ## Get Platform Header
    #
    # Gen Platform Header of Dsc as <Key> = <Value>
    #
    # @param ContainerFile: The Dsc file full path
    #
    def GenPlatformHeader(self, ContainerFile):
        EdkLogger.debug(2, "Generate PlatformHeader ...")
        #
        # Update all defines item in database
        #
        SqlCommand = """select ID, Value1, Arch, StartLine from %s
                        where Model = %s
                        and BelongsToFile = %s
                        and Enabled > -1""" % (self.TblDsc.Table, MODEL_META_DATA_HEADER, self.FileID)
        RecordSet = self.TblDsc.Exec(SqlCommand)
        for Record in RecordSet:
            ValueList = GetSplitValueList(Record[1], TAB_EQUAL_SPLIT)
            if len(ValueList) != 2:
                RaiseParserError(Record[1], 'Defines', ContainerFile, '<Key> = <Value>', Record[3])
            ID, Value1, Value2, Arch = Record[0], ValueList[0], ValueList[1], Record[2]
            SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
                            where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(Value1), ConvertToSqlString2(Value2), ID)
            self.TblDsc.Exec(SqlCommand)

        #
        # Get detailed information
        #
        for Arch in DataType.ARCH_LIST:
            PlatformHeader = PlatformHeaderClass()

            PlatformHeader.Name = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_NAME, Arch, self.FileID)[0]
            PlatformHeader.Guid = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_GUID, Arch, self.FileID)[0]
            PlatformHeader.Version = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_VERSION, Arch, self.FileID)[0]
            PlatformHeader.FileName = self.Identification.FileName
            PlatformHeader.FullPath = self.Identification.FileFullPath
            PlatformHeader.DscSpecification = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_DSC_SPECIFICATION, Arch, self.FileID)[0]

            PlatformHeader.SkuIdName = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_SKUID_IDENTIFIER, Arch, self.FileID)
            PlatformHeader.SupArchList = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES, Arch, self.FileID)
            PlatformHeader.BuildTargets = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BUILD_TARGETS, Arch, self.FileID)
            PlatformHeader.OutputDirectory = NormPath(QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_OUTPUT_DIRECTORY, Arch, self.FileID)[0])
            PlatformHeader.BuildNumber = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BUILD_NUMBER, Arch, self.FileID)[0]
            PlatformHeader.MakefileName = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_MAKEFILE_NAME, Arch, self.FileID)[0]

            PlatformHeader.BsBaseAddress = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BS_BASE_ADDRESS, Arch, self.FileID)[0]
            PlatformHeader.RtBaseAddress = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_RT_BASE_ADDRESS, Arch, self.FileID)[0]

            self.Platform.Header[Arch] = PlatformHeader
            Fdf = PlatformFlashDefinitionFileClass()
            Fdf.FilePath = NormPath(QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_FLASH_DEFINITION, Arch, self.FileID)[0])
            self.Platform.FlashDefinitionFile = Fdf

    ## GenBuildOptions
    #
    # Gen BuildOptions of Dsc
    # [<Family>:]<ToolFlag>=Flag
    #
    # @param ContainerFile: The Dsc file full path
    #
    def GenBuildOptions(self, ContainerFile):
        EdkLogger.debug(2, "Generate %s ..." % TAB_BUILD_OPTIONS)
        BuildOptions = {}
        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_META_DATA_BUILD_OPTION, self.FileID)

        #
        # Get all BuildOptions
        #
        RecordSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_BUILD_OPTION, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_BUILD_OPTIONS, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        (Family, ToolChain, Flag) = GetBuildOption(NewItem, Filename, -1)
                        MergeArches(BuildOptions, (Family, ToolChain, Flag), Arch)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    (Family, ToolChain, Flag) = GetBuildOption(Record[0], ContainerFile, Record[2])
                    MergeArches(BuildOptions, (Family, ToolChain, Flag), Arch)
                    #
                    # Update to Database
                    #
                    if self.IsToDatabase:
                        SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
                                        where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), ConvertToSqlString2(Flag), Record[3])
                        self.TblDsc.Exec(SqlCommand)

        for Key in BuildOptions.keys():
            BuildOption = BuildOptionClass(Key[0], Key[1], Key[2])
            BuildOption.SupArchList = BuildOptions[Key]
            self.Platform.BuildOptions.BuildOptionList.append(BuildOption)

    ## GenSkuInfos
    #
    # Gen SkuInfos of Dsc
    # <Integer>|<UiName>
    #
    # @param ContainerFile: The Dsc file full path
    #
    def GenSkuInfos(self, ContainerFile):
        EdkLogger.debug(2, "Generate %s ..." % TAB_SKUIDS)
        #
        # SkuIds
        # <Integer>|<UiName>
        #
        self.Platform.SkuInfos.SkuInfoList['DEFAULT'] = '0'

        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_SKU_ID, self.FileID)

        #
        # Get all SkuInfos
        #
        RecordSet = QueryDscItem(self.TblDsc, MODEL_EFI_SKU_ID, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_SKUIDS, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        List = GetSplitValueList(NewItem)
                        if len(List) != 2:
                            RaiseParserError(NewItem, TAB_SKUIDS, Filename, '<Integer>|<UiName>')
                        else:
                            self.Platform.SkuInfos.SkuInfoList[List[1]] = List[0]

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    List = GetSplitValueList(Record[0])
                    if len(List) != 2:
                        RaiseParserError(Record[0], TAB_SKUIDS, ContainerFile, '<Integer>|<UiName>')
                    else:
                        self.Platform.SkuInfos.SkuInfoList[List[1]] = List[0]
                        #
                        # Update to Database
                        #
                        if self.IsToDatabase:
                            SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
                                            where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), Record[3])
                            self.TblDsc.Exec(SqlCommand)

    ## GenLibraries
    #
    # Gen Libraries of Dsc
    # <PathAndFilename>
    #
    # @param ContainerFile: The Dsc file full path
    #
    def GenLibraries(self, ContainerFile):
        EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARIES)
        Libraries = {}
        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_LIBRARY_INSTANCE, self.FileID)

        #
        # Get all Libraries
        #
        RecordSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_INSTANCE, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARIES, '', IncludeFile[2])
                    if os.path.exists(Filename):
                        for NewItem in open(Filename, 'r').readlines():
                            if CleanString(NewItem) == '':
                                continue
                            MergeArches(Libraries, NewItem, Arch)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    MergeArches(Libraries, Record[0], Arch)

        for Key in Libraries.keys():
            Library = PlatformLibraryClass()
            Library.FilePath = NormPath(Key)
            Library.SupArchList = Libraries[Key]
            self.Platform.Libraries.LibraryList.append(Library)

    ## GenLibraryClasses
    #
    # Get LibraryClasses of Dsc
    # <LibraryClassKeyWord>|<LibraryInstance>
    #
    # @param ContainerFile: The Dsc file full path
    #
    def GenLibraryClasses(self, ContainerFile):
        EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES)
        LibraryClasses = {}
        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_LIBRARY_CLASS, self.FileID)

        #
        # Get all LibraryClasses
        #
        RecordSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARY_CLASSES, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        MergeArches(LibraryClasses, GetLibraryClass([NewItem, IncludeFile[4]], Filename, self.WorkspaceDir, -1), Arch)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    (LibClassName, LibClassIns, SupModelList) = GetLibraryClass([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])
                    MergeArches(LibraryClasses, (LibClassName, LibClassIns, SupModelList), Arch)
                    #
                    # Update to Database
                    #
                    if self.IsToDatabase:
                        SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
                                        where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])
                        self.TblDsc.Exec(SqlCommand)

        for Key in LibraryClasses.keys():
            Library = PlatformLibraryClass()
            Library.Name = Key[0]
            Library.FilePath = NormPath(Key[1])
            Library.SupModuleList = GetSplitValueList(Key[2])
            Library.SupArchList = LibraryClasses[Key]
            self.Platform.LibraryClasses.LibraryList.append(Library)

    ## Gen Pcds
    #
    # Gen Pcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]
    #
    # @param Type:           The type of Pcd
    # @param ContainerFile:  The file which describes the pcd, used for error report
    #
    def GenPcds(self, Type = '', ContainerFile = ''):
        Pcds = {}
        if Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:
            Model = MODEL_PCD_PATCHABLE_IN_MODULE
        elif Type == DataType.TAB_PCDS_FIXED_AT_BUILD:
            Model = MODEL_PCD_FIXED_AT_BUILD
        else:
            pass
        EdkLogger.debug(2, "Generate %s ..." % Type)

        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)

        #
        # Get all Pcds
        #
        RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(NewItem, Type, Filename, -1)
                        MergeArches(Pcds, (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type), Arch)
                        self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(Record[0], Type, ContainerFile, Record[2])
                    MergeArches(Pcds, (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type), Arch)
                    self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)

        for Key in Pcds:
            Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], {}, [])
            Pcd.SupArchList = Pcds[Key]
            self.Platform.DynamicPcdBuildDefinitions.append(Pcd)

    ## Gen FeatureFlagPcds
    #
    # Gen FeatureFlagPcds of Dsc file as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE
    #
    # @param Type:           The type of Pcd
    # @param ContainerFile:  The file which describes the pcd, used for error report
    #
    def GenFeatureFlagPcds(self, Type = '', ContainerFile = ''):
        Pcds = {}
        if Type == DataType.TAB_PCDS_FEATURE_FLAG:
            Model = MODEL_PCD_FEATURE_FLAG
        else:
            pass
        EdkLogger.debug(2, "Generate %s ..." % Type)

        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)

        #
        # Get all FeatureFlagPcds
        #
        RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        (TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(NewItem, Type, Filename, -1)
                        MergeArches(Pcds, (TokenName, TokenGuidCName, Value, Type), Arch)
                        self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    (TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(Record[0], Type, ContainerFile, Record[2])
                    MergeArches(Pcds, (TokenName, TokenGuidCName, Value, Type), Arch)
                    self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)

        for Key in Pcds:
            Pcd = PcdClass(Key[0], '', Key[1], '', '', Key[2], Key[3], [], {}, [])
            Pcd.SupArchList = Pcds[Key]
            self.Platform.DynamicPcdBuildDefinitions.append(Pcd)

    ## Gen DynamicDefaultPcds
    #
    # Gen DynamicDefaultPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<DatumTyp>[|<MaxDatumSize>]]
    #
    # @param Type:           The type of Pcd
    # @param ContainerFile:  The file which describes the pcd, used for error report
    #
    def GenDynamicDefaultPcds(self, Type = '', ContainerFile = ''):
        Pcds = {}
        SkuInfoList = {}
        if Type == DataType.TAB_PCDS_DYNAMIC_DEFAULT:
            Model = MODEL_PCD_DYNAMIC_DEFAULT
        elif Type == DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT:
            Model = MODEL_PCD_DYNAMIC_EX_DEFAULT
        else:
            pass
        EdkLogger.debug(2, "Generate %s ..." % Type)

        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)

        #
        # Get all DynamicDefaultPcds
        #
        RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        (K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(NewItem, Type, Filename, -1)
                        MergeArches(Pcds,  (K1, K2, K3, K4, K5, K6, IncludeFile[4]), Arch)
                        self.PcdToken[Record[3]] = (K2, K1)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    (K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(Record[0], Type, ContainerFile, Record[2])
                    MergeArches(Pcds,  (K1, K2, K3, K4, K5, K6, Record[4]), Arch)
                    self.PcdToken[Record[3]] = (K2, K1)

        for Key in Pcds:
            (Status, SkuInfoList) = self.GenSkuInfoList(Key[6], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2])
            if Status == False:
                ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
                EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
            Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], SkuInfoList, [])
            Pcd.SupArchList = Pcds[Key]
            self.Platform.DynamicPcdBuildDefinitions.append(Pcd)

    ## Gen DynamicHiiPcds
    #
    # Gen DynamicHiiPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<String>|<VariableGuidCName>|<VariableOffset>[|<DefaultValue>[|<MaximumDatumSize>]]
    #
    # @param Type:           The type of Pcd
    # @param ContainerFile:  The file which describes the pcd, used for error report
    #
    def GenDynamicHiiPcds(self, Type = '', ContainerFile = ''):
        Pcds = {}
        SkuInfoList = {}
        if Type == DataType.TAB_PCDS_DYNAMIC_HII:
            Model = MODEL_PCD_DYNAMIC_HII
        elif Type == DataType.TAB_PCDS_DYNAMIC_EX_HII:
            Model = MODEL_PCD_DYNAMIC_EX_HII
        else:
            pass
        EdkLogger.debug(2, "Generate %s ..." % Type)

        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)

        #
        # Get all DynamicHiiPcds
        #
        RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        (K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(NewItem, Type, Filename, -1)
                        MergeArches(Pcds,  (K1, K2, K3, K4, K5, K6, K7, K8, IncludeFile[4]), Arch)
                        self.PcdToken[Record[3]] = (K2, K1)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    (K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(Record[0], Type, ContainerFile, Record[2])
                    MergeArches(Pcds,  (K1, K2, K3, K4, K5, K6, K7, K8, Record[4]), Arch)
                    self.PcdToken[Record[3]] = (K2, K1)

        for Key in Pcds:
            (Status, SkuInfoList) = self.GenSkuInfoList(Key[8], self.Platform.SkuInfos.SkuInfoList, Key[2], Key[3], Key[4], Key[5], '', '')
            if Status == False:
                ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
                EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
            Pcd = PcdClass(Key[0], '', Key[1], '', Key[6], Key[5], Key[7], [], SkuInfoList, [])
            Pcd.SupArchList = Pcds[Key]
            self.Platform.DynamicPcdBuildDefinitions.append(Pcd)

    ## Gen DynamicVpdPcds
    #
    # Gen DynamicVpdPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<VpdOffset>[|<MaximumDatumSize>]
    #
    # @param Type:           The type of Pcd
    # @param ContainerFile:  The file which describes the pcd, used for error report
    #
    def GenDynamicVpdPcds(self, Type = '', ContainerFile = ''):
        Pcds = {}
        SkuInfoList = {}
        if Type == DataType.TAB_PCDS_DYNAMIC_VPD:
            Model = MODEL_PCD_DYNAMIC_VPD
        elif Type == DataType.TAB_PCDS_DYNAMIC_EX_VPD:
            Model = MODEL_PCD_DYNAMIC_EX_VPD
        else:
            pass
        EdkLogger.debug(2, "Generate %s ..." % Type)

        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)

        #
        # Get all DynamicVpdPcds
        #
        RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        (K1, K2, K3, K4, K5) = GetDynamicVpdPcd(NewItem, Type, Filename, -1)
                        MergeArches(Pcds,  (K1, K2, K3, K4, K5, IncludeFile[4]), Arch)
                        self.PcdToken[Record[3]] = (K2, K1)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    (K1, K2, K3, K4, K5) = GetDynamicVpdPcd(Record[0], Type, ContainerFile, Record[2])
                    MergeArches(Pcds,  (K1, K2, K3, K4, K5, Record[4]), Arch)
                    self.PcdToken[Record[3]] = (K2, K1)

        for Key in Pcds:
            (Status, SkuInfoList) = self.GenSkuInfoList(Key[5], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '')
            if Status == False:
                ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
                EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
            Pcd = PcdClass(Key[0], '', Key[1], '', Key[3], '', Key[4], [], SkuInfoList, [])
            Pcd.SupArchList = Pcds[Key]
            self.Platform.DynamicPcdBuildDefinitions.append(Pcd)


    ## Get Component
    #
    # Get Component section defined in Dsc file
    #
    # @param ContainerFile:  The file which describes the Components, used for error report
    #
    # @retval PlatformModuleClass() A instance for PlatformModuleClass
    #
    def GenComponents(self, ContainerFile):
        EdkLogger.debug(2, "Generate %s ..." % TAB_COMPONENTS)
        Components = sdict()
        #
        # Get all include files
        #
        IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_META_DATA_COMPONENT, self.FileID)

        #
        # Get all Components
        #
        RecordSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_COMPONENT, -1, self.FileID)

        #
        # Go through each arch
        #
        for Arch in DataType.ARCH_LIST:
            for IncludeFile in IncludeFiles:
                if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
                    Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_COMPONENTS, '', IncludeFile[2])
                    for NewItem in open(Filename, 'r').readlines():
                        if CleanString(NewItem) == '':
                            continue
                        NewItems = []
                        GetComponents(open(Filename, 'r').read(), TAB_COMPONENTS, NewItems, TAB_COMMENT_SPLIT)
                        for NewComponent in NewItems:
                            MergeArches(Components, self.GenComponent(NewComponent, Filename), Arch)

            for Record in RecordSet:
                if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
                    Lib, Bo, Pcd = [], [], []

                    SubLibSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, Record[3], self.FileID)
                    for SubLib in SubLibSet:
                        Lib.append(TAB_VALUE_SPLIT.join([SubLib[0],SubLib[4]]))

                    SubBoSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_BUILD_OPTION, Record[3], self.FileID)
                    for SubBo in SubBoSet:
                        Bo.append(SubBo[0])

                    SubPcdSet1 = QueryDscItem(self.TblDsc, MODEL_PCD_FIXED_AT_BUILD, Record[3], self.FileID)
                    SubPcdSet2 = QueryDscItem(self.TblDsc, MODEL_PCD_PATCHABLE_IN_MODULE, Record[3], self.FileID)
                    SubPcdSet3 = QueryDscItem(self.TblDsc, MODEL_PCD_FEATURE_FLAG, Record[3], self.FileID)
                    SubPcdSet4 = QueryDscItem(self.TblDsc, MODEL_PCD_DYNAMIC_EX_DEFAULT, Record[3], self.FileID)
                    SubPcdSet5 = QueryDscItem(self.TblDsc, MODEL_PCD_DYNAMIC_DEFAULT, Record[3], self.FileID)
                    for SubPcd in SubPcdSet1:
                        Pcd.append([DataType.TAB_PCDS_FIXED_AT_BUILD, SubPcd[0], SubPcd[3]])
                    for SubPcd in SubPcdSet2:
                        Pcd.append([DataType.TAB_PCDS_PATCHABLE_IN_MODULE, SubPcd[0], SubPcd[3]])
                    for SubPcd in SubPcdSet3:
                        Pcd.append([DataType.TAB_PCDS_FEATURE_FLAG, SubPcd[0], SubPcd[3]])
                    for SubPcd in SubPcdSet4:
                        Pcd.append([DataType.TAB_PCDS_DYNAMIC_EX, SubPcd[0], SubPcd[3]])
                    for SubPcd in SubPcdSet5:
                        Pcd.append([DataType.TAB_PCDS_DYNAMIC, SubPcd[0], SubPcd[3]])
                    Item = [Record[0], Lib, Bo, Pcd]
                    MergeArches(Components, self.GenComponent(Item, ContainerFile), Arch)

        for Key in Components.keys():
            Key.SupArchList = Components[Key]
            self.Platform.Modules.ModuleList.append(Key)

    ## Get Component
    #
    # Get Component section defined in Dsc file
    #
    # @param Item:           Contents includes a component block
    # @param ContainerFile:  The file which describes the library class, used for error report
    #
    # @retval PlatformModuleClass() A instance for PlatformModuleClass
    #
    def GenComponent(self, Item, ContainerFile, LineNo = -1):
        (InfFilename, ExecFilename) = GetExec(Item[0])
        LibraryClasses = Item[1]
        BuildOptions = Item[2]
        Pcds = Item[3]
        Component = PlatformModuleClass()
        Component.FilePath = NormPath(InfFilename)
        Component.ExecFilePath = NormPath(ExecFilename)
        CheckFileType(Component.FilePath, '.Inf', ContainerFile, 'component name', Item[0], LineNo)
        CheckFileExist(self.WorkspaceDir, Component.FilePath, ContainerFile, 'component', Item[0], LineNo)
        for Lib in LibraryClasses:
            List = GetSplitValueList(Lib)
            if len(List) != 2:
                RaiseParserError(Lib, 'LibraryClasses', ContainerFile, '<ClassName>|<InfFilename>')
            LibName = List[0]
            LibFile = NormPath(List[1])
            if LibName == "" or LibName == "NULL":
                LibName = "NULL%d" % self._NullClassIndex
                self._NullClassIndex += 1
            CheckFileType(List[1], '.Inf', ContainerFile, 'library instance of component ', Lib, LineNo)
            CheckFileExist(self.WorkspaceDir, LibFile, ContainerFile, 'library instance of component', Lib, LineNo)
            Component.LibraryClasses.LibraryList.append(PlatformLibraryClass(LibName, LibFile))
        for BuildOption in BuildOptions:
            Key = GetBuildOption(BuildOption, ContainerFile)
            Component.ModuleSaBuildOption.BuildOptionList.append(BuildOptionClass(Key[0], Key[1], Key[2]))
        for Pcd in Pcds:
            Type = Pcd[0]
            List = GetSplitValueList(Pcd[1])
            PcdId = Pcd[2]

            TokenInfo = None
            #
            # For FeatureFlag
            #
            if Type == DataType.TAB_PCDS_FEATURE_FLAG:
                if len(List) != 2:
                    RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|TRUE/FALSE')

                CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
                TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
                Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', List[1], Type, [], {}, []))
            #
            # For FixedAtBuild or PatchableInModule
            #
            if Type == DataType.TAB_PCDS_FIXED_AT_BUILD or Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:
                List.append('')
                if len(List) != 3 and len(List) != 4:
                    RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|<Value>[|<MaxDatumSize>]')

                CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
                TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
                Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', List[2], List[1], Type, [], {}, []))

            #
            # For Dynamic or DynamicEx
            #
            if Type == DataType.TAB_PCDS_DYNAMIC or Type == DataType.TAB_PCDS_DYNAMIC_EX:
                if len(List) != 1:
                    RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>')

                CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
                TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
                Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', '', Type, [], {}, []))

            #
            # Add to PcdToken
            #
            self.PcdToken[PcdId] = (TokenInfo[0], TokenInfo[1])

        return Component
    #End of GenComponent

    ## Gen SkuInfoList
    #
    # Gen SkuInfoList section defined in Dsc file
    #
    # @param SkuNameList:      Input value for SkuNameList
    # @param SkuInfo:          Input value for SkuInfo
    # @param VariableName:     Input value for VariableName
    # @param VariableGuid:     Input value for VariableGuid
    # @param VariableOffset:   Input value for VariableOffset
    # @param HiiDefaultValue:  Input value for HiiDefaultValue
    # @param VpdOffset:        Input value for VpdOffset
    # @param DefaultValue:     Input value for DefaultValue
    #
    # @retval (False, SkuName)     Not found in section SkuId Dsc file
    # @retval (True, SkuInfoList)  Found in section SkuId of Dsc file
    #
    def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName = '', VariableGuid = '', VariableOffset = '', HiiDefaultValue = '', VpdOffset = '', DefaultValue = ''):
        SkuNameList = GetSplitValueList(SkuNameList)
        if SkuNameList == None or SkuNameList == [] or SkuNameList == ['']:
            SkuNameList = ['DEFAULT']
        SkuInfoList = {}
        for Item in SkuNameList:
            if Item not in SkuInfo:
                return False, Item
            Sku = SkuInfoClass(Item, SkuInfo[Item], VariableName, VariableGuid, VariableOffset, HiiDefaultValue, VpdOffset, DefaultValue)
            SkuInfoList[Item] = Sku

        return True, SkuInfoList

    ## Parse Include statement
    #
    # Get include file path
    #
    # 1. Insert a record into TblFile ???
    # 2. Insert a record into TblDsc
    # Value1: IncludeFilePath
    #
    # @param LineValue:  The line of incude statement
    def ParseInclude(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
        EdkLogger.debug(EdkLogger.DEBUG_2, "!include statement '%s' found in section %s" % (LineValue, SectionName))
        SectionModel = Section[SectionName.upper()]
        IncludeFile = CleanString(LineValue[LineValue.upper().find(DataType.TAB_INCLUDE.upper() + ' ') + len(DataType.TAB_INCLUDE + ' ') : ])
        Table.Insert(Model, IncludeFile, '', '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)

    ## Parse DEFINE statement
    #
    # Get DEFINE macros
    #
    # 1. Insert a record into TblDsc
    # Value1: Macro Name
    # Value2: Macro Value
    #
    def ParseDefine(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
        EdkLogger.debug(EdkLogger.DEBUG_2, "DEFINE statement '%s' found in section %s" % (LineValue, SectionName))
        SectionModel = Section[SectionName.upper()]
        Define = GetSplitValueList(CleanString(LineValue[LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') + len(DataType.TAB_DEFINE + ' ') : ]), TAB_EQUAL_SPLIT, 1)
        Table.Insert(Model, Define[0], Define[1], '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)

    ## Parse Defines section
    #
    # Get one item in defines section
    #
    # Value1: Item Name
    # Value2: Item Value
    #
    def ParseDefinesSection(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
        EdkLogger.debug(EdkLogger.DEBUG_2, "Parse '%s' found in section %s" % (LineValue, SectionName))
        Defines = GetSplitValueList(LineValue, TAB_EQUAL_SPLIT, 1)
        if len(Defines) != 2:
            RaiseParserError(LineValue, SectionName, Filename, '', StartLine)
        self.TblDsc.Insert(Model, Defines[0], Defines[1], '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)

    ## Insert conditional statements
    #
    # Pop an item from IfDefList
    # Insert conditional statements to database
    #
    # @param Filename:   Path of parsing file
    # @param IfDefList:  A list stored current conditional statements
    # @param EndLine:    The end line no
    # @param ArchList:   Support arch list
    #
    def InsertConditionalStatement(self, Filename, FileID, BelongsToItem, IfDefList, EndLine, ArchList):
        (Value1, Value2, Value3, Model, StartColumn, EndColumn, Enabled) = ('', '', '', -1, -1, -1, 0)
        if IfDefList == []:
            ErrorMsg = 'Not suited conditional statement in file %s' % Filename
            EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename, RaiseError = EdkLogger.IsRaiseError)
        else:
            #
            # Get New Dsc item ID
            #
            DscID = self.TblDsc.GetCount() + 1

            #
            # Pop the conditional statements which is closed
            #
            PreviousIf = IfDefList.pop()
            EdkLogger.debug(EdkLogger.DEBUG_5, 'Previous IfDef: ' + str(PreviousIf))

            #
            # !ifdef and !ifndef
            #
            if PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF):
                Value1 = PreviousIf[0]
                Model = PreviousIf[2]
                self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
            #
            # !if and !elseif
            #
            elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, Model):
                List = PreviousIf[0].split(' ')
                Value1, Value2, Value3 = '', '==', '0'
                if len(List) == 3:
                    Value1 = List[0]
                    Value2 = List[1]
                    Value3 = List[2]
                    Value3 = SplitString(Value3)
                if len(List) == 1:
                    Value1 = List[0]
                Model = PreviousIf[2]
                self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
            #
            # !else
            #
            elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, Model):
                Value1 = PreviousIf[0].strip()
                Model = PreviousIf[2]
                self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)

    ## Load Dsc file
    #
    # Load the file if it exists
    #
    # @param Filename:  Input value for filename of Dsc file
    #
    def LoadDscFile(self, Filename):
        #
        # Insert a record for file
        #
        Filename = NormPath(Filename)
        self.Identification.FileFullPath = Filename
        (self.Identification.FileRelativePath, self.Identification.FileName) = os.path.split(Filename)
        self.FileID = self.TblFile.InsertFile(Filename, MODEL_FILE_DSC)

        #
        # Init DscTable
        #
        #self.TblDsc.Table = "Dsc%s" % FileID
        #self.TblDsc.Create()

        #
        # Init common datas
        #
        IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \
        [], [], TAB_UNKNOWN, [], [], []
        LineNo = 0

        #
        # Parse file content
        #
        IsFindBlockComment = False
        ReservedLine = ''
        for Line in open(Filename, 'r'):
            LineNo = LineNo + 1
            #
            # Remove comment block
            #
            if Line.find(TAB_COMMENT_EDK_START) > -1:
                ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]
                IsFindBlockComment = True
            if Line.find(TAB_COMMENT_EDK_END) > -1:
                Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]
                ReservedLine = ''
                IsFindBlockComment = False
            if IsFindBlockComment:
                continue

            #
            # Remove comments at tail and remove spaces again
            #
            Line = CleanString(Line)
            if Line == '':
                continue

            #
            # Find a new section tab
            # First insert previous section items
            # And then parse the content of the new section
            #
            if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SECTION_END):
                #
                # Insert items data of previous section
                #
                self.InsertSectionItemsIntoDatabase(self.FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList)
                #
                # Parse the new section
                #
                SectionItemList = []
                ArchList = []
                ThirdList = []

                CurrentSection = ''
                LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
                for Item in LineList:
                    ItemList = GetSplitValueList(Item, TAB_SPLIT)
                    if CurrentSection == '':
                        CurrentSection = ItemList[0]
                    else:
                        if CurrentSection != ItemList[0]:
                            EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
                    if CurrentSection.upper() not in self.KeyList:
                        RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
                        CurrentSection = TAB_UNKNOWN
                        continue
                    ItemList.append('')
                    ItemList.append('')
                    if len(ItemList) > 5:
                        RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
                    else:
                        if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
                            EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
                        ArchList.append(ItemList[1].upper())
                        ThirdList.append(ItemList[2])

                continue

            #
            # Not in any defined section
            #
            if CurrentSection == TAB_UNKNOWN:
                ErrorMsg = "%s is not in any defined section" % Line
                EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)

            #
            # Add a section item
            #
            SectionItemList.append([Line, LineNo])
            # End of parse
        #End of For

        #
        # Insert items data of last section
        #
        self.InsertSectionItemsIntoDatabase(self.FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList)

        #
        # Parse conditional statements
        #
        self.ParseConditionalStatement()

        #
        # Replace all DEFINE macros with its actual values
        #
        #ParseDefineMacro2(self.TblDsc, self.RecordSet, GlobalData.gGlobalDefines)
        ParseDefineMacro(self.TblDsc, GlobalData.gGlobalDefines)


    ## ParseConditionalStatement
    #
    # Search all conditional statement and disable no match records
    #
    def ParseConditionalStatement(self):
        #
        # Disabled all !if/!elif/!ifdef statements without DEFINE
        #
        SqlCommand = """select A.StartLine, A.EndLine from %s as A
                        where A.Model in (%s, %s, %s)
                        and A.Enabled = 0
                        and A.BelongsToFile = %s
                        and A.Value1 not in (select B.Value1 from %s as B
                                             where B.Model = %s
                                             and B.Enabled = 0
                                             and A.StartLine > B.StartLine
                                             and A.Arch = B.Arch
                                             and A.BelongsToItem = B.BelongsToItem
                                             and A.BelongsToFile = B.BelongsToFile) """ % \
                        (self.TblDsc.Table, \
                         MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, \
                         self.FileID, \
                         self.TblDsc.Table, \
                         MODEL_META_DATA_DEFINE)
        RecordSet = self.TblDsc.Exec(SqlCommand)
        for Record in RecordSet:
            SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[0], Record[1])
            self.TblDsc.Exec(SqlCommand)

        #
        # Disabled !ifndef with DEFINE
        #
        SqlCommand = """select A.StartLine, A.EndLine from %s as A
                        where A.Model = %s
                        and A.Enabled = 0
                        and A.BelongsToFile = %s
                        and A.Value1 in (select B.Value1 from %s as B
                                         where B.Model = %s
                                         and B.Enabled = 0
                                         and A.StartLine > B.StartLine
                                         and A.Arch = B.Arch
                                         and A.BelongsToItem = B.BelongsToItem
                                         and A.BelongsToFile = B.BelongsToFile)""" % \
                        (self.TblDsc.Table, \
                         MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF, \
                         self.FileID, \
                         self.TblDsc.Table, \
                         MODEL_META_DATA_DEFINE)
        RecordSet = self.TblDsc.Exec(SqlCommand)
        for Record in RecordSet:
            SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[0], Record[1])
            EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)
            self.Cur.execute(SqlCommand)

        #
        # Disabled !if, !elif and !else with un-match value
        #
        SqlCommand = """select A.Model, A.Value1, A.Value2, A.Value3, A.StartLine, A.EndLine, B.Value2 from %s as A join %s as B
                        where A.Model in (%s, %s)
                        and A.Enabled = 0
                        and A.BelongsToFile = %s
                        and B.Enabled = 0
                        and B.Model = %s
                        and A.Value1 = B.Value1
                        and A.StartLine > B.StartLine
                        and A.BelongsToItem = B.BelongsToItem
                        and A.BelongsToFile = B.BelongsToFile""" % \
                        (self.TblDsc.Table, self.TblDsc.Table, \
                         MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, \
                         self.FileID, MODEL_META_DATA_DEFINE)
        RecordSet = self.TblDsc.Exec(SqlCommand)
        DisabledList = []
        for Record in RecordSet:
            if Record[0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_IF:
                if not self.Compare(Record[6], Record[2], Record[3]):
                    SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[4], Record[5])
                    self.TblDsc.Exec(SqlCommand)
                else:
                    DisabledList.append(Record[1])
                continue
            if Record[0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE and Record[1] in DisabledList:
                SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[4], Record[5])
                self.TblDsc.Exec(SqlCommand)

    ## Compare
    #
    # Compare two values
    # @param Value1:
    # @param CompareType:
    # @param Value2:
    #
    def Compare(self, Value1, CompareType, Value2):
        Command = """Value1 %s Value2""" %CompareType
        return eval(Command)

    ## First time to insert records to database
    #
    # Insert item data of a section to database
    # @param FileID:           The ID of belonging file
    # @param Filename:         The name of belonging file
    # @param CurrentSection:   The name of currect section
    # @param SectionItemList:  A list of items of the section
    # @param ArchList:         A list of arches
    # @param ThirdList:        A list of third parameters, ModuleType for LibraryClass and SkuId for Dynamic Pcds
    # @param IfDefList:        A list of all conditional statements
    #
    def InsertSectionItemsIntoDatabase(self, FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList):
        #
        # Insert each item data of a section
        #
        for Index in range(0, len(ArchList)):
            Arch = ArchList[Index]
            Third = ThirdList[Index]
            if Arch == '':
                Arch = TAB_ARCH_COMMON.upper()

            Model = Section[CurrentSection.upper()]
            #Records = self.RecordSet[Model]

            for SectionItem in SectionItemList:
                BelongsToItem, EndLine, EndColumn = -1, -1, -1
                LineValue, StartLine, EndLine = SectionItem[0], SectionItem[1], SectionItem[1]


                EdkLogger.debug(4, "Parsing %s ..." %LineValue)
                #
                # Parse '!ifdef'
                #
                if LineValue.upper().find(TAB_IF_DEF.upper()) > -1:
                    IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF))
                    continue

                #
                # Parse '!ifndef'
                #
                if LineValue.upper().find(TAB_IF_N_DEF.upper()) > -1:
                    IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF))
                    continue

                #
                # Parse '!endif'
                #
                if LineValue.upper().find(TAB_END_IF.upper()) > -1:
                    self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine, Arch)
                    continue
                #
                # Parse '!if'
                #
                if LineValue.upper().find(TAB_IF.upper()) > -1:
                    IfDefList.append((LineValue[len(TAB_IF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF))
                    continue

                #
                # Parse '!elseif'
                #
                if LineValue.upper().find(TAB_ELSE_IF.upper()) > -1:
                    self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine - 1, Arch)
                    IfDefList.append((LineValue[len(TAB_ELSE_IF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF))
                    continue

                #
                # Parse '!else'
                #
                if LineValue.upper().find(TAB_ELSE.upper()) > -1:
                    Key = IfDefList[-1][0].split(' ' , 1)[0].strip()
                    self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine, Arch)
                    IfDefList.append((Key, StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE))
                    continue

                #
                # Parse !include statement first
                #
                if LineValue.upper().find(DataType.TAB_INCLUDE.upper() + ' ') > -1:
                    self.ParseInclude(LineValue, StartLine, self.TblDsc, FileID, Filename, CurrentSection, MODEL_META_DATA_INCLUDE, Arch)
                    continue

                #
                # And then parse DEFINE statement
                #
                if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') > -1:
                    self.ParseDefine(LineValue, StartLine, self.TblDsc, FileID, Filename, CurrentSection, MODEL_META_DATA_DEFINE, Arch)
                    continue

                #
                # At last parse other sections
                #
                if CurrentSection == TAB_LIBRARY_CLASSES or CurrentSection in TAB_PCD_DYNAMIC_TYPE_LIST or CurrentSection in TAB_PCD_DYNAMIC_EX_TYPE_LIST:
                    ID = self.TblDsc.Insert(Model, LineValue, Third, '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
                    #Records.append([LineValue, Arch, StartLine, ID, Third])
                    continue
                elif CurrentSection != TAB_COMPONENTS:
                    ID = self.TblDsc.Insert(Model, LineValue, '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
                    #Records.append([LineValue, Arch, StartLine, ID, Third])
                    continue

            #
            # Parse COMPONENT section
            #
            if CurrentSection == TAB_COMPONENTS:
                Components = []
                GetComponent(SectionItemList, Components)
                for Component in Components:
                    EdkLogger.debug(4, "Parsing component %s ..." %Component)
                    DscItmeID = self.TblDsc.Insert(MODEL_META_DATA_COMPONENT, Component[0], '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
                    for Item in Component[1]:
                        List = GetSplitValueList(Item, MaxSplit = 2)
                        LibName, LibIns = '', ''
                        if len(List) == 2:
                            LibName = List[0]
                            LibIns = List[1]
                        else:
                            LibName = List[0]
                        self.TblDsc.Insert(MODEL_EFI_LIBRARY_CLASS, LibName, LibIns, '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)
                    for Item in Component[2]:
                        self.TblDsc.Insert(MODEL_META_DATA_BUILD_OPTION, Item, '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)
                    for Item in Component[3]:
                        Model = Section[Item[0].upper()]
                        self.TblDsc.Insert(Model, Item[1], '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)

    ## Show detailed information of Dsc
    #
    # Print all members and their values of Dsc class
    #
    def ShowDsc(self):
        print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END
        printDict(self.Defines.DefinesDictionary)

        for Key in self.KeyList:
            for Arch in DataType.ARCH_LIST_FULL:
                Command = "printList(TAB_SECTION_START + '" + \
                                    Key + DataType.TAB_SPLIT + Arch + \
                                    "' + TAB_SECTION_END, self.Contents[arch]." + Key + ')'
                eval(Command)

    ## Show detailed information of Platform
    #
    # Print all members and their values of Platform class
    #
    def ShowPlatform(self):
        M = self.Platform
        for Arch in M.Header.keys():
            print '\nArch =', Arch
            print 'Filename =', M.Header[Arch].FileName
            print 'FullPath =', M.Header[Arch].FullPath
            print 'BaseName =', M.Header[Arch].Name
            print 'Guid =', M.Header[Arch].Guid
            print 'Version =', M.Header[Arch].Version
            print 'DscSpecification =', M.Header[Arch].DscSpecification
            print 'SkuId =', M.Header[Arch].SkuIdName
            print 'SupArchList =', M.Header[Arch].SupArchList
            print 'BuildTargets =', M.Header[Arch].BuildTargets
            print 'OutputDirectory =', M.Header[Arch].OutputDirectory
            print 'BuildNumber =', M.Header[Arch].BuildNumber
            print 'MakefileName =', M.Header[Arch].MakefileName
            print 'BsBaseAddress =', M.Header[Arch].BsBaseAddress
            print 'RtBaseAddress =', M.Header[Arch].RtBaseAddress
            print 'Define =', M.Header[Arch].Define
        print 'Fdf =', M.FlashDefinitionFile.FilePath
        print '\nBuildOptions =', M.BuildOptions, M.BuildOptions.IncludeFiles
        for Item in M.BuildOptions.BuildOptionList:
            print '\t', 'ToolChainFamily =', Item.ToolChainFamily, 'ToolChain =', Item.ToolChain, 'Option =', Item.Option, 'Arch =', Item.SupArchList
        print '\nSkuIds =', M.SkuInfos.SkuInfoList, M.SkuInfos.IncludeFiles
        print '\nLibraries =', M.Libraries, M.Libraries.IncludeFiles
        for Item in M.Libraries.LibraryList:
            print '\t', Item.FilePath, Item.SupArchList, Item.Define
        print '\nLibraryClasses =', M.LibraryClasses, M.LibraryClasses.IncludeFiles
        for Item in M.LibraryClasses.LibraryList:
            print '\t', Item.Name, Item.FilePath, Item.SupModuleList, Item.SupArchList, Item.Define
        print '\nPcds =', M.DynamicPcdBuildDefinitions
        for Item in M.DynamicPcdBuildDefinitions:
            print '\tCname=', Item.CName, 'TSG=', Item.TokenSpaceGuidCName, 'Value=', Item.DefaultValue, 'Token=', Item.Token, 'Type=', Item.ItemType, 'Datum=', Item.DatumType, 'Size=', Item.MaxDatumSize, 'Arch=', Item.SupArchList, Item.SkuInfoList
            for Sku in Item.SkuInfoList.values():
                print '\t\t', str(Sku)
        print '\nComponents =', M.Modules.ModuleList, M.Modules.IncludeFiles
        for Item in M.Modules.ModuleList:
            print '\t', Item.FilePath, Item.ExecFilePath, Item.SupArchList
            for Lib in Item.LibraryClasses.LibraryList:
                print '\t\tLib:', Lib.Name, Lib.FilePath
            for Bo in Item.ModuleSaBuildOption.BuildOptionList:
                print '\t\tBuildOption:', Bo.ToolChainFamily, Bo.ToolChain, Bo.Option
            for Pcd in Item.PcdBuildDefinitions:
                print '\t\tPcd:', Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.MaxDatumSize, Pcd.DefaultValue, Pcd.ItemType

##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
#
if __name__ == '__main__':
    EdkLogger.Initialize()
    EdkLogger.SetLevel(EdkLogger.DEBUG_0)

    W = os.getenv('WORKSPACE')
    F = os.path.join(W, 'Nt32Pkg/Nt32Pkg.dsc')

    Db = Database.Database('Dsc.db')
    Db.InitDatabase()

    P = Dsc(os.path.normpath(F), True, True, W, Db)
    P.ShowPlatform()

    Db.Close()