]>
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 class ModuleInfo
{
23 ModuleInfo(String modulepath
) throws Exception
{
24 this.modulepath
= modulepath
;
26 ModuleInfo
.ui
.println("Choose where to place the result");
27 if ((outputpath
= ModuleInfo
.ui
.getFilepath()) == null) {
28 outputpath
= modulepath
;
30 ModuleInfo
.ui
.println(outputpath
);
35 public String modulepath
= null;
37 public String outputpath
= null;
39 public String modulename
= null;
40 public String guidvalue
= null;
41 public String moduletype
= null;
42 public String entrypoint
= null;
44 public Set
<String
> localmodulesources
= new HashSet
<String
>(); //contains both .c and .h
45 public Set
<String
> preprocessedccodes
= new HashSet
<String
>();
46 public Set
<String
> msaorinf
= new HashSet
<String
>(); //only a little, hash may be too big for this
48 public Set
<String
> hashfuncc
= new HashSet
<String
>();
49 public Set
<String
> hashfuncd
= new HashSet
<String
>();
50 public Set
<String
> hashnonlocalfunc
= new HashSet
<String
>();
51 public Set
<String
> hashnonlocalmacro
= new HashSet
<String
>();
52 public Set
<String
> hashEFIcall
= new HashSet
<String
>();
53 public Set
<String
> hashr8only
= new HashSet
<String
>();
55 public Set
<String
> hashrequiredr9libs
= new HashSet
<String
>(); // hashrequiredr9libs is now all added in SourceFileReplacer
56 public Set
<String
> guid
= new HashSet
<String
>();
57 public Set
<String
> protocol
= new HashSet
<String
>();
58 public Set
<String
> ppi
= new HashSet
<String
>();
60 private void mainFlow() throws Exception
{
62 ModuleReader
.ModuleScan(this);
64 SourceFileReplacer
.flush(this); // some adding library actions are taken here,so it must be put before "MsaWriter"
67 if (ModuleInfo
.printModuleInfo
) {
68 ModuleInfo
.ui
.println("\nModule Information : ");
69 ModuleInfo
.ui
.println("Entrypoint : " + entrypoint
);
70 show(protocol
, "Protocol : ");
72 show(guid
, "Guid : ");
73 show(hashfuncc
, "call : ");
74 show(hashfuncd
, "def : ");
75 show(hashEFIcall
, "EFIcall : ");
76 show(hashnonlocalmacro
, "macro : ");
77 show(hashnonlocalfunc
, "nonlocal : ");
78 show(hashr8only
, "hashr8only : ");
81 new MsaWriter(this).flush();
83 if (ModuleInfo
.doCritic
) {
84 Critic
.fireAt(outputpath
+ File
.separator
+ "Migration_" + modulename
);
87 Common
.deleteDir(modulepath
+ File
.separator
+ "temp");
89 ModuleInfo
.ui
.println("Errors Left : " + ModuleInfo
.db
.error
);
90 ModuleInfo
.ui
.println("Complete!");
91 ModuleInfo
.ui
.println("Your R9 module was placed here: " + modulepath
+ File
.separator
+ "result");
92 ModuleInfo
.ui
.println("Your logfile was placed here: " + modulepath
);
95 private void show(Set
<String
> hash
, String show
) {
96 ModuleInfo
.ui
.println(show
+ hash
.size());
97 ModuleInfo
.ui
.println(hash
);
100 public final void enroll(String filepath
) throws Exception
{
102 if (filepath
.contains(".c") || filepath
.contains(".C") || filepath
.contains(".h") ||
103 filepath
.contains(".H") || filepath
.contains(".dxs") || filepath
.contains(".uni")) {
104 temp
= filepath
.split("\\\\");
105 localmodulesources
.add(temp
[temp
.length
- 1]);
106 } else if (filepath
.contains(".inf") || filepath
.contains(".msa")) {
107 temp
= filepath
.split("\\\\");
108 msaorinf
.add(temp
[temp
.length
- 1]);
112 public static final void seekModule(String filepath
) throws Exception
{
113 if (isModule(filepath
)) {
114 new ModuleInfo(filepath
);
118 private static final boolean isModule(String path
) {
119 String
[] list
= new File(path
).list();
120 for (int i
= 0 ; i
< list
.length
; i
++) {
121 if (!new File(list
[i
]).isDirectory()) {
122 if (list
[i
].contains(".inf") || list
[i
].contains(".msa")) {
130 public static final void triger(String path
) throws Exception
{
131 ModuleInfo
.ui
.println("Project Migration");
132 ModuleInfo
.ui
.println("Copyright (c) 2006, Intel Corporation");
133 Common
.toDoAll(path
, ModuleInfo
.class.getMethod("seekModule", String
.class), null, null, Common
.DIR
);
136 //---------------------------------------------------------------------------//
138 public static UI ui
= null;
139 public static Database db
= null;
141 public static final String migrationcomment
= "//%$//";
143 public static boolean printModuleInfo
= false;
144 public static boolean doCritic
= false;
146 public static void main(String
[] args
) throws Exception
{
147 ui
= FirstPanel
.init();
148 db
= Database
.init();