]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java
dd106d5eb919b5d4ddd914dc1d2981ef34490830
[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 import org.tianocore.UsageTypes;
19
20 /*
21 Class ModuleInfo is built for scanning the source files, it contains all the needed
22 information and all the temporary data.
23 */
24 public final class ModuleInfo {
25 ModuleInfo(String modulepath) throws Exception {
26 this.modulepath = modulepath;
27 this.temppath = MigrationTool.getTempDir(this.modulepath);
28 }
29
30 public final String modulepath;
31 public final String temppath;
32
33 private MsaOwner msaowner = MsaOwner.initNewMsaOwner();
34
35 public String modulename = null;
36 public String guidvalue = null;
37 public String moduletype = null;
38 public String entrypoint = null;
39
40 public final Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h
41 public final Set<String> preprocessedccodes = new HashSet<String>();
42 public final Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this
43 public final Set<String> infincludes = new HashSet<String>();
44 public final Set<String> infsources = new HashSet<String>();
45
46 public final Set<String> hashfuncc = new HashSet<String>();
47 public final Set<String> hashfuncd = new HashSet<String>();
48 public final Set<String> hashnonlocalfunc = new HashSet<String>();
49 public final Set<String> hashnonlocalmacro = new HashSet<String>();
50 public final Set<String> hashEFIcall = new HashSet<String>();
51 public final Set<String> hashr8only = new HashSet<String>();
52 public final Set<String> hashmacro = new HashSet<String>();
53
54 public final Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer
55 public final Set<String> guids = new HashSet<String>();
56 public final Set<String> protocols = new HashSet<String>();
57 public final Set<String> ppis = new HashSet<String>();
58
59 //-----------------------------------------------------------------------------------//
60
61 public final boolean addProtocol (String proname, UsageTypes.Enum usage) {
62 //protocols.add(proname);
63 System.out.println("I'm in");
64 return msaowner.addProtocol(proname, usage);
65 }
66
67 public final boolean addPpi (String ppiname, UsageTypes.Enum usage) {
68 //ppis.add(ppiname);
69 return msaowner.addPpi(ppiname, usage);
70 }
71
72 public final boolean addGuid (String guidname, UsageTypes.Enum usage) {
73 //guids.add(guidname);
74 return msaowner.addGuid(guidname, usage);
75 }
76
77 public final boolean addLibraryClass(String name, UsageTypes.Enum usage) {
78 //hashrequiredr9libs.add(name);
79 return msaowner.addLibraryClass(name, usage);
80 }
81
82 //-----------------------------------------------------------------------------------//
83
84 public final String getModuleType() {
85 if (moduletype.contains("PEI")) {
86 return "PEIM";
87 } else {
88 return "DXE_DRIVER";
89 }
90 }
91
92 public final void enroll(String filepath) throws Exception {
93 String temp = null;
94 if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") ||
95 filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {
96 localmodulesources.add(filepath.replace(modulepath + File.separator, ""));
97 } else if (filepath.contains(".inf") || filepath.contains(".msa")) {
98 temp = filepath.replace(modulepath + File.separator, "");
99 if (!temp.contains(File.separator)) { // .inf in subdirectory is not regarded
100 msaorinf.add(temp);
101 }
102 }
103 }
104
105 public static final boolean isModule(String path) {
106 String[] list = new File(path).list();
107 for (int i = 0 ; i < list.length ; i++) {
108 if (!new File(list[i]).isDirectory()) {
109 if (list[i].contains(".inf") || list[i].contains(".msa")) {
110 return true;
111 }
112 }
113 }
114 return false;
115 }
116
117 public final MsaOwner getMsaOwner() {
118 return msaowner;
119 }
120 }