]>
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 final class ModuleReader {\r | |
21 | private static final Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*=\\s*([^\\s]*)");\r | |
22 | private static final Pattern ptnsection = Pattern.compile("\\[([^\\[\\]]*)\\]([^\\[\\]]*)\\n", Pattern.MULTILINE);\r | |
23 | private static final Pattern ptnfilename = Pattern.compile("[^\\s]+");\r | |
24 | \r | |
25 | public static final void readMsa(String name, ModuleInfo mi) throws Exception {\r | |
26 | ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(new File(mi.modulepath + File.separator + name));\r | |
27 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = msadoc.getModuleSurfaceArea();\r | |
28 | MsaHeaderDocument.MsaHeader msaheader = msa.getMsaHeader();\r | |
29 | \r | |
30 | mi.modulename = msaheader.getModuleName();\r | |
31 | mi.guidvalue = msaheader.getGuidValue();\r | |
32 | mi.moduletype = msaheader.getModuleType().toString(); // ???\r | |
33 | \r | |
34 | SourceFilesDocument.SourceFiles sourcefiles = msa.getSourceFiles();\r | |
35 | \r | |
36 | String temp;\r | |
37 | Iterator<FilenameDocument.Filename> li = sourcefiles.getFilenameList().iterator();\r | |
38 | while (li.hasNext()) {\r | |
39 | if (!mi.localmodulesources.contains(temp = li.next().toString())) {\r | |
40 | System.out.println("Source File Missing! : " + temp);\r | |
41 | }\r | |
42 | }\r | |
43 | }\r | |
44 | \r | |
45 | public static final void readInf(String name, ModuleInfo mi) throws Exception {\r | |
46 | System.out.println("\nParsing INF file: " + name);\r | |
47 | String wholeline;\r | |
48 | Matcher mtrinfequation;\r | |
49 | Matcher mtrsection;\r | |
50 | Matcher mtrfilename;\r | |
51 | \r | |
52 | wholeline = Common.file2string(mi.modulepath + File.separator + name);\r | |
53 | mtrsection = ptnsection.matcher(wholeline);\r | |
54 | while (mtrsection.find()) {\r | |
55 | if (mtrsection.group(1).matches("defines")) {\r | |
56 | mtrinfequation = ptninfequation.matcher(mtrsection.group(2));\r | |
57 | while (mtrinfequation.find()) {\r | |
58 | if (mtrinfequation.group(1).matches("BASE_NAME")) {\r | |
59 | mi.modulename = mtrinfequation.group(2);\r | |
60 | }\r | |
61 | if (mtrinfequation.group(1).matches("FILE_GUID")) {\r | |
62 | mi.guidvalue = mtrinfequation.group(2);\r | |
63 | }\r | |
64 | if (mtrinfequation.group(1).matches("COMPONENT_TYPE")) {\r | |
65 | mi.moduletype = mtrinfequation.group(2);\r | |
66 | }\r | |
67 | }\r | |
68 | }\r | |
69 | if (mtrsection.group(1).matches("nmake.common")) {\r | |
70 | mtrinfequation = ptninfequation.matcher(mtrsection.group(2));\r | |
71 | while (mtrinfequation.find()) {\r | |
72 | if (mtrinfequation.group(1).matches("IMAGE_ENTRY_POINT")) {\r | |
73 | mi.entrypoint = mtrinfequation.group(2);\r | |
74 | }\r | |
75 | if (mtrinfequation.group(1).matches("DPX_SOURCE")) {\r | |
76 | if (!mi.localmodulesources.contains(mtrinfequation.group(2))) {\r | |
77 | MigrationTool.ui.println("DPX File Missing! : " + mtrinfequation.group(2));\r | |
78 | }\r | |
79 | }\r | |
80 | }\r | |
81 | }\r | |
82 | if (mtrsection.group(1).contains("sources.")) {\r | |
83 | mtrfilename = ptnfilename.matcher(mtrsection.group(2));\r | |
84 | while (mtrfilename.find()) {\r | |
85 | if (!mi.localmodulesources.contains(mtrfilename.group())) {\r | |
86 | MigrationTool.ui.println("Source File Missing! : " + mtrfilename.group());\r | |
87 | }\r | |
88 | }\r | |
89 | }\r | |
90 | }\r | |
91 | }\r | |
92 | }\r |