summaryrefslogtreecommitdiff
path: root/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java
blob: 5c74ee03f18724d6fea8a7a83b47031c06d0112b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package org.tianocore.migration;

import java.io.File;
import java.util.Set;

public class MigrationTool {
	public static UI ui = null;
	public static Database db = null;

	public static String MIGRATIONCOMMENT = "//%$//";

	public static boolean printModuleInfo = false;
	public static boolean doCritic = false;
	public static boolean defaultoutput = false;

	private static final void mainFlow(ModuleInfo mi) throws Exception {

		ModuleReader.ModuleScan(mi);
		//MigrationTool.ui.yesOrNo("go on replace?");
		SourceFileReplacer.flush(mi);	// some adding library actions are taken here,so it must be put before "MsaWriter"

		//MigrationTool.ui.yesOrNo("go on show?");
		// show result
		if (MigrationTool.printModuleInfo) {
			MigrationTool.ui.println("\nModule Information : ");
			MigrationTool.ui.println("Entrypoint : " + mi.entrypoint);
			show(mi.protocol, "Protocol : ");
			show(mi.ppi, "Ppi : ");
			show(mi.guid, "Guid : ");
			show(mi.hashfuncc, "call : ");
			show(mi.hashfuncd, "def : ");
			show(mi.hashEFIcall, "EFIcall : ");
			show(mi.hashnonlocalmacro, "macro : ");
			show(mi.hashnonlocalfunc, "nonlocal : ");
			show(mi.hashr8only, "hashr8only : ");
		}

		//MigrationTool.ui.yesOrNo("go on msawrite?");
		new MsaWriter(mi).flush();
		//MigrationTool.ui.yesOrNo("go on critic?");

		if (MigrationTool.doCritic) {
			Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);
		}

		//MigrationTool.ui.yesOrNo("go on delete?");
		Common.deleteDir(mi.modulepath + File.separator + "temp");

		MigrationTool.ui.println("Errors Left : " + MigrationTool.db.error);
		MigrationTool.ui.println("Complete!");
		//MigrationTool.ui.println("Your R9 module was placed here: " + mi.modulepath + File.separator + "result");
		//MigrationTool.ui.println("Your logfile was placed here: " + mi.modulepath);
	}

	private static final void show(Set<String> hash, String show) {
		MigrationTool.ui.println(show + hash.size());
		MigrationTool.ui.println(hash);
	}

	public static final void seekModule(String filepath) throws Exception {
		if (ModuleInfo.isModule(filepath)) {
			mainFlow(new ModuleInfo(filepath));
		}
	}

	public static final void startMigrateAll(String path) throws Exception {
		MigrationTool.ui.println("Project Migration");
		MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");
		Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);
	}

	public static void main(String[] args) throws Exception {
		ui = FirstPanel.getInstance();
		db = Database.getInstance();
	}
}