Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4
2010-11-26 01:54:49 +00:00
parent 68bb5ce77e
commit 3e99020dbf
183 changed files with 15250 additions and 2636 deletions

View File

@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
VfrCompiler.cpp
VfrCompiler.cpp
Abstract:
@ -41,7 +41,7 @@ CVfrCompiler::IS_RUN_STATUS (
VOID
CVfrCompiler::OptionInitialization (
IN INT32 Argc,
IN INT32 Argc,
IN INT8 **Argv
)
{
@ -57,6 +57,7 @@ CVfrCompiler::OptionInitialization (
mOptions.PreprocessorOutputFileName[0] = '\0';
mOptions.VfrBaseFileName[0] = '\0';
mOptions.IncludePaths = NULL;
mOptions.SkipCPreprocessor = FALSE;
mOptions.CPreprocessorOptions = NULL;
for (Index = 1; (Index < Argc) && (Argv[Index][0] == '-'); Index++) {
@ -70,7 +71,7 @@ CVfrCompiler::OptionInitialization (
} else if (_stricmp(Argv[Index], "-i") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
printf ("%s -i - missing path argument\n", PROGRAM_NAME);
printf ("%s -i - missing path argument\n", UTILITY_NAME);
goto Fail;
}
@ -78,30 +79,33 @@ CVfrCompiler::OptionInitialization (
} else if (_stricmp(Argv[Index], "-od") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
printf ("%s -od - missing output directory name\n", PROGRAM_NAME);
printf ("%s -od - missing output directory name\n", UTILITY_NAME);
goto Fail;
}
strcpy (mOptions.OutputDirectory, Argv[Index]);
strcat (mOptions.OutputDirectory, "\\");
} else if (_stricmp(Argv[Index], "-ibin") == 0) {
mOptions.CreateIfrPkgFile = TRUE;
} else if (_stricmp(Argv[Index], "-nostrings") == 0) {
} else if (_stricmp(Argv[Index], "-nopp") == 0) {
mOptions.SkipCPreprocessor = TRUE;
} else if (_stricmp(Argv[Index], "-ppflag") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
printf ("%s -od - missing C-preprocessor argument\n", PROGRAM_NAME);
printf ("%s -od - missing C-preprocessor argument\n", UTILITY_NAME);
goto Fail;
}
AppendCPreprocessorOptions (Argv[Index]);
} else {
printf ("%s unrecognized option %s\n", PROGRAM_NAME, Argv[Index]);
printf ("%s unrecognized option %s\n", UTILITY_NAME, Argv[Index]);
Usage ();
goto Fail;
}
}
if (Index != Argc - 1) {
printf ("%s must specify VFR file name", PROGRAM_NAME);
printf ("%s must specify VFR file name\n", UTILITY_NAME);
Usage ();
goto Fail;
} else {
@ -140,7 +144,7 @@ Fail:
if (mOptions.IncludePaths != NULL) {
delete mOptions.IncludePaths;
mOptions.IncludePaths = NULL;
}
}
if (mOptions.CPreprocessorOptions != NULL) {
delete mOptions.CPreprocessorOptions;
mOptions.CPreprocessorOptions = NULL;
@ -161,7 +165,7 @@ CVfrCompiler::AppendIncludePath (
}
IncludePaths = new INT8[Len];
if (IncludePaths == NULL) {
printf ("%s memory allocation failure\n", PROGRAM_NAME);
printf ("%s memory allocation failure\n", UTILITY_NAME);
return;
}
IncludePaths[0] = '\0';
@ -190,7 +194,7 @@ CVfrCompiler::AppendCPreprocessorOptions (
}
Opt = new INT8[Len];
if (Opt == NULL) {
printf ("%s memory allocation failure\n", PROGRAM_NAME);
printf ("%s memory allocation failure\n", UTILITY_NAME);
return;
}
Opt[0] = 0;
@ -217,7 +221,11 @@ CVfrCompiler::SetBaseFileName (
}
pFileName = mOptions.VfrFileName;
while ((pPath = strchr (pFileName, '\\')) != NULL) {
while (
((pPath = strchr (pFileName, '\\')) != NULL) ||
((pPath = strchr (pFileName, '/')) != NULL)
)
{
pFileName = pPath + 1;
}
@ -300,7 +308,7 @@ CVfrCompiler::SetRecordListFileName (
}
CVfrCompiler::CVfrCompiler (
IN INT32 Argc,
IN INT32 Argc,
IN INT8 **Argv
)
{
@ -333,35 +341,40 @@ CVfrCompiler::~CVfrCompiler (
SET_RUN_STATUS(STATUS_DEAD);
}
VOID
VOID
CVfrCompiler::Usage (
VOID
)
{
UINT32 Index;
CONST INT8 *Help[] = {
" ",
"VfrCompile version " VFR_COMPILER_VERSION,
" ",
" Usage: VfrCompile {options} [VfrFile]",
" ",
" where options include:",
" -? or -h prints this help",
" -l create an output IFR listing file",
" -i IncPath add IncPath to the search path for VFR included files",
" -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
" -ibin create an IFR HII pack file"
" -ppflag C-preprocessor argument",
" where parameters include:",
" VfrFile name of the input VFR script file",
" ",
int Index;
const char *Str[] = {
UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI VFR Compiler Utility",
" Copyright (C), 2004 - 2008 Intel Corporation",
#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
" Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
#endif
"",
"Usage:",
" "UTILITY_NAME" [OPTION] VFRFILE",
"Description:",
" Compile VFRFILE.",
"Options:",
" -? or -h print this help",
" -l create an output IFR listing file",
" -i IncPath add IncPath to the search path for VFR included files",
" -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
" -ibin create an IFR HII pack file",
" -ppflag CFlags pass Flags as C-preprocessor-flag",
" -v or -version print version information",
NULL
};
for (Index = 0; Help[Index] != NULL; Index++) {
fprintf (stdout, "%s\n", Help[Index]);
};
for (Index = 0; Str[Index] != NULL; Index++) {
fprintf (stdout, "%s\n", Str[Index]);
}
}
VOID
CVfrCompiler::PreProcess (
VOID
@ -375,8 +388,12 @@ CVfrCompiler::PreProcess (
goto Fail;
}
if (mOptions.SkipCPreprocessor == TRUE) {
goto Out;
}
if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {
printf ("%s could not open input VFR file - %s\n", PROGRAM_NAME, mOptions.VfrFileName);
printf ("%s could not open input VFR file - %s\n", UTILITY_NAME, mOptions.VfrFileName);
goto Fail;
}
fclose (pVfrFile);
@ -392,7 +409,7 @@ CVfrCompiler::PreProcess (
PreProcessCmd = new INT8[CmdLen + 10];
if (PreProcessCmd == NULL) {
printf ("%s could not allocate memory\n", PROGRAM_NAME);
printf ("%s could not allocate memory\n", UTILITY_NAME);
goto Fail;
}
strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");
@ -407,11 +424,13 @@ CVfrCompiler::PreProcess (
strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);
if (system (PreProcessCmd) != 0) {
printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", PROGRAM_NAME, PreProcessCmd);
printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", UTILITY_NAME, PreProcessCmd);
goto Fail;
}
delete PreProcessCmd;
Out:
SET_RUN_STATUS (STATUS_PREPROCESSED);
return;
@ -429,22 +448,27 @@ CVfrCompiler::Compile (
VOID
)
{
FILE *VfrFile = NULL;
FILE *pInFile = NULL;
INT8 *InFileName = NULL;
if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {
goto Fail;
}
if ((VfrFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
gCVfrErrorHandle.SetInputFile (InFileName);
if ((pInFile = fopen (InFileName, "r")) == NULL) {
printf ("%s failed to open input file - %s\n", UTILITY_NAME, InFileName);
goto Fail;
}
if (VfrParserStart (VfrFile) != 0) {
if (VfrParserStart (pInFile) != 0) {
goto Fail;
}
fclose (VfrFile);
fclose (pInFile);
if (gCFormPkg.HavePendingUnassigned () == TRUE) {
gCFormPkg.PendingAssignPrintAll ();
@ -456,11 +480,11 @@ CVfrCompiler::Compile (
Fail:
if (!IS_RUN_STATUS(STATUS_DEAD)) {
printf ("%s compile error!\n", PROGRAM_NAME);
printf ("%s compile error!\n", UTILITY_NAME);
SET_RUN_STATUS (STATUS_FAILED);
}
if (VfrFile != NULL) {
fclose (VfrFile);
if (pInFile != NULL) {
fclose (pInFile);
}
}
@ -477,7 +501,7 @@ CVfrCompiler::GenBinary (
if (mOptions.CreateIfrPkgFile == TRUE) {
if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {
printf ("can not open PkgFileName\n", mOptions.PkgOutputFileName);
printf ("can not open %s\n", mOptions.PkgOutputFileName);
goto Fail;
}
if (gCFormPkg.BuildPkg (pFile) != VFR_RETURN_SUCCESS) {
@ -548,27 +572,30 @@ CVfrCompiler::GenRecordListFile (
VOID
)
{
FILE *pInFile = NULL;
FILE *pOutFile = NULL;
INT8 *InFileName = NULL;
FILE *pInFile = NULL;
FILE *pOutFile = NULL;
INT8 LineBuf[MAX_LINE_LEN];
UINT32 LineNo;
InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
if (mOptions.CreateRecordListFile == TRUE) {
if ((mOptions.PreprocessorOutputFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
if ((InFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
return;
}
if ((pInFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
if ((pInFile = fopen (InFileName, "r")) == NULL) {
printf ("%s failed to open input VFR preprocessor output file - %s\n", UTILITY_NAME, InFileName);
return;
}
if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {
printf ("%s failed to open record list file for writing - %s\n", PROGRAM_NAME, mOptions.RecordListFile);
printf ("%s failed to open record list file for writing - %s\n", UTILITY_NAME, mOptions.RecordListFile);
goto Err1;
}
fprintf (pOutFile, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
fprintf (pOutFile, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");
LineNo = 0;
while (!feof (pInFile)) {
if (fgets (LineBuf, MAX_LINE_LEN, pInFile) != NULL) {
@ -590,7 +617,7 @@ Err1:
INT32
main (
IN INT32 Argc,
IN INT32 Argc,
IN INT8 **Argv
)
{