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