3 VfrCompiler main class and main function.
5 Copyright (c) 2004 - 2016, 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 mOptions
.AutoDefault
= FALSE
;
87 mOptions
.CheckDefault
= FALSE
;
88 memset (&mOptions
.OverrideClassGuid
, 0, sizeof (EFI_GUID
));
92 SET_RUN_STATUS (STATUS_DEAD
);
96 for (Index
= 1; (Index
< Argc
) && (Argv
[Index
][0] == '-'); Index
++) {
97 if ((stricmp(Argv
[Index
], "-h") == 0) || (stricmp(Argv
[Index
], "--help") == 0)) {
99 SET_RUN_STATUS (STATUS_DEAD
);
101 } else if (stricmp(Argv
[Index
], "--version") == 0) {
103 SET_RUN_STATUS (STATUS_DEAD
);
105 } else if (stricmp(Argv
[Index
], "-l") == 0) {
106 mOptions
.CreateRecordListFile
= TRUE
;
107 gCIfrRecordInfoDB
.TurnOn ();
108 } else if (stricmp(Argv
[Index
], "-i") == 0) {
110 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
111 DebugError (NULL
, 0, 1001, "Missing option", "-i missing path argument");
115 AppendIncludePath(Argv
[Index
]);
116 } else if (stricmp(Argv
[Index
], "-o") == 0 || stricmp(Argv
[Index
], "--output-directory") == 0 || stricmp(Argv
[Index
], "-od") == 0) {
118 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
119 DebugError (NULL
, 0, 1001, "Missing option", "-o missing output directory name");
122 strcpy (mOptions
.OutputDirectory
, Argv
[Index
]);
124 CHAR8 lastChar
= mOptions
.OutputDirectory
[strlen(mOptions
.OutputDirectory
) - 1];
125 if ((lastChar
!= '/') && (lastChar
!= '\\')) {
126 if (strchr(mOptions
.OutputDirectory
, '/') != NULL
) {
127 strcat (mOptions
.OutputDirectory
, "/");
129 strcat (mOptions
.OutputDirectory
, "\\");
132 DebugMsg (NULL
, 0, 9, (CHAR8
*) "Output Directory", mOptions
.OutputDirectory
);
133 } else if (stricmp(Argv
[Index
], "-b") == 0 || stricmp(Argv
[Index
], "--create-ifr-package") == 0 || stricmp(Argv
[Index
], "-ibin") == 0) {
134 mOptions
.CreateIfrPkgFile
= TRUE
;
135 } else if (stricmp(Argv
[Index
], "-n") == 0 || stricmp(Argv
[Index
], "--no-pre-processing") == 0 || stricmp(Argv
[Index
], "-nopp") == 0) {
136 mOptions
.SkipCPreprocessor
= TRUE
;
137 } else if (stricmp(Argv
[Index
], "-f") == 0 || stricmp(Argv
[Index
], "--pre-processing-flag") == 0 || stricmp(Argv
[Index
], "-ppflag") == 0) {
139 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
140 DebugError (NULL
, 0, 1001, "Missing option", "-od - missing C-preprocessor argument");
144 AppendCPreprocessorOptions (Argv
[Index
]);
145 } else if (stricmp(Argv
[Index
], "-c") == 0 || stricmp(Argv
[Index
], "--compatible-framework") == 0) {
146 mOptions
.CompatibleMode
= TRUE
;
147 } else if (stricmp(Argv
[Index
], "-s") == 0|| stricmp(Argv
[Index
], "--string-db") == 0) {
149 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
150 DebugError (NULL
, 0, 1001, "Missing option", "-s missing input string file name");
153 gCVfrStringDB
.SetStringFileName(Argv
[Index
]);
154 DebugMsg (NULL
, 0, 9, (CHAR8
*) "Input string file path", Argv
[Index
]);
155 } else if ((stricmp (Argv
[Index
], "-g") == 0) || (stricmp (Argv
[Index
], "--guid") == 0)) {
157 Status
= StringToGuid (Argv
[Index
], &mOptions
.OverrideClassGuid
);
158 if (EFI_ERROR (Status
)) {
159 DebugError (NULL
, 0, 1000, "Invalid format:", "%s", Argv
[Index
]);
162 mOptions
.HasOverrideClassGuid
= TRUE
;
163 } else if (stricmp(Argv
[Index
], "-w") == 0 || stricmp(Argv
[Index
], "--warning-as-error") == 0) {
164 mOptions
.WarningAsError
= TRUE
;
165 } else if (stricmp(Argv
[Index
], "-a") == 0 ||stricmp(Argv
[Index
], "--autodefault") == 0) {
166 mOptions
.AutoDefault
= TRUE
;
167 } else if (stricmp(Argv
[Index
], "-d") == 0 ||stricmp(Argv
[Index
], "--checkdefault") == 0) {
168 mOptions
.CheckDefault
= TRUE
;
170 DebugError (NULL
, 0, 1000, "Unknown option", "unrecognized option %s", Argv
[Index
]);
175 if (Index
!= Argc
- 1) {
176 DebugError (NULL
, 0, 1001, "Missing option", "VFR file name is not specified.");
179 strcpy (mOptions
.VfrFileName
, Argv
[Index
]);
182 if (SetBaseFileName() != 0) {
185 if (SetPkgOutputFileName () != 0) {
188 if (SetCOutputFileName() != 0) {
191 if (SetPreprocessorOutputFileName () != 0) {
194 if (SetRecordListFileName () != 0) {
200 SET_RUN_STATUS (STATUS_DEAD
);
202 mOptions
.VfrFileName
[0] = '\0';
203 mOptions
.RecordListFile
[0] = '\0';
204 mOptions
.CreateRecordListFile
= FALSE
;
205 mOptions
.CreateIfrPkgFile
= FALSE
;
206 mOptions
.PkgOutputFileName
[0] = '\0';
207 mOptions
.COutputFileName
[0] = '\0';
208 mOptions
.OutputDirectory
[0] = '\0';
209 mOptions
.PreprocessorOutputFileName
[0] = '\0';
210 mOptions
.VfrBaseFileName
[0] = '\0';
211 if (mOptions
.IncludePaths
!= NULL
) {
212 delete mOptions
.IncludePaths
;
213 mOptions
.IncludePaths
= NULL
;
215 if (mOptions
.CPreprocessorOptions
!= NULL
) {
216 delete mOptions
.CPreprocessorOptions
;
217 mOptions
.CPreprocessorOptions
= NULL
;
222 CVfrCompiler::AppendIncludePath (
227 CHAR8
*IncludePaths
= NULL
;
229 Len
= strlen (" -I ") + strlen (PathStr
) + 1;
230 if (mOptions
.IncludePaths
!= NULL
) {
231 Len
+= strlen (mOptions
.IncludePaths
);
233 IncludePaths
= new CHAR8
[Len
];
234 if (IncludePaths
== NULL
) {
235 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
238 IncludePaths
[0] = '\0';
239 if (mOptions
.IncludePaths
!= NULL
) {
240 strcat (IncludePaths
, mOptions
.IncludePaths
);
242 strcat (IncludePaths
, " -I ");
243 strcat (IncludePaths
, PathStr
);
244 if (mOptions
.IncludePaths
!= NULL
) {
245 delete mOptions
.IncludePaths
;
247 mOptions
.IncludePaths
= IncludePaths
;
251 CVfrCompiler::AppendCPreprocessorOptions (
258 Len
= strlen (Options
) + strlen (" ") + 1;
259 if (mOptions
.CPreprocessorOptions
!= NULL
) {
260 Len
+= strlen (mOptions
.CPreprocessorOptions
);
262 Opt
= new CHAR8
[Len
];
264 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
268 if (mOptions
.CPreprocessorOptions
!= NULL
) {
269 strcat (Opt
, mOptions
.CPreprocessorOptions
);
272 strcat (Opt
, Options
);
273 if (mOptions
.CPreprocessorOptions
!= NULL
) {
274 delete mOptions
.CPreprocessorOptions
;
276 mOptions
.CPreprocessorOptions
= Opt
;
280 CVfrCompiler::SetBaseFileName (
284 CHAR8
*pFileName
, *pPath
, *pExt
;
286 if (mOptions
.VfrFileName
[0] == '\0') {
290 pFileName
= mOptions
.VfrFileName
;
292 ((pPath
= strchr (pFileName
, '\\')) != NULL
) ||
293 ((pPath
= strchr (pFileName
, '/')) != NULL
)
296 pFileName
= pPath
+ 1;
299 if (pFileName
== NULL
) {
303 if ((pExt
= strchr (pFileName
, '.')) == NULL
) {
307 strncpy (mOptions
.VfrBaseFileName
, pFileName
, pExt
- pFileName
);
308 mOptions
.VfrBaseFileName
[pExt
- pFileName
] = '\0';
314 CVfrCompiler::SetPkgOutputFileName (
318 if (mOptions
.VfrBaseFileName
[0] == '\0') {
322 strcpy (mOptions
.PkgOutputFileName
, mOptions
.OutputDirectory
);
323 strcat (mOptions
.PkgOutputFileName
, mOptions
.VfrBaseFileName
);
324 strcat (mOptions
.PkgOutputFileName
, VFR_PACKAGE_FILENAME_EXTENSION
);
330 CVfrCompiler::SetCOutputFileName (
334 if (mOptions
.VfrBaseFileName
[0] == '\0') {
338 strcpy (mOptions
.COutputFileName
, mOptions
.OutputDirectory
);
339 strcat (mOptions
.COutputFileName
, mOptions
.VfrBaseFileName
);
340 strcat (mOptions
.COutputFileName
, ".c");
346 CVfrCompiler::SetPreprocessorOutputFileName (
350 if (mOptions
.VfrBaseFileName
[0] == '\0') {
354 strcpy (mOptions
.PreprocessorOutputFileName
, mOptions
.OutputDirectory
);
355 strcat (mOptions
.PreprocessorOutputFileName
, mOptions
.VfrBaseFileName
);
356 strcat (mOptions
.PreprocessorOutputFileName
, VFR_PREPROCESS_FILENAME_EXTENSION
);
362 CVfrCompiler::SetRecordListFileName (
366 if (mOptions
.VfrBaseFileName
[0] == '\0') {
370 strcpy (mOptions
.RecordListFile
, mOptions
.OutputDirectory
);
371 strcat (mOptions
.RecordListFile
, mOptions
.VfrBaseFileName
);
372 strcat (mOptions
.RecordListFile
, VFR_RECORDLIST_FILENAME_EXTENSION
);
377 CVfrCompiler::CVfrCompiler (
382 mPreProcessCmd
= (CHAR8
*) PREPROCESSOR_COMMAND
;
383 mPreProcessOpt
= (CHAR8
*) PREPROCESSOR_OPTIONS
;
385 SET_RUN_STATUS (STATUS_STARTED
);
387 OptionInitialization(Argc
, Argv
);
389 if ((IS_RUN_STATUS(STATUS_FAILED
)) || (IS_RUN_STATUS(STATUS_DEAD
))) {
393 SET_RUN_STATUS(STATUS_INITIALIZED
);
396 CVfrCompiler::~CVfrCompiler (
400 if (mOptions
.IncludePaths
!= NULL
) {
401 delete mOptions
.IncludePaths
;
402 mOptions
.IncludePaths
= NULL
;
405 if (mOptions
.CPreprocessorOptions
!= NULL
) {
406 delete mOptions
.CPreprocessorOptions
;
407 mOptions
.CPreprocessorOptions
= NULL
;
410 SET_RUN_STATUS(STATUS_DEAD
);
414 CVfrCompiler::Usage (
419 CONST CHAR8
*Help
[] = {
421 "VfrCompile version " VFR_COMPILER_VERSION
"Build " __BUILD_VERSION
,
422 "Copyright (c) 2004-2016 Intel Corporation. All rights reserved.",
424 "Usage: VfrCompile [options] VfrFile",
427 " -h, --help prints this help",
428 " --version prints version info",
429 " -l create an output IFR listing file",
430 " -o DIR, --output-directory DIR",
431 " deposit all output files to directory OutputDir",
432 " default is current directory",
433 " -b, --create-ifr-package",
434 " create an IFR HII pack file",
435 " -n, --no-pre-processing",
436 " do not preprocessing input file",
437 " -c, --compatible-framework",
438 " compatible framework vfr file",
440 " input uni string package file",
442 " override class guid input",
443 " format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
444 " -w --warning-as-error",
445 " treat warning as an error",
446 " -a --autodefaut generate default value for question opcode if some default is missing",
447 " -d --checkdefault check the default information in a question opcode",
450 for (Index
= 0; Help
[Index
] != NULL
; Index
++) {
451 fprintf (stdout
, "%s\n", Help
[Index
]);
456 CVfrCompiler::Version (
461 CONST CHAR8
*Help
[] = {
462 "VfrCompile version " VFR_COMPILER_VERSION
"Build " __BUILD_VERSION
,
465 for (Index
= 0; Help
[Index
] != NULL
; Index
++) {
466 fprintf (stdout
, "%s\n", Help
[Index
]);
471 CVfrCompiler::PreProcess (
475 FILE *pVfrFile
= NULL
;
477 CHAR8
*PreProcessCmd
= NULL
;
479 if (!IS_RUN_STATUS(STATUS_INITIALIZED
)) {
483 if (mOptions
.SkipCPreprocessor
== TRUE
) {
487 if ((pVfrFile
= fopen (LongFilePath (mOptions
.VfrFileName
), "r")) == NULL
) {
488 DebugError (NULL
, 0, 0001, "Error opening the input VFR file", mOptions
.VfrFileName
);
493 CmdLen
= strlen (mPreProcessCmd
) + strlen (mPreProcessOpt
) +
494 strlen (mOptions
.VfrFileName
) + strlen (mOptions
.PreprocessorOutputFileName
);
495 if (mOptions
.CPreprocessorOptions
!= NULL
) {
496 CmdLen
+= strlen (mOptions
.CPreprocessorOptions
);
498 if (mOptions
.IncludePaths
!= NULL
) {
499 CmdLen
+= strlen (mOptions
.IncludePaths
);
502 PreProcessCmd
= new CHAR8
[CmdLen
+ 10];
503 if (PreProcessCmd
== NULL
) {
504 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
507 strcpy (PreProcessCmd
, mPreProcessCmd
), strcat (PreProcessCmd
, " ");
508 strcat (PreProcessCmd
, mPreProcessOpt
), strcat (PreProcessCmd
, " ");
509 if (mOptions
.IncludePaths
!= NULL
) {
510 strcat (PreProcessCmd
, mOptions
.IncludePaths
), strcat (PreProcessCmd
, " ");
512 if (mOptions
.CPreprocessorOptions
!= NULL
) {
513 strcat (PreProcessCmd
, mOptions
.CPreprocessorOptions
), strcat (PreProcessCmd
, " ");
515 strcat (PreProcessCmd
, mOptions
.VfrFileName
), strcat (PreProcessCmd
, " > ");
516 strcat (PreProcessCmd
, mOptions
.PreprocessorOutputFileName
);
518 if (system (PreProcessCmd
) != 0) {
519 DebugError (NULL
, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd
);
523 delete PreProcessCmd
;
526 SET_RUN_STATUS (STATUS_PREPROCESSED
);
530 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
531 SET_RUN_STATUS (STATUS_FAILED
);
533 delete PreProcessCmd
;
536 extern UINT8
VfrParserStart (IN
FILE *, IN INPUT_INFO_TO_SYNTAX
*);
539 CVfrCompiler::Compile (
543 FILE *pInFile
= NULL
;
544 CHAR8
*InFileName
= NULL
;
545 INPUT_INFO_TO_SYNTAX InputInfo
;
547 if (!IS_RUN_STATUS(STATUS_PREPROCESSED
)) {
551 InFileName
= (mOptions
.SkipCPreprocessor
== TRUE
) ? mOptions
.VfrFileName
: mOptions
.PreprocessorOutputFileName
;
553 gCVfrErrorHandle
.SetInputFile (InFileName
);
554 gCVfrErrorHandle
.SetWarningAsError(mOptions
.WarningAsError
);
556 if ((pInFile
= fopen (LongFilePath (InFileName
), "r")) == NULL
) {
557 DebugError (NULL
, 0, 0001, "Error opening the input file", InFileName
);
561 InputInfo
.CompatibleMode
= mOptions
.CompatibleMode
;
562 if (mOptions
.HasOverrideClassGuid
) {
563 InputInfo
.OverrideClassGuid
= &mOptions
.OverrideClassGuid
;
565 InputInfo
.OverrideClassGuid
= NULL
;
568 if (VfrParserStart (pInFile
, &InputInfo
) != 0) {
574 if (gCFormPkg
.HavePendingUnassigned () == TRUE
) {
575 gCFormPkg
.PendingAssignPrintAll ();
579 SET_RUN_STATUS (STATUS_COMPILEED
);
583 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
584 DebugError (NULL
, 0, 0003, "Error parsing", "compile error in file %s", InFileName
);
585 SET_RUN_STATUS (STATUS_FAILED
);
587 if (pInFile
!= NULL
) {
593 CVfrCompiler::AdjustBin (
597 EFI_VFR_RETURN_CODE Status
;
599 if (!IS_RUN_STATUS(STATUS_COMPILEED
)) {
603 if (gNeedAdjustOpcode
) {
605 // When parsing the Vfr, has created some opcodes, now need to update the record info.
607 gCIfrRecordInfoDB
.IfrUpdateRecordInfoForDynamicOpcode (FALSE
);
611 // Check whether need to check default info for question or auto add default for question.
613 if (mOptions
.AutoDefault
|| mOptions
.CheckDefault
) {
614 gCIfrRecordInfoDB
.IfrCheckAddDefaultRecord (mOptions
.AutoDefault
, mOptions
.CheckDefault
);
618 // Check Binary Code consistent between Form and IfrRecord
622 // Get Package Data and IfrRecord Data
624 gCFormPkg
.BuildPkg (gCBuffer
);
625 gCIfrRecordInfoDB
.IfrRecordOutput (gRBuffer
);
628 // Compare Form and Record data
630 if (gCBuffer
.Buffer
!= NULL
&& gRBuffer
.Buffer
!= NULL
) {
632 if (gCBuffer
.Size
!= gRBuffer
.Size
) {
633 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
);
635 for (Index
= 0; Index
< gCBuffer
.Size
; Index
++) {
636 if (gCBuffer
.Buffer
[Index
] != gRBuffer
.Buffer
[Index
]) {
640 if (Index
!= gCBuffer
.Size
) {
641 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions
.VfrFileName
, Index
);
643 DebugMsg (NULL
, 0, 9, (CHAR8
*) "IFR Buffer", (CHAR8
*) "Form Buffer same to Record Buffer and Size is 0x%X", Index
);
644 } else if (gCBuffer
.Buffer
== NULL
&& gRBuffer
.Buffer
== NULL
) {
647 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions
.VfrFileName
);
651 // For UEFI mode, not do OpCode Adjust
653 if (mOptions
.CompatibleMode
) {
655 // Adjust Opcode to be compatible with framework vfr
657 Status
= gCIfrRecordInfoDB
.IfrRecordAdjust ();
658 if (Status
!= VFR_RETURN_SUCCESS
) {
660 // Record List Adjust Failed
662 SET_RUN_STATUS (STATUS_FAILED
);
666 // Re get the IfrRecord Buffer.
668 gCIfrRecordInfoDB
.IfrRecordOutput (gRBuffer
);
675 CVfrCompiler::GenBinary (
681 if (!IS_RUN_STATUS(STATUS_COMPILEED
)) {
685 if (mOptions
.CreateIfrPkgFile
== TRUE
) {
686 if ((pFile
= fopen (LongFilePath (mOptions
.PkgOutputFileName
), "wb")) == NULL
) {
687 DebugError (NULL
, 0, 0001, "Error opening file", mOptions
.PkgOutputFileName
);
690 if (gCFormPkg
.BuildPkg (pFile
, &gRBuffer
) != VFR_RETURN_SUCCESS
) {
697 SET_RUN_STATUS (STATUS_GENBINARY
);
702 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
703 SET_RUN_STATUS (STATUS_FAILED
);
707 static const char *gSourceFileHeader
[] = {
709 "// DO NOT EDIT -- auto-generated file",
711 "// This file is generated by the vfrcompiler utility",
717 CVfrCompiler::GenCFile (
724 if (!IS_RUN_STATUS(STATUS_GENBINARY
)) {
728 if (!mOptions
.CreateIfrPkgFile
|| mOptions
.CompatibleMode
) {
729 if ((pFile
= fopen (LongFilePath (mOptions
.COutputFileName
), "w")) == NULL
) {
730 DebugError (NULL
, 0, 0001, "Error opening output C file", mOptions
.COutputFileName
);
734 for (Index
= 0; gSourceFileHeader
[Index
] != NULL
; Index
++) {
735 fprintf (pFile
, "%s\n", gSourceFileHeader
[Index
]);
738 if (mOptions
.CompatibleMode
) {
739 gCVfrBufferConfig
.OutputCFile (pFile
, mOptions
.VfrBaseFileName
);
742 if (gCFormPkg
.GenCFile (mOptions
.VfrBaseFileName
, pFile
, &gRBuffer
) != VFR_RETURN_SUCCESS
) {
749 SET_RUN_STATUS (STATUS_FINISHED
);
753 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
754 SET_RUN_STATUS (STATUS_FAILED
);
759 CVfrCompiler::GenRecordListFile (
763 CHAR8
*InFileName
= NULL
;
764 FILE *pInFile
= NULL
;
765 FILE *pOutFile
= NULL
;
766 CHAR8 LineBuf
[MAX_VFR_LINE_LEN
];
769 InFileName
= (mOptions
.SkipCPreprocessor
== TRUE
) ? mOptions
.VfrFileName
: mOptions
.PreprocessorOutputFileName
;
771 if (mOptions
.CreateRecordListFile
== TRUE
) {
772 if ((InFileName
[0] == '\0') || (mOptions
.RecordListFile
[0] == '\0')) {
776 if ((pInFile
= fopen (LongFilePath (InFileName
), "r")) == NULL
) {
777 DebugError (NULL
, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName
);
781 if ((pOutFile
= fopen (LongFilePath (mOptions
.RecordListFile
), "w")) == NULL
) {
782 DebugError (NULL
, 0, 0001, "Error opening the record list file", mOptions
.RecordListFile
);
786 fprintf (pOutFile
, "//\n// VFR compiler version " VFR_COMPILER_VERSION __BUILD_VERSION
"\n//\n");
788 while (!feof (pInFile
)) {
789 if (fgets (LineBuf
, MAX_VFR_LINE_LEN
, pInFile
) != NULL
) {
790 fprintf (pOutFile
, "%s", LineBuf
);
792 gCIfrRecordInfoDB
.IfrRecordOutput (pOutFile
, LineNo
);
796 fprintf (pOutFile
, "\n//\n// All Opcode Record List \n//\n");
797 gCIfrRecordInfoDB
.IfrRecordOutput (pOutFile
, 0);
798 gCVfrVarDataTypeDB
.Dump(pOutFile
);
816 COMPILER_RUN_STATUS Status
;
818 SetPrintLevel(WARNING_LOG_LEVEL
);
819 CVfrCompiler
Compiler(Argc
, Argv
);
821 Compiler
.PreProcess();
823 Compiler
.AdjustBin();
824 Compiler
.GenBinary();
826 Compiler
.GenRecordListFile ();
828 Status
= Compiler
.RunStatus ();
829 if ((Status
== STATUS_DEAD
) || (Status
== STATUS_FAILED
)) {
833 if (gCBuffer
.Buffer
!= NULL
) {
834 delete gCBuffer
.Buffer
;
837 if (gRBuffer
.Buffer
!= NULL
) {
838 delete gRBuffer
.Buffer
;
841 return GetUtilityStatus ();