diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java index dd33b540c1..fdf90b620c 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java @@ -339,19 +339,22 @@ public class PCDAutoGenAction extends BuildAction { (guidStringArray[4].substring(6, 8)), (guidStringArray[4].substring(8, 10)), (guidStringArray[4].substring(10, 12))); - if (!isBuildUsedLibrary) { - Pattern pattern = Pattern.compile("(" + guidStringCName + ")+?"); - Matcher matcher = pattern.matcher(cAutoGenString + " "); - // - // Find whether this guid array variable has been generated into autogen.c - // For different DyanmicEx pcd token who use same token space guid, the token space - // guid array should be only generated once. - // - if (!matcher.find()) { + + Pattern pattern = Pattern.compile("(" + guidStringCName + ")+?"); + Matcher matcher = pattern.matcher(cAutoGenString + " "); + // + // Find whether this guid array variable has been generated into autogen.c + // For different DyanmicEx pcd token who use same token space guid, the token space + // guid array should be only generated once. + // + if (!matcher.find()) { + hAutoGenString += String.format("extern EFI_GUID %s;\r\n", + guidStringCName); + if (!isBuildUsedLibrary) { cAutoGenString += String.format("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID %s = %s;\r\n", guidStringCName, guidString); - } + } } } diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java index cfbdb1e149..2769d497f7 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java @@ -200,7 +200,7 @@ public class UsageInstance { @param isBuildUsedLibrary whether the autogen is for library. */ public void generateAutoGen(boolean isBuildUsedLibrary) - throws EntityException { + throws EntityException { String guidStringCName = null; boolean isByteArray = false; String printDatum = null; @@ -340,20 +340,13 @@ public class UsageInstance { guidStringCName = "_gPcd_TokenSpaceGuid_" + parentToken.tokenSpaceName.toString().replaceAll("-", "_"); - hAutogenStr += String.format("extern const EFI_GUID *_gPcd_DynamicEx_TokenSpaceGuid_%s;\r\n", - parentToken.cName); - hAutogenStr += String.format("#define _PCD_MODE_%s_%s LibPcdGetEx%s(_gPcd_DynamicEx_TokenSpaceGuid_%s, _PCD_TOKEN_%s)\r\n", + hAutogenStr += String.format("#define _PCD_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n", Token.GetAutogenDefinedatumTypeString(parentToken.datumType), parentToken.cName, Token.getAutogenLibrarydatumTypeString(parentToken.datumType), - parentToken.cName, + guidStringCName, parentToken.cName); - if (!isBuildUsedLibrary) { - cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const EFI_GUID *_gPcd_DynamicEx_TokenSpaceGuid_%s = &%s;\r\n", - parentToken.cName, - guidStringCName); - } break; } }