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 final class ModuleReader
{
21 private static final Pattern ptninfequation
= Pattern
.compile("([^\\s]*)\\s*=\\s*([^\\s]*)");
22 private static final Pattern ptnsection
= Pattern
.compile("\\[([^\\[\\]]*)\\]([^\\[\\]]*)\\n", Pattern
.MULTILINE
);
23 private static final Pattern ptnfilename
= Pattern
.compile("[^\\s]+");
25 public static final void readMsa(String name
, ModuleInfo mi
) throws Exception
{
26 ModuleSurfaceAreaDocument msadoc
= ModuleSurfaceAreaDocument
.Factory
.parse(new File(mi
.modulepath
+ File
.separator
+ name
));
27 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= msadoc
.getModuleSurfaceArea();
28 MsaHeaderDocument
.MsaHeader msaheader
= msa
.getMsaHeader();
30 mi
.modulename
= msaheader
.getModuleName();
31 mi
.guidvalue
= msaheader
.getGuidValue();
32 mi
.moduletype
= msaheader
.getModuleType().toString(); // ???
34 SourceFilesDocument
.SourceFiles sourcefiles
= msa
.getSourceFiles();
37 Iterator
<FilenameDocument
.Filename
> li
= sourcefiles
.getFilenameList().iterator();
38 while (li
.hasNext()) {
39 if (!mi
.localmodulesources
.contains(temp
= li
.next().toString())) {
40 System
.out
.println("Source File Missing! : " + temp
);
45 public static final void readInf(String name
, ModuleInfo mi
) throws Exception
{
46 System
.out
.println("\nParsing INF file: " + name
);
48 Matcher mtrinfequation
;
52 wholeline
= Common
.file2string(mi
.modulepath
+ File
.separator
+ name
);
53 mtrsection
= ptnsection
.matcher(wholeline
);
54 while (mtrsection
.find()) {
55 if (mtrsection
.group(1).matches("defines")) {
56 mtrinfequation
= ptninfequation
.matcher(mtrsection
.group(2));
57 while (mtrinfequation
.find()) {
58 if (mtrinfequation
.group(1).matches("BASE_NAME")) {
59 mi
.modulename
= mtrinfequation
.group(2);
61 if (mtrinfequation
.group(1).matches("FILE_GUID")) {
62 mi
.guidvalue
= mtrinfequation
.group(2);
64 if (mtrinfequation
.group(1).matches("COMPONENT_TYPE")) {
65 mi
.moduletype
= mtrinfequation
.group(2);
69 if (mtrsection
.group(1).matches("nmake.common")) {
70 mtrinfequation
= ptninfequation
.matcher(mtrsection
.group(2));
71 while (mtrinfequation
.find()) {
72 if (mtrinfequation
.group(1).matches("IMAGE_ENTRY_POINT")) {
73 mi
.entrypoint
= mtrinfequation
.group(2);
75 if (mtrinfequation
.group(1).matches("DPX_SOURCE")) {
76 if (!mi
.localmodulesources
.contains(mtrinfequation
.group(2))) {
77 MigrationTool
.ui
.println("DPX File Missing! : " + mtrinfequation
.group(2));
82 if (mtrsection
.group(1).contains("sources.")) {
83 mtrfilename
= ptnfilename
.matcher(mtrsection
.group(2));
84 while (mtrfilename
.find()) {
85 if (!mi
.localmodulesources
.contains(mtrfilename
.group())) {
86 MigrationTool
.ui
.println("Source File Missing! : " + mtrfilename
.group());