From 10788a8d302f10cbf11921d47612c2a80b1cedac Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Tue, 13 Sep 2011 15:49:11 +0200 Subject: Added --verify-only option to qmlmin. qmlmin has three different stages. In the first stage it generates the QML/JS minified code. In the second stage we verify that minified code is equivalent to the original code and in the final stage we produce the output. With --verify-only you can tell qmlmin to quit after the verification step. Note that this option is pretty much equivalent to the unix command qmlmin file.qml -o /dev/null. Change-Id: I91373bc1c1db8c35af2e301ad13d7b34fc384529 Reviewed-on: http://codereview.qt-project.org/4670 Reviewed-by: Qt Sanity Bot Reviewed-by: Kent Hansen --- tools/qmlmin/main.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp index ef848f6c1e..5343a72c81 100644 --- a/tools/qmlmin/main.cpp +++ b/tools/qmlmin/main.cpp @@ -411,6 +411,7 @@ static void usage(bool showHelp = false) std::cerr << " Removes comments and layout characters" << std::endl << " The options are:" << std::endl << " -o write output to file rather than stdout" << std::endl + << " -v --verify-only just run the verifier, no output" << std::endl << " -h display this output" << std::endl; } } @@ -423,6 +424,7 @@ int main(int argc, char *argv[]) QString fileName; QString outputFile; + bool verifyOnly = false; int index = 1; while (index < args.size()) { @@ -432,6 +434,8 @@ int main(int argc, char *argv[]) if (arg == QLatin1String("-h") || arg == QLatin1String("--help")) { usage(/*showHelp*/ true); return 0; + } else if (arg == QLatin1String("-v") || arg == QLatin1String("--verify-only")) { + verifyOnly = true; } else if (arg == QLatin1String("-o")) { if (next.isEmpty()) { std::cerr << "qmlmin: argument to '-o' is missing" << std::endl; @@ -500,18 +504,20 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - if (outputFile.isEmpty()) { - const QByteArray chars = minify.minifiedCode().toUtf8(); - std::cout << chars.constData(); - } else { - QFile file(outputFile); - if (! file.open(QFile::WriteOnly)) { - std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << "' (permission denied)" << std::endl; - return EXIT_FAILURE; - } + if (! verifyOnly) { + if (outputFile.isEmpty()) { + const QByteArray chars = minify.minifiedCode().toUtf8(); + std::cout << chars.constData(); + } else { + QFile file(outputFile); + if (! file.open(QFile::WriteOnly)) { + std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << "' (permission denied)" << std::endl; + return EXIT_FAILURE; + } - file.write(minify.minifiedCode().toUtf8()); - file.close(); + file.write(minify.minifiedCode().toUtf8()); + file.close(); + } } return 0; -- cgit v1.2.3