add MigrationTool
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / ModuleInfo.java
1 /** @file
2
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
8
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.
11
12 **/
13 package org.tianocore.migration;
14
15 import java.io.*;
16 import java.util.*;
17
18 /*
19 Class ModuleInfo is built for scanning the source files, it contains all the needed
20 information and all the temporary data.
21 */
22 public final class ModuleInfo {
23 ModuleInfo(String modulepath) throws Exception {
24 this.modulepath = modulepath;
25
26 if (MigrationTool.defaultoutput) {
27 this.outputpath = this.modulepath.replaceAll(Common.strseparate, "$1");
28 } else {
29 MigrationTool.ui.println("Choose where to place the result");
30 if ((outputpath = MigrationTool.ui.getFilepath("Please choose where to place the output module")) == null) {
31 outputpath = modulepath;
32 }
33 MigrationTool.ui.println("Output to: " + outputpath);
34 }
35 }
36
37 public final String modulepath;
38
39 public String outputpath = null;
40
41 public String modulename = null;
42 public String guidvalue = null;
43 public String moduletype = null;
44 public String entrypoint = null;
45
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
49
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>();
56
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>();
61
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 + "\\", ""));
68 }
69 }
70
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")) {
76 return true;
77 }
78 }
79 }
80 return false;
81 }
82 }