Commit 97d98c96 authored by hjk's avatar hjk Committed by David Schulz

Utils: Compile winutils on all platform

... and simplify "user" code.

Change-Id: I2dfa402f25ab83f1ab80adc0ac508e8383c69641
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent c2015ea3
......@@ -86,14 +86,10 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/function.cpp \
$$PWD/ansiescapecodehandler.cpp \
$$PWD/execmenu.cpp \
$$PWD/completinglineedit.cpp
$$PWD/completinglineedit.cpp \
$$PWD/winutils.cpp
win32 {
SOURCES += \
$$PWD/consoleprocess_win.cpp \
$$PWD/winutils.cpp
HEADERS += $$PWD/winutils.h
}
win32:SOURCES += $$PWD/consoleprocess_win.cpp
else:SOURCES += $$PWD/consoleprocess_unix.cpp
HEADERS += \
......@@ -181,7 +177,8 @@ HEADERS += \
$$PWD/ansiescapecodehandler.h \
$$PWD/execmenu.h \
$$PWD/completinglineedit.h \
$$PWD/logging.h
$$PWD/logging.h \
$$PWD/winutils.h
FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \
......
......@@ -176,6 +176,8 @@ QtcLibrary {
"unixutils.h",
"utils.qrc",
"utils_global.h",
"winutils.cpp",
"winutils.h",
"wizard.cpp",
"wizard.h",
"images/arrow.png",
......@@ -208,8 +210,6 @@ QtcLibrary {
condition: qbs.targetOS.contains("windows")
files: [
"consoleprocess_win.cpp",
"winutils.cpp",
"winutils.h",
]
}
......
......@@ -31,9 +31,11 @@
#include "qtcassert.h"
// Enable WinAPI Windows XP and later
#ifdef Q_OS_WIN
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#include <windows.h>
#endif
#include <QString>
#include <QVector>
......@@ -47,6 +49,7 @@ namespace Utils {
QTCREATOR_UTILS_EXPORT QString winErrorMessage(unsigned long error)
{
QString rc = QString::fromLatin1("#%1: ").arg(error);
#ifdef Q_OS_WIN
ushort *lpMsgBuf;
const int len = FormatMessage(
......@@ -58,6 +61,7 @@ QTCREATOR_UTILS_EXPORT QString winErrorMessage(unsigned long error)
} else {
rc += QString::fromLatin1("<unknown error>");
}
#endif
return rc;
}
......@@ -76,6 +80,7 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
const QString &name,
QString *errorMessage)
{
#ifdef Q_OS_WIN
// Resolve required symbols from the version.dll
typedef DWORD (APIENTRY *GetFileVersionInfoSizeProtoType)(LPCTSTR, LPDWORD);
typedef BOOL (APIENTRY *GetFileVersionInfoWProtoType)(LPCWSTR, DWORD, DWORD, LPVOID);
......@@ -127,17 +132,26 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
break;
}
return rc;
#endif
Q_UNUSED(t);
Q_UNUSED(name);
Q_UNUSED(errorMessage);
return QString();
}
QTCREATOR_UTILS_EXPORT bool winIs64BitSystem()
QTCREATOR_UTILS_EXPORT bool is64BitWindowsSystem()
{
#ifdef Q_OS_WIN
SYSTEM_INFO systemInfo;
GetNativeSystemInfo(&systemInfo);
return systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64
|| systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64;
#else
return false;
#endif
}
QTCREATOR_UTILS_EXPORT bool winIs64BitBinary(const QString &binaryIn)
QTCREATOR_UTILS_EXPORT bool is64BitWindowsBinary(const QString &binaryIn)
{
QTC_ASSERT(!binaryIn.isEmpty(), return false);
#ifdef Q_OS_WIN32
......
......@@ -32,12 +32,6 @@
#include "utils_global.h"
#include <QProcess> // Q_PID (is PROCESS_INFORMATION*)
QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace Utils {
// Helper to format a Windows error message, taking the
......@@ -50,10 +44,10 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
const QString &name,
QString *errorMessage);
QTCREATOR_UTILS_EXPORT bool winIs64BitSystem();
QTCREATOR_UTILS_EXPORT bool is64BitWindowsSystem();
// Check for a 64bit binary.
QTCREATOR_UTILS_EXPORT bool winIs64BitBinary(const QString &binary);
QTCREATOR_UTILS_EXPORT bool is64BitWindowsBinary(const QString &binary);
} // namespace Utils
......
......@@ -352,7 +352,6 @@ CdbEngine::CdbEngine(const DebuggerStartParameters &sp) :
m_verboseLog(false), // Default CDB setting
m_notifyEngineShutdownOnTermination(false),
m_hasDebuggee(false),
m_cdbIs64Bit(false),
m_wow64State(wow64Uninitialized),
m_elapsedLogTime(0),
m_sourceStepInto(false),
......@@ -669,15 +668,10 @@ bool CdbEngine::launchCDB(const DebuggerStartParameters &sp, QString *errorMessa
return false;
}
m_cdbIs64Bit =
#ifdef Q_OS_WIN
Utils::winIs64BitBinary(executable);
#else
false;
#endif
if (!m_cdbIs64Bit)
bool cdbIs64Bit = Utils::is64BitWindowsBinary(executable);
if (!cdbIs64Bit)
m_wow64State = noWow64Stack;
const QFileInfo extensionFi(CdbEngine::extensionLibraryName(m_cdbIs64Bit));
const QFileInfo extensionFi(CdbEngine::extensionLibraryName(cdbIs64Bit));
if (!extensionFi.isFile()) {
*errorMessage = QString::fromLatin1("Internal error: The extension %1 cannot be found.\n"
"If you build Qt Creator from sources, check out "
......
......@@ -271,7 +271,6 @@ private:
bool m_verboseLog;
bool m_notifyEngineShutdownOnTermination;
bool m_hasDebuggee;
bool m_cdbIs64Bit;
enum Wow64State {
wow64Uninitialized,
noWow64Stack,
......
......@@ -139,11 +139,7 @@ void DebuggerItemConfigWidget::setItem(const DebuggerItem &item)
QString text;
QString versionCommand;
if (item.engineType() == CdbEngineType) {
#ifdef Q_OS_WIN
const bool is64bit = winIs64BitSystem();
#else
const bool is64bit = false;
#endif
const bool is64bit = is64BitWindowsSystem();
const QString versionString = is64bit ? tr("64-bit version") : tr("32-bit version");
//: Label text for path configuration. %2 is "x-bit version".
text = tr("<html><body><p>Specify the path to the "
......
......@@ -106,9 +106,7 @@
#include <utils/styledbar.h>
#include <utils/proxyaction.h>
#include <utils/statuslabel.h>
#ifdef Q_OS_WIN
# include <utils/winutils.h>
#endif
#include <utils/winutils.h>
#include <QComboBox>
#include <QDockWidget>
......@@ -588,13 +586,11 @@ public:
// On a 64bit OS, prefer a 64bit debugger.
static Kit *findUniversalCdbKit()
{
#ifdef Q_OS_WIN
if (Utils::winIs64BitSystem()) {
if (Utils::is64BitWindowsSystem()) {
CdbMatcher matcher64(64);
if (Kit *cdb64Kit = KitManager::find(matcher64))
return cdb64Kit;
}
#endif
CdbMatcher matcher;
return KitManager::find(matcher);
}
......
......@@ -40,10 +40,7 @@
#include "debuggerstringutils.h"
#include "debuggertooltipmanager.h"
#include "breakhandler.h"
#ifdef Q_OS_WIN
# include "shared/peutils.h"
#endif
#include "shared/peutils.h"
#include <projectexplorer/localapplicationrunconfiguration.h> // For LocalApplication*
#include <projectexplorer/environmentaspect.h> // For the environment
......
......@@ -34,6 +34,7 @@
#include <QCoreApplication>
#include <QDir>
#include <QProcess>
#ifdef Q_OS_WIN
#define _WIN32_WINNT 0x0502
......@@ -123,10 +124,10 @@ void DesktopProcessSignalOperation::interruptProcessSilently(int pid)
#ifdef Q_OS_WIN
enum SpecialInterrupt { NoSpecialInterrupt, Win32Interrupt, Win64Interrupt };
bool is64BitSystem = Utils::winIs64BitSystem();
bool is64BitSystem = Utils::is64BitWindowsSystem();
SpecialInterrupt si = NoSpecialInterrupt;
if (is64BitSystem)
si = Utils::winIs64BitBinary(m_debuggerCommand) ? Win64Interrupt : Win32Interrupt;
si = Utils::is64BitWindowsBinary(m_debuggerCommand) ? Win64Interrupt : Win32Interrupt;
/*
Windows 64 bit has a 32 bit subsystem (WOW64) which makes it possible to run a
32 bit application inside a 64 bit environment.
......@@ -167,7 +168,7 @@ GDB 32bit | Api | Api | N/A | Win32
+ Utils::winErrorMessage(GetLastError()));
break;
}
bool creatorIs64Bit = Utils::winIs64BitBinary(qApp->applicationFilePath());
bool creatorIs64Bit = Utils::is64BitWindowsBinary(qApp->applicationFilePath());
if (!is64BitSystem
|| si == NoSpecialInterrupt
|| si == Win64Interrupt && creatorIs64Bit
......
......@@ -43,10 +43,7 @@
#include <utils/fileutils.h>
#include <utils/qtcprocess.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h>
#endif
using namespace Core;
using namespace QmlProjectManager::Internal;
......
......@@ -33,10 +33,7 @@
#include "screenshotcropper.h"
#include <utils/pathchooser.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h>
#endif
#include <coreplugin/coreconstants.h>
#include <coreplugin/documentmanager.h>
......
......@@ -35,11 +35,6 @@
#include <QFileInfo>
#include <utils/qtcassert.h>
#include <utils/winutils.h>
#ifdef Q_OS_WIN
# include <qt_windows.h>
#endif
namespace Valgrind {
......
......@@ -46,10 +46,6 @@
#include <utils/iwelcomepage.h>
#include <utils/networkaccessmanager.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h>
#endif
#include <QScrollArea>
#include <QDesktopServices>
#include <QPainter>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment