aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoaquim Rocha <jrocha@igalia.com>2010-09-23 12:39:09 +0200
committerArmin Berres <armin.berres@basyskom.de>2010-09-30 17:44:44 +0200
commit874d682e74cd324acd33dd96e9ee3193ec45913a (patch)
tree31923334d33b2de8aa1bc90fb6d90f2af3f682e5 /tools
parent4b51b0c74c6a1f6bee170cf4c1fbd6866b311aef (diff)
Changes: Add a CSS validator tool that verifies CSS the files' syntax.
RevBy: TrustMe Details: These changes add the MStyleSheetParser::validate method checks the source of CSS files by performing the save operations as MStyleSheetParser::parse but ignoring the contants' replacement and other instantiations since what is needed in a syntax check only. The mentioned method is used in the "mcssvalidator" tool which outputs information about the verified CSS files and exits with a code according to the existence of problems (1) or not (0).
Diffstat (limited to 'tools')
-rw-r--r--tools/mcssvalidator/.gitignore1
-rw-r--r--tools/mcssvalidator/mcssvalidator.cpp50
-rw-r--r--tools/mcssvalidator/mcssvalidator.pro22
-rw-r--r--tools/tools.pro2
4 files changed, 75 insertions, 0 deletions
diff --git a/tools/mcssvalidator/.gitignore b/tools/mcssvalidator/.gitignore
new file mode 100644
index 00000000..7dd1d9c6
--- /dev/null
+++ b/tools/mcssvalidator/.gitignore
@@ -0,0 +1 @@
+mcssvalidator
diff --git a/tools/mcssvalidator/mcssvalidator.cpp b/tools/mcssvalidator/mcssvalidator.cpp
new file mode 100644
index 00000000..66ee7eaa
--- /dev/null
+++ b/tools/mcssvalidator/mcssvalidator.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (directui@nokia.com)
+**
+** This file is part of libmeegotouch.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at directui@nokia.com.
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation
+** and appearing in the file LICENSE.LGPL included in the packaging
+** of this file.
+**
+****************************************************************************/
+
+//==============================================================
+// Description : Tool to check if CSS files have a valid syntax
+//==============================================================
+
+#include <QFile>
+#include <mstylesheetparser.h>
+#include <iostream>
+using namespace std;
+
+int main(int argc, char **argv)
+{
+ bool valid = true;
+ if (argc < 2) {
+ cout <<
+ "MeeGo CSS Validator, usage:\n " <<
+ argv[0] <<
+ " PATH_TO_CSS_FILE [PATH_TO_CSS_FILE_2…]\n";
+ return 0;
+ }
+ for (int i = 1; i < argc; i++) {
+ if (!QFile::exists(argv[i])) {
+ cout << "Skipping \"" << argv[i] << "\", does not exist\n";
+ continue;
+ }
+ cout << "Validating \"" << argv[i] << "\"\n";
+ bool passedTest = MStyleSheetParser::validate(argv[i]);
+ cout << argv[i] << " : " << (passedTest ? "VALID" : "INVALID") << "\n";
+ valid = valid && passedTest;
+ }
+ return valid ? 0 : 1;
+}
diff --git a/tools/mcssvalidator/mcssvalidator.pro b/tools/mcssvalidator/mcssvalidator.pro
new file mode 100644
index 00000000..4a85eccd
--- /dev/null
+++ b/tools/mcssvalidator/mcssvalidator.pro
@@ -0,0 +1,22 @@
+include(../../mkspecs/common.pri)
+
+TEMPLATE = app
+TARGET = mcssvalidator
+INCLUDEPATH += . \
+ ../../src/include \
+ ../../src/corelib/notification
+
+DEPENDPATH += $$INCLUDEPATH
+win32|macx {
+ macx {
+ QMAKE_LFLAGS += -F../../lib
+ LIBS += -framework m
+ }
+ win32:LIBS += -lmeegotouchcore0
+} else {
+ LIBS += -lmeegotouchcore
+}
+
+SOURCES += mcssvalidator.cpp
+target.path = $$M_INSTALL_BIN
+INSTALLS += target
diff --git a/tools/tools.pro b/tools/tools.pro
index a1aa4caf..e42803de 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -6,10 +6,12 @@ SUBDIRS = \
mapplicationextensiontester \
mnotificationtool \
m-servicefwgen.d \
+ mcssvalidator
macx:SUBDIRS -= mnotificationtool
macx:SUBDIRS -= mapplettester
macx:SUBDIRS -= mapplicationextensiontester
+macx:SUBDIRS -= mcssvalidator
QMAKE_EXTRA_TARGETS += check
check.depends =