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 SET_RUN_STATUS (STATUS_STARTED
);
377 OptionInitialization(Argc
, Argv
);
379 if ((IS_RUN_STATUS(STATUS_FAILED
)) || (IS_RUN_STATUS(STATUS_DEAD
))) {
383 SET_RUN_STATUS(STATUS_INITIALIZED
);
386 CVfrCompiler::~CVfrCompiler (
390 if (mOptions
.IncludePaths
!= NULL
) {
391 delete mOptions
.IncludePaths
;
392 mOptions
.IncludePaths
= NULL
;
395 if (mOptions
.CPreprocessorOptions
!= NULL
) {
396 delete mOptions
.CPreprocessorOptions
;
397 mOptions
.CPreprocessorOptions
= NULL
;
400 SET_RUN_STATUS(STATUS_DEAD
);
404 CVfrCompiler::Usage (
409 CONST CHAR8
*Help
[] = {
411 "VfrCompile version " VFR_COMPILER_VERSION __BUILD_VERSION
,
412 "Copyright (c) 2004-2013 Intel Corporation. All rights reserved.",
414 "Usage: VfrCompile [options] VfrFile",
417 " -h, --help prints this help",
418 " -l create an output IFR listing file",
419 " -o DIR, --output-directory DIR",
420 " deposit all output files to directory OutputDir",
421 " default is current directory",
422 " -b, --create-ifr-package",
423 " create an IFR HII pack file",
424 " -n, --no-pre-processing",
425 " do not preprocessing input file",
426 " -c, --compatible-framework",
427 " compatible framework vfr file",
429 " input uni string package file",
431 " override class guid input",
432 " format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
433 " -w --warning-as-error",
434 " treat warning as an error",
437 for (Index
= 0; Help
[Index
] != NULL
; Index
++) {
438 fprintf (stdout
, "%s\n", Help
[Index
]);
443 CVfrCompiler::PreProcess (
447 FILE *pVfrFile
= NULL
;
449 CHAR8
*PreProcessCmd
= NULL
;
451 if (!IS_RUN_STATUS(STATUS_INITIALIZED
)) {
455 if (mOptions
.SkipCPreprocessor
== TRUE
) {
459 if ((pVfrFile
= fopen (mOptions
.VfrFileName
, "r")) == NULL
) {
460 DebugError (NULL
, 0, 0001, "Error opening the input VFR file", mOptions
.VfrFileName
);
465 CmdLen
= strlen (mPreProcessCmd
) + strlen (mPreProcessOpt
) +
466 strlen (mOptions
.VfrFileName
) + strlen (mOptions
.PreprocessorOutputFileName
);
467 if (mOptions
.CPreprocessorOptions
!= NULL
) {
468 CmdLen
+= strlen (mOptions
.CPreprocessorOptions
);
470 if (mOptions
.IncludePaths
!= NULL
) {
471 CmdLen
+= strlen (mOptions
.IncludePaths
);
474 PreProcessCmd
= new CHAR8
[CmdLen
+ 10];
475 if (PreProcessCmd
== NULL
) {
476 DebugError (NULL
, 0, 4001, "Resource: memory can't be allocated", NULL
);
479 strcpy (PreProcessCmd
, mPreProcessCmd
), strcat (PreProcessCmd
, " ");
480 strcat (PreProcessCmd
, mPreProcessOpt
), strcat (PreProcessCmd
, " ");
481 if (mOptions
.IncludePaths
!= NULL
) {
482 strcat (PreProcessCmd
, mOptions
.IncludePaths
), strcat (PreProcessCmd
, " ");
484 if (mOptions
.CPreprocessorOptions
!= NULL
) {
485 strcat (PreProcessCmd
, mOptions
.CPreprocessorOptions
), strcat (PreProcessCmd
, " ");
487 strcat (PreProcessCmd
, mOptions
.VfrFileName
), strcat (PreProcessCmd
, " > ");
488 strcat (PreProcessCmd
, mOptions
.PreprocessorOutputFileName
);
490 if (system (PreProcessCmd
) != 0) {
491 DebugError (NULL
, 0, 0003, "Error parsing file", "failed to spawn C preprocessor on VFR file %s\n", PreProcessCmd
);
495 delete PreProcessCmd
;
498 SET_RUN_STATUS (STATUS_PREPROCESSED
);
502 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
503 SET_RUN_STATUS (STATUS_FAILED
);
505 delete PreProcessCmd
;
508 extern UINT8
VfrParserStart (IN
FILE *, IN INPUT_INFO_TO_SYNTAX
*);
511 CVfrCompiler::Compile (
515 FILE *pInFile
= NULL
;
516 CHAR8
*InFileName
= NULL
;
517 INPUT_INFO_TO_SYNTAX InputInfo
;
519 if (!IS_RUN_STATUS(STATUS_PREPROCESSED
)) {
523 InFileName
= (mOptions
.SkipCPreprocessor
== TRUE
) ? mOptions
.VfrFileName
: mOptions
.PreprocessorOutputFileName
;
525 gCVfrErrorHandle
.SetInputFile (InFileName
);
526 gCVfrErrorHandle
.SetWarningAsError(mOptions
.WarningAsError
);
528 if ((pInFile
= fopen (InFileName
, "r")) == NULL
) {
529 DebugError (NULL
, 0, 0001, "Error opening the input file", InFileName
);
533 InputInfo
.CompatibleMode
= mOptions
.CompatibleMode
;
534 if (mOptions
.HasOverrideClassGuid
) {
535 InputInfo
.OverrideClassGuid
= &mOptions
.OverrideClassGuid
;
537 InputInfo
.OverrideClassGuid
= NULL
;
540 if (VfrParserStart (pInFile
, &InputInfo
) != 0) {
546 if (gCFormPkg
.HavePendingUnassigned () == TRUE
) {
547 gCFormPkg
.PendingAssignPrintAll ();
551 SET_RUN_STATUS (STATUS_COMPILEED
);
555 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
556 DebugError (NULL
, 0, 0003, "Error parsing", "compile error in file %s", InFileName
);
557 SET_RUN_STATUS (STATUS_FAILED
);
559 if (pInFile
!= NULL
) {
565 CVfrCompiler::UpdateInfoForDynamicOpcode (
571 if (!gNeedAdjustOpcode
) {
576 // Base on the original offset info to update the record list.
578 if (!gCIfrRecordInfoDB
.IfrAdjustDynamicOpcodeInRecords()) {
579 DebugError (NULL
, 0, 1001, "Error parsing vfr file", "Can find the offset in the record.");
583 // Base on the opcode binary length to recalculate the offset for each opcode.
585 gCIfrRecordInfoDB
.IfrAdjustOffsetForRecord();
588 // Base on the offset to find the binary address.
590 pRecord
= gCIfrRecordInfoDB
.GetRecordInfoFromOffset(gAdjustOpcodeOffset
);
591 while (pRecord
!= NULL
) {
592 pRecord
->mIfrBinBuf
= gCFormPkg
.GetBufAddrBaseOnOffset(pRecord
->mOffset
);
593 if (pRecord
->mIfrBinBuf
== NULL
) {
594 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " 0x%X. offset not allocated.", pRecord
->mOffset
);
596 pRecord
= pRecord
->mNext
;
601 CVfrCompiler::AdjustBin (
605 EFI_VFR_RETURN_CODE Status
;
607 if (!IS_RUN_STATUS(STATUS_COMPILEED
)) {
611 UpdateInfoForDynamicOpcode ();
614 // Check Binary Code consistent between Form and IfrRecord
618 // Get Package Data and IfrRecord Data
620 gCFormPkg
.BuildPkg (gCBuffer
);
621 gCIfrRecordInfoDB
.IfrRecordOutput (gRBuffer
);
624 // Compare Form and Record data
626 if (gCBuffer
.Buffer
!= NULL
&& gRBuffer
.Buffer
!= NULL
) {
628 if (gCBuffer
.Size
!= gRBuffer
.Size
) {
629 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
);
631 for (Index
= 0; Index
< gCBuffer
.Size
; Index
++) {
632 if (gCBuffer
.Buffer
[Index
] != gRBuffer
.Buffer
[Index
]) {
636 if (Index
!= gCBuffer
.Size
) {
637 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " %s. the 0x%X byte is different between Form and Record", mOptions
.VfrFileName
, Index
);
639 DebugMsg (NULL
, 0, 9, (CHAR8
*) "IFR Buffer", (CHAR8
*) "Form Buffer same to Record Buffer and Size is 0x%X", Index
);
640 } else if (gCBuffer
.Buffer
== NULL
&& gRBuffer
.Buffer
== NULL
) {
643 DebugError (NULL
, 0, 0001, "Error parsing vfr file", " %s.Buffer not allocated.", mOptions
.VfrFileName
);
647 // For UEFI mode, not do OpCode Adjust
649 if (mOptions
.CompatibleMode
) {
651 // Adjust Opcode to be compatible with framework vfr
653 Status
= gCIfrRecordInfoDB
.IfrRecordAdjust ();
654 if (Status
!= VFR_RETURN_SUCCESS
) {
656 // Record List Adjust Failed
658 SET_RUN_STATUS (STATUS_FAILED
);
662 // Re get the IfrRecord Buffer.
664 gCIfrRecordInfoDB
.IfrRecordOutput (gRBuffer
);
671 CVfrCompiler::GenBinary (
677 if (!IS_RUN_STATUS(STATUS_COMPILEED
)) {
681 if (mOptions
.CreateIfrPkgFile
== TRUE
) {
682 if ((pFile
= fopen (mOptions
.PkgOutputFileName
, "wb")) == NULL
) {
683 DebugError (NULL
, 0, 0001, "Error opening file", mOptions
.PkgOutputFileName
);
686 if (gCFormPkg
.BuildPkg (pFile
, &gRBuffer
) != VFR_RETURN_SUCCESS
) {
693 SET_RUN_STATUS (STATUS_GENBINARY
);
698 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
699 SET_RUN_STATUS (STATUS_FAILED
);
703 static const char *gSourceFileHeader
[] = {
705 "// DO NOT EDIT -- auto-generated file",
707 "// This file is generated by the vfrcompiler utility",
713 CVfrCompiler::GenCFile (
720 if (!IS_RUN_STATUS(STATUS_GENBINARY
)) {
724 if (!mOptions
.CreateIfrPkgFile
|| mOptions
.CompatibleMode
) {
725 if ((pFile
= fopen (mOptions
.COutputFileName
, "w")) == NULL
) {
726 DebugError (NULL
, 0, 0001, "Error opening output C file", mOptions
.COutputFileName
);
730 for (Index
= 0; gSourceFileHeader
[Index
] != NULL
; Index
++) {
731 fprintf (pFile
, "%s\n", gSourceFileHeader
[Index
]);
734 if (mOptions
.CompatibleMode
) {
735 gCVfrBufferConfig
.OutputCFile (pFile
, mOptions
.VfrBaseFileName
);
738 if (gCFormPkg
.GenCFile (mOptions
.VfrBaseFileName
, pFile
, &gRBuffer
) != VFR_RETURN_SUCCESS
) {
745 SET_RUN_STATUS (STATUS_FINISHED
);
749 if (!IS_RUN_STATUS(STATUS_DEAD
)) {
750 SET_RUN_STATUS (STATUS_FAILED
);
755 CVfrCompiler::GenRecordListFile (
759 CHAR8
*InFileName
= NULL
;
760 FILE *pInFile
= NULL
;
761 FILE *pOutFile
= NULL
;
762 CHAR8 LineBuf
[MAX_VFR_LINE_LEN
];
765 InFileName
= (mOptions
.SkipCPreprocessor
== TRUE
) ? mOptions
.VfrFileName
: mOptions
.PreprocessorOutputFileName
;
767 if (mOptions
.CreateRecordListFile
== TRUE
) {
768 if ((InFileName
[0] == '\0') || (mOptions
.RecordListFile
[0] == '\0')) {
772 if ((pInFile
= fopen (InFileName
, "r")) == NULL
) {
773 DebugError (NULL
, 0, 0001, "Error opening the input VFR preprocessor output file", InFileName
);
777 if ((pOutFile
= fopen (mOptions
.RecordListFile
, "w")) == NULL
) {
778 DebugError (NULL
, 0, 0001, "Error opening the record list file", mOptions
.RecordListFile
);
782 fprintf (pOutFile
, "//\n// VFR compiler version " VFR_COMPILER_VERSION __BUILD_VERSION
"\n//\n");
784 while (!feof (pInFile
)) {
785 if (fgets (LineBuf
, MAX_VFR_LINE_LEN
, pInFile
) != NULL
) {
786 fprintf (pOutFile
, "%s", LineBuf
);
788 gCIfrRecordInfoDB
.IfrRecordOutput (pOutFile
, LineNo
);
792 fprintf (pOutFile
, "\n//\n// All Opcode Record List \n//\n");
793 gCIfrRecordInfoDB
.IfrRecordOutput (pOutFile
, 0);
794 gCVfrVarDataTypeDB
.Dump(pOutFile
);
812 COMPILER_RUN_STATUS Status
;
814 SetPrintLevel(WARNING_LOG_LEVEL
);
815 CVfrCompiler
Compiler(Argc
, Argv
);
817 Compiler
.PreProcess();
819 Compiler
.AdjustBin();
820 Compiler
.GenBinary();
822 Compiler
.GenRecordListFile ();
824 Status
= Compiler
.RunStatus ();
825 if ((Status
== STATUS_DEAD
) || (Status
== STATUS_FAILED
)) {
829 if (gCBuffer
.Buffer
!= NULL
) {
830 delete gCBuffer
.Buffer
;
833 if (gRBuffer
.Buffer
!= NULL
) {
834 delete gRBuffer
.Buffer
;
837 return GetUtilityStatus ();