]>
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 | |
0dc8c589 | 17 | \r |
18 | /*\r | |
19 | Class ModuleInfo is built for scanning the source files, it contains all the needed\r | |
20 | information and all the temporary data.\r | |
21 | */\r | |
22 | public class ModuleInfo {\r | |
5ea254f6 | 23 | ModuleInfo(String modulepath) throws Exception {\r |
0dc8c589 | 24 | this.modulepath = modulepath;\r |
5ea254f6 | 25 | \r |
050e979f | 26 | ModuleInfo.ui.println("Choose where to place the result");\r |
27 | if ((outputpath = ModuleInfo.ui.getFilepath()) == null) {\r | |
5ea254f6 | 28 | outputpath = modulepath; \r |
29 | }\r | |
050e979f | 30 | ModuleInfo.ui.println(outputpath);\r |
0dc8c589 | 31 | }\r |
5ea254f6 | 32 | \r |
5ea254f6 | 33 | public String modulepath = null;\r |
0dc8c589 | 34 | \r |
5ea254f6 | 35 | public String outputpath = null;\r |
0dc8c589 | 36 | \r |
37 | public String modulename = null;\r | |
38 | public String guidvalue = null;\r | |
39 | public String moduletype = null;\r | |
40 | public String entrypoint = null;\r | |
41 | \r | |
42 | public Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h\r | |
0dc8c589 | 43 | public Set<String> preprocessedccodes = new HashSet<String>();\r |
e6a5df3b | 44 | public Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this\r |
0dc8c589 | 45 | \r |
46 | public Set<String> hashfuncc = new HashSet<String>();\r | |
47 | public Set<String> hashfuncd = new HashSet<String>();\r | |
48 | public Set<String> hashnonlocalfunc = new HashSet<String>();\r | |
49 | public Set<String> hashnonlocalmacro = new HashSet<String>();\r | |
50 | public Set<String> hashEFIcall = new HashSet<String>();\r | |
51 | public Set<String> hashr8only = new HashSet<String>();\r | |
52 | \r | |
53 | public Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer \r | |
54 | public Set<String> guid = new HashSet<String>();\r | |
55 | public Set<String> protocol = new HashSet<String>();\r | |
56 | public Set<String> ppi = new HashSet<String>();\r | |
23e3b888 | 57 | \r |
58 | public final void enroll(String filepath) throws Exception {\r | |
59 | String[] temp;\r | |
60 | if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || \r | |
61 | filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {\r | |
62 | temp = filepath.split("\\\\");\r | |
63 | localmodulesources.add(temp[temp.length - 1]);\r | |
64 | } else if (filepath.contains(".inf") || filepath.contains(".msa")) {\r | |
65 | temp = filepath.split("\\\\");\r | |
66 | msaorinf.add(temp[temp.length - 1]);\r | |
67 | }\r | |
68 | }\r | |
69 | \r | |
70 | private static final boolean isModule(String path) {\r | |
71 | String[] list = new File(path).list();\r | |
72 | for (int i = 0 ; i < list.length ; i++) {\r | |
73 | if (!new File(list[i]).isDirectory()) {\r | |
74 | if (list[i].contains(".inf") || list[i].contains(".msa")) {\r | |
75 | return true;\r | |
76 | }\r | |
77 | }\r | |
78 | }\r | |
79 | return false;\r | |
80 | }\r | |
81 | \r | |
82 | //---------------------------------------------------------------------------//\r | |
0dc8c589 | 83 | \r |
23e3b888 | 84 | private static final void manipulate(ModuleInfo mi) throws Exception {\r |
5ea254f6 | 85 | \r |
23e3b888 | 86 | ModuleReader.ModuleScan(mi);\r |
0dc8c589 | 87 | \r |
23e3b888 | 88 | SourceFileReplacer.flush(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"\r |
0dc8c589 | 89 | \r |
90 | // show result\r | |
050e979f | 91 | if (ModuleInfo.printModuleInfo) {\r |
92 | ModuleInfo.ui.println("\nModule Information : ");\r | |
23e3b888 | 93 | ModuleInfo.ui.println("Entrypoint : " + mi.entrypoint);\r |
94 | show(mi.protocol, "Protocol : ");\r | |
95 | show(mi.ppi, "Ppi : ");\r | |
96 | show(mi.guid, "Guid : ");\r | |
97 | show(mi.hashfuncc, "call : ");\r | |
98 | show(mi.hashfuncd, "def : ");\r | |
99 | show(mi.hashEFIcall, "EFIcall : ");\r | |
100 | show(mi.hashnonlocalmacro, "macro : ");\r | |
101 | show(mi.hashnonlocalfunc, "nonlocal : ");\r | |
102 | show(mi.hashr8only, "hashr8only : ");\r | |
0dc8c589 | 103 | }\r |
104 | \r | |
23e3b888 | 105 | new MsaWriter(mi).flush();\r |
5ea254f6 | 106 | \r |
050e979f | 107 | if (ModuleInfo.doCritic) {\r |
23e3b888 | 108 | Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);\r |
446e26ee | 109 | }\r |
110 | \r | |
23e3b888 | 111 | Common.deleteDir(mi.modulepath + File.separator + "temp");\r |
0dc8c589 | 112 | \r |
050e979f | 113 | ModuleInfo.ui.println("Errors Left : " + ModuleInfo.db.error);\r |
114 | ModuleInfo.ui.println("Complete!");\r | |
23e3b888 | 115 | ModuleInfo.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");\r |
116 | ModuleInfo.ui.println("Your logfile was placed here: " + mi.modulepath);\r | |
0dc8c589 | 117 | }\r |
118 | \r | |
23e3b888 | 119 | private static final void show(Set<String> hash, String show) {\r |
050e979f | 120 | ModuleInfo.ui.println(show + hash.size());\r |
121 | ModuleInfo.ui.println(hash);\r | |
0dc8c589 | 122 | }\r |
e6a5df3b | 123 | \r |
5ea254f6 | 124 | public static final void seekModule(String filepath) throws Exception {\r |
23e3b888 | 125 | if (ModuleInfo.isModule(filepath)) {\r |
126 | manipulate(new ModuleInfo(filepath));\r | |
5ea254f6 | 127 | }\r |
5ea254f6 | 128 | }\r |
446e26ee | 129 | \r |
7bcb8d17 | 130 | public static final void triger(String path) throws Exception {\r |
050e979f | 131 | ModuleInfo.ui.println("Project Migration");\r |
132 | ModuleInfo.ui.println("Copyright (c) 2006, Intel Corporation");\r | |
7bcb8d17 | 133 | Common.toDoAll(path, ModuleInfo.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r |
0dc8c589 | 134 | }\r |
050e979f | 135 | \r |
050e979f | 136 | public static UI ui = null;\r |
137 | public static Database db = null;\r | |
138 | \r | |
139 | public static final String migrationcomment = "//%$//";\r | |
140 | \r | |
141 | public static boolean printModuleInfo = false;\r | |
142 | public static boolean doCritic = false;\r | |
143 | \r | |
144 | public static void main(String[] args) throws Exception {\r | |
145 | ui = FirstPanel.init();\r | |
146 | db = Database.init();\r | |
147 | }\r | |
e6a5df3b | 148 | } |