[Uml-devel] KDE/kdesdk/umbrello/umbrello/codeimport
Ralf Habacker
ralf.habacker at gmail.com
Wed Nov 30 15:20:24 UTC 2011
SVN commit 1266793 by habacker:
added support for msvc2010 preprocessor (windows only)
On the first instance creation available preprocessors are detected and saved.
If neither cpp and cl could not be found in the pathes provided by
KStandardDirs::findExe(), then the default install location of msvc2010 is
searched for.
M +9 -2 classimport.h
M +48 -5 idlimport.cpp
M +3 -0 idlimport.h
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/classimport.h #1266792:1266793
@@ -25,12 +25,19 @@
class ClassImport
{
public:
- ClassImport(CodeImpThread* thread = 0) : m_thread(thread) {}
+ ClassImport(CodeImpThread* thread = 0) : m_thread(thread), m_enabled(true) {}
virtual ~ClassImport() {}
void importFiles(const QStringList& fileNames);
void importFile(const QString& fileName);
+ /**
+ * Return state of the importer. It may be disabled because of
+ * missing dependencies for example.
+ * @return false - disabled, true - enabled
+ */
+ bool enabled() { return m_enabled; }
+
static ClassImport *createImporterByFileExt(const QString &fileName, CodeImpThread* thread = 0);
protected:
@@ -55,7 +62,7 @@
void log(const QString& text);
CodeImpThread* m_thread; ///< thread in which the work of importing is done
-
+ bool m_enabled; ///< state of importer
};
#endif
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/idlimport.cpp #1266792:1266793
@@ -23,6 +23,9 @@
#include "umldoc.h"
#include "umlpackagelist.h"
+// kde includes
+#include <KStandardDirs>
+
// qt includes
#include <QtCore/QProcess>
#include <QtCore/QStringList>
@@ -30,12 +33,50 @@
#include <stdio.h>
+QString IDLImport::m_preProcessor;
+QStringList IDLImport::m_preProcessorArguments;
+bool IDLImport::m_preProcessorChecked = false;
+
IDLImport::IDLImport() : NativeImportBase("//")
{
m_isOneway = m_isReadonly = m_isAttribute = false;
setMultiLineComment("/*", "*/");
+
+ // we do not want to find the executable on each imported file
+ if (m_preProcessorChecked) {
+ m_enabled = !m_preProcessor.isEmpty();
+ return;
}
+ QStringList arguments;
+ QString executable = KStandardDirs::findExe("cpp");
+ if (!executable.isEmpty()) {
+ arguments << "-C"; // -C means "preserve comments"
+ }
+#ifdef Q_WS_WIN
+ else {
+ executable = KStandardDirs::findExe("cl");
+ if (executable.isEmpty()) {
+ QString path = qgetenv("VS100COMNTOOLS");
+ if (!path.isEmpty())
+ executable = KStandardDirs::findExe("cl", path + "/../../VC/bin");
+ }
+ if (!executable.isEmpty()) {
+ arguments << "-E"; // -E means "preprocess to stdout"
+ }
+ }
+#endif
+ if (!executable.isEmpty()) {
+ m_preProcessor = executable;
+ m_preProcessorArguments = arguments;
+ }
+ else {
+ uError() << "Cannot find any of the supported preprocessors (gcc, Microsoft Visual Studio 2010)";
+ m_enabled = false;
+ }
+ m_preProcessorChecked = true;
+}
+
IDLImport::~IDLImport()
{
}
@@ -113,9 +154,11 @@
}
const QStringList includePaths = Import_Utils::includePathList();
- QString executable = "cpp";
- QStringList arguments;
- arguments << "-C"; // -C means "preserve comments"
+ if (m_preProcessor.isEmpty()) {
+ uError() << "no preprocessor installed, could not import file";
+ return false;
+ }
+ QStringList arguments(m_preProcessorArguments);
QProcess p(UMLApp::app());
for (QStringList::ConstIterator pathIt = includePaths.begin();
@@ -124,8 +167,8 @@
arguments << "-I" + path;
}
arguments << filename;
- uDebug() << "importIDL: " << executable << arguments;
- p.start(executable, arguments);
+ uDebug() << "importIDL: " << m_preProcessor << arguments;
+ p.start(m_preProcessor, arguments);
if (!p.waitForStarted()) {
uError() << "could not run preprocessor";
return false;
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/idlimport.h #1266792:1266793
@@ -34,6 +34,9 @@
protected:
QString joinTypename();
bool m_isOneway, m_isReadonly, m_isAttribute;
+ static QString m_preProcessor;
+ static QStringList m_preProcessorArguments;
+ static bool m_preProcessorChecked;
};
#endif
More information about the umbrello-devel
mailing list