]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.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
;
18 import javax
.swing
.JFileChooser
;
20 public class MigrationTool
{
21 public static UI ui
= null;
22 public static Database db
= null;
24 public static String MIGRATIONCOMMENT
= "//@MT:";
26 public static boolean printModuleInfo
= false;
27 public static boolean doCritic
= false;
28 public static boolean defaultoutput
= false;
30 public static final HashMap
<ModuleInfo
, String
> ModuleInfoMap
= new HashMap
<ModuleInfo
, String
>();
32 private static String startpath
= null;
34 private static final void mainFlow(ModuleInfo mi
) throws Exception
{
36 ModuleReader
.aimAt(mi
);
38 //MigrationTool.ui.yesOrNo("go on replace?");
39 SourceFileReplacer
.fireAt(mi
); // some adding library actions are taken here,so it must be put before "MsaWriter"
41 //MigrationTool.ui.yesOrNo("go on show?");
43 if (MigrationTool
.printModuleInfo
) {
44 MigrationTool
.ui
.println("\nModule Information : ");
45 MigrationTool
.ui
.println("Entrypoint : " + mi
.entrypoint
);
46 show(mi
.protocol
, "Protocol : ");
47 show(mi
.ppi
, "Ppi : ");
48 show(mi
.guid
, "Guid : ");
49 show(mi
.hashfuncc
, "call : ");
50 show(mi
.hashfuncd
, "def : ");
51 show(mi
.hashEFIcall
, "EFIcall : ");
52 show(mi
.hashnonlocalmacro
, "macro : ");
53 show(mi
.hashnonlocalfunc
, "nonlocal : ");
54 show(mi
.hashr8only
, "hashr8only : ");
57 //MigrationTool.ui.yesOrNo("go on msawrite?");
58 new MsaWriter(mi
).flush();
59 //MigrationTool.ui.yesOrNo("go on critic?");
61 if (MigrationTool
.doCritic
) {
62 Critic
.fireAt(ModuleInfoMap
.get(mi
) + File
.separator
+ "Migration_" + mi
.modulename
);
65 MigrationTool
.ui
.println("Errors Left : " + MigrationTool
.db
.error
);
66 MigrationTool
.ui
.println("Complete!");
67 //MigrationTool.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");
68 //MigrationTool.ui.println("Your logfile was placed here: " + mi.modulepath);
71 private static final void show(Set
<String
> hash
, String show
) {
72 MigrationTool
.ui
.println(show
+ hash
.size());
73 MigrationTool
.ui
.println(hash
);
76 public static final String
getTempDir(String modulepath
) {
77 return "C:" + File
.separator
+ "MigrationTool_Temp" + modulepath
.replace(startpath
, "");
80 private static final String
assignOutPutPath(String inputpath
) {
81 if (MigrationTool
.defaultoutput
) {
82 return inputpath
.replaceAll(Common
.STRSEPARATER
, "$1");
84 return MigrationTool
.ui
.getFilepath("Please choose where to place the output module", JFileChooser
.DIRECTORIES_ONLY
);
88 public static final void seekModule(String filepath
) throws Exception
{
89 if (ModuleInfo
.isModule(filepath
)) {
90 ModuleInfoMap
.put(new ModuleInfo(filepath
), assignOutPutPath(filepath
));
94 public static final void startMigrateAll(String path
) throws Exception
{
96 MigrationTool
.ui
.println("Project Migration");
97 MigrationTool
.ui
.println("Copyright (c) 2006, Intel Corporation");
99 if (new File("C:" + File
.separator
+ "MigrationTool_Temp").exists()) {
100 Common
.deleteDir("C:" + File
.separator
+ "MigrationTool_Temp");
103 Common
.toDoAll(path
, MigrationTool
.class.getMethod("seekModule", String
.class), null, null, Common
.DIR
);
105 Iterator
<ModuleInfo
> miit
= ModuleInfoMap
.keySet().iterator();
106 while (miit
.hasNext()) {
107 mainFlow(miit
.next());
110 ModuleInfoMap
.clear();
112 Common
.deleteDir("C:" + File
.separator
+ "MigrationTool_Temp");
115 public static void main(String
[] args
) throws Exception
{
116 ui
= FirstPanel
.getInstance();
117 db
= Database
.getInstance();