Sync EDKII BaseTools to BaseTools project r1903.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10123 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
VfrCompiler main class and main function.
|
||||
|
||||
Copyright (c) 2004 - 2008, Intel Corporation
|
||||
Copyright (c) 2004 - 2010, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@ -24,9 +24,19 @@ PACKAGE_DATA gCBuffer;
|
||||
PACKAGE_DATA gRBuffer;
|
||||
|
||||
VOID
|
||||
CVfrCompiler::DebugError () {
|
||||
Error (NULL, 0, 0001, "Error parsing vfr file", " %s", mOptions.VfrFileName);
|
||||
//_asm int 3;
|
||||
CVfrCompiler::DebugError (
|
||||
IN CHAR8 *FileName,
|
||||
IN UINT32 LineNumber,
|
||||
IN UINT32 MessageCode,
|
||||
IN CONST CHAR8 *Text,
|
||||
IN CONST CHAR8 *MsgFmt,
|
||||
...
|
||||
)
|
||||
{
|
||||
va_list List;
|
||||
va_start (List, MsgFmt);
|
||||
PrintMessage ((CHAR8 *) "ERROR", FileName, LineNumber, MessageCode, (CHAR8 *) Text, (CHAR8 *) MsgFmt, List);
|
||||
va_end (List);
|
||||
}
|
||||
|
||||
VOID
|
||||
@ -53,7 +63,7 @@ CVfrCompiler::OptionInitialization (
|
||||
{
|
||||
INT32 Index;
|
||||
|
||||
SetUtilityName (PROGRAM_NAME);
|
||||
SetUtilityName ((CHAR8*) PROGRAM_NAME);
|
||||
|
||||
mOptions.VfrFileName[0] = '\0';
|
||||
mOptions.RecordListFile[0] = '\0';
|
||||
@ -84,11 +94,9 @@ CVfrCompiler::OptionInitialization (
|
||||
mOptions.CreateRecordListFile = TRUE;
|
||||
gCIfrRecordInfoDB.TurnOn ();
|
||||
} else if (stricmp(Argv[Index], "-i") == 0) {
|
||||
Error (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
|
||||
goto Fail;
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
Error (NULL, 0, 1001, "Missing option", "-i missing path argument");
|
||||
DebugError (NULL, 0, 1001, "Missing option", "-i missing path argument");
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@ -96,7 +104,7 @@ CVfrCompiler::OptionInitialization (
|
||||
} else if (stricmp(Argv[Index], "-o") == 0 || stricmp(Argv[Index], "--output-directory") == 0 || stricmp(Argv[Index], "-od") == 0) {
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
Error (NULL, 0, 1001, "Missing option", "-o missing output directory name");
|
||||
DebugError (NULL, 0, 1001, "Missing option", "-o missing output directory name");
|
||||
goto Fail;
|
||||
}
|
||||
strcpy (mOptions.OutputDirectory, Argv[Index]);
|
||||
@ -109,17 +117,15 @@ CVfrCompiler::OptionInitialization (
|
||||
strcat (mOptions.OutputDirectory, "\\");
|
||||
}
|
||||
}
|
||||
DebugMsg (NULL, 0, 9, "Output Directory", mOptions.OutputDirectory);
|
||||
DebugMsg (NULL, 0, 9, (CHAR8 *) "Output Directory", mOptions.OutputDirectory);
|
||||
} else if (stricmp(Argv[Index], "-b") == 0 || stricmp(Argv[Index], "--create-ifr-package") == 0 || stricmp(Argv[Index], "-ibin") == 0) {
|
||||
mOptions.CreateIfrPkgFile = TRUE;
|
||||
} else if (stricmp(Argv[Index], "-n") == 0 || stricmp(Argv[Index], "--no-pre-processing") == 0 || stricmp(Argv[Index], "-nopp") == 0) {
|
||||
mOptions.SkipCPreprocessor = TRUE;
|
||||
} else if (stricmp(Argv[Index], "-f") == 0 || stricmp(Argv[Index], "--pre-processing-flag") == 0 || stricmp(Argv[Index], "-ppflag") == 0) {
|
||||
Error (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
|
||||
goto Fail;
|
||||
Index++;
|
||||
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
|
||||
Error (NULL, 0, 1001, "Missing option", "-od - missing C-preprocessor argument");
|
||||
DebugError (NULL, 0, 1001, "Missing option", "-od - missing C-preprocessor argument");
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@ -127,13 +133,13 @@ CVfrCompiler::OptionInitialization (
|
||||
} else if (stricmp(Argv[Index], "-c") == 0 || stricmp(Argv[Index], "--compatible-framework") == 0) {
|
||||
mOptions.CompatibleMode = TRUE;
|
||||
} else {
|
||||
Error (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
|
||||
DebugError (NULL, 0, 1000, "Unknown option", "unrecognized option %s", Argv[Index]);
|
||||
goto Fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index != Argc - 1) {
|
||||
Error (NULL, 0, 1001, "Missing option", "VFR file name is not specified.");
|
||||
DebugError (NULL, 0, 1001, "Missing option", "VFR file name is not specified.");
|
||||
goto Fail;
|
||||
} else {
|
||||
strcpy (mOptions.VfrFileName, Argv[Index]);
|
||||
@ -192,7 +198,7 @@ CVfrCompiler::AppendIncludePath (
|
||||
}
|
||||
IncludePaths = new CHAR8[Len];
|
||||
if (IncludePaths == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
DebugError (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
return;
|
||||
}
|
||||
IncludePaths[0] = '\0';
|
||||
@ -221,7 +227,7 @@ CVfrCompiler::AppendCPreprocessorOptions (
|
||||
}
|
||||
Opt = new CHAR8[Len];
|
||||
if (Opt == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
DebugError (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
return;
|
||||
}
|
||||
Opt[0] = 0;
|
||||
@ -339,8 +345,8 @@ CVfrCompiler::CVfrCompiler (
|
||||
IN CHAR8 **Argv
|
||||
)
|
||||
{
|
||||
mPreProcessCmd = PREPROCESSOR_COMMAND;
|
||||
mPreProcessOpt = PREPROCESSOR_OPTIONS;
|
||||
mPreProcessCmd = (CHAR8 *) PREPROCESSOR_COMMAND;
|
||||
mPreProcessOpt = (CHAR8 *) PREPROCESSOR_OPTIONS;
|
||||
|
||||
OptionInitialization(Argc, Argv);
|
||||
|
||||
@ -377,6 +383,7 @@ CVfrCompiler::Usage (
|
||||
CONST CHAR8 *Help[] = {
|
||||
" ",
|
||||
"VfrCompile version " VFR_COMPILER_VERSION VFR_COMPILER_UPDATE_TIME,
|
||||
"Copyright (c) 2004-2010 Intel Corporation. All rights reserved.",
|
||||
" ",
|
||||
"Usage: VfrCompile [options] VfrFile",
|
||||
" ",
|
||||
@ -417,7 +424,7 @@ CVfrCompiler::PreProcess (
|
||||
}
|
||||
|
||||
if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening the input VFR file", mOptions.VfrFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening the input VFR file", mOptions.VfrFileName);
|
||||
goto Fail;
|
||||
}
|
||||
fclose (pVfrFile);
|
||||
@ -433,7 +440,7 @@ CVfrCompiler::PreProcess (
|
||||
|
||||
PreProcessCmd = new CHAR8[CmdLen + 10];
|
||||
if (PreProcessCmd == NULL) {
|
||||
Error (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
DebugError (NULL, 0, 4001, "Resource: memory can't be allocated", NULL);
|
||||
goto Fail;
|
||||
}
|
||||
strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");
|
||||
@ -448,7 +455,7 @@ CVfrCompiler::PreProcess (
|
||||
strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);
|
||||
|
||||
if (system (PreProcessCmd) != 0) {
|
||||
Error (NULL, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd);
|
||||
DebugError (NULL, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@ -484,7 +491,7 @@ CVfrCompiler::Compile (
|
||||
gCVfrErrorHandle.SetInputFile (InFileName);
|
||||
|
||||
if ((pInFile = fopen (InFileName, "r")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening the input file", InFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening the input file", InFileName);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@ -504,7 +511,7 @@ CVfrCompiler::Compile (
|
||||
|
||||
Fail:
|
||||
if (!IS_RUN_STATUS(STATUS_DEAD)) {
|
||||
Error (NULL, 0, 0003, "Error parsing", "compile error in file %s", InFileName);
|
||||
DebugError (NULL, 0, 0003, "Error parsing", "compile error in file %s", InFileName);
|
||||
SET_RUN_STATUS (STATUS_FAILED);
|
||||
}
|
||||
if (pInFile != NULL) {
|
||||
@ -534,7 +541,7 @@ CVfrCompiler::AdjustBin (
|
||||
if (gCBuffer.Buffer != NULL && gRBuffer.Buffer != NULL) {
|
||||
UINT32 Index;
|
||||
if (gCBuffer.Size != gRBuffer.Size) {
|
||||
Error (NULL, 0, 0001, "Error parsing vfr file", " %s. FormBinary Size 0x%X is not same to RecordBuffer Size 0x%X", mOptions.VfrFileName, gCBuffer.Size, gRBuffer.Size);
|
||||
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s. FormBinary Size 0x%X is not same to RecordBuffer Size 0x%X", mOptions.VfrFileName, gCBuffer.Size, gRBuffer.Size);
|
||||
}
|
||||
for (Index = 0; Index < gCBuffer.Size; Index ++) {
|
||||
if (gCBuffer.Buffer[Index] != gRBuffer.Buffer[Index]) {
|
||||
@ -542,13 +549,13 @@ CVfrCompiler::AdjustBin (
|
||||
}
|
||||
}
|
||||
if (Index != gCBuffer.Size) {
|
||||
Error (NULL, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions.VfrFileName, Index);
|
||||
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions.VfrFileName, Index);
|
||||
}
|
||||
DebugMsg (NULL, 0, 9, "IFR Buffer", "Form Buffer same to Record Buffer and Size is 0x%X", Index);
|
||||
DebugMsg (NULL, 0, 9, (CHAR8 *) "IFR Buffer", (CHAR8 *) "Form Buffer same to Record Buffer and Size is 0x%X", Index);
|
||||
} else if (gCBuffer.Buffer == NULL && gRBuffer.Buffer == NULL) {
|
||||
//ok
|
||||
} else {
|
||||
Error (NULL, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions.VfrFileName);
|
||||
DebugError (NULL, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions.VfrFileName);
|
||||
}
|
||||
|
||||
//
|
||||
@ -588,7 +595,7 @@ CVfrCompiler::GenBinary (
|
||||
|
||||
if (mOptions.CreateIfrPkgFile == TRUE) {
|
||||
if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening file", mOptions.PkgOutputFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening file", mOptions.PkgOutputFileName);
|
||||
goto Fail;
|
||||
}
|
||||
if (gCFormPkg.BuildPkg (pFile, &gRBuffer) != VFR_RETURN_SUCCESS) {
|
||||
@ -631,7 +638,7 @@ CVfrCompiler::GenCFile (
|
||||
|
||||
if (!mOptions.CreateIfrPkgFile || mOptions.CompatibleMode) {
|
||||
if ((pFile = fopen (mOptions.COutputFileName, "w")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening output C file", mOptions.COutputFileName);
|
||||
goto Fail;
|
||||
}
|
||||
|
||||
@ -678,12 +685,12 @@ CVfrCompiler::GenRecordListFile (
|
||||
}
|
||||
|
||||
if ((pInFile = fopen (InFileName, "r")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName);
|
||||
DebugError (NULL, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {
|
||||
Error (NULL, 0, 0001, "Error opening the record list file", mOptions.RecordListFile);
|
||||
DebugError (NULL, 0, 0001, "Error opening the record list file", mOptions.RecordListFile);
|
||||
goto Err1;
|
||||
}
|
||||
|
||||
@ -713,8 +720,8 @@ Err1:
|
||||
|
||||
int
|
||||
main (
|
||||
IN INT32 Argc,
|
||||
IN CHAR8 **Argv
|
||||
IN int Argc,
|
||||
IN char **Argv
|
||||
)
|
||||
{
|
||||
COMPILER_RUN_STATUS Status;
|
||||
@ -743,3 +750,4 @@ main (
|
||||
return GetUtilityStatus ();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user