X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fautogen%2FCommonDefinition.java;h=335ff8f9d4c3335583dc4f26b3913cf35bfc5f26;hp=2da1c6b6f58b554b855adabd6a1e3264aa5f20ed;hb=5f907e4a5b747377513bb772e8fc87add4233ab0;hpb=0b8c16e4725f189f8112cd83bf1a6c645cbb9342 diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java index 2da1c6b6f5..335ff8f9d4 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java +++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java @@ -15,6 +15,11 @@ **/ package org.tianocore.build.autogen; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Set; + /** CommonDefinition @@ -29,50 +34,63 @@ public class CommonDefinition { public final static String autoGenHbegin = "extern int __make_me_compile_correctly;\r\n"; public final static String include = "#include"; public final static String autoGenCLine1 = "\r\n"; - + public final static String autoGenCLine2 = "const UINT8 _gDebugPropertyMask " - + "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED" - + " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED" - + " | DEBUG_PROPERTY_DEBUG_CODE_ENABLED;\r\n"; + + "= DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED" + + " | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED" + + " | DEBUG_PROPERTY_DEBUG_CODE_ENABLED;\r\n"; public final static String autoGenCLine3 = "const UINTN _gModuleDefaultErrorLevel" - + " = EFI_D_ERROR | EFI_D_LOAD;\r\n"; - + + " = EFI_D_ERROR | EFI_D_LOAD;\r\n"; + public final static String autoGenHLine1 = "#define EFI_SPECIFICATION_VERSION 0x00020000\r\n"; public final static String autoGenHVersionDefault = "#define EFI_SPECIFICATION_VERSION 0x00000000\r\n"; public final static String autoGenHLine2 = "#define EDK_RELEASE_VERSION 0x00090000\r\n"; public final static String autoGenHReleaseDefault = "#define EDK_RELEASE_VERSION 0x00000000\r\n"; public final static String includeAutogenH = "#include \r\n" ; + public final static String marcDefineStr = "#define "; public final static String gEfi = "gEfi"; public final static String protocolGuid = "ProtocolGuid"; public final static String ppiGuid = "PpiGuid"; public final static String guidGuid = "Guid"; - + + public final static String tianoR8FlashMapH = "TianoR8FlashMap.h"; + public final static String flashMapH = "FlashMap.h"; + + // + // The defintions for identifying current module + // is PEI Pcd driver or Dxe Pcd driver. + // + public static enum PCD_DRIVER_TYPE { NOT_PCD_DRIVER, + PEI_PCD_DRIVER, + DXE_PCD_DRIVER, + UNKNOWN_PCD_DRIVER}; + // // AutoGen.h and AutoGen.c file's header // public final static String autogenHNotation = - "/**\r\n" + - " DO NOT EDIT\r\n" + - " FILE auto-generated by GenBuild tasks\r\n" + - " Module name:\r\n" + - " AutoGen.h\r\n" + - " Abstract:" + - " Auto-generated AutoGen.h for building module or library.\r\n" + - "**/\r\n\r\n"; - + "/**\r\n" + + " DO NOT EDIT\r\n" + + " FILE auto-generated by GenBuild tasks\r\n" + + " Module name:\r\n" + + " AutoGen.h\r\n" + + " Abstract:" + + " Auto-generated AutoGen.h for building module or library.\r\n" + + "**/\r\n\r\n"; + public final static String autogenCNotation = - "/**\r\n" + - " DO NOT EDIT\r\n" + - " FILE auto-generated by GenBuild tasks\r\n" + - " Module name:\r\n" + - " AutoGen.c\r\n" + - " Abstract:" + - " Auto-generated AutoGen.c for building module or library.\r\n" + - "**/\r\n\r\n"; - + "/**\r\n" + + " DO NOT EDIT\r\n" + + " FILE auto-generated by GenBuild tasks\r\n" + + " Module name:\r\n" + + " AutoGen.c\r\n" + + " Abstract:" + + " Auto-generated AutoGen.c for building module or library.\r\n" + + "**/\r\n\r\n"; + // // module type // @@ -88,8 +106,8 @@ public class CommonDefinition { public final static int ModuleTypeUefiDriver = 9; public final static int ModuleTypeUefiApplication = 10; public final static int ModuleTypeUnknown = 11; - - + + // // component type // @@ -114,13 +132,13 @@ public class CommonDefinition { public final static int ComponentTypeCustomBuild = 18; public final static int ComponentTypeUnknown = 19; - + // // Usaged style // public final static String AlwaysConsumed = "ALWAYS_CONSUMED"; public final static String AlwaysProduced = "ALWAYS_PRODUCED"; - + public static class MyEnum { String moduleTypeStr; @@ -138,47 +156,47 @@ public class CommonDefinition { return -1; } } - + // // Module type // public static final MyEnum[] moduleEnum = new MyEnum[] { - new MyEnum("BASE", ModuleTypeBase), - new MyEnum("SEC", ModuleTypeSec), - new MyEnum("PEI_CORE", ModuleTypePeiCore), - new MyEnum("PEIM", ModuleTypePeim), - new MyEnum("DXE_CORE", ModuleTypeDxeCore), - new MyEnum("DXE_DRIVER", ModuleTypeDxeDriver), - new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver), - new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver), - new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver), - new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver), - new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) }; - + new MyEnum("BASE", ModuleTypeBase), + new MyEnum("SEC", ModuleTypeSec), + new MyEnum("PEI_CORE", ModuleTypePeiCore), + new MyEnum("PEIM", ModuleTypePeim), + new MyEnum("DXE_CORE", ModuleTypeDxeCore), + new MyEnum("DXE_DRIVER", ModuleTypeDxeDriver), + new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver), + new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver), + new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver), + new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver), + new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication)}; + // // Component type // public static final MyEnum[] componentEnum = new MyEnum[]{ - new MyEnum("APRIORI", ComponentTypeApriori), - new MyEnum("SEC", ComponentTypeSec), - new MyEnum("LIBRARY", ComponentTypeLibrary), - new MyEnum("FV_IMAGE_FILE", ComponentTypeFvImageFile), - new MyEnum("BS_DRIVER", ComponentTypeBsDriver), - new MyEnum("RT_DRIVER", ComponentTypeRtDriver), - new MyEnum("SAL_RT_DRIVER", ComponentTypeSalRtDriver), - new MyEnum("PE32_PEIM", ComponentTypePe32Peim), - new MyEnum("PIC_PEIM", ComponentTypePicPeim), - new MyEnum("COMBINED_PEIM_DRIVER", ComponentTypeCombinedPeimDriver), - new MyEnum("PEI_CORE", ComponentTypePeiCore), - new MyEnum("DXE_CORE", ComponentTypeDxeCore), - new MyEnum("APPLICATION", ComponentTypeApplication), - new MyEnum("BS_DRIVER_EFI", ComponentTypeBsDriverEfi), - new MyEnum("SHELLAPP", ComponentTypeShellApp), - new MyEnum("BINARY", ComponentTypeBinary), - new MyEnum("LOGO", ComponentTypeLogo), - new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild) - }; - + new MyEnum("APRIORI", ComponentTypeApriori), + new MyEnum("SEC", ComponentTypeSec), + new MyEnum("LIBRARY", ComponentTypeLibrary), + new MyEnum("FV_IMAGE_FILE", ComponentTypeFvImageFile), + new MyEnum("BS_DRIVER", ComponentTypeBsDriver), + new MyEnum("RT_DRIVER", ComponentTypeRtDriver), + new MyEnum("SAL_RT_DRIVER", ComponentTypeSalRtDriver), + new MyEnum("PE32_PEIM", ComponentTypePe32Peim), + new MyEnum("PIC_PEIM", ComponentTypePicPeim), + new MyEnum("COMBINED_PEIM_DRIVER", ComponentTypeCombinedPeimDriver), + new MyEnum("PEI_CORE", ComponentTypePeiCore), + new MyEnum("DXE_CORE", ComponentTypeDxeCore), + new MyEnum("APPLICATION", ComponentTypeApplication), + new MyEnum("BS_DRIVER_EFI", ComponentTypeBsDriverEfi), + new MyEnum("SHELLAPP", ComponentTypeShellApp), + new MyEnum("BINARY", ComponentTypeBinary), + new MyEnum("LOGO", ComponentTypeLogo), + new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild) + }; + /** getModuleType @@ -225,18 +243,18 @@ public class CommonDefinition { @param componentType Integer value of component type. @return - **/ + **/ static public String getComponentTypeString (int componentType) { - if ((componentType > CommonDefinition.ComponentTypeUnknown) || - (componentType < CommonDefinition.ComponentTypeNull)) { - return null; - } - for (int index = 0; index < CommonDefinition.componentEnum.length; index ++) { - if (componentType == CommonDefinition.componentEnum[index].type) { - return CommonDefinition.componentEnum[index].moduleTypeStr; + if ((componentType > CommonDefinition.ComponentTypeUnknown) || + (componentType < CommonDefinition.ComponentTypeNull)) { + return null; } - } - return null; + for (int index = 0; index < CommonDefinition.componentEnum.length; index ++) { + if (componentType == CommonDefinition.componentEnum[index].type) { + return CommonDefinition.componentEnum[index].moduleTypeStr; + } + } + return null; } /** @@ -249,34 +267,97 @@ public class CommonDefinition { @return **/ static public boolean isLibraryComponent (int componentType) { - if (ComponentTypeLibrary == componentType) { - return true; - } - return false; + if (ComponentTypeLibrary == componentType) { + return true; + } + return false; + } + + /** + * formateGuidName + * + * This function is to formate GUID to ANSI c form. + * + * @param guidNameCon + * String of GUID. + * @return Formated GUID. + */ + public static String formatGuidName(String guidNameConv) { + String[] strList; + String guid = ""; + int index = 0; + if (guidNameConv + .matches("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}")) { + strList = guidNameConv.split("-"); + guid = "0x" + strList[0] + ", "; + guid = guid + "0x" + strList[1] + ", "; + guid = guid + "0x" + strList[2] + ", "; + guid = guid + "{"; + guid = guid + "0x" + strList[3].substring(0, 2) + ", "; + guid = guid + "0x" + strList[3].substring(2, 4); + + while (index < strList[4].length()) { + guid = guid + ", "; + guid = guid + "0x" + strList[4].substring(index, index + 2); + index = index + 2; + } + guid = guid + "}"; + return guid; + } else if (guidNameConv + .matches("0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},( )*0x[a-fA-F0-9]{1,4}(,( )*\\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\\})?")) { + strList = guidNameConv.split(","); + + // + // chang Microsoft specific form to ANSI c form + // + for (int i = 0; i < 3; i++) { + guid = guid + strList[i] + ","; + } + guid = guid + "{"; + + for (int i = 3; i < strList.length; i++) { + if (i == strList.length - 1) { + guid = guid + strList[i]; + } else { + guid = guid + strList[i] + ","; + } + } + guid = guid + "}"; + return guid; + } else { + System.out + .println("Check GUID Value, It doesn't conform to the registry format specified in the schema!!!"); + return "0"; + + } + } + + /** + * Remove deuplicat string in list + * + * This function is to duplicat string in list + * + * @param String[] + * String list. + * @return String[] String list which remove the duplicate string. + */ + public static String[] remDupString (String[] orgList){ + Set strList = new LinkedHashSet(); + String[] desList ; + if (orgList == null) { + return new String[0]; + } + for (int i = 0; i < orgList.length; i++) { + strList.add(orgList[i]); + } + desList = new String[strList.size()]; + Iterator item = strList.iterator(); + int index = 0; + while (item.hasNext()) { + desList[index] = (String)item.next(); + index++; + } + return desList; } - static public boolean isPeiPhaseComponent (int componentType) { - if (ComponentTypePe32Peim == componentType - || ComponentTypePicPeim == componentType - || ComponentTypeCombinedPeimDriver == componentType - || ComponentTypePeiCore == componentType) { - return true; - } - return false; - } - - static public boolean isPe32PeimComponent (int componentType) { - if (ComponentTypePe32Peim == componentType) { - return true; - } - return false; - } - - static public boolean isBsDriverComponent (int componentType) { - if (ComponentTypeBsDriver == componentType) { - return true; - } - return false; - } - }