From c9d4103e52b28c7a242d90433112bfaedb77f0cc Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 30 Oct 2019 10:04:14 +0100 Subject: Temporarily disable binary JSON mode for qgltf in bootstrap mode We need to update the bootstrap library in order to remove binary JSON support and add CBOR support. As we cannot use CBOR before and we cannot use binary JSON afterwards, we need to disable binary JSON in qgltf, then update the bootstrap library, and then add CBOR support to qgltf. Change-Id: I4d70b831cf1924d08c821c74f0c1b63fd0d21844 Reviewed-by: Simon Hausmann --- tools/qgltf/qgltf.cpp | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/tools/qgltf/qgltf.cpp b/tools/qgltf/qgltf.cpp index 562e50911..91ecd5ba2 100644 --- a/tools/qgltf/qgltf.cpp +++ b/tools/qgltf/qgltf.cpp @@ -216,7 +216,9 @@ static inline QVector ai2qt(const aiMatrix4x4 &matrix) struct Options { QString outDir; +#ifndef QT_BOOTSTRAPPED bool genBin; +#endif bool compact; bool compress; bool genTangents; @@ -2450,23 +2452,31 @@ void GltfExporter::save(const QString &inputFilename) QString gltfName = opts.outDir + basename + QStringLiteral(".qgltf"); f.setFileName(gltfName); + +#ifndef QT_BOOTSTRAPPED if (opts.showLog) qDebug().noquote() << (opts.genBin ? "Writing (binary JSON)" : "Writing") << gltfName; - if (opts.genBin) { - if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - m_files.insert(QFileInfo(f.fileName()).fileName()); - QByteArray json = m_doc.toBinaryData(); - f.write(json); - f.close(); - } - } else { - if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { - m_files.insert(QFileInfo(f.fileName()).fileName()); - QByteArray json = m_doc.toJson(opts.compact ? QJsonDocument::Compact : QJsonDocument::Indented); - f.write(json); - f.close(); - } + const QIODevice::OpenMode openMode = opts.genBin + ? (QIODevice::WriteOnly | QIODevice::Truncate) + : (QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text); + const QByteArray json = opts.genBin + ? m_doc.toBinaryData() + : m_doc.toJson(opts.compact ? QJsonDocument::Compact : QJsonDocument::Indented); +#else + if (opts.showLog) + qDebug().noquote() << "Writing" << gltfName; + + const QIODevice::OpenMode openMode + = QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text; + const QByteArray json + = m_doc.toJson(opts.compact ? QJsonDocument::Compact : QJsonDocument::Indented); +#endif + + if (f.open(openMode)) { + m_files.insert(QFileInfo(f.fileName()).fileName()); + f.write(json); + f.close(); } QString qrcName = opts.outDir + basename + QStringLiteral(".qrc"); @@ -2509,8 +2519,10 @@ int main(int argc, char **argv) cmdLine.setApplicationDescription(QString::fromUtf8(description)); QCommandLineOption outDirOpt(QStringLiteral("d"), QStringLiteral("Place all output data into "), QStringLiteral("dir")); cmdLine.addOption(outDirOpt); +#ifndef QT_BOOTSTRAPPED QCommandLineOption binOpt(QStringLiteral("b"), QStringLiteral("Store binary JSON data in the .qgltf file")); cmdLine.addOption(binOpt); +#endif QCommandLineOption compactOpt(QStringLiteral("m"), QStringLiteral("Store compact JSON in the .qgltf file")); cmdLine.addOption(compactOpt); QCommandLineOption compOpt(QStringLiteral("c"), QStringLiteral("qCompress() vertex/index data in the .bin file")); @@ -2533,7 +2545,9 @@ int main(int argc, char **argv) cmdLine.addOption(silentOpt); cmdLine.process(app); opts.outDir = cmdLine.value(outDirOpt); +#ifndef QT_BOOTSTRAPPED opts.genBin = cmdLine.isSet(binOpt); +#endif opts.compact = cmdLine.isSet(compactOpt); opts.compress = cmdLine.isSet(compOpt); opts.genTangents = cmdLine.isSet(tangentOpt); -- cgit v1.2.3