]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | **/\r | |
13 | package org.tianocore.migration;\r | |
14 | \r | |
15 | import java.io.*;\r | |
16 | import java.util.*;\r | |
17 | import java.util.regex.*;\r | |
18 | import org.tianocore.*;\r | |
19 | \r | |
20 | public class ModuleReader {\r | |
21 | ModuleReader(String path, ModuleInfo moduleinfo, Database database, UI u) {\r | |
22 | modulepath = path;\r | |
23 | mi = moduleinfo;\r | |
24 | db = database;\r | |
25 | ui = u;\r | |
26 | }\r | |
27 | private String modulepath;\r | |
28 | private ModuleInfo mi;\r | |
29 | private Database db;\r | |
30 | private UI ui;\r | |
31 | \r | |
32 | private static Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*=\\s*([^\\s]*)");\r | |
33 | private static Pattern ptnsection = Pattern.compile("\\[([^\\[\\]]*)\\]([^\\[\\]]*)\\n", Pattern.MULTILINE);\r | |
34 | private static Pattern ptnfilename = Pattern.compile("[^\\s]+");\r | |
35 | \r | |
36 | public void readMsa(String name) throws Exception {\r | |
37 | ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(new File(modulepath + File.separator + name));\r | |
38 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = msadoc.getModuleSurfaceArea();\r | |
39 | MsaHeaderDocument.MsaHeader msaheader = msa.getMsaHeader();\r | |
40 | \r | |
41 | mi.modulename = msaheader.getModuleName();\r | |
42 | mi.guidvalue = msaheader.getGuidValue();\r | |
43 | mi.moduletype = msaheader.getModuleType().toString(); // ???\r | |
44 | \r | |
45 | SourceFilesDocument.SourceFiles sourcefiles = msa.getSourceFiles();\r | |
46 | \r | |
47 | String temp;\r | |
48 | Iterator<FilenameDocument.Filename> li = sourcefiles.getFilenameList().iterator();\r | |
49 | while (li.hasNext()) {\r | |
50 | if (!mi.localmodulesources.contains(temp = li.next().toString())) {\r | |
51 | System.out.println("Source File Missing! : " + temp);\r | |
52 | }\r | |
53 | }\r | |
54 | }\r | |
55 | \r | |
56 | public void readInf(String name) throws Exception {\r | |
57 | System.out.println("Parsing INF file: " + name);\r | |
58 | BufferedReader rd = new BufferedReader(new FileReader(modulepath + File.separator + name));\r | |
59 | String line;\r | |
60 | String wholeline;\r | |
61 | String[] linecontext;\r | |
62 | boolean inSrc = false;\r | |
63 | Matcher mtrinfequation;\r | |
64 | Matcher mtrsection;\r | |
65 | Matcher mtrfilename;\r | |
66 | \r | |
67 | wholeline = Common.sourcefiletostring(modulepath + File.separator + name);\r | |
68 | mtrsection = ptnsection.matcher(wholeline);\r | |
69 | while (mtrsection.find()) {\r | |
70 | if (mtrsection.group(1).matches("defines")) {\r | |
71 | mtrinfequation = ptninfequation.matcher(mtrsection.group(2));\r | |
72 | while (mtrinfequation.find()) {\r | |
73 | if (mtrinfequation.group(1).matches("BASE_NAME")) {\r | |
74 | mi.modulename = mtrinfequation.group(2);\r | |
75 | }\r | |
76 | if (mtrinfequation.group(1).matches("FILE_GUID")) {\r | |
77 | mi.guidvalue = mtrinfequation.group(2);\r | |
78 | }\r | |
79 | if (mtrinfequation.group(1).matches("COMPONENT_TYPE")) {\r | |
80 | mi.moduletype = mtrinfequation.group(2);\r | |
81 | }\r | |
82 | }\r | |
83 | }\r | |
84 | if (mtrsection.group(1).matches("nmake.common")) {\r | |
85 | mtrinfequation = ptninfequation.matcher(mtrsection.group(2));\r | |
86 | while (mtrinfequation.find()) {\r | |
87 | if (mtrinfequation.group(1).matches("IMAGE_ENTRY_POINT")) {\r | |
88 | mi.entrypoint = mtrinfequation.group(2);\r | |
89 | }\r | |
90 | if (mtrinfequation.group(1).matches("DPX_SOURCE")) {\r | |
91 | if (!mi.localmodulesources.contains(mtrinfequation.group(2))) {\r | |
92 | ui.println("DPX File Missing! : " + mtrinfequation.group(2));\r | |
93 | }\r | |
94 | }\r | |
95 | }\r | |
96 | }\r | |
97 | if (mtrsection.group(1).contains("sources.")) {\r | |
98 | mtrfilename = ptnfilename.matcher(mtrsection.group(2));\r | |
99 | while (mtrfilename.find()) {\r | |
100 | if (!mi.localmodulesources.contains(mtrfilename.group())) {\r | |
101 | ui.println("Source File Missing! : " + mtrfilename.group());\r | |
102 | }\r | |
103 | }\r | |
104 | }\r | |
105 | }\r | |
106 | }\r | |
107 | }\r |