aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2023-12-20 13:50:19 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2023-12-22 09:50:34 +0100
commit107c5da80c56cf2540c415810fc7b2b9a2540cd2 (patch)
tree1e3e49399821381a2b3cfdb2ce43c59dca143fb6
parent1cc20d181bdee1131bf2eb191e7f8fe4e4927e03 (diff)
Add --warnings-are-errors option to qmlcachegen
[ChangeLog][qmlcachegen] Added the --warnings-are-errors option that treats warnings as errors when generating C++ code. Like gcc's -Werror, this option is useful when aiming at warning-free QML code. Add it to the QT_QMLCACHEGEN_ARGUMENTS target property to error out once warnings have been encountered. Change-Id: If72875b33052b37642b18fa192a1344c347990d8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp
index da30307466..bcd6a7387f 100644
--- a/tools/qmlcachegen/qmlcachegen.cpp
+++ b/tools/qmlcachegen/qmlcachegen.cpp
@@ -91,6 +91,9 @@ int main(int argc, char **argv)
parser.addOption(onlyBytecode);
QCommandLineOption verboseOption("verbose"_L1, QCoreApplication::translate("main", "Output compile warnings"));
parser.addOption(verboseOption);
+ QCommandLineOption warningsAreErrorsOption("warnings-are-errors"_L1, QCoreApplication::translate("main", "Treat warnings as errors"));
+ parser.addOption(warningsAreErrorsOption);
+
QCommandLineOption validateBasicBlocksOption("validate-basic-blocks"_L1, QCoreApplication::translate("main", "Performs checks on the basic blocks of a function compiled ahead of time to validate its structure and coherence"));
parser.addOption(validateBasicBlocksOption);
@@ -247,7 +250,7 @@ int main(int argc, char **argv)
logger.setCategoryIgnored(qmlCompiler, false);
logger.setCategoryFatal(qmlCompiler, true);
- if (!parser.isSet(verboseOption))
+ if (!parser.isSet(verboseOption) && !parser.isSet(warningsAreErrorsOption))
logger.setSilent(true);
QQmlJSAotCompiler cppCodeGen(
@@ -268,6 +271,8 @@ int main(int argc, char **argv)
logger.log("Type warnings occurred while compiling file:"_L1,
qmlImport, QQmlJS::SourceLocation());
logger.processMessages(warnings, qmlImport);
+ if (parser.isSet(warningsAreErrorsOption))
+ return EXIT_FAILURE;
}
}
} else if (inputFile.endsWith(".js"_L1) || inputFile.endsWith(".mjs"_L1)) {
@@ -278,6 +283,8 @@ int main(int argc, char **argv)
}
} else {
fprintf(stderr, "Ignoring %s input file as it is not QML source code - maybe remove from QML_FILES?\n", qPrintable(inputFile));
+ if (parser.isSet(warningsAreErrorsOption))
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;