Skip to content

generator: improve error handling #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions generator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
**
****************************************************************************/

#include <cstdio>

#include "main.h"
#include "asttoxml.h"
#include "reporthandler.h"
Expand All @@ -53,6 +55,8 @@ void displayHelp(GeneratorSet *generatorSet);
#include <QDebug>
int main(int argc, char *argv[])
{
ReportHandler::setContext("Arguments");

QScopedPointer<GeneratorSet> gs(GeneratorSet::getInstance());

QString default_file = ":/trolltech/generator/qtscript_masterinclude.h";
Expand Down Expand Up @@ -135,11 +139,13 @@ int main(int argc, char *argv[])
printf("Please wait while source files are being generated...\n");

printf("Parsing typesystem file [%s]\n", qPrintable(typesystemFileName));
ReportHandler::setContext("Typesystem");
if (!TypeDatabase::instance()->parseFile(typesystemFileName))
qFatal("Cannot parse file: '%s'", qPrintable(typesystemFileName));

printf("PreProcessing - Generate [%s] using [%s] and include-paths [%s]\n",
qPrintable(pp_file), qPrintable(fileName), qPrintable(args.value("include-paths")));
ReportHandler::setContext("Preprocess");
if (!Preprocess::preprocess(fileName, pp_file, args.value("include-paths"))) {
fprintf(stderr, "Preprocessor failed on file: '%s'\n", qPrintable(fileName));
return 1;
Expand All @@ -148,16 +154,19 @@ int main(int argc, char *argv[])
if (args.contains("ast-to-xml")) {
printf("Running ast-to-xml on file [%s] using pp_file [%s] and include-paths [%s]\n",
qPrintable(fileName), qPrintable(pp_file), qPrintable(args.value("include-paths")));
ReportHandler::setContext(QString("AST-to-XML"));
astToXML(pp_file);
return 0;
}

printf("Building model using [%s]\n", qPrintable(pp_file));
ReportHandler::setContext("Build");
gs->buildModel(pp_file);
if (args.contains("dump-object-tree")) {
gs->dumpObjectTree();
return 0;
}
ReportHandler::setContext("Generate");
printf("%s\n", qPrintable(gs->generate()));

printf("Done, %d warnings (%d known issues)\n", ReportHandler::warningCount(),
Expand Down