diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-30 10:04:14 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-31 10:37:47 +0100 |
commit | c9d4103e52b28c7a242d90433112bfaedb77f0cc (patch) | |
tree | 2e273ef5c918ac19e441e14c8cf4913f8a3c3fa0 /tools | |
parent | 6e84e993f42be3530bff2550b89e5066c4d9cea6 (diff) |
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 <simon.hausmann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qgltf/qgltf.cpp | 42 |
1 files 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<float> 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 <dir>"), 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); |