2009-04-28 12:43:04 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2009-04-28 12:43:04 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2009-04-28 12:43:04 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used 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.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-04-28 12:43:04 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2009-04-28 12:43:04 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "debugginghelper.h"
|
2009-08-07 15:20:05 +02:00
|
|
|
|
2009-04-28 12:43:04 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2011-01-20 14:03:07 +01:00
|
|
|
|
|
|
|
|
#include <utils/synchronousprocess.h>
|
|
|
|
|
|
2009-04-28 12:43:04 +02:00
|
|
|
#include <QtCore/QFileInfo>
|
2009-08-07 15:20:05 +02:00
|
|
|
#include <QtCore/QCoreApplication>
|
2009-04-28 12:43:04 +02:00
|
|
|
#include <QtCore/QHash>
|
|
|
|
|
#include <QtCore/QProcess>
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtCore/QDateTime>
|
2011-01-20 14:03:07 +01:00
|
|
|
#include <QtCore/QStringList>
|
2010-09-08 15:22:58 +02:00
|
|
|
|
2009-04-28 12:43:04 +02:00
|
|
|
#include <QtGui/QDesktopServices>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2010-09-27 15:51:49 +02:00
|
|
|
static inline QStringList validBinaryFilenames()
|
2009-04-28 12:43:04 +02:00
|
|
|
{
|
2010-09-27 15:51:49 +02:00
|
|
|
return QStringList()
|
|
|
|
|
<< QLatin1String("debug/gdbmacros.dll")
|
|
|
|
|
<< QLatin1String("libgdbmacros.dylib")
|
|
|
|
|
<< QLatin1String("libgdbmacros.so");
|
2009-04-28 12:43:04 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-03 19:16:22 +02:00
|
|
|
QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QString &qtInstallData)
|
2009-04-28 12:43:04 +02:00
|
|
|
{
|
2009-08-07 15:20:05 +02:00
|
|
|
const QChar slash = QLatin1Char('/');
|
2009-09-03 19:16:22 +02:00
|
|
|
const uint hash = qHash(qtInstallData);
|
2009-04-28 12:43:04 +02:00
|
|
|
QStringList directories;
|
|
|
|
|
directories
|
2009-08-07 15:20:05 +02:00
|
|
|
<< (qtInstallData + QLatin1String("/qtc-debugging-helper/"))
|
|
|
|
|
<< QDir::cleanPath((QCoreApplication::applicationDirPath() + QLatin1String("/../qtc-debugging-helper/") + QString::number(hash))) + slash
|
|
|
|
|
<< (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/qtc-debugging-helper/") + QString::number(hash)) + slash;
|
2009-04-28 12:43:04 +02:00
|
|
|
return directories;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-27 15:51:49 +02:00
|
|
|
QStringList DebuggingHelperLibrary::locationsByInstallData(const QString &qtInstallData)
|
2009-08-07 15:20:05 +02:00
|
|
|
{
|
|
|
|
|
QStringList result;
|
2009-10-29 12:04:43 +01:00
|
|
|
QFileInfo fileInfo;
|
2010-09-27 15:51:49 +02:00
|
|
|
const QStringList binFilenames = validBinaryFilenames();
|
2009-10-29 12:04:43 +01:00
|
|
|
foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData)) {
|
2010-09-27 15:51:49 +02:00
|
|
|
if (getHelperFileInfoFor(binFilenames, directory, &fileInfo))
|
2009-10-29 12:04:43 +01:00
|
|
|
result << fileInfo.filePath();
|
|
|
|
|
}
|
2009-07-15 17:41:45 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-18 14:43:33 +01:00
|
|
|
static QString sourcePath()
|
|
|
|
|
{
|
|
|
|
|
return Core::ICore::instance()->resourcePath() + QLatin1String("/gdbmacros/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QStringList sourceFileNames()
|
|
|
|
|
{
|
|
|
|
|
return QStringList()
|
|
|
|
|
<< QLatin1String("gdbmacros.cpp") << QLatin1String("gdbmacros_p.h")
|
|
|
|
|
<< QLatin1String("gdbmacros.h") << QLatin1String("gdbmacros.pro")
|
|
|
|
|
<< QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT");
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-03 19:16:22 +02:00
|
|
|
QString DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(const QString &qtInstallData)
|
2009-04-28 12:43:04 +02:00
|
|
|
{
|
2010-06-08 13:55:50 +02:00
|
|
|
if (!Core::ICore::instance())
|
|
|
|
|
return QString();
|
2009-09-17 15:47:28 +02:00
|
|
|
|
2010-09-27 15:51:49 +02:00
|
|
|
const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData);
|
|
|
|
|
const QStringList binFilenames = validBinaryFilenames();
|
2009-04-28 12:43:04 +02:00
|
|
|
|
2011-04-18 14:13:18 +02:00
|
|
|
return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames, false);
|
2009-08-07 15:20:05 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-27 15:51:49 +02:00
|
|
|
QString DebuggingHelperLibrary::copy(const QString &qtInstallData,
|
|
|
|
|
QString *errorMessage)
|
2009-04-28 12:43:04 +02:00
|
|
|
{
|
|
|
|
|
// Locations to try:
|
|
|
|
|
// $QTDIR/qtc-debugging-helper
|
|
|
|
|
// $APPLICATION-DIR/qtc-debugging-helper/$hash
|
|
|
|
|
// $USERDIR/qtc-debugging-helper/$hash
|
2009-09-03 19:16:22 +02:00
|
|
|
const QStringList directories = DebuggingHelperLibrary::debuggingHelperLibraryDirectories(qtInstallData);
|
2009-04-28 12:43:04 +02:00
|
|
|
|
2009-08-07 15:20:05 +02:00
|
|
|
// Try to find a writeable directory.
|
|
|
|
|
foreach(const QString &directory, directories)
|
2011-02-18 14:43:33 +01:00
|
|
|
if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) {
|
2009-08-07 15:20:05 +02:00
|
|
|
errorMessage->clear();
|
2009-08-07 14:20:27 +02:00
|
|
|
return directory;
|
2009-08-07 15:20:05 +02:00
|
|
|
}
|
2010-09-27 17:22:57 +02:00
|
|
|
*errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
|
|
|
|
|
"The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2")
|
2009-08-07 15:20:05 +02:00
|
|
|
.arg(directories.join(QLatin1String("\n- ")), *errorMessage);
|
|
|
|
|
return QString();
|
2009-04-28 12:43:04 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-29 13:35:19 +02:00
|
|
|
bool DebuggingHelperLibrary::build(BuildHelperArguments arguments, QString *log, QString *errorMessage)
|
2009-04-28 12:43:04 +02:00
|
|
|
{
|
2011-04-29 13:35:19 +02:00
|
|
|
arguments.proFilename = QLatin1String("gdbmacros.pro");
|
|
|
|
|
arguments.helperName = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary",
|
|
|
|
|
"GDB helper");
|
|
|
|
|
return buildHelper(arguments, log, errorMessage);
|
2009-04-28 12:43:04 +02:00
|
|
|
}
|