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
;
17 import java
.util
.regex
.*;
18 import org
.tianocore
.*;
20 public class ModuleReader
{
21 ModuleReader(String path
, ModuleInfo moduleinfo
, Database database
) {
26 private String modulepath
;
27 private ModuleInfo mi
;
30 private static Pattern ptninfequation
= Pattern
.compile("([^ ]*) *= *([^ ]*)");
32 public void readMsa(String name
) throws Exception
{
33 ModuleSurfaceAreaDocument msadoc
= ModuleSurfaceAreaDocument
.Factory
.parse(new File(modulepath
+ File
.separator
+ name
));
34 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= msadoc
.getModuleSurfaceArea();
35 MsaHeaderDocument
.MsaHeader msaheader
= msa
.getMsaHeader();
37 mi
.modulename
= msaheader
.getModuleName();
38 mi
.guidvalue
= msaheader
.getGuidValue();
39 mi
.moduletype
= msaheader
.getModuleType().toString(); // ???
41 SourceFilesDocument
.SourceFiles sourcefiles
= msa
.getSourceFiles();
44 Iterator
<FilenameDocument
.Filename
> li
= sourcefiles
.getFilenameList().iterator();
45 while (li
.hasNext()) {
46 if (!mi
.localmodulesources
.contains(temp
= li
.next().toString())) {
47 System
.out
.println("Source File Missing! : " + temp
);
52 public void readInf(String name
) throws Exception
{
53 System
.out
.println("Parsing INF file: " + name
);
54 BufferedReader rd
= new BufferedReader(new FileReader(modulepath
+ File
.separator
+ name
));
57 boolean inSrc
= false;
58 Matcher mtrinfequation
;
60 while ((line
= rd
.readLine()) != null) {
61 if (line
.length() != 0) {
63 if (line
.contains("[")) {
66 linecontext
= line
.split(" ");
67 if (linecontext
[2].length() != 0) {
68 if (!mi
.localmodulesources
.contains(linecontext
[2])) {
69 System
.out
.println("Source File Missing! : " + linecontext
[2]);
74 if ((mtrinfequation
= ptninfequation
.matcher(line
)).find()) {
75 if (mtrinfequation
.group(1).matches("BASE_NAME")) {
76 mi
.modulename
= mtrinfequation
.group(2);
78 if (mtrinfequation
.group(1).matches("FILE_GUID")) {
79 mi
.guidvalue
= mtrinfequation
.group(2);
81 if (mtrinfequation
.group(1).matches("COMPONENT_TYPE")) {
82 mi
.moduletype
= mtrinfequation
.group(2);
84 if (mtrinfequation
.group(1).matches("IMAGE_ENTRY_POINT")) {
85 mi
.entrypoint
= mtrinfequation
.group(2);
88 if (line
.contains("sources")) {