]>
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("\nParsing INF file: " + name);\r | |
58 | String wholeline;\r | |
59 | Matcher mtrinfequation;\r | |
60 | Matcher mtrsection;\r | |
61 | Matcher mtrfilename;\r | |
62 | \r | |
63 | wholeline = Common.file2string(modulepath + File.separator + name);\r | |
64 | mtrsection = ptnsection.matcher(wholeline);\r | |
65 | while (mtrsection.find()) {\r | |
66 | if (mtrsection.group(1).matches("defines")) {\r | |
67 | mtrinfequation = ptninfequation.matcher(mtrsection.group(2));\r | |
68 | while (mtrinfequation.find()) {\r | |
69 | if (mtrinfequation.group(1).matches("BASE_NAME")) {\r | |
70 | mi.modulename = mtrinfequation.group(2);\r | |
71 | }\r | |
72 | if (mtrinfequation.group(1).matches("FILE_GUID")) {\r | |
73 | mi.guidvalue = mtrinfequation.group(2);\r | |
74 | }\r | |
75 | if (mtrinfequation.group(1).matches("COMPONENT_TYPE")) {\r | |
76 | mi.moduletype = mtrinfequation.group(2);\r | |
77 | }\r | |
78 | }\r | |
79 | }\r | |
80 | if (mtrsection.group(1).matches("nmake.common")) {\r | |
81 | mtrinfequation = ptninfequation.matcher(mtrsection.group(2));\r | |
82 | while (mtrinfequation.find()) {\r | |
83 | if (mtrinfequation.group(1).matches("IMAGE_ENTRY_POINT")) {\r | |
84 | mi.entrypoint = mtrinfequation.group(2);\r | |
85 | }\r | |
86 | if (mtrinfequation.group(1).matches("DPX_SOURCE")) {\r | |
87 | if (!mi.localmodulesources.contains(mtrinfequation.group(2))) {\r | |
88 | ui.println("DPX File Missing! : " + mtrinfequation.group(2));\r | |
89 | }\r | |
90 | }\r | |
91 | }\r | |
92 | }\r | |
93 | if (mtrsection.group(1).contains("sources.")) {\r | |
94 | mtrfilename = ptnfilename.matcher(mtrsection.group(2));\r | |
95 | while (mtrfilename.find()) {\r | |
96 | if (!mi.localmodulesources.contains(mtrfilename.group())) {\r | |
97 | ui.println("Source File Missing! : " + mtrfilename.group());\r | |
98 | }\r | |
99 | }\r | |
100 | }\r | |
101 | }\r | |
102 | }\r | |
103 | }\r |