3 VfrCompiler main class and main function.
5 Copyright (c) 2004 - 2013, 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
], "-l") == 0) {
100 mOptions
.CreateRecordListFile
= TRUE
;
101 gCIfrRecordInfoDB
.TurnOn ();
102 } else if (stricmp(Argv
[Index
], "-i") == 0) {
104 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
105 DebugError (NULL
, 0, 1001, "Missing option", "-i missing path argument");
109 AppendIncludePath(Argv
[Index
]);
110 } else if (stricmp(Argv
[Index
], "-o") == 0 || stricmp(Argv
[Index
], "--output-directory") == 0 || stricmp(Argv
[Index
], "-od") == 0) {
112 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
113 DebugError (NULL
, 0, 1001, "Missing option", "-o missing output directory name");
116 strcpy (mOptions
.OutputDirectory
, Argv
[Index
]);
118 CHAR8 lastChar
= mOptions
.OutputDirectory
[strlen(mOptions
.OutputDirectory
) - 1];
119 if ((lastChar
!= '/') && (lastChar
!= '\\')) {
120 if (strchr(mOptions
.OutputDirectory
, '/') != NULL
) {
121 strcat (mOptions
.OutputDirectory
, "/");
123 strcat (mOptions
.OutputDirectory
, "\\");
126 DebugMsg (NULL
, 0, 9, (CHAR8
*) "Output Directory", mOptions
.OutputDirectory
);
127 } else if (stricmp(Argv
[Index
], "-b") == 0 || stricmp(Argv
[Index
], "--create-ifr-package") == 0 || stricmp(Argv
[Index
], "-ibin") == 0) {
128 mOptions
.CreateIfrPkgFile
= TRUE
;
129 } else if (stricmp(Argv
[Index
], "-n") == 0 || stricmp(Argv
[Index
], "--no-pre-processing") == 0 || stricmp(Argv
[Index
], "-nopp") == 0) {
130 mOptions
.SkipCPreprocessor
= TRUE
;
131 } else if (stricmp(Argv
[Index
], "-f") == 0 || stricmp(Argv
[Index
], "--pre-processing-flag") == 0 || stricmp(Argv
[Index
], "-ppflag") == 0) {
133 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
134 DebugError (NULL
, 0, 1001, "Missing option", "-od - missing C-preprocessor argument");
138 AppendCPreprocessorOptions (Argv
[Index
]);
139 } else if (stricmp(Argv
[Index
], "-c") == 0 || stricmp(Argv
[Index
], "--compatible-framework") == 0) {
140 mOptions
.CompatibleMode
= TRUE
;
141 } else if (stricmp(Argv
[Index
], "-s") == 0|| stricmp(Argv
[Index
], "--string-db") == 0) {
143 if ((Index
>= Argc
) || (Argv
[Index
][0] == '-')) {
144 DebugError (NULL
, 0, 1001, "Missing option", "-s missing input string file name");
147 gCVfrStringDB
.SetStringFileName(Argv
[Index
]);
148 DebugMsg (NULL
, 0, 9, (CHAR8
*) "Input string file path", Argv
[Index
]);
149 } else if ((stricmp (Argv
[Index
], "-g") == 0) || (stricmp (Argv
[Index
], "--guid") == 0)) {
151 Status
= StringToGuid (Argv
[Index
], &mOptions
.OverrideClassGuid
);
152 if (EFI_ERROR (Status
)) {
153 DebugError (NULL
, 0, 1000, "Invalid format:", "%s", Argv
[Index
]);
156 mOptions
.HasOverrideClassGuid
= TRUE
;
157 } else if (stricmp(Argv
[Index
], "-w") == 0 || stricmp(Argv
[Index
], "--warning-as-error") == 0) {
158 mOptions
.WarningAsError
= TRUE
;
160 DebugError (NULL
, 0, 1000, "Unknown option", "unrecognized option %s", Argv
[Index
]);
165 if (Index
!= Argc
- 1) {
166 DebugError (NULL
, 0, 1001, "Missing option", "VFR file name is not specified.");
169 strcpy (mOptions
.VfrFileName
, Argv
[Index
]);
172 if (SetBaseFileName() != 0) {
175 if (SetPkgOutputFileName () != 0) {
178 if (SetCOutputFileName() != 0) {
181 if (SetPreprocessorOutputFileName () != 0) {
184 if (SetRecordListFileName () != 0) {
190 SET_RUN_STATUS (STATUS_DEAD
);
192 mOptions
.VfrFileName
[0] = '\0';
193 mOptions
.RecordListFile
[0] = '\0';
194 mOptions
.CreateRecordListFile
= FALSE
;
195 mOptions
.CreateIfrPkgFile
= FALSE
;
196 mOptions
.PkgOutputFileName
[0] = '\0';
197 mOptions
.COutputFileName
[0] = '\0';
198 mOptions
.OutputDirectory
[0] = '\0';
199 mOptions
.PreprocessorOutputFileName
[0] = '\0';
200 mOptions
.VfrBaseFileName
[0] = '\0';
201 if (mOptions
.IncludePaths
!= NULL
) {
202 delete mOptions
.IncludePaths
;
203 mOptions
.IncludePaths
= NULL
;
205 if (mOptions
.CPreprocessorOptions
!= NULL
) {
206 delete mOptions
.CPreprocessorOptions
;
207 mOptions
.CPreprocessorOptions
= NULL
;
212 CVfrCompiler::AppendIncludePath (
217 CHAR8
*IncludePaths
= NULL
;
219 Len
= strlen (" -I ") + strlen (PathStr
) + 1;
220 if (mOptions
.IncludePaths
!= NULL
) {
221 Len
+= strlen (mOptions
.IncludePaths
);
223 IncludePaths
= new CHAR8
[Len
];
224 if (IncludePaths
== NULL
) {
225 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
228 IncludePaths
[0] = '\0';
229 if (mOptions
.IncludePaths
!= NULL
) {
230 strcat (IncludePaths
, mOptions
.IncludePaths
);
232 strcat (IncludePaths
, " -I ");
233 strcat (IncludePaths
, PathStr
);
234 if (mOptions
.IncludePaths
!= NULL
) {
235 delete mOptions
.IncludePaths
;
237 mOptions
.IncludePaths
= IncludePaths
;
241 CVfrCompiler::AppendCPreprocessorOptions (
248 Len
= strlen (Options
) + strlen (" ") + 1;
249 if (mOptions
.CPreprocessorOptions
!= NULL
) {
250 Len
+= strlen (mOptions
.CPreprocessorOptions
);
252 Opt
= new CHAR8
[Len
];
254 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
258 if (mOptions
.CPreprocessorOptions
!= NULL
) {
259 strcat (Opt
, mOptions
.CPreprocessorOptions
);
262 strcat (Opt
, Options
);
263 if (mOptions
.CPreprocessorOptions
!= NULL
) {
264 delete mOptions
.CPreprocessorOptions
;
266 mOptions
.CPreprocessorOptions
= Opt
;
270 CVfrCompiler::SetBaseFileName (
274 CHAR8
*pFileName
, *pPath
, *pExt
;
276 if (mOptions
.VfrFileName
[0] == '\0') {
280 pFileName
= mOptions
.VfrFileName
;
282 ((pPath
= strchr (pFileName
, '\\')) != NULL
) ||
283 ((pPath
= strchr (pFileName
, '/')) != NULL
)
286 pFileName
= pPath
+ 1;
289 if (pFileName
== NULL
) {
293 if ((pExt
= strchr (pFileName
, '.')) == NULL
) {
297 strncpy (mOptions
.VfrBaseFileName
, pFileName
, pExt
- pFileName
);
298 mOptions
.VfrBaseFileName
[pExt
- pFileName
] = '\0';
304 CVfrCompiler::SetPkgOutputFileName (
308 if (mOptions
.VfrBaseFileName
[0] == '\0') {
312 strcpy (mOptions
.PkgOutputFileName
, mOptions
.OutputDirectory
);
313 strcat (mOptions
.PkgOutputFileName
, mOptions
.VfrBaseFileName
);
314 strcat (mOptions
.PkgOutputFileName
, VFR_PACKAGE_FILENAME_EXTENSION
);
320 CVfrCompiler::SetCOutputFileName (
324 if (mOptions
.VfrBaseFileName
[0] == '\0') {
328 strcpy (mOptions
.COutputFileName
, mOptions
.OutputDirectory
);
329 strcat (mOptions
.COutputFileName
, mOptions
.VfrBaseFileName
);
330 strcat (mOptions
.COutputFileName
, ".c");
336 CVfrCompiler::SetPreprocessorOutputFileName (
340 if (mOptions
.VfrBaseFileName
[0] == '\0') {
344 strcpy (mOptions
.PreprocessorOutputFileName
, mOptions
.OutputDirectory
);
345 strcat (mOptions
.PreprocessorOutputFileName
, mOptions
.VfrBaseFileName
);
346 strcat (mOptions
.PreprocessorOutputFileName
, VFR_PREPROCESS_FILENAME_EXTENSION
);
352 CVfrCompiler::SetRecordListFileName (
356 if (mOptions
.VfrBaseFileName
[0] == '\0') {
360 strcpy (mOptions
.RecordListFile
, mOptions
.OutputDirectory
);
361 strcat (mOptions
.RecordListFile
, mOptions
.VfrBaseFileName
);
362 strcat (mOptions
.RecordListFile
, VFR_RECORDLIST_FILENAME_EXTENSION
);
367 CVfrCompiler::CVfrCompiler (
372 mPreProcessCmd
= (CHAR8
*) PREPROCESSOR_COMMAND
;
373 mPreProcessOpt
= (CHAR8
*) PREPROCESSOR_OPTIONS
;
375 OptionInitialization(Argc
, Argv
);
377 if ((IS_RUN_STATUS(STATUS_FAILED
)) || (IS_RUN_STATUS(STATUS_DEAD
))) {
381 SET_RUN_STATUS(STATUS_INITIALIZED
);
384 CVfrCompiler::~CVfrCompiler (
388 if (mOptions
.IncludePaths
!= NULL
) {
389 delete mOptions
.IncludePaths
;
390 mOptions
.IncludePaths
= NULL
;
393 if (mOptions
.CPreprocessorOptions
!= NULL
) {
394 delete mOptions
.CPreprocessorOptions
;
395 mOptions
.CPreprocessorOptions
= NULL
;
398 SET_RUN_STATUS(STATUS_DEAD
);
402 CVfrCompiler::Usage (
407 CONST CHAR8
*Help
[] = {
409 "VfrCompile version " VFR_COMPILER_VERSION __BUILD_VERSION
,
410 "Copyright (c) 2004-2013 Intel Corporation. All rights reserved.",
412 "Usage: VfrCompile [options] VfrFile",
415 " -h, --help prints this help",
416 " -l create an output IFR listing file",
417 " -o DIR, --output-directory DIR",
418 " deposit all output files to directory OutputDir",
419 " default is current directory",
420 " -b, --create-ifr-package",
421 " create an IFR HII pack file",
422 " -n, --no-pre-processing",
423 " do not preprocessing input file",
424 " -c, --compatible-framework",
425 " compatible framework vfr file",
427 " input uni string package file",
429 " override class guid input",
430 " format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
431 " -w --warning-as-error",
432 " treat warning as an error",
435 for (Index
= 0; Help
[Index
] != NULL
; Index
++) {
436 fprintf (stdout
, "%s\n", Help
[Index
]);
441 CVfrCompiler::PreProcess (
445 FILE *pVfrFile
= NULL
;
447 CHAR8
*PreProcessCmd
= NULL
;
449 if (!IS_RUN_STATUS(STATUS_INITIALIZED
)) {
453 if (mOptions
.SkipCPreprocessor
== TRUE
) {
457 if ((pVfrFile
= fopen (mOptions
.VfrFileName
, "r")) == NULL
) {
458 DebugError (NULL
, 0, 0001, "Error opening the input VFR file", mOptions
.VfrFileName
);
463 CmdLen
= strlen (mPreProcessCmd
) + strlen (mPreProcessOpt
) +
464 strlen (mOptions
.VfrFileName
) + strlen (mOptions
.PreprocessorOutputFileName
);
465 if (mOptions
.CPreprocessorOptions
!= NULL
) {
466 CmdLen
+= strlen (mOptions
.CPreprocessorOptions
);
468 if (mOptions
.IncludePaths
!= NULL
) {
469 CmdLen
+= strlen (mOptions
.IncludePaths
);
472 PreProcessCmd
= new CHAR8
[CmdLen
+ 10];
473 if (PreProcessCmd
== NULL
) {
474 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
477 strcpy (PreProcessCmd
, mPreProcessCmd
), strcat (PreProcessCmd
, " ");
478 strcat (PreProcessCmd
, mPreProcessOpt
), strcat (PreProcessCmd
, " ");
479 if (mOptions
.IncludePaths
!= NULL
) {
480 strcat (PreProcessCmd
, mOptions
.IncludePaths
), strcat (PreProcessCmd
, " ");
482 if (mOptions
.CPreprocessorOptions
!= NULL
) {
483 strcat (PreProcessCmd
, mOptions
.CPreprocessorOptions
), strcat (PreProcessCmd
, " ");
485 strcat (PreProcessCmd
, mOptions
.VfrFileName
), strcat (PreProcessCmd
, " > ");
486 strcat (PreProcessCmd
, mOptions
.PreprocessorOutputFileName
);
488 if (system (PreProcessCmd
) != 0) {
489 DebugError (NULL
, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd
);
493 delete PreProcessCmd
;
496 SET_RUN_STATUS (STATUS_PREPROCESSED
);
500 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
501 SET_RUN_STATUS (STATUS_FAILED
);
503 delete PreProcessCmd
;
506 extern UINT8
VfrParserStart (IN
FILE *, IN INPUT_INFO_TO_SYNTAX
*);
509 CVfrCompiler::Compile (
513 FILE *pInFile
= NULL
;
514 CHAR8
*InFileName
= NULL
;
515 INPUT_INFO_TO_SYNTAX InputInfo
;
517 if (!IS_RUN_STATUS(STATUS_PREPROCESSED
)) {
521 InFileName
= (mOptions
.SkipCPreprocessor
== TRUE
) ? mOptions
.VfrFileName
: mOptions
.PreprocessorOutputFileName
;
523 gCVfrErrorHandle
.SetInputFile (InFileName
);
524 gCVfrErrorHandle
.SetWarningAsError(mOptions
.WarningAsError
);
526 if ((pInFile
= fopen (InFileName
, "r")) == NULL
) {
527 DebugError (NULL
, 0, 0001, "Error opening the input file", InFileName
);
531 InputInfo
.CompatibleMode
= mOptions
.CompatibleMode
;
532 if (mOptions
.HasOverrideClassGuid
) {
533 InputInfo
.OverrideClassGuid
= &mOptions
.OverrideClassGuid
;
535 InputInfo
.OverrideClassGuid
= NULL
;
538 if (VfrParserStart (pInFile
, &InputInfo
) != 0) {
544 if (gCFormPkg
.HavePendingUnassigned () == TRUE
) {
545 gCFormPkg
.PendingAssignPrintAll ();
549 SET_RUN_STATUS (STATUS_COMPILEED
);
553 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
554 DebugError (NULL
, 0, 0003, "Error parsing", "compile error in file %s", InFileName
);
555 SET_RUN_STATUS (STATUS_FAILED
);
557 if (pInFile
!= NULL
) {
563 CVfrCompiler::UpdateInfoForDynamicOpcode (
569 if (!gNeedAdjustOpcode
) {
574 // Base on the original offset info to update the record list.
576 if (!gCIfrRecordInfoDB
.IfrAdjustDynamicOpcodeInRecords()) {
577 DebugError (NULL
, 0, 1001, "Error parsing vfr file", "Can find the offset in the record.");
581 // Base on the opcode binary length to recalculate the offset for each opcode.
583 gCIfrRecordInfoDB
.IfrAdjustOffsetForRecord();
586 // Base on the offset to find the binary address.
588 pRecord
= gCIfrRecordInfoDB
.GetRecordInfoFromOffset(gAdjustOpcodeOffset
);
589 while (pRecord
!= NULL
) {
590 pRecord
->mIfrBinBuf
= gCFormPkg
.GetBufAddrBaseOnOffset(pRecord
->mOffset
);
591 if (pRecord
->mIfrBinBuf
== NULL
) {
592 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " 0x%X. offset not allocated.", pRecord
->mOffset
);
594 pRecord
= pRecord
->mNext
;
599 CVfrCompiler::AdjustBin (
603 EFI_VFR_RETURN_CODE Status
;
605 if (!IS_RUN_STATUS(STATUS_COMPILEED
)) {
609 UpdateInfoForDynamicOpcode ();
612 // Check Binary Code consistent between Form and IfrRecord
616 // Get Package Data and IfrRecord Data
618 gCFormPkg
.BuildPkg (gCBuffer
);
619 gCIfrRecordInfoDB
.IfrRecordOutput (gRBuffer
);
622 // Compare Form and Record data
624 if (gCBuffer
.Buffer
!= NULL
&& gRBuffer
.Buffer
!= NULL
) {
626 if (gCBuffer
.Size
!= gRBuffer
.Size
) {
627 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
);
629 for (Index
= 0; Index
< gCBuffer
.Size
; Index
++) {
630 if (gCBuffer
.Buffer
[Index
] != gRBuffer
.Buffer
[Index
]) {
634 if (Index
!= gCBuffer
.Size
) {
635 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions
.VfrFileName
, Index
);
637 DebugMsg (NULL
, 0, 9, (CHAR8
*) "IFR Buffer", (CHAR8
*) "Form Buffer same to Record Buffer and Size is 0x%X", Index
);
638 } else if (gCBuffer
.Buffer
== NULL
&& gRBuffer
.Buffer
== NULL
) {
641 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions
.VfrFileName
);
645 // For UEFI mode, not do OpCode Adjust
647 if (mOptions
.CompatibleMode
) {
649 // Adjust Opcode to be compatible with framework vfr
651 Status
= gCIfrRecordInfoDB
.IfrRecordAdjust ();
652 if (Status
!= VFR_RETURN_SUCCESS
) {
654 // Record List Adjust Failed
656 SET_RUN_STATUS (STATUS_FAILED
);
660 // Re get the IfrRecord Buffer.
662 gCIfrRecordInfoDB
.IfrRecordOutput (gRBuffer
);
669 CVfrCompiler::GenBinary (
675 if (!IS_RUN_STATUS(STATUS_COMPILEED
)) {
679 if (mOptions
.CreateIfrPkgFile
== TRUE
) {
680 if ((pFile
= fopen (mOptions
.PkgOutputFileName
, "wb")) == NULL
) {
681 DebugError (NULL
, 0, 0001, "Error opening file", mOptions
.PkgOutputFileName
);
684 if (gCFormPkg
.BuildPkg (pFile
, &gRBuffer
) != VFR_RETURN_SUCCESS
) {
691 SET_RUN_STATUS (STATUS_GENBINARY
);
696 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
697 SET_RUN_STATUS (STATUS_FAILED
);
701 static const char *gSourceFileHeader
[] = {
703 "// DO NOT EDIT -- auto-generated file",
705 "// This file is generated by the vfrcompiler utility",
711 CVfrCompiler::GenCFile (
718 if (!IS_RUN_STATUS(STATUS_GENBINARY
)) {
722 if (!mOptions
.CreateIfrPkgFile
|| mOptions
.CompatibleMode
) {
723 if ((pFile
= fopen (mOptions
.COutputFileName
, "w")) == NULL
) {
724 DebugError (NULL
, 0, 0001, "Error opening output C file", mOptions
.COutputFileName
);
728 for (Index
= 0; gSourceFileHeader
[Index
] != NULL
; Index
++) {
729 fprintf (pFile
, "%s\n", gSourceFileHeader
[Index
]);
732 if (mOptions
.CompatibleMode
) {
733 gCVfrBufferConfig
.OutputCFile (pFile
, mOptions
.VfrBaseFileName
);
736 if (gCFormPkg
.GenCFile (mOptions
.VfrBaseFileName
, pFile
, &gRBuffer
) != VFR_RETURN_SUCCESS
) {
743 SET_RUN_STATUS (STATUS_FINISHED
);
747 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
748 SET_RUN_STATUS (STATUS_FAILED
);
753 CVfrCompiler::GenRecordListFile (
757 CHAR8
*InFileName
= NULL
;
758 FILE *pInFile
= NULL
;
759 FILE *pOutFile
= NULL
;
760 CHAR8 LineBuf
[MAX_VFR_LINE_LEN
];
763 InFileName
= (mOptions
.SkipCPreprocessor
== TRUE
) ? mOptions
.VfrFileName
: mOptions
.PreprocessorOutputFileName
;
765 if (mOptions
.CreateRecordListFile
== TRUE
) {
766 if ((InFileName
[0] == '\0') || (mOptions
.RecordListFile
[0] == '\0')) {
770 if ((pInFile
= fopen (InFileName
, "r")) == NULL
) {
771 DebugError (NULL
, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName
);
775 if ((pOutFile
= fopen (mOptions
.RecordListFile
, "w")) == NULL
) {
776 DebugError (NULL
, 0, 0001, "Error opening the record list file", mOptions
.RecordListFile
);
780 fprintf (pOutFile
, "//\n// VFR compiler version " VFR_COMPILER_VERSION __BUILD_VERSION
"\n//\n");
782 while (!feof (pInFile
)) {
783 if (fgets (LineBuf
, MAX_VFR_LINE_LEN
, pInFile
) != NULL
) {
784 fprintf (pOutFile
, "%s", LineBuf
);
786 gCIfrRecordInfoDB
.IfrRecordOutput (pOutFile
, LineNo
);
790 fprintf (pOutFile
, "\n//\n// All Opcode Record List \n//\n");
791 gCIfrRecordInfoDB
.IfrRecordOutput (pOutFile
, 0);
792 gCVfrVarDataTypeDB
.Dump(pOutFile
);
810 COMPILER_RUN_STATUS Status
;
812 SetPrintLevel(WARNING_LOG_LEVEL
);
813 CVfrCompiler
Compiler(Argc
, Argv
);
815 Compiler
.PreProcess();
817 Compiler
.AdjustBin();
818 Compiler
.GenBinary();
820 Compiler
.GenRecordListFile ();
822 Status
= Compiler
.RunStatus ();
823 if ((Status
== STATUS_DEAD
) || (Status
== STATUS_FAILED
)) {
827 if (gCBuffer
.Buffer
!= NULL
) {
828 delete gCBuffer
.Buffer
;
831 if (gRBuffer
.Buffer
!= NULL
) {
832 delete gRBuffer
.Buffer
;
835 return GetUtilityStatus ();