Build tools need to auto-generated the FlashMap.h from .fdf file before a module is built, and then included by Autogen.h based on attributes of module in build time, and copy FlashMap.h to Module\DEBUG dir and change "FlashMap.h" to "TianoR8FlashMap.h".


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@874 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qouyang 2006-07-11 08:19:18 +00:00
parent 4748b24d77
commit 73b4e31adc
5 changed files with 106 additions and 34 deletions

View File

@ -542,7 +542,7 @@ public class GenBuildTask extends Ant {
// AutoGen // AutoGen
// //
AutoGen autogen = new AutoGen(getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch()); AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch());
autogen.genAutogen(); autogen.genAutogen();

View File

@ -17,22 +17,9 @@
package org.tianocore.build.autogen; package org.tianocore.build.autogen;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.Spd;
import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
import org.tianocore.GuidsDocument;
import org.tianocore.LibraryClassDocument.LibraryClass;
import org.tianocore.PPIsDocument;
import org.tianocore.ProtocolsDocument;
import org.tianocore.build.pcd.action.PCDAutoGenAction;
import org.tianocore.build.exception.*;
import org.tianocore.logger.EdkLog;
import org.apache.tools.ant.BuildException;
import org.apache.xmlbeans.XmlObject;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.util.ArrayList; import java.util.ArrayList;
@ -43,6 +30,21 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.tools.ant.BuildException;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.GuidsDocument;
import org.tianocore.LibraryClassDocument.LibraryClass;
import org.tianocore.PPIsDocument;
import org.tianocore.ProtocolsDocument;
import org.tianocore.build.exception.*;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.Spd;
import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.pcd.action.PCDAutoGenAction;
import org.tianocore.logger.EdkLog;
/** /**
* This class is to generate Autogen.h and Autogen.c according to module surface * This class is to generate Autogen.h and Autogen.c according to module surface
* area or library surface area. * area or library surface area.
@ -52,7 +54,10 @@ public class AutoGen {
// / The output path of Autogen.h and Autogen.c // / The output path of Autogen.h and Autogen.c
// / // /
private String outputPath; private String outputPath;
///
/// The name of FV directory
///
private String fvDir;
// / // /
// / The base name of module or library. // / The base name of module or library.
// / // /
@ -104,10 +109,11 @@ public class AutoGen {
* @param arch * @param arch
* Target architecture. * Target architecture.
*/ */
public AutoGen(String outputPath, ModuleIdentification moduleId, String arch) { public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch) {
this.outputPath = outputPath; this.outputPath = outputPath;
this.moduleId = moduleId; this.moduleId = moduleId;
this.arch = arch; this.arch = arch;
this.fvDir = fvDir;
} }
@ -316,7 +322,17 @@ public class AutoGen {
} }
fileBuffer.append("\r\n"); fileBuffer.append("\r\n");
// //
// If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
// {DEST_DIR_DRBUG}/FlashMap.h
//
if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {
fileBuffer.append(CommonDefinition.include);
fileBuffer.append(" <");
fileBuffer.append(CommonDefinition.tianoR8FlashMapH + ">\r\n");
copyFlashMapHToDebugDir();
}
// Write PCD autogen information to AutoGen.h. // Write PCD autogen information to AutoGen.h.
// //
if (this.myPcdAutogen != null) { if (this.myPcdAutogen != null) {
@ -544,6 +560,17 @@ public class AutoGen {
} }
fileBuffer.append("\r\n"); fileBuffer.append("\r\n");
//
// If is TianoR8FlashMap, copy {Fv_DIR}/FlashMap.h to
// {DEST_DIR_DRBUG}/FlashMap.h
//
if (SurfaceAreaQuery.isHaveTianoR8FlashMap()) {
fileBuffer.append(CommonDefinition.include);
fileBuffer.append(" <");
fileBuffer.append(CommonDefinition.tianoR8FlashMapH + ">\r\n");
copyFlashMapHToDebugDir();
}
// //
// Write PCD information to library AutoGen.h. // Write PCD information to library AutoGen.h.
// //
@ -2029,4 +2056,27 @@ public class AutoGen {
} }
private void copyFlashMapHToDebugDir() throws AutoGenException{
File inFile = new File(fvDir + File.separatorChar + CommonDefinition.flashMapH);
int size = (int)inFile.length();
byte[] buffer = new byte[size];
File outFile = new File (this.outputPath + File.separatorChar + CommonDefinition.tianoR8FlashMapH);
try{
if (inFile.exists()) {
FileInputStream fis = new FileInputStream (inFile);
fis.read(buffer);
FileOutputStream fos = new FileOutputStream(outFile);
fos.write(buffer);
fis.close();
fos.close();
}else {
throw new AutoGenException("The flashMap.h file don't exist!!");
}
} catch (Exception e){
throw new AutoGenException(e.getMessage());
}
}
} }

View File

@ -54,6 +54,9 @@ public class CommonDefinition {
public final static String protocolGuid = "ProtocolGuid"; public final static String protocolGuid = "ProtocolGuid";
public final static String ppiGuid = "PpiGuid"; public final static String ppiGuid = "PpiGuid";
public final static String guidGuid = "Guid"; public final static String guidGuid = "Guid";
public final static String tianoR8FlashMapH = "TianoR8FlashMap.h";
public final static String flashMapH = "FlashMap.h";
// //
// AutoGen.h and AutoGen.c file's header // AutoGen.h and AutoGen.c file's header

View File

@ -16,13 +16,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
package org.tianocore.build.global; package org.tianocore.build.global;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlObject;
import org.tianocore.DbPathAndFilename; import org.tianocore.DbPathAndFilename;
import org.tianocore.FrameworkDatabaseDocument; import org.tianocore.FrameworkDatabaseDocument;
import org.tianocore.ModuleSurfaceAreaDocument; import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.PcdBuildDefinitionDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PcdBuildDefinitionDocument;
import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.build.id.ModuleIdentification; import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification; import org.tianocore.build.id.PackageIdentification;
@ -37,15 +47,6 @@ import org.tianocore.build.toolchain.ToolChainMap;
import org.tianocore.exception.EdkException; import org.tianocore.exception.EdkException;
import org.tianocore.logger.EdkLog; import org.tianocore.logger.EdkLog;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
/** /**
GlobalData provide initializing, instoring, querying and update global data. GlobalData provide initializing, instoring, querying and update global data.
It is a bridge to intercommunicate between multiple component, such as AutoGen, It is a bridge to intercommunicate between multiple component, such as AutoGen,
@ -133,8 +134,6 @@ public class GlobalData {
private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager(); private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();
/** /**
Parse framework database (DB) and all SPD files listed in DB to initialize Parse framework database (DB) and all SPD files listed in DB to initialize
the environment for next build. This method will only be executed only once the environment for next build. This method will only be executed only once
@ -145,7 +144,7 @@ public class GlobalData {
@throws BuildException @throws BuildException
Framework Dababase or SPD or MSA file is not valid Framework Dababase or SPD or MSA file is not valid
**/ **/
public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename) throws BuildException { public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws BuildException {
// //
// ensure this method will be revoked only once // ensure this method will be revoked only once
// //
@ -153,8 +152,8 @@ public class GlobalData {
return; return;
} }
globalFlag = true; globalFlag = true;
// //
// Backup workspace directory. It will be used by other method // Backup workspace directory. It will be used by other method
// //
GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/"); GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");

View File

@ -1916,4 +1916,24 @@ public class SurfaceAreaQuery {
return false; return false;
} }
public static boolean isHaveTianoR8FlashMap(){
PcdCodedDocument.PcdCoded.PcdEntry[] pcdEntries = null;
String[] results;
int index;
String[] xPath = new String[] {"/"};
Object[] returns = get ("Externs", xPath);
if (returns == null) {
return false;
}
ExternsDocument.Externs ext = (ExternsDocument.Externs)returns[0];
if (ext.getTianoR8FlashMapH()){
return true;
}else {
return false;
}
}
} }