X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FMsaOwner.java;h=46cd82a32afd36314e6f9bc49783b2bd78cbbd32;hp=f63e8e14129cb69a0ea0d838bff282c0c71fa0a2;hb=b88170614f5c89173d7b9672369980c62a678cb9;hpb=5c55f71cc90ff2c6be6f83c385818710cef93eec diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/MsaOwner.java b/Tools/Source/MigrationTools/org/tianocore/migration/MsaOwner.java index f63e8e1412..46cd82a32a 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/MsaOwner.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/MsaOwner.java @@ -1,6 +1,9 @@ package org.tianocore.migration; +import java.util.*; + import org.tianocore.*; +import org.tianocore.SupportedArchitectures.Enum; public class MsaOwner { public static final String COPYRIGHT = "Copyright (c) 2006, Intel Corporation"; @@ -17,21 +20,232 @@ public class MsaOwner { " Intel Corporation."; public static final String SPECIFICATION = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; + public static final Enum IA32 = SupportedArchitectures.IA_32; + public static final Enum X64 = SupportedArchitectures.X_64; + public static final Enum IPF = SupportedArchitectures.IPF; + public static final Enum EBC = SupportedArchitectures.EBC; + private ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance(); private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; private MsaHeaderDocument.MsaHeader msaheader = null; private LicenseDocument.License license = null; - private ModuleDefinitionsDocument.ModuleDefinitions md = null; + private ModuleDefinitionsDocument.ModuleDefinitions moduledefinitions = null; private SourceFilesDocument.SourceFiles sourcefiles = null; //found local .h files are not written private GuidsDocument.Guids guids = null; private ProtocolsDocument.Protocols protocols = null; private PPIsDocument.PPIs ppis = null; - private PackageDependenciesDocument.PackageDependencies pd = null; + private PackageDependenciesDocument.PackageDependencies packagedependencies = null; private LibraryClassDefinitionsDocument.LibraryClassDefinitions libclassdefs = null; private ExternsDocument.Externs externs = null; + + private List listarch = new ArrayList(); + //private Map mapfilenames = new HashMap(); //this need to be installed manually when msa is to be written + //private Map mapprotocols = new HashMap(); //-----------------------------msaheader-------------------------------------// + + public final boolean addLibraryClass (String name, UsageTypes.Enum usage) { + Iterator classit = libclassdefs.getLibraryClassList().iterator(); + while (classit.hasNext()) { + if (classit.next().getKeyword() == name) { + MigrationTool.ui.println ("Warning: Duplicate LibraryClass"); + return false; + } + } + + LibraryClassDocument.LibraryClass classname; + List arch = new ArrayList(); + classname = libclassdefs.addNewLibraryClass(); + classname.setKeyword(name); + arch.add(usage); + classname.setSupArchList(arch); + return true; + } + + public final boolean addGuid (String guidname, UsageTypes.Enum usage) { + if (guids == null) { + guids = msa.addNewGuids(); + } + + Iterator guidit = guids.getGuidCNamesList().iterator(); + while (guidit.hasNext()) { + if (guidit.next().getGuidCName() == guidname) { + MigrationTool.ui.println ("Warning: Duplicate Guid"); + return false; + } + } + + GuidsDocument.Guids.GuidCNames guid; + List arch = new ArrayList(); + guid = guids.addNewGuidCNames(); + guid.setGuidCName(guidname); + arch.add(usage); + guid.setSupArchList(arch); + return true; + } + + + public final boolean addPpi (String ppiname, UsageTypes.Enum usage) { + if (ppis == null) { + ppis = msa.addNewPPIs(); + } + + Iterator ppiit = ppis.getPpiList().iterator(); + while (ppiit.hasNext()) { + if (ppiit.next().getPpiCName() == ppiname) { + MigrationTool.ui.println ("Warning: Duplicate Ppi"); + return false; + } + } + + PPIsDocument.PPIs.Ppi ppi; + List arch = new ArrayList(); + ppi = ppis.addNewPpi(); + ppi.setPpiCName(ppiname); + arch.add(usage); + ppi.setSupArchList(arch); + return true; + } + + /* + private final boolean installProtocols () { + if (mapprotocols.isEmpty()) { + return false; + } + Set setprotocols = mapprotocols.keySet(); + ProtocolsDocument.Protocols.Protocol protocol; + Iterator it = setprotocols.iterator(); + while (it.hasNext()) { + protocol = protocols.addNewProtocol(); + protocol.setProtocolCName(it.next()); + protocol.setUsage(mapprotocols.get(protocol.getProtocolCName())); + } + return true; + } + + public final boolean addProtocols (String protocol, UsageTypes.Enum usage) { + if (mapprotocols.containsKey(protocol)) { + return false; + } else { + mapprotocols.put(protocol, usage); + return true; + } + } + */ + public final boolean addProtocol (String proname, UsageTypes.Enum usage) { + if (protocols == null) { + protocols = msa.addNewProtocols(); + } + + Iterator proit = protocols.getProtocolList().iterator(); + while (proit.hasNext()) { + if (proit.next().getProtocolCName() == proname) { + MigrationTool.ui.println ("Warning: Duplicate Protocol"); + return false; + } + } + + ProtocolsDocument.Protocols.Protocol protocol; + List arch = new ArrayList(); + protocol = protocols.addNewProtocol(); + protocol.setProtocolCName(proname); + arch.add(usage); + protocol.setSupArchList(arch); + return true; + } + + /* + private final boolean installHashFilename () { + if (mapfilenames.isEmpty()) { + return false; + } + Set setfilename = mapfilenames.keySet(); + FilenameDocument.Filename filename; + List arch = new ArrayList(); + Iterator it = setfilename.iterator(); + while (it.hasNext()) { + filename = sourcefiles.addNewFilename(); + filename.setStringValue(it.next()); + arch.add(mapfilenames.get(filename.getStringValue())); + filename.setSupArchList(arch); + } + return true; + } + + public final boolean addSourceFile (String filename, Enum arch) { // dummy & null how to imply? + if (mapfilenames.containsKey(filename)) { + return false; + } else { + mapfilenames.put(filename, arch); + return true; + } + } + */ + public final boolean addSourceFile (String name, Enum en) { + Iterator fileit = sourcefiles.getFilenameList().iterator(); + while (fileit.hasNext()) { + if (fileit.next().getStringValue() == name) { + MigrationTool.ui.println ("Warning: Duplicate SourceFileName"); + return false; + } + } + + FilenameDocument.Filename filename; + List arch = new ArrayList(); + filename = sourcefiles.addNewFilename(); + filename.setStringValue(name); + arch.add(en); + filename.setSupArchList(arch); + return true; + } + + // entry point todo + + public final boolean setupExternSpecification () { + addExternSpecification("EFI_SPECIFICATION_VERSION 0x00020000"); + addExternSpecification("EDK_RELEASE_VERSION 0x00020000"); + return true; + } + + public final boolean addExternSpecification (String specification) { + if (externs.getSpecificationList().contains(specification)) { + return false; + } else { + externs.addSpecification(specification); + return true; + } + } + + public final boolean setupPackageDependencies() { + addPackage("5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"); + addPackage("68169ab0-d41b-4009-9060-292c253ac43d"); + return true; + } + + public final boolean addPackage (String guid) { + if (packagedependencies.getPackageList().contains(guid)) { + return false; + } else { + packagedependencies.addNewPackage().setPackageGuid(guid); + return true; + } + } + + public final boolean setupModuleDefinitions () { //????????? give this job to moduleinfo + moduledefinitions.setBinaryModule(false); + moduledefinitions.setOutputFileBasename(msaheader.getModuleName()); + return true; + } + public final boolean addSupportedArchitectures (Enum arch) { + if (listarch.contains(arch)) { + return false; + } else { + listarch.add(arch); + return true; + } + } + public final boolean addSpecification (String specification) { if (msaheader.getSpecification() == null) { if (specification == null) { @@ -155,9 +369,11 @@ public class MsaOwner { private final MsaOwner init () { msa = msadoc.addNewModuleSurfaceArea(); msaheader = msa.addNewMsaHeader(); - md = msa.addNewModuleDefinitions(); + moduledefinitions = msa.addNewModuleDefinitions(); + moduledefinitions.setSupportedArchitectures(listarch); + sourcefiles = msa.addNewSourceFiles(); - pd = msa.addNewPackageDependencies(); + packagedependencies = msa.addNewPackageDependencies(); libclassdefs = msa.addNewLibraryClassDefinitions(); externs = msa.addNewExterns(); return this;