summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/AutoGen/GenC.py
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-09 04:32:08 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-09 04:32:08 +0000
commitd40b2ee60ef161044bcaf05a8b36aa60eac633cc (patch)
tree1a74bea930f47fe2bb8f9d07d0151c6c7d9adac3 /BaseTools/Source/Python/AutoGen/GenC.py
parent080681592188f45228616983f9e1610ab9e86615 (diff)
downloadedk2-platforms-d40b2ee60ef161044bcaf05a8b36aa60eac633cc.tar.xz
Sync BaseTool trunk (version r2397) into EDKII BaseTools. The change mainly includes
1. Fix the issue that root directory of disk can’t be used as WORKSPACE. 2. Update AutoGen code style to pass C++ compiler. Signed-off-by: lgao4 Reviewed-by: jsu1 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12676 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/AutoGen/GenC.py')
-rw-r--r--BaseTools/Source/Python/AutoGen/GenC.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index c6b65f4924..561114d141 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -310,9 +310,18 @@ gAutoGenHPrologueString = TemplateString("""
#ifndef _${File}_${Guid}
#define _${File}_${Guid}
+#ifdef __cplusplus
+extern "C" {
+#endif
+
""")
gAutoGenHEpilogueString = """
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
"""
@@ -917,7 +926,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
"No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
ExtraData="[%s]" % str(Info))
TokenNumber = PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName]
- AutoGenH.Append('\n#define %s %d\n' % (PcdTokenName, TokenNumber))
+ AutoGenH.Append('\n#define %s %dU\n' % (PcdTokenName, TokenNumber))
EdkLogger.debug(EdkLogger.DEBUG_3, "Creating code for " + Pcd.TokenCName + "." + Pcd.TokenSpaceGuidCName)
if Pcd.Type not in gItemTypeStringDatabase:
@@ -960,9 +969,9 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
if Pcd.DatumType == 'BOOLEAN':
BoolValue = Value.upper()
if BoolValue == 'TRUE':
- Value = 1
+ Value = '1U'
elif BoolValue == 'FALSE':
- Value = 0
+ Value = '0U'
if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']:
try:
@@ -994,6 +1003,8 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
EdkLogger.error("build", AUTOGEN_ERROR,
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
ExtraData="[%s]" % str(Info))
+ if not Value.endswith('U'):
+ Value += 'U'
elif Pcd.DatumType == 'UINT16':
if ValueNumber < 0:
EdkLogger.error("build", AUTOGEN_ERROR,
@@ -1003,6 +1014,8 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
EdkLogger.error("build", AUTOGEN_ERROR,
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
ExtraData="[%s]" % str(Info))
+ if not Value.endswith('U'):
+ Value += 'U'
elif Pcd.DatumType == 'UINT8':
if ValueNumber < 0:
EdkLogger.error("build", AUTOGEN_ERROR,
@@ -1012,6 +1025,8 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
EdkLogger.error("build", AUTOGEN_ERROR,
"Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
ExtraData="[%s]" % str(Info))
+ if not Value.endswith('U'):
+ Value += 'U'
if Pcd.DatumType == 'VOID*':
if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':
EdkLogger.error("build", AUTOGEN_ERROR,
@@ -1131,7 +1146,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
Type = '(VOID *)'
Array = '[]'
- AutoGenH.Append('#define _PCD_TOKEN_%s %d\n' % (TokenCName, TokenNumber))
+ AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, TokenNumber))
PcdItemType = Pcd.Type
#if PcdItemType in gDynamicPcd:
@@ -1405,6 +1420,8 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
#
if Pcd.DatumType == "UINT64":
ValueList.append(Sku.DefaultValue + "ULL")
+ elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):
+ ValueList.append(Sku.DefaultValue + "U")
else:
ValueList.append(Sku.DefaultValue)