3 VfrCompiler main class and main function.
5 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include "VfrCompiler.h"
20 #include "CommonLib.h"
21 #include "EfiUtilityMsgs.h"
23 PACKAGE_DATA gCBuffer
;
24 PACKAGE_DATA gRBuffer
;
25 CVfrStringDB gCVfrStringDB
;
28 CVfrCompiler::DebugError (
31 IN UINT32 MessageCode
,
33 IN CONST CHAR8
*MsgFmt
,
38 va_start (List
, MsgFmt
);
39 PrintMessage ((CHAR8
*) "ERROR", FileName
, LineNumber
, MessageCode
, (CHAR8
*) Text
, (CHAR8
*) MsgFmt
, List
);
44 CVfrCompiler::SET_RUN_STATUS (
45 IN COMPILER_RUN_STATUS Status
52 CVfrCompiler::IS_RUN_STATUS (
53 IN COMPILER_RUN_STATUS Status
56 return mRunStatus
== Status
;
60 CVfrCompiler::OptionInitialization (
69 SetUtilityName ((CHAR8
*) PROGRAM_NAME
);
71 mOptions
.VfrFileName
[0] = '\0';
72 mOptions
.RecordListFile
[0] = '\0';
73 mOptions
.CreateRecordListFile
= FALSE
;
74 mOptions
.CreateIfrPkgFile
= FALSE
;
75 mOptions
.PkgOutputFileName
[0] = '\0';
76 mOptions
.COutputFileName
[0] = '\0';
77 mOptions
.OutputDirectory
[0] = '\0';
78 mOptions
.PreprocessorOutputFileName
[0] = '\0';
79 mOptions
.VfrBaseFileName
[0] = '\0';
80 mOptions
.IncludePaths
= NULL
;
81 mOptions
.SkipCPreprocessor
= TRUE
;
82 mOptions
.CPreprocessorOptions
= NULL
;
83 mOptions
.CompatibleMode
= FALSE
;
84 mOptions
.HasOverrideClassGuid
= FALSE
;
85 mOptions
.WarningAsError
= FALSE
;
86 memset (&mOptions
.OverrideClassGuid
, 0, sizeof (EFI_GUID
));
90 SET_RUN_STATUS (STATUS_DEAD
);
94 for (Index
= 1; (Index
< Argc
) && (Argv
[Index
][0] == '-'); Index
++) {
95 if ((stricmp(Argv
[Index
], "-h") == 0) || (stricmp(Argv
[Index
], "--help") == 0)) {
97 SET_RUN_STATUS (STATUS_DEAD
);
99 } else if (stricmp(Argv
[Index
], "--version") == 0) {
101 SET_RUN_STATUS (STATUS_DEAD
);
103 } else if (stricmp(Argv
[Index
], "-l") == 0) {
104 mOptions
.CreateRecordListFile
= TRUE
;
105 gCIfrRecordInfoDB
.TurnOn ();
106 } else if (stricmp(Argv
[Index
], "-i") == 0) {
108 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
109 DebugError (NULL
, 0, 1001, "Missing option", "-i missing path argument");
113 AppendIncludePath(Argv
[Index
]);
114 } else if (stricmp(Argv
[Index
], "-o") == 0 || stricmp(Argv
[Index
], "--output-directory") == 0 || stricmp(Argv
[Index
], "-od") == 0) {
116 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
117 DebugError (NULL
, 0, 1001, "Missing option", "-o missing output directory name");
120 strcpy (mOptions
.OutputDirectory
, Argv
[Index
]);
122 CHAR8 lastChar
= mOptions
.OutputDirectory
[strlen(mOptions
.OutputDirectory
) - 1];
123 if ((lastChar
!= '/') && (lastChar
!= '\\')) {
124 if (strchr(mOptions
.OutputDirectory
, '/') != NULL
) {
125 strcat (mOptions
.OutputDirectory
, "/");
127 strcat (mOptions
.OutputDirectory
, "\\");
130 DebugMsg (NULL
, 0, 9, (CHAR8
*) "Output Directory", mOptions
.OutputDirectory
);
131 } else if (stricmp(Argv
[Index
], "-b") == 0 || stricmp(Argv
[Index
], "--create-ifr-package") == 0 || stricmp(Argv
[Index
], "-ibin") == 0) {
132 mOptions
.CreateIfrPkgFile
= TRUE
;
133 } else if (stricmp(Argv
[Index
], "-n") == 0 || stricmp(Argv
[Index
], "--no-pre-processing") == 0 || stricmp(Argv
[Index
], "-nopp") == 0) {
134 mOptions
.SkipCPreprocessor
= TRUE
;
135 } else if (stricmp(Argv
[Index
], "-f") == 0 || stricmp(Argv
[Index
], "--pre-processing-flag") == 0 || stricmp(Argv
[Index
], "-ppflag") == 0) {
137 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
138 DebugError (NULL
, 0, 1001, "Missing option", "-od - missing C-preprocessor argument");
142 AppendCPreprocessorOptions (Argv
[Index
]);
143 } else if (stricmp(Argv
[Index
], "-c") == 0 || stricmp(Argv
[Index
], "--compatible-framework") == 0) {
144 mOptions
.CompatibleMode
= TRUE
;
145 } else if (stricmp(Argv
[Index
], "-s") == 0|| stricmp(Argv
[Index
], "--string-db") == 0) {
147 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
148 DebugError (NULL
, 0, 1001, "Missing option", "-s missing input string file name");
151 gCVfrStringDB
.SetStringFileName(Argv
[Index
]);
152 DebugMsg (NULL
, 0, 9, (CHAR8
*) "Input string file path", Argv
[Index
]);
153 } else if ((stricmp (Argv
[Index
], "-g") == 0) || (stricmp (Argv
[Index
], "--guid") == 0)) {
155 Status
= StringToGuid (Argv
[Index
], &mOptions
.OverrideClassGuid
);
156 if (EFI_ERROR (Status
)) {
157 DebugError (NULL
, 0, 1000, "Invalid format:", "%s", Argv
[Index
]);
160 mOptions
.HasOverrideClassGuid
= TRUE
;
161 } else if (stricmp(Argv
[Index
], "-w") == 0 || stricmp(Argv
[Index
], "--warning-as-error") == 0) {
162 mOptions
.WarningAsError
= TRUE
;
164 DebugError (NULL
, 0, 1000, "Unknown option", "unrecognized option %s", Argv
[Index
]);
169 if (Index
!= Argc
- 1) {
170 DebugError (NULL
, 0, 1001, "Missing option", "VFR file name is not specified.");
173 strcpy (mOptions
.VfrFileName
, Argv
[Index
]);
176 if (SetBaseFileName() != 0) {
179 if (SetPkgOutputFileName () != 0) {
182 if (SetCOutputFileName() != 0) {
185 if (SetPreprocessorOutputFileName () != 0) {
188 if (SetRecordListFileName () != 0) {
194 SET_RUN_STATUS (STATUS_DEAD
);
196 mOptions
.VfrFileName
[0] = '\0';
197 mOptions
.RecordListFile
[0] = '\0';
198 mOptions
.CreateRecordListFile
= FALSE
;
199 mOptions
.CreateIfrPkgFile
= FALSE
;
200 mOptions
.PkgOutputFileName
[0] = '\0';
201 mOptions
.COutputFileName
[0] = '\0';
202 mOptions
.OutputDirectory
[0] = '\0';
203 mOptions
.PreprocessorOutputFileName
[0] = '\0';
204 mOptions
.VfrBaseFileName
[0] = '\0';
205 if (mOptions
.IncludePaths
!= NULL
) {
206 delete mOptions
.IncludePaths
;
207 mOptions
.IncludePaths
= NULL
;
209 if (mOptions
.CPreprocessorOptions
!= NULL
) {
210 delete mOptions
.CPreprocessorOptions
;
211 mOptions
.CPreprocessorOptions
= NULL
;
216 CVfrCompiler::AppendIncludePath (
221 CHAR8
*IncludePaths
= NULL
;
223 Len
= strlen (" -I ") + strlen (PathStr
) + 1;
224 if (mOptions
.IncludePaths
!= NULL
) {
225 Len
+= strlen (mOptions
.IncludePaths
);
227 IncludePaths
= new CHAR8
[Len
];
228 if (IncludePaths
== NULL
) {
229 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
232 IncludePaths
[0] = '\0';
233 if (mOptions
.IncludePaths
!= NULL
) {
234 strcat (IncludePaths
, mOptions
.IncludePaths
);
236 strcat (IncludePaths
, " -I ");
237 strcat (IncludePaths
, PathStr
);
238 if (mOptions
.IncludePaths
!= NULL
) {
239 delete mOptions
.IncludePaths
;
241 mOptions
.IncludePaths
= IncludePaths
;
245 CVfrCompiler::AppendCPreprocessorOptions (
252 Len
= strlen (Options
) + strlen (" ") + 1;
253 if (mOptions
.CPreprocessorOptions
!= NULL
) {
254 Len
+= strlen (mOptions
.CPreprocessorOptions
);
256 Opt
= new CHAR8
[Len
];
258 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
262 if (mOptions
.CPreprocessorOptions
!= NULL
) {
263 strcat (Opt
, mOptions
.CPreprocessorOptions
);
266 strcat (Opt
, Options
);
267 if (mOptions
.CPreprocessorOptions
!= NULL
) {
268 delete mOptions
.CPreprocessorOptions
;
270 mOptions
.CPreprocessorOptions
= Opt
;
274 CVfrCompiler::SetBaseFileName (
278 CHAR8
*pFileName
, *pPath
, *pExt
;
280 if (mOptions
.VfrFileName
[0] == '\0') {
284 pFileName
= mOptions
.VfrFileName
;
286 ((pPath
= strchr (pFileName
, '\\')) != NULL
) ||
287 ((pPath
= strchr (pFileName
, '/')) != NULL
)
290 pFileName
= pPath
+ 1;
293 if (pFileName
== NULL
) {
297 if ((pExt
= strchr (pFileName
, '.')) == NULL
) {
301 strncpy (mOptions
.VfrBaseFileName
, pFileName
, pExt
- pFileName
);
302 mOptions
.VfrBaseFileName
[pExt
- pFileName
] = '\0';
308 CVfrCompiler::SetPkgOutputFileName (
312 if (mOptions
.VfrBaseFileName
[0] == '\0') {
316 strcpy (mOptions
.PkgOutputFileName
, mOptions
.OutputDirectory
);
317 strcat (mOptions
.PkgOutputFileName
, mOptions
.VfrBaseFileName
);
318 strcat (mOptions
.PkgOutputFileName
, VFR_PACKAGE_FILENAME_EXTENSION
);
324 CVfrCompiler::SetCOutputFileName (
328 if (mOptions
.VfrBaseFileName
[0] == '\0') {
332 strcpy (mOptions
.COutputFileName
, mOptions
.OutputDirectory
);
333 strcat (mOptions
.COutputFileName
, mOptions
.VfrBaseFileName
);
334 strcat (mOptions
.COutputFileName
, ".c");
340 CVfrCompiler::SetPreprocessorOutputFileName (
344 if (mOptions
.VfrBaseFileName
[0] == '\0') {
348 strcpy (mOptions
.PreprocessorOutputFileName
, mOptions
.OutputDirectory
);
349 strcat (mOptions
.PreprocessorOutputFileName
, mOptions
.VfrBaseFileName
);
350 strcat (mOptions
.PreprocessorOutputFileName
, VFR_PREPROCESS_FILENAME_EXTENSION
);
356 CVfrCompiler::SetRecordListFileName (
360 if (mOptions
.VfrBaseFileName
[0] == '\0') {
364 strcpy (mOptions
.RecordListFile
, mOptions
.OutputDirectory
);
365 strcat (mOptions
.RecordListFile
, mOptions
.VfrBaseFileName
);
366 strcat (mOptions
.RecordListFile
, VFR_RECORDLIST_FILENAME_EXTENSION
);
371 CVfrCompiler::CVfrCompiler (
376 mPreProcessCmd
= (CHAR8
*) PREPROCESSOR_COMMAND
;
377 mPreProcessOpt
= (CHAR8
*) PREPROCESSOR_OPTIONS
;
379 SET_RUN_STATUS (STATUS_STARTED
);
381 OptionInitialization(Argc
, Argv
);
383 if ((IS_RUN_STATUS(STATUS_FAILED
)) || (IS_RUN_STATUS(STATUS_DEAD
))) {
387 SET_RUN_STATUS(STATUS_INITIALIZED
);
390 CVfrCompiler::~CVfrCompiler (
394 if (mOptions
.IncludePaths
!= NULL
) {
395 delete mOptions
.IncludePaths
;
396 mOptions
.IncludePaths
= NULL
;
399 if (mOptions
.CPreprocessorOptions
!= NULL
) {
400 delete mOptions
.CPreprocessorOptions
;
401 mOptions
.CPreprocessorOptions
= NULL
;
404 SET_RUN_STATUS(STATUS_DEAD
);
408 CVfrCompiler::Usage (
413 CONST CHAR8
*Help
[] = {
415 "VfrCompile version " VFR_COMPILER_VERSION __BUILD_VERSION
,
416 "Copyright (c) 2004-2014 Intel Corporation. All rights reserved.",
418 "Usage: VfrCompile [options] VfrFile",
421 " -h, --help prints this help",
422 " --version prints version info",
423 " -l create an output IFR listing file",
424 " -o DIR, --output-directory DIR",
425 " deposit all output files to directory OutputDir",
426 " default is current directory",
427 " -b, --create-ifr-package",
428 " create an IFR HII pack file",
429 " -n, --no-pre-processing",
430 " do not preprocessing input file",
431 " -c, --compatible-framework",
432 " compatible framework vfr file",
434 " input uni string package file",
436 " override class guid input",
437 " format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
438 " -w --warning-as-error",
439 " treat warning as an error",
442 for (Index
= 0; Help
[Index
] != NULL
; Index
++) {
443 fprintf (stdout
, "%s\n", Help
[Index
]);
448 CVfrCompiler::Version (
453 CONST CHAR8
*Help
[] = {
454 "VfrCompile version " VFR_COMPILER_VERSION __BUILD_VERSION
,
457 for (Index
= 0; Help
[Index
] != NULL
; Index
++) {
458 fprintf (stdout
, "%s\n", Help
[Index
]);
463 CVfrCompiler::PreProcess (
467 FILE *pVfrFile
= NULL
;
469 CHAR8
*PreProcessCmd
= NULL
;
471 if (!IS_RUN_STATUS(STATUS_INITIALIZED
)) {
475 if (mOptions
.SkipCPreprocessor
== TRUE
) {
479 if ((pVfrFile
= fopen (LongFilePath (mOptions
.VfrFileName
), "r")) == NULL
) {
480 DebugError (NULL
, 0, 0001, "Error opening the input VFR file", mOptions
.VfrFileName
);
485 CmdLen
= strlen (mPreProcessCmd
) + strlen (mPreProcessOpt
) +
486 strlen (mOptions
.VfrFileName
) + strlen (mOptions
.PreprocessorOutputFileName
);
487 if (mOptions
.CPreprocessorOptions
!= NULL
) {
488 CmdLen
+= strlen (mOptions
.CPreprocessorOptions
);
490 if (mOptions
.IncludePaths
!= NULL
) {
491 CmdLen
+= strlen (mOptions
.IncludePaths
);
494 PreProcessCmd
= new CHAR8
[CmdLen
+ 10];
495 if (PreProcessCmd
== NULL
) {
496 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
499 strcpy (PreProcessCmd
, mPreProcessCmd
), strcat (PreProcessCmd
, " ");
500 strcat (PreProcessCmd
, mPreProcessOpt
), strcat (PreProcessCmd
, " ");
501 if (mOptions
.IncludePaths
!= NULL
) {
502 strcat (PreProcessCmd
, mOptions
.IncludePaths
), strcat (PreProcessCmd
, " ");
504 if (mOptions
.CPreprocessorOptions
!= NULL
) {
505 strcat (PreProcessCmd
, mOptions
.CPreprocessorOptions
), strcat (PreProcessCmd
, " ");
507 strcat (PreProcessCmd
, mOptions
.VfrFileName
), strcat (PreProcessCmd
, " > ");
508 strcat (PreProcessCmd
, mOptions
.PreprocessorOutputFileName
);
510 if (system (PreProcessCmd
) != 0) {
511 DebugError (NULL
, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd
);
515 delete PreProcessCmd
;
518 SET_RUN_STATUS (STATUS_PREPROCESSED
);
522 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
523 SET_RUN_STATUS (STATUS_FAILED
);
525 delete PreProcessCmd
;
528 extern UINT8
VfrParserStart (IN
FILE *, IN INPUT_INFO_TO_SYNTAX
*);
531 CVfrCompiler::Compile (
535 FILE *pInFile
= NULL
;
536 CHAR8
*InFileName
= NULL
;
537 INPUT_INFO_TO_SYNTAX InputInfo
;
539 if (!IS_RUN_STATUS(STATUS_PREPROCESSED
)) {
543 InFileName
= (mOptions
.SkipCPreprocessor
== TRUE
) ? mOptions
.VfrFileName
: mOptions
.PreprocessorOutputFileName
;
545 gCVfrErrorHandle
.SetInputFile (InFileName
);
546 gCVfrErrorHandle
.SetWarningAsError(mOptions
.WarningAsError
);
548 if ((pInFile
= fopen (LongFilePath (InFileName
), "r")) == NULL
) {
549 DebugError (NULL
, 0, 0001, "Error opening the input file", InFileName
);
553 InputInfo
.CompatibleMode
= mOptions
.CompatibleMode
;
554 if (mOptions
.HasOverrideClassGuid
) {
555 InputInfo
.OverrideClassGuid
= &mOptions
.OverrideClassGuid
;
557 InputInfo
.OverrideClassGuid
= NULL
;
560 if (VfrParserStart (pInFile
, &InputInfo
) != 0) {
566 if (gCFormPkg
.HavePendingUnassigned () == TRUE
) {
567 gCFormPkg
.PendingAssignPrintAll ();
571 SET_RUN_STATUS (STATUS_COMPILEED
);
575 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
576 DebugError (NULL
, 0, 0003, "Error parsing", "compile error in file %s", InFileName
);
577 SET_RUN_STATUS (STATUS_FAILED
);
579 if (pInFile
!= NULL
) {
585 CVfrCompiler::UpdateInfoForDynamicOpcode (
591 if (!gNeedAdjustOpcode
) {
596 // Base on the original offset info to update the record list.
598 if (!gCIfrRecordInfoDB
.IfrAdjustDynamicOpcodeInRecords()) {
599 DebugError (NULL
, 0, 1001, "Error parsing vfr file", "Can find the offset in the record.");
603 // Base on the opcode binary length to recalculate the offset for each opcode.
605 gCIfrRecordInfoDB
.IfrAdjustOffsetForRecord();
608 // Base on the offset to find the binary address.
610 pRecord
= gCIfrRecordInfoDB
.GetRecordInfoFromOffset(gAdjustOpcodeOffset
);
611 while (pRecord
!= NULL
) {
612 pRecord
->mIfrBinBuf
= gCFormPkg
.GetBufAddrBaseOnOffset(pRecord
->mOffset
);
613 if (pRecord
->mIfrBinBuf
== NULL
) {
614 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " 0x%X. offset not allocated.", pRecord
->mOffset
);
616 pRecord
= pRecord
->mNext
;
621 CVfrCompiler::AdjustBin (
625 EFI_VFR_RETURN_CODE Status
;
627 if (!IS_RUN_STATUS(STATUS_COMPILEED
)) {
631 UpdateInfoForDynamicOpcode ();
634 // Check Binary Code consistent between Form and IfrRecord
638 // Get Package Data and IfrRecord Data
640 gCFormPkg
.BuildPkg (gCBuffer
);
641 gCIfrRecordInfoDB
.IfrRecordOutput (gRBuffer
);
644 // Compare Form and Record data
646 if (gCBuffer
.Buffer
!= NULL
&& gRBuffer
.Buffer
!= NULL
) {
648 if (gCBuffer
.Size
!= gRBuffer
.Size
) {
649 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
);
651 for (Index
= 0; Index
< gCBuffer
.Size
; Index
++) {
652 if (gCBuffer
.Buffer
[Index
] != gRBuffer
.Buffer
[Index
]) {
656 if (Index
!= gCBuffer
.Size
) {
657 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions
.VfrFileName
, Index
);
659 DebugMsg (NULL
, 0, 9, (CHAR8
*) "IFR Buffer", (CHAR8
*) "Form Buffer same to Record Buffer and Size is 0x%X", Index
);
660 } else if (gCBuffer
.Buffer
== NULL
&& gRBuffer
.Buffer
== NULL
) {
663 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions
.VfrFileName
);
667 // For UEFI mode, not do OpCode Adjust
669 if (mOptions
.CompatibleMode
) {
671 // Adjust Opcode to be compatible with framework vfr
673 Status
= gCIfrRecordInfoDB
.IfrRecordAdjust ();
674 if (Status
!= VFR_RETURN_SUCCESS
) {
676 // Record List Adjust Failed
678 SET_RUN_STATUS (STATUS_FAILED
);
682 // Re get the IfrRecord Buffer.
684 gCIfrRecordInfoDB
.IfrRecordOutput (gRBuffer
);
691 CVfrCompiler::GenBinary (
697 if (!IS_RUN_STATUS(STATUS_COMPILEED
)) {
701 if (mOptions
.CreateIfrPkgFile
== TRUE
) {
702 if ((pFile
= fopen (LongFilePath (mOptions
.PkgOutputFileName
), "wb")) == NULL
) {
703 DebugError (NULL
, 0, 0001, "Error opening file", mOptions
.PkgOutputFileName
);
706 if (gCFormPkg
.BuildPkg (pFile
, &gRBuffer
) != VFR_RETURN_SUCCESS
) {
713 SET_RUN_STATUS (STATUS_GENBINARY
);
718 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
719 SET_RUN_STATUS (STATUS_FAILED
);
723 static const char *gSourceFileHeader
[] = {
725 "// DO NOT EDIT -- auto-generated file",
727 "// This file is generated by the vfrcompiler utility",
733 CVfrCompiler::GenCFile (
740 if (!IS_RUN_STATUS(STATUS_GENBINARY
)) {
744 if (!mOptions
.CreateIfrPkgFile
|| mOptions
.CompatibleMode
) {
745 if ((pFile
= fopen (LongFilePath (mOptions
.COutputFileName
), "w")) == NULL
) {
746 DebugError (NULL
, 0, 0001, "Error opening output C file", mOptions
.COutputFileName
);
750 for (Index
= 0; gSourceFileHeader
[Index
] != NULL
; Index
++) {
751 fprintf (pFile
, "%s\n", gSourceFileHeader
[Index
]);
754 if (mOptions
.CompatibleMode
) {
755 gCVfrBufferConfig
.OutputCFile (pFile
, mOptions
.VfrBaseFileName
);
758 if (gCFormPkg
.GenCFile (mOptions
.VfrBaseFileName
, pFile
, &gRBuffer
) != VFR_RETURN_SUCCESS
) {
765 SET_RUN_STATUS (STATUS_FINISHED
);
769 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
770 SET_RUN_STATUS (STATUS_FAILED
);
775 CVfrCompiler::GenRecordListFile (
779 CHAR8
*InFileName
= NULL
;
780 FILE *pInFile
= NULL
;
781 FILE *pOutFile
= NULL
;
782 CHAR8 LineBuf
[MAX_VFR_LINE_LEN
];
785 InFileName
= (mOptions
.SkipCPreprocessor
== TRUE
) ? mOptions
.VfrFileName
: mOptions
.PreprocessorOutputFileName
;
787 if (mOptions
.CreateRecordListFile
== TRUE
) {
788 if ((InFileName
[0] == '\0') || (mOptions
.RecordListFile
[0] == '\0')) {
792 if ((pInFile
= fopen (LongFilePath (InFileName
), "r")) == NULL
) {
793 DebugError (NULL
, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName
);
797 if ((pOutFile
= fopen (LongFilePath (mOptions
.RecordListFile
), "w")) == NULL
) {
798 DebugError (NULL
, 0, 0001, "Error opening the record list file", mOptions
.RecordListFile
);
802 fprintf (pOutFile
, "//\n// VFR compiler version " VFR_COMPILER_VERSION __BUILD_VERSION
"\n//\n");
804 while (!feof (pInFile
)) {
805 if (fgets (LineBuf
, MAX_VFR_LINE_LEN
, pInFile
) != NULL
) {
806 fprintf (pOutFile
, "%s", LineBuf
);
808 gCIfrRecordInfoDB
.IfrRecordOutput (pOutFile
, LineNo
);
812 fprintf (pOutFile
, "\n//\n// All Opcode Record List \n//\n");
813 gCIfrRecordInfoDB
.IfrRecordOutput (pOutFile
, 0);
814 gCVfrVarDataTypeDB
.Dump(pOutFile
);
832 COMPILER_RUN_STATUS Status
;
834 SetPrintLevel(WARNING_LOG_LEVEL
);
835 CVfrCompiler
Compiler(Argc
, Argv
);
837 Compiler
.PreProcess();
839 Compiler
.AdjustBin();
840 Compiler
.GenBinary();
842 Compiler
.GenRecordListFile ();
844 Status
= Compiler
.RunStatus ();
845 if ((Status
== STATUS_DEAD
) || (Status
== STATUS_FAILED
)) {
849 if (gCBuffer
.Buffer
!= NULL
) {
850 delete gCBuffer
.Buffer
;
853 if (gRBuffer
.Buffer
!= NULL
) {
854 delete gRBuffer
.Buffer
;
857 return GetUtilityStatus ();