]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
Sync BaseTool trunk (version r2599) into EDKII BaseTools.
[mirror_edk2.git] / BaseTools / Source / C / VfrCompile / VfrCompiler.cpp
index 926561760a5b8e7d92790dd1e1bdad81b27645fc..da8c52989417ef220ba420bc25a89f5a91c99cb9 100644 (file)
@@ -2,7 +2,7 @@
   \r
   VfrCompiler main class and main function.\r
 \r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -82,6 +82,7 @@ CVfrCompiler::OptionInitialization (
   mOptions.CPreprocessorOptions          = NULL;\r
   mOptions.CompatibleMode                = FALSE;\r
   mOptions.HasOverrideClassGuid          = FALSE;\r
+  mOptions.WarningAsError                = FALSE;\r
   memset (&mOptions.OverrideClassGuid, 0, sizeof (EFI_GUID));\r
   \r
   if (Argc == 1) {\r
@@ -153,6 +154,8 @@ CVfrCompiler::OptionInitialization (
         goto Fail;\r
       }\r
       mOptions.HasOverrideClassGuid = TRUE;\r
+    } else if (stricmp(Argv[Index], "-w") == 0 || stricmp(Argv[Index], "--warning-as-error") == 0) {\r
+      mOptions.WarningAsError = TRUE;\r
     } else {\r
       DebugError (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);\r
       goto Fail;\r
@@ -403,7 +406,7 @@ CVfrCompiler::Usage (
   UINT32 Index;\r
   CONST  CHAR8 *Help[] = {\r
     " ", \r
-    "VfrCompile version " VFR_COMPILER_VERSION VFR_COMPILER_UPDATE_TIME,\r
+    "VfrCompile version " VFR_COMPILER_VERSION __BUILD_VERSION VFR_COMPILER_UPDATE_TIME,\r
     "Copyright (c) 2004-2011 Intel Corporation. All rights reserved.",\r
     " ",\r
     "Usage: VfrCompile [options] VfrFile",\r
@@ -425,6 +428,8 @@ CVfrCompiler::Usage (
     "  -g, --guid",\r
     "                 override class guid input",\r
     "                 format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",\r
+    "  -w  --warning-as-error",\r
+    "                 treat warning as an error",\r
     NULL\r
     };\r
   for (Index = 0; Help[Index] != NULL; Index++) {\r
@@ -516,6 +521,7 @@ CVfrCompiler::Compile (
   InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;\r
 \r
   gCVfrErrorHandle.SetInputFile (InFileName);\r
+  gCVfrErrorHandle.SetWarningAsError(mOptions.WarningAsError);\r
 \r
   if ((pInFile = fopen (InFileName, "r")) == NULL) {\r
     DebugError (NULL, 0, 0001, "Error opening the input file", InFileName);\r
@@ -553,12 +559,55 @@ Fail:
   }\r
 }\r
 \r
+VOID\r
+CVfrCompiler::UpdateInfoForDynamicOpcode (\r
+  VOID\r
+  )\r
+{\r
+  SIfrRecord          *pRecord;\r
+\r
+  if (!gNeedAdjustOpcode) {\r
+    return;\r
+  }\r
+  \r
+  //\r
+  // Base on the original offset info to update the record list.\r
+  //\r
+  if (!gCIfrRecordInfoDB.IfrAdjustDynamicOpcodeInRecords()) {\r
+    DebugError (NULL, 0, 1001, "Error parsing vfr file", "Can find the offset in the record.");\r
+  }\r
+\r
+  //\r
+  // Base on the opcode binary length to recalculate the offset for each opcode.\r
+  //\r
+  gCIfrRecordInfoDB.IfrAdjustOffsetForRecord();\r
+\r
+  //\r
+  // Base on the offset to find the binary address.\r
+  //\r
+  pRecord = gCIfrRecordInfoDB.GetRecordInfoFromOffset(gAdjustOpcodeOffset);\r
+  while (pRecord != NULL) {\r
+    pRecord->mIfrBinBuf = gCFormPkg.GetBufAddrBaseOnOffset(pRecord->mOffset);\r
+    if (pRecord->mIfrBinBuf == NULL) {\r
+      DebugError (NULL, 0, 0001, "Error parsing vfr file", " 0x%X. offset not allocated.", pRecord->mOffset);\r
+    }\r
+    pRecord = pRecord->mNext;\r
+  }\r
+}\r
+\r
 VOID\r
 CVfrCompiler::AdjustBin (\r
   VOID\r
   )\r
 {\r
   EFI_VFR_RETURN_CODE Status;\r
+\r
+  if (!IS_RUN_STATUS(STATUS_COMPILEED)) {\r
+    return;\r
+  }\r
+\r
+  UpdateInfoForDynamicOpcode ();\r
+\r
   //\r
   // Check Binary Code consistent between Form and IfrRecord\r
   //\r
@@ -728,7 +777,7 @@ CVfrCompiler::GenRecordListFile (
       goto Err1;\r
     }\r
 \r
-    fprintf (pOutFile, "//\n//  VFR compiler version " VFR_COMPILER_VERSION "\n//\n");\r
+    fprintf (pOutFile, "//\n//  VFR compiler version " VFR_COMPILER_VERSION __BUILD_VERSION "\n//\n");\r
     LineNo = 0;\r
     while (!feof (pInFile)) {\r
       if (fgets (LineBuf, MAX_VFR_LINE_LEN, pInFile) != NULL) {\r
@@ -759,6 +808,8 @@ main (
   )\r
 {\r
   COMPILER_RUN_STATUS  Status;\r
+\r
+  SetPrintLevel(WARNING_LOG_LEVEL);\r
   CVfrCompiler         Compiler(Argc, Argv);\r
   \r
   Compiler.PreProcess();\r