]>
Commit | Line | Data |
---|---|---|
b0282412 | 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 | |
0dc8c589 | 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 | |
5ea254f6 | 20 | public final class ModuleReader {\r |
5ea254f6 | 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 | |
0dc8c589 | 24 | \r |
5ea254f6 | 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 | |
0dc8c589 | 27 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = msadoc.getModuleSurfaceArea();\r |
28 | MsaHeaderDocument.MsaHeader msaheader = msa.getMsaHeader();\r | |
7bcb8d17 | 29 | \r |
0dc8c589 | 30 | mi.modulename = msaheader.getModuleName();\r |
31 | mi.guidvalue = msaheader.getGuidValue();\r | |
32 | mi.moduletype = msaheader.getModuleType().toString(); // ???\r | |
7bcb8d17 | 33 | \r |
0dc8c589 | 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 | |
719cebfe | 40 | System.out.println("Source File Missing! : " + temp);\r |
0dc8c589 | 41 | }\r |
42 | }\r | |
43 | }\r | |
44 | \r | |
5ea254f6 | 45 | public static final void readInf(String name, ModuleInfo mi) throws Exception {\r |
fed802b1 | 46 | System.out.println("\nParsing INF file: " + name);\r |
90503bad | 47 | String wholeline;\r |
0dc8c589 | 48 | Matcher mtrinfequation;\r |
90503bad | 49 | Matcher mtrsection;\r |
50 | Matcher mtrfilename;\r | |
0dc8c589 | 51 | \r |
5ea254f6 | 52 | wholeline = Common.file2string(mi.modulepath + File.separator + name);\r |
90503bad | 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 | |
0dc8c589 | 60 | }\r |
90503bad | 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 | |
7bcb8d17 | 77 | MigrationTool.ui.println("DPX File Missing! : " + mtrinfequation.group(2));\r |
0dc8c589 | 78 | }\r |
79 | }\r | |
90503bad | 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 | |
7bcb8d17 | 86 | MigrationTool.ui.println("Source File Missing! : " + mtrfilename.group());\r |
0dc8c589 | 87 | }\r |
88 | }\r | |
89 | }\r | |
90 | }\r | |
91 | }\r | |
719cebfe | 92 | }\r |