summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2011-09-13 15:49:11 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-19 12:07:46 +0200
commit10788a8d302f10cbf11921d47612c2a80b1cedac (patch)
treead6e556ce0a4531e6485cfe9f075b64c09a9daaa /tools
parent9fa9a56e19f58934ec278c5af3ec5ee23d496659 (diff)
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 <qt_sanity_bot@ovi.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmlmin/main.cpp28
1 files 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<file> 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;