]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java
3e4c4cbae2abb90736255a2bf46e6ed48c3b790d
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.migration
;
19 Class ModuleInfo is built for scanning the source files, it contains all the needed
20 information and all the temporary data.
22 public class ModuleInfo
{
23 ModuleInfo(String modulepath
) throws Exception
{
24 this.modulepath
= modulepath
;
26 if (ModuleInfo
.defaultoutput
) {
27 this.outputpath
= this.modulepath
.replaceAll(Common
.strseparate
, "$1");
29 ModuleInfo
.ui
.println("Choose where to place the result");
30 if ((outputpath
= ModuleInfo
.ui
.getFilepath()) == null) {
31 outputpath
= modulepath
;
33 ModuleInfo
.ui
.println("Output to: " + outputpath
);
37 public String modulepath
= null;
39 public String outputpath
= null;
41 public String modulename
= null;
42 public String guidvalue
= null;
43 public String moduletype
= null;
44 public String entrypoint
= null;
46 public Set
<String
> localmodulesources
= new HashSet
<String
>(); //contains both .c and .h
47 public Set
<String
> preprocessedccodes
= new HashSet
<String
>();
48 public Set
<String
> msaorinf
= new HashSet
<String
>(); //only a little, hash may be too big for this
50 public Set
<String
> hashfuncc
= new HashSet
<String
>();
51 public Set
<String
> hashfuncd
= new HashSet
<String
>();
52 public Set
<String
> hashnonlocalfunc
= new HashSet
<String
>();
53 public Set
<String
> hashnonlocalmacro
= new HashSet
<String
>();
54 public Set
<String
> hashEFIcall
= new HashSet
<String
>();
55 public Set
<String
> hashr8only
= new HashSet
<String
>();
57 public Set
<String
> hashrequiredr9libs
= new HashSet
<String
>(); // hashrequiredr9libs is now all added in SourceFileReplacer
58 public Set
<String
> guid
= new HashSet
<String
>();
59 public Set
<String
> protocol
= new HashSet
<String
>();
60 public Set
<String
> ppi
= new HashSet
<String
>();
62 public final void enroll(String filepath
) throws Exception
{
64 if (filepath
.contains(".c") || filepath
.contains(".C") || filepath
.contains(".h") ||
65 filepath
.contains(".H") || filepath
.contains(".dxs") || filepath
.contains(".uni")) {
66 temp
= filepath
.split("\\\\");
67 localmodulesources
.add(temp
[temp
.length
- 1]);
68 } else if (filepath
.contains(".inf") || filepath
.contains(".msa")) {
69 temp
= filepath
.split("\\\\");
70 msaorinf
.add(temp
[temp
.length
- 1]);
74 public static final boolean isModule(String path
) {
75 String
[] list
= new File(path
).list();
76 for (int i
= 0 ; i
< list
.length
; i
++) {
77 if (!new File(list
[i
]).isDirectory()) {
78 if (list
[i
].contains(".inf") || list
[i
].contains(".msa")) {
86 //---------------------------------------------------------------------------//
88 private static final void manipulate(ModuleInfo mi
) throws Exception
{
90 ModuleReader
.ModuleScan(mi
);
92 SourceFileReplacer
.flush(mi
); // some adding library actions are taken here,so it must be put before "MsaWriter"
95 if (ModuleInfo
.printModuleInfo
) {
96 ModuleInfo
.ui
.println("\nModule Information : ");
97 ModuleInfo
.ui
.println("Entrypoint : " + mi
.entrypoint
);
98 show(mi
.protocol
, "Protocol : ");
99 show(mi
.ppi
, "Ppi : ");
100 show(mi
.guid
, "Guid : ");
101 show(mi
.hashfuncc
, "call : ");
102 show(mi
.hashfuncd
, "def : ");
103 show(mi
.hashEFIcall
, "EFIcall : ");
104 show(mi
.hashnonlocalmacro
, "macro : ");
105 show(mi
.hashnonlocalfunc
, "nonlocal : ");
106 show(mi
.hashr8only
, "hashr8only : ");
109 new MsaWriter(mi
).flush();
111 if (ModuleInfo
.doCritic
) {
112 Critic
.fireAt(mi
.outputpath
+ File
.separator
+ "Migration_" + mi
.modulename
);
115 Common
.deleteDir(mi
.modulepath
+ File
.separator
+ "temp");
117 ModuleInfo
.ui
.println("Errors Left : " + ModuleInfo
.db
.error
);
118 ModuleInfo
.ui
.println("Complete!");
119 //ModuleInfo.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");
120 //ModuleInfo.ui.println("Your logfile was placed here: " + mi.modulepath);
123 private static final void show(Set
<String
> hash
, String show
) {
124 ModuleInfo
.ui
.println(show
+ hash
.size());
125 ModuleInfo
.ui
.println(hash
);
128 public static final void seekModule(String filepath
) throws Exception
{
129 if (ModuleInfo
.isModule(filepath
)) {
130 manipulate(new ModuleInfo(filepath
));
134 public static final void triger(String path
) throws Exception
{
135 ModuleInfo
.ui
.println("Project Migration");
136 ModuleInfo
.ui
.println("Copyright (c) 2006, Intel Corporation");
137 Common
.toDoAll(path
, ModuleInfo
.class.getMethod("seekModule", String
.class), null, null, Common
.DIR
);
140 public static UI ui
= null;
141 public static Database db
= null;
143 public static final String migrationcomment
= "//%$//";
145 public static boolean printModuleInfo
= false;
146 public static boolean doCritic
= false;
147 public static boolean defaultoutput
= false;
149 public static void main(String
[] args
) throws Exception
{
150 ui
= FirstPanel
.init();
151 db
= Database
.init();