]>
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 | \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 final class ModuleInfo {\r | |
23 | ModuleInfo(String modulepath) throws Exception {\r | |
24 | this.modulepath = modulepath;\r | |
25 | \r | |
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("Please choose where to place the output module")) == null) {\r | |
31 | outputpath = modulepath; \r | |
32 | }\r | |
33 | ModuleInfo.ui.println("Output to: " + outputpath);\r | |
34 | }\r | |
35 | }\r | |
36 | \r | |
37 | public final String modulepath;\r | |
38 | \r | |
39 | public String outputpath = null;\r | |
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 | |
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 | |
49 | \r | |
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 | |
56 | \r | |
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 | |
61 | \r | |
62 | public final void enroll(String filepath) throws Exception {\r | |
63 | if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || \r | |
64 | filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {\r | |
65 | localmodulesources.add(filepath.replace(modulepath + "\\", ""));\r | |
66 | } else if (filepath.contains(".inf") || filepath.contains(".msa")) {\r | |
67 | msaorinf.add(filepath.replace(modulepath + "\\", ""));\r | |
68 | }\r | |
69 | }\r | |
70 | \r | |
71 | public static final boolean isModule(String path) {\r | |
72 | String[] list = new File(path).list();\r | |
73 | for (int i = 0 ; i < list.length ; i++) {\r | |
74 | if (!new File(list[i]).isDirectory()) {\r | |
75 | if (list[i].contains(".inf") || list[i].contains(".msa")) {\r | |
76 | return true;\r | |
77 | }\r | |
78 | }\r | |
79 | }\r | |
80 | return false;\r | |
81 | }\r | |
82 | \r | |
83 | //---------------------------------------------------------------------------//\r | |
84 | \r | |
85 | private static final void manipulate(ModuleInfo mi) throws Exception {\r | |
86 | \r | |
87 | ModuleReader.ModuleScan(mi);\r | |
88 | //ModuleInfo.ui.yesOrNo("go on replace?");\r | |
89 | SourceFileReplacer.flush(mi); // some adding library actions are taken here,so it must be put before "MsaWriter"\r | |
90 | \r | |
91 | //ModuleInfo.ui.yesOrNo("go on show?");\r | |
92 | // show result\r | |
93 | if (ModuleInfo.printModuleInfo) {\r | |
94 | ModuleInfo.ui.println("\nModule Information : ");\r | |
95 | ModuleInfo.ui.println("Entrypoint : " + mi.entrypoint);\r | |
96 | show(mi.protocol, "Protocol : ");\r | |
97 | show(mi.ppi, "Ppi : ");\r | |
98 | show(mi.guid, "Guid : ");\r | |
99 | show(mi.hashfuncc, "call : ");\r | |
100 | show(mi.hashfuncd, "def : ");\r | |
101 | show(mi.hashEFIcall, "EFIcall : ");\r | |
102 | show(mi.hashnonlocalmacro, "macro : ");\r | |
103 | show(mi.hashnonlocalfunc, "nonlocal : ");\r | |
104 | show(mi.hashr8only, "hashr8only : ");\r | |
105 | }\r | |
106 | \r | |
107 | //ModuleInfo.ui.yesOrNo("go on msawrite?");\r | |
108 | new MsaWriter(mi).flush();\r | |
109 | //ModuleInfo.ui.yesOrNo("go on critic?");\r | |
110 | \r | |
111 | if (ModuleInfo.doCritic) {\r | |
112 | Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);\r | |
113 | }\r | |
114 | \r | |
115 | //ModuleInfo.ui.yesOrNo("go on delete?");\r | |
116 | Common.deleteDir(mi.modulepath + File.separator + "temp");\r | |
117 | \r | |
118 | ModuleInfo.ui.println("Errors Left : " + ModuleInfo.db.error);\r | |
119 | ModuleInfo.ui.println("Complete!");\r | |
120 | //ModuleInfo.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");\r | |
121 | //ModuleInfo.ui.println("Your logfile was placed here: " + mi.modulepath);\r | |
122 | }\r | |
123 | \r | |
124 | private static final void show(Set<String> hash, String show) {\r | |
125 | ModuleInfo.ui.println(show + hash.size());\r | |
126 | ModuleInfo.ui.println(hash);\r | |
127 | }\r | |
128 | \r | |
129 | public static final void seekModule(String filepath) throws Exception {\r | |
130 | if (ModuleInfo.isModule(filepath)) {\r | |
131 | manipulate(new ModuleInfo(filepath));\r | |
132 | }\r | |
133 | }\r | |
134 | \r | |
135 | public static final void triger(String path) throws Exception {\r | |
136 | ModuleInfo.ui.println("Project Migration");\r | |
137 | ModuleInfo.ui.println("Copyright (c) 2006, Intel Corporation");\r | |
138 | Common.toDoAll(path, ModuleInfo.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r | |
139 | }\r | |
140 | \r | |
141 | public static UI ui = null;\r | |
142 | public static Database db = null;\r | |
143 | \r | |
144 | public static final String migrationcomment = "//%$//";\r | |
145 | \r | |
146 | public static boolean printModuleInfo = false;\r | |
147 | public static boolean doCritic = false;\r | |
148 | public static boolean defaultoutput = false;\r | |
149 | \r | |
150 | public static void main(String[] args) throws Exception {\r | |
151 | ui = FirstPanel.init();\r | |
152 | db = Database.init();\r | |
153 | }\r | |
154 | } |