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
);
33 public String modulepath
= null;
35 public String outputpath
= null;
37 public String modulename
= null;
38 public String guidvalue
= null;
39 public String moduletype
= null;
40 public String entrypoint
= null;
42 public Set
<String
> localmodulesources
= new HashSet
<String
>(); //contains both .c and .h
43 public Set
<String
> preprocessedccodes
= new HashSet
<String
>();
44 public Set
<String
> msaorinf
= new HashSet
<String
>(); //only a little, hash may be too big for this
46 public Set
<String
> hashfuncc
= new HashSet
<String
>();
47 public Set
<String
> hashfuncd
= new HashSet
<String
>();
48 public Set
<String
> hashnonlocalfunc
= new HashSet
<String
>();
49 public Set
<String
> hashnonlocalmacro
= new HashSet
<String
>();
50 public Set
<String
> hashEFIcall
= new HashSet
<String
>();
51 public Set
<String
> hashr8only
= new HashSet
<String
>();
53 public Set
<String
> hashrequiredr9libs
= new HashSet
<String
>(); // hashrequiredr9libs is now all added in SourceFileReplacer
54 public Set
<String
> guid
= new HashSet
<String
>();
55 public Set
<String
> protocol
= new HashSet
<String
>();
56 public Set
<String
> ppi
= new HashSet
<String
>();
58 public final void enroll(String filepath
) throws Exception
{
60 if (filepath
.contains(".c") || filepath
.contains(".C") || filepath
.contains(".h") ||
61 filepath
.contains(".H") || filepath
.contains(".dxs") || filepath
.contains(".uni")) {
62 temp
= filepath
.split("\\\\");
63 localmodulesources
.add(temp
[temp
.length
- 1]);
64 } else if (filepath
.contains(".inf") || filepath
.contains(".msa")) {
65 temp
= filepath
.split("\\\\");
66 msaorinf
.add(temp
[temp
.length
- 1]);
70 private static final boolean isModule(String path
) {
71 String
[] list
= new File(path
).list();
72 for (int i
= 0 ; i
< list
.length
; i
++) {
73 if (!new File(list
[i
]).isDirectory()) {
74 if (list
[i
].contains(".inf") || list
[i
].contains(".msa")) {
82 //---------------------------------------------------------------------------//
84 private static final void manipulate(ModuleInfo mi
) throws Exception
{
86 ModuleReader
.ModuleScan(mi
);
88 SourceFileReplacer
.flush(mi
); // some adding library actions are taken here,so it must be put before "MsaWriter"
91 if (ModuleInfo
.printModuleInfo
) {
92 ModuleInfo
.ui
.println("\nModule Information : ");
93 ModuleInfo
.ui
.println("Entrypoint : " + mi
.entrypoint
);
94 show(mi
.protocol
, "Protocol : ");
95 show(mi
.ppi
, "Ppi : ");
96 show(mi
.guid
, "Guid : ");
97 show(mi
.hashfuncc
, "call : ");
98 show(mi
.hashfuncd
, "def : ");
99 show(mi
.hashEFIcall
, "EFIcall : ");
100 show(mi
.hashnonlocalmacro
, "macro : ");
101 show(mi
.hashnonlocalfunc
, "nonlocal : ");
102 show(mi
.hashr8only
, "hashr8only : ");
105 new MsaWriter(mi
).flush();
107 if (ModuleInfo
.doCritic
) {
108 Critic
.fireAt(mi
.outputpath
+ File
.separator
+ "Migration_" + mi
.modulename
);
111 Common
.deleteDir(mi
.modulepath
+ File
.separator
+ "temp");
113 ModuleInfo
.ui
.println("Errors Left : " + ModuleInfo
.db
.error
);
114 ModuleInfo
.ui
.println("Complete!");
115 ModuleInfo
.ui
.println("Your R9 module was placed here: " + mi
.modulepath
+ File
.separator
+ "result");
116 ModuleInfo
.ui
.println("Your logfile was placed here: " + mi
.modulepath
);
119 private static final void show(Set
<String
> hash
, String show
) {
120 ModuleInfo
.ui
.println(show
+ hash
.size());
121 ModuleInfo
.ui
.println(hash
);
124 public static final void seekModule(String filepath
) throws Exception
{
125 if (ModuleInfo
.isModule(filepath
)) {
126 manipulate(new ModuleInfo(filepath
));
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 public static UI ui
= null;
137 public static Database db
= null;
139 public static final String migrationcomment
= "//%$//";
141 public static boolean printModuleInfo
= false;
142 public static boolean doCritic
= false;
144 public static void main(String
[] args
) throws Exception
{
145 ui
= FirstPanel
.init();
146 db
= Database
.init();