]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java
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 final 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("Please choose where to place the output module")) == null) {
31 outputpath
= modulepath
;
33 ModuleInfo
.ui
.println("Output to: " + outputpath
);
37 public final String modulepath
;
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 final Set
<String
> localmodulesources
= new HashSet
<String
>(); //contains both .c and .h
47 public final Set
<String
> preprocessedccodes
= new HashSet
<String
>();
48 public final Set
<String
> msaorinf
= new HashSet
<String
>(); //only a little, hash may be too big for this
50 public final Set
<String
> hashfuncc
= new HashSet
<String
>();
51 public final Set
<String
> hashfuncd
= new HashSet
<String
>();
52 public final Set
<String
> hashnonlocalfunc
= new HashSet
<String
>();
53 public final Set
<String
> hashnonlocalmacro
= new HashSet
<String
>();
54 public final Set
<String
> hashEFIcall
= new HashSet
<String
>();
55 public final Set
<String
> hashr8only
= new HashSet
<String
>();
57 public final Set
<String
> hashrequiredr9libs
= new HashSet
<String
>(); // hashrequiredr9libs is now all added in SourceFileReplacer
58 public final Set
<String
> guid
= new HashSet
<String
>();
59 public final Set
<String
> protocol
= new HashSet
<String
>();
60 public final Set
<String
> ppi
= new HashSet
<String
>();
62 public final void enroll(String filepath
) throws Exception
{
63 if (filepath
.contains(".c") || filepath
.contains(".C") || filepath
.contains(".h") ||
64 filepath
.contains(".H") || filepath
.contains(".dxs") || filepath
.contains(".uni")) {
65 localmodulesources
.add(filepath
.replace(modulepath
+ "\\", ""));
66 } else if (filepath
.contains(".inf") || filepath
.contains(".msa")) {
67 msaorinf
.add(filepath
.replace(modulepath
+ "\\", ""));
71 public static final boolean isModule(String path
) {
72 String
[] list
= new File(path
).list();
73 for (int i
= 0 ; i
< list
.length
; i
++) {
74 if (!new File(list
[i
]).isDirectory()) {
75 if (list
[i
].contains(".inf") || list
[i
].contains(".msa")) {
83 //---------------------------------------------------------------------------//
85 private static final void manipulate(ModuleInfo mi
) throws Exception
{
87 ModuleReader
.ModuleScan(mi
);
88 //ModuleInfo.ui.yesOrNo("go on replace?");
89 SourceFileReplacer
.flush(mi
); // some adding library actions are taken here,so it must be put before "MsaWriter"
91 //ModuleInfo.ui.yesOrNo("go on show?");
93 if (ModuleInfo
.printModuleInfo
) {
94 ModuleInfo
.ui
.println("\nModule Information : ");
95 ModuleInfo
.ui
.println("Entrypoint : " + mi
.entrypoint
);
96 show(mi
.protocol
, "Protocol : ");
97 show(mi
.ppi
, "Ppi : ");
98 show(mi
.guid
, "Guid : ");
99 show(mi
.hashfuncc
, "call : ");
100 show(mi
.hashfuncd
, "def : ");
101 show(mi
.hashEFIcall
, "EFIcall : ");
102 show(mi
.hashnonlocalmacro
, "macro : ");
103 show(mi
.hashnonlocalfunc
, "nonlocal : ");
104 show(mi
.hashr8only
, "hashr8only : ");
107 //ModuleInfo.ui.yesOrNo("go on msawrite?");
108 new MsaWriter(mi
).flush();
109 //ModuleInfo.ui.yesOrNo("go on critic?");
111 if (ModuleInfo
.doCritic
) {
112 Critic
.fireAt(mi
.outputpath
+ File
.separator
+ "Migration_" + mi
.modulename
);
115 //ModuleInfo.ui.yesOrNo("go on delete?");
116 Common
.deleteDir(mi
.modulepath
+ File
.separator
+ "temp");
118 ModuleInfo
.ui
.println("Errors Left : " + ModuleInfo
.db
.error
);
119 ModuleInfo
.ui
.println("Complete!");
120 //ModuleInfo.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");
121 //ModuleInfo.ui.println("Your logfile was placed here: " + mi.modulepath);
124 private static final void show(Set
<String
> hash
, String show
) {
125 ModuleInfo
.ui
.println(show
+ hash
.size());
126 ModuleInfo
.ui
.println(hash
);
129 public static final void seekModule(String filepath
) throws Exception
{
130 if (ModuleInfo
.isModule(filepath
)) {
131 manipulate(new ModuleInfo(filepath
));
135 public static final void triger(String path
) throws Exception
{
136 ModuleInfo
.ui
.println("Project Migration");
137 ModuleInfo
.ui
.println("Copyright (c) 2006, Intel Corporation");
138 Common
.toDoAll(path
, ModuleInfo
.class.getMethod("seekModule", String
.class), null, null, Common
.DIR
);
141 public static UI ui
= null;
142 public static Database db
= null;
144 public static final String migrationcomment
= "//%$//";
146 public static boolean printModuleInfo
= false;
147 public static boolean doCritic
= false;
148 public static boolean defaultoutput
= false;
150 public static void main(String
[] args
) throws Exception
{
151 ui
= FirstPanel
.init();
152 db
= Database
.init();