aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltyperegistrar
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2020-01-28 13:28:57 +0100
committerLeander Beernaert <leander.beernaert@qt.io>2020-01-29 14:33:47 +0000
commitba0ac519e3f4acb3fb73ff68393624ec855918aa (patch)
treef91e7b75fd750522f45bed72bea85bb7257f61f8 /src/qmltyperegistrar
parent7590f07278ae2cc4ddade7668b5c34ce16751260 (diff)
Update qmltypes to use the new metatypes dependency format
The foreign types list for qmltypesregistrar is now generated by recursively processing the ${targets}_metatypes_dep.txt file. At build time we now use a custom script (Qt6QmlResolveDependencies.cmake) to generate the final foreign types file. qmltypesregistrar has also been updated in order to support the resolution of response files supplied to the command line arguments. Change-Id: Ib61d82fa92bf5d5a24631f461248f81147aad947 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/qmltyperegistrar')
-rw-r--r--src/qmltyperegistrar/qmltyperegistrar.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/qmltyperegistrar/qmltyperegistrar.cpp b/src/qmltyperegistrar/qmltyperegistrar.cpp
index 49c9fccb66..4738e28314 100644
--- a/src/qmltyperegistrar/qmltyperegistrar.cpp
+++ b/src/qmltyperegistrar/qmltyperegistrar.cpp
@@ -57,6 +57,35 @@ static bool acceptClassForQmlTypeRegistration(const QJsonObject &classDef)
return false;
}
+static bool argumentsFromCommandLineAndFile(QStringList &allArguments, const QStringList &arguments)
+{
+ allArguments.reserve(arguments.size());
+ for (const QString &argument : arguments) {
+ // "@file" doesn't start with a '-' so we can't use QCommandLineParser for it
+ if (argument.startsWith(QLatin1Char('@'))) {
+ QString optionsFile = argument;
+ optionsFile.remove(0, 1);
+ if (optionsFile.isEmpty()) {
+ fprintf(stderr, "The @ option requires an input file");
+ return false;
+ }
+ QFile f(optionsFile);
+ if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ fprintf(stderr, "Cannot open options file specified with @");
+ return false;
+ }
+ while (!f.atEnd()) {
+ QString line = QString::fromLocal8Bit(f.readLine().trimmed());
+ if (!line.isEmpty())
+ allArguments << line;
+ }
+ } else {
+ allArguments << argument;
+ }
+ }
+ return true;
+}
+
static QVector<QJsonObject> foreignRelatedTypes(const QVector<QJsonObject> &types,
const QVector<QJsonObject> &foreignTypes)
{
@@ -229,7 +258,11 @@ int main(int argc, char **argv)
parser.addPositionalArgument(QStringLiteral("[MOC generated json file]"),
QStringLiteral("MOC generated json output."));
- parser.process(app);
+ QStringList arguments;
+ if (!argumentsFromCommandLineAndFile(arguments, app.arguments()))
+ return EXIT_FAILURE;
+
+ parser.process(arguments);
FILE *output = stdout;
QScopedPointer<FILE, ScopedPointerFileCloser> outputFile;