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