]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Ecc/MetaDataParser.py
Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / MetaDataParser.py
1 ## @file
2 # This file is used to define common parser functions for meta-data
3 #
4 # Copyright (c) 2008, Intel Corporation
5 # All rights reserved. This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13
14 import os
15 from CommonDataClass.DataClass import *
16
17
18 ## Get the inlcude path list for a source file
19 #
20 # 1. Find the source file belongs to which inf file
21 # 2. Find the inf's package
22 # 3. Return the include path list of the package
23 #
24 def GetIncludeListOfFile(WorkSpace, Filepath, Db):
25 IncludeList = []
26 Filepath = os.path.normpath(Filepath)
27 SqlCommand = """
28 select Value1, FullPath from Inf, File where Inf.Model = %s and Inf.BelongsToFile in(
29 select distinct B.BelongsToFile from File as A left join Inf as B
30 where A.ID = B.BelongsToFile and B.Model = %s and (A.Path || '%s' || B.Value1) = '%s')
31 and Inf.BelongsToFile = File.ID""" \
32 % (MODEL_META_DATA_PACKAGE, MODEL_EFI_SOURCE_FILE, '\\', Filepath)
33 RecordSet = Db.TblFile.Exec(SqlCommand)
34 for Record in RecordSet:
35 DecFullPath = os.path.normpath(os.path.join(WorkSpace, Record[0]))
36 InfFullPath = os.path.normpath(os.path.join(WorkSpace, Record[1]))
37 (DecPath, DecName) = os.path.split(DecFullPath)
38 (InfPath, InfName) = os.path.split(InfFullPath)
39 SqlCommand = """select Value1 from Dec where BelongsToFile =
40 (select ID from File where FullPath = '%s') and Model = %s""" \
41 % (DecFullPath, MODEL_EFI_INCLUDE)
42 NewRecordSet = Db.TblDec.Exec(SqlCommand)
43 if InfPath not in IncludeList:
44 IncludeList.append(InfPath)
45 for NewRecord in NewRecordSet:
46 IncludePath = os.path.normpath(os.path.join(DecPath, NewRecord[0]))
47 if IncludePath not in IncludeList:
48 IncludeList.append(IncludePath)
49
50 return IncludeList
51
52 ## Get the table list
53 #
54 # Search table file and find all small tables
55 #
56 def GetTableList(FileModelList, Table, Db):
57 TableList = []
58 SqlCommand = """select ID from File where Model in %s""" % str(FileModelList)
59 RecordSet = Db.TblFile.Exec(SqlCommand)
60 for Record in RecordSet:
61 TableName = Table + str(Record[0])
62 TableList.append(TableName)
63
64 return TableList
65