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