]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/MigrationTools/org/tianocore/migration/MsaOwner.java
enhance MsaOwner.java
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / MsaOwner.java
index f63e8e14129cb69a0ea0d838bff282c0c71fa0a2..44b1dca90777ae632ac6af3f6dc96da0e50cf72f 100644 (file)
@@ -1,6 +1,9 @@
 package org.tianocore.migration;\r
 \r
 package org.tianocore.migration;\r
 \r
+import java.util.*;\r
+\r
 import org.tianocore.*;\r
 import org.tianocore.*;\r
+import org.tianocore.SupportedArchitectures.Enum;\r
 \r
 public class MsaOwner {\r
        public static final String COPYRIGHT = "Copyright (c) 2006, Intel Corporation";\r
 \r
 public class MsaOwner {\r
        public static final String COPYRIGHT = "Copyright (c) 2006, Intel Corporation";\r
@@ -17,21 +20,126 @@ public class MsaOwner {
     "      Intel Corporation.";\r
        public static final String SPECIFICATION = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052";\r
        \r
     "      Intel Corporation.";\r
        public static final String SPECIFICATION = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052";\r
        \r
+       public static final Enum IA32 = SupportedArchitectures.IA_32;\r
+       public static final Enum X64 = SupportedArchitectures.X_64;\r
+       public static final Enum IPF = SupportedArchitectures.IPF;\r
+       public static final Enum EBC = SupportedArchitectures.EBC;\r
+       \r
     private ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance();\r
     \r
     private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;\r
     private MsaHeaderDocument.MsaHeader msaheader = null;\r
     private LicenseDocument.License license = null;\r
     private ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance();\r
     \r
     private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;\r
     private MsaHeaderDocument.MsaHeader msaheader = null;\r
     private LicenseDocument.License license = null;\r
-    private ModuleDefinitionsDocument.ModuleDefinitions md = null;\r
+    private ModuleDefinitionsDocument.ModuleDefinitions moduledefinitions = null;\r
     private SourceFilesDocument.SourceFiles sourcefiles = null;    //found local .h files are not written\r
     private GuidsDocument.Guids guids = null;\r
     private ProtocolsDocument.Protocols protocols = null;\r
     private PPIsDocument.PPIs ppis = null;\r
     private SourceFilesDocument.SourceFiles sourcefiles = null;    //found local .h files are not written\r
     private GuidsDocument.Guids guids = null;\r
     private ProtocolsDocument.Protocols protocols = null;\r
     private PPIsDocument.PPIs ppis = null;\r
-    private PackageDependenciesDocument.PackageDependencies pd = null;\r
+    private PackageDependenciesDocument.PackageDependencies packagedependencies = null;\r
     private LibraryClassDefinitionsDocument.LibraryClassDefinitions libclassdefs = null;\r
     private ExternsDocument.Externs externs = null;\r
     private LibraryClassDefinitionsDocument.LibraryClassDefinitions libclassdefs = null;\r
     private ExternsDocument.Externs externs = null;\r
+    \r
+    private List<Enum> listarch = new ArrayList<Enum>();\r
+    private Map<String, Enum> mapfilenames = new HashMap<String, Enum>();      //this need to be installed manually when msa is to be written\r
+    private Map<String, UsageTypes.Enum> mapprotocols = new HashMap<String, UsageTypes.Enum>();\r
 \r
     //-----------------------------msaheader-------------------------------------//\r
 \r
     //-----------------------------msaheader-------------------------------------//\r
+    private final boolean installProtocols () {\r
+       if (mapprotocols.isEmpty()) {\r
+               return false;\r
+       }\r
+       Set<String> setprotocols = mapprotocols.keySet();\r
+       ProtocolsDocument.Protocols.Protocol protocol;\r
+       Iterator<String> it = setprotocols.iterator();\r
+       while (it.hasNext()) {\r
+               protocol = protocols.addNewProtocol();\r
+               protocol.setProtocolCName(it.next());\r
+               protocol.setUsage(mapprotocols.get(protocol.getProtocolCName()));\r
+       }\r
+       return true;\r
+    }\r
+    \r
+    public final boolean addProtocols (String protocol, UsageTypes.Enum usage) {\r
+       if (mapprotocols.containsKey(protocol)) {\r
+               return false;\r
+       } else {\r
+               mapprotocols.put(protocol, usage);\r
+               return true;\r
+       }\r
+    }\r
+    \r
+    private final boolean installHashFilename () {\r
+       if (mapfilenames.isEmpty()) {\r
+               return false;\r
+       }\r
+       Set<String> setfilename = mapfilenames.keySet();\r
+       FilenameDocument.Filename filename;\r
+       List<Enum> arch = new ArrayList<Enum>();\r
+       Iterator<String> it = setfilename.iterator();\r
+       while (it.hasNext()) {\r
+               filename = sourcefiles.addNewFilename();\r
+               filename.setStringValue(it.next());\r
+               arch.add(mapfilenames.get(filename.getStringValue()));\r
+               filename.setSupArchList(arch);\r
+       }\r
+       return true;\r
+    }\r
+    \r
+    public final boolean addSourceFile (String filename, Enum arch) {          // dummy & null how to imply?\r
+       if (mapfilenames.containsKey(filename)) {\r
+               return false;\r
+       } else {\r
+            mapfilenames.put(filename, arch);\r
+            return true;\r
+       }\r
+    }\r
+    \r
+    // entry point todo\r
+    \r
+    public final boolean setupExternSpecification () {\r
+       addExternSpecification("EFI_SPECIFICATION_VERSION 0x00020000");\r
+       addExternSpecification("EDK_RELEASE_VERSION 0x00020000");\r
+       return true;\r
+    }\r
+    \r
+    public final boolean addExternSpecification (String specification) {\r
+       if (externs.getSpecificationList().contains(specification)) {\r
+               return false;\r
+       } else {\r
+               externs.addSpecification(specification);\r
+               return true;\r
+       }\r
+    }\r
+    \r
+    public final boolean setupPackageDependencies() {\r
+       addPackage("5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec");\r
+       addPackage("68169ab0-d41b-4009-9060-292c253ac43d");\r
+       return true;\r
+    }\r
+    \r
+    public final boolean addPackage (String guid) {\r
+       if (packagedependencies.getPackageList().contains(guid)) {\r
+               return false;\r
+       } else {\r
+            packagedependencies.addNewPackage().setPackageGuid(guid);\r
+            return true;\r
+       }\r
+    }\r
+    \r
+    public final boolean setupModuleDefinitions () {                           //????????? give this job to moduleinfo\r
+       moduledefinitions.setBinaryModule(false);\r
+       moduledefinitions.setOutputFileBasename(msaheader.getModuleName());\r
+       return true;\r
+    }\r
+    public final boolean addSupportedArchitectures (Enum arch) {\r
+       if (listarch.contains(arch)) {\r
+               return false;\r
+       } else {\r
+               listarch.add(arch);\r
+               return true;\r
+       }\r
+    }\r
+    \r
     public final boolean addSpecification (String specification) {\r
         if (msaheader.getSpecification() == null) {\r
             if (specification == null) {\r
     public final boolean addSpecification (String specification) {\r
         if (msaheader.getSpecification() == null) {\r
             if (specification == null) {\r
@@ -155,9 +263,11 @@ public class MsaOwner {
     private final MsaOwner init () {\r
        msa = msadoc.addNewModuleSurfaceArea();\r
        msaheader = msa.addNewMsaHeader();\r
     private final MsaOwner init () {\r
        msa = msadoc.addNewModuleSurfaceArea();\r
        msaheader = msa.addNewMsaHeader();\r
-       md = msa.addNewModuleDefinitions();\r
+       moduledefinitions = msa.addNewModuleDefinitions();\r
+       moduledefinitions.setSupportedArchitectures(listarch);\r
+       \r
        sourcefiles = msa.addNewSourceFiles();\r
        sourcefiles = msa.addNewSourceFiles();\r
-       pd = msa.addNewPackageDependencies();\r
+       packagedependencies = msa.addNewPackageDependencies();\r
        libclassdefs = msa.addNewLibraryClassDefinitions();\r
        externs = msa.addNewExterns();\r
        return this;\r
        libclassdefs = msa.addNewLibraryClassDefinitions();\r
        externs = msa.addNewExterns();\r
        return this;\r