Utils: Compile winutils on all platform

... and simplify "user" code.

Change-Id: I2dfa402f25ab83f1ab80adc0ac508e8383c69641
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
hjk
2014-02-19 15:35:58 +01:00
committed by David Schulz
parent c2015ea3dc
commit 97d98c96e5
14 changed files with 36 additions and 63 deletions

View File

@@ -86,14 +86,10 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/function.cpp \ $$PWD/function.cpp \
$$PWD/ansiescapecodehandler.cpp \ $$PWD/ansiescapecodehandler.cpp \
$$PWD/execmenu.cpp \ $$PWD/execmenu.cpp \
$$PWD/completinglineedit.cpp $$PWD/completinglineedit.cpp \
win32 {
SOURCES += \
$$PWD/consoleprocess_win.cpp \
$$PWD/winutils.cpp $$PWD/winutils.cpp
HEADERS += $$PWD/winutils.h
} win32:SOURCES += $$PWD/consoleprocess_win.cpp
else:SOURCES += $$PWD/consoleprocess_unix.cpp else:SOURCES += $$PWD/consoleprocess_unix.cpp
HEADERS += \ HEADERS += \
@@ -181,7 +177,8 @@ HEADERS += \
$$PWD/ansiescapecodehandler.h \ $$PWD/ansiescapecodehandler.h \
$$PWD/execmenu.h \ $$PWD/execmenu.h \
$$PWD/completinglineedit.h \ $$PWD/completinglineedit.h \
$$PWD/logging.h $$PWD/logging.h \
$$PWD/winutils.h
FORMS += $$PWD/filewizardpage.ui \ FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \ $$PWD/projectintropage.ui \

View File

@@ -176,6 +176,8 @@ QtcLibrary {
"unixutils.h", "unixutils.h",
"utils.qrc", "utils.qrc",
"utils_global.h", "utils_global.h",
"winutils.cpp",
"winutils.h",
"wizard.cpp", "wizard.cpp",
"wizard.h", "wizard.h",
"images/arrow.png", "images/arrow.png",
@@ -208,8 +210,6 @@ QtcLibrary {
condition: qbs.targetOS.contains("windows") condition: qbs.targetOS.contains("windows")
files: [ files: [
"consoleprocess_win.cpp", "consoleprocess_win.cpp",
"winutils.cpp",
"winutils.h",
] ]
} }

View File

@@ -31,9 +31,11 @@
#include "qtcassert.h" #include "qtcassert.h"
// Enable WinAPI Windows XP and later // Enable WinAPI Windows XP and later
#ifdef Q_OS_WIN
#undef _WIN32_WINNT #undef _WIN32_WINNT
#define _WIN32_WINNT 0x0501 #define _WIN32_WINNT 0x0501
#include <windows.h> #include <windows.h>
#endif
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@@ -47,6 +49,7 @@ namespace Utils {
QTCREATOR_UTILS_EXPORT QString winErrorMessage(unsigned long error) QTCREATOR_UTILS_EXPORT QString winErrorMessage(unsigned long error)
{ {
QString rc = QString::fromLatin1("#%1: ").arg(error); QString rc = QString::fromLatin1("#%1: ").arg(error);
#ifdef Q_OS_WIN
ushort *lpMsgBuf; ushort *lpMsgBuf;
const int len = FormatMessage( const int len = FormatMessage(
@@ -58,6 +61,7 @@ QTCREATOR_UTILS_EXPORT QString winErrorMessage(unsigned long error)
} else { } else {
rc += QString::fromLatin1("<unknown error>"); rc += QString::fromLatin1("<unknown error>");
} }
#endif
return rc; return rc;
} }
@@ -76,6 +80,7 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
const QString &name, const QString &name,
QString *errorMessage) QString *errorMessage)
{ {
#ifdef Q_OS_WIN
// Resolve required symbols from the version.dll // Resolve required symbols from the version.dll
typedef DWORD (APIENTRY *GetFileVersionInfoSizeProtoType)(LPCTSTR, LPDWORD); typedef DWORD (APIENTRY *GetFileVersionInfoSizeProtoType)(LPCTSTR, LPDWORD);
typedef BOOL (APIENTRY *GetFileVersionInfoWProtoType)(LPCWSTR, DWORD, DWORD, LPVOID); typedef BOOL (APIENTRY *GetFileVersionInfoWProtoType)(LPCWSTR, DWORD, DWORD, LPVOID);
@@ -127,17 +132,26 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
break; break;
} }
return rc; 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; SYSTEM_INFO systemInfo;
GetNativeSystemInfo(&systemInfo); GetNativeSystemInfo(&systemInfo);
return systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 return systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64
|| systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64; || 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); QTC_ASSERT(!binaryIn.isEmpty(), return false);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32

View File

@@ -32,12 +32,6 @@
#include "utils_global.h" #include "utils_global.h"
#include <QProcess> // Q_PID (is PROCESS_INFORMATION*)
QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace Utils { namespace Utils {
// Helper to format a Windows error message, taking the // Helper to format a Windows error message, taking the
@@ -50,10 +44,10 @@ QTCREATOR_UTILS_EXPORT QString winGetDLLVersion(WinDLLVersionType t,
const QString &name, const QString &name,
QString *errorMessage); QString *errorMessage);
QTCREATOR_UTILS_EXPORT bool winIs64BitSystem(); QTCREATOR_UTILS_EXPORT bool is64BitWindowsSystem();
// Check for a 64bit binary. // Check for a 64bit binary.
QTCREATOR_UTILS_EXPORT bool winIs64BitBinary(const QString &binary); QTCREATOR_UTILS_EXPORT bool is64BitWindowsBinary(const QString &binary);
} // namespace Utils } // namespace Utils

View File

@@ -352,7 +352,6 @@ CdbEngine::CdbEngine(const DebuggerStartParameters &sp) :
m_verboseLog(false), // Default CDB setting m_verboseLog(false), // Default CDB setting
m_notifyEngineShutdownOnTermination(false), m_notifyEngineShutdownOnTermination(false),
m_hasDebuggee(false), m_hasDebuggee(false),
m_cdbIs64Bit(false),
m_wow64State(wow64Uninitialized), m_wow64State(wow64Uninitialized),
m_elapsedLogTime(0), m_elapsedLogTime(0),
m_sourceStepInto(false), m_sourceStepInto(false),
@@ -669,15 +668,10 @@ bool CdbEngine::launchCDB(const DebuggerStartParameters &sp, QString *errorMessa
return false; return false;
} }
m_cdbIs64Bit = bool cdbIs64Bit = Utils::is64BitWindowsBinary(executable);
#ifdef Q_OS_WIN if (!cdbIs64Bit)
Utils::winIs64BitBinary(executable);
#else
false;
#endif
if (!m_cdbIs64Bit)
m_wow64State = noWow64Stack; m_wow64State = noWow64Stack;
const QFileInfo extensionFi(CdbEngine::extensionLibraryName(m_cdbIs64Bit)); const QFileInfo extensionFi(CdbEngine::extensionLibraryName(cdbIs64Bit));
if (!extensionFi.isFile()) { if (!extensionFi.isFile()) {
*errorMessage = QString::fromLatin1("Internal error: The extension %1 cannot be found.\n" *errorMessage = QString::fromLatin1("Internal error: The extension %1 cannot be found.\n"
"If you build Qt Creator from sources, check out " "If you build Qt Creator from sources, check out "

View File

@@ -271,7 +271,6 @@ private:
bool m_verboseLog; bool m_verboseLog;
bool m_notifyEngineShutdownOnTermination; bool m_notifyEngineShutdownOnTermination;
bool m_hasDebuggee; bool m_hasDebuggee;
bool m_cdbIs64Bit;
enum Wow64State { enum Wow64State {
wow64Uninitialized, wow64Uninitialized,
noWow64Stack, noWow64Stack,

View File

@@ -139,11 +139,7 @@ void DebuggerItemConfigWidget::setItem(const DebuggerItem &item)
QString text; QString text;
QString versionCommand; QString versionCommand;
if (item.engineType() == CdbEngineType) { if (item.engineType() == CdbEngineType) {
#ifdef Q_OS_WIN const bool is64bit = is64BitWindowsSystem();
const bool is64bit = winIs64BitSystem();
#else
const bool is64bit = false;
#endif
const QString versionString = is64bit ? tr("64-bit version") : tr("32-bit version"); const QString versionString = is64bit ? tr("64-bit version") : tr("32-bit version");
//: Label text for path configuration. %2 is "x-bit version". //: Label text for path configuration. %2 is "x-bit version".
text = tr("<html><body><p>Specify the path to the " text = tr("<html><body><p>Specify the path to the "

View File

@@ -106,9 +106,7 @@
#include <utils/styledbar.h> #include <utils/styledbar.h>
#include <utils/proxyaction.h> #include <utils/proxyaction.h>
#include <utils/statuslabel.h> #include <utils/statuslabel.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h> #include <utils/winutils.h>
#endif
#include <QComboBox> #include <QComboBox>
#include <QDockWidget> #include <QDockWidget>
@@ -588,13 +586,11 @@ public:
// On a 64bit OS, prefer a 64bit debugger. // On a 64bit OS, prefer a 64bit debugger.
static Kit *findUniversalCdbKit() static Kit *findUniversalCdbKit()
{ {
#ifdef Q_OS_WIN if (Utils::is64BitWindowsSystem()) {
if (Utils::winIs64BitSystem()) {
CdbMatcher matcher64(64); CdbMatcher matcher64(64);
if (Kit *cdb64Kit = KitManager::find(matcher64)) if (Kit *cdb64Kit = KitManager::find(matcher64))
return cdb64Kit; return cdb64Kit;
} }
#endif
CdbMatcher matcher; CdbMatcher matcher;
return KitManager::find(matcher); return KitManager::find(matcher);
} }

View File

@@ -40,10 +40,7 @@
#include "debuggerstringutils.h" #include "debuggerstringutils.h"
#include "debuggertooltipmanager.h" #include "debuggertooltipmanager.h"
#include "breakhandler.h" #include "breakhandler.h"
#ifdef Q_OS_WIN
#include "shared/peutils.h" #include "shared/peutils.h"
#endif
#include <projectexplorer/localapplicationrunconfiguration.h> // For LocalApplication* #include <projectexplorer/localapplicationrunconfiguration.h> // For LocalApplication*
#include <projectexplorer/environmentaspect.h> // For the environment #include <projectexplorer/environmentaspect.h> // For the environment

View File

@@ -34,6 +34,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
#include <QProcess>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#define _WIN32_WINNT 0x0502 #define _WIN32_WINNT 0x0502
@@ -123,10 +124,10 @@ void DesktopProcessSignalOperation::interruptProcessSilently(int pid)
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
enum SpecialInterrupt { NoSpecialInterrupt, Win32Interrupt, Win64Interrupt }; enum SpecialInterrupt { NoSpecialInterrupt, Win32Interrupt, Win64Interrupt };
bool is64BitSystem = Utils::winIs64BitSystem(); bool is64BitSystem = Utils::is64BitWindowsSystem();
SpecialInterrupt si = NoSpecialInterrupt; SpecialInterrupt si = NoSpecialInterrupt;
if (is64BitSystem) 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 Windows 64 bit has a 32 bit subsystem (WOW64) which makes it possible to run a
32 bit application inside a 64 bit environment. 32 bit application inside a 64 bit environment.
@@ -167,7 +168,7 @@ GDB 32bit | Api | Api | N/A | Win32
+ Utils::winErrorMessage(GetLastError())); + Utils::winErrorMessage(GetLastError()));
break; break;
} }
bool creatorIs64Bit = Utils::winIs64BitBinary(qApp->applicationFilePath()); bool creatorIs64Bit = Utils::is64BitWindowsBinary(qApp->applicationFilePath());
if (!is64BitSystem if (!is64BitSystem
|| si == NoSpecialInterrupt || si == NoSpecialInterrupt
|| si == Win64Interrupt && creatorIs64Bit || si == Win64Interrupt && creatorIs64Bit

View File

@@ -43,10 +43,7 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h> #include <utils/winutils.h>
#endif
using namespace Core; using namespace Core;
using namespace QmlProjectManager::Internal; using namespace QmlProjectManager::Internal;

View File

@@ -33,10 +33,7 @@
#include "screenshotcropper.h" #include "screenshotcropper.h"
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h> #include <utils/winutils.h>
#endif
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/documentmanager.h> #include <coreplugin/documentmanager.h>

View File

@@ -35,11 +35,6 @@
#include <QFileInfo> #include <QFileInfo>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/winutils.h>
#ifdef Q_OS_WIN
# include <qt_windows.h>
#endif
namespace Valgrind { namespace Valgrind {

View File

@@ -46,10 +46,6 @@
#include <utils/iwelcomepage.h> #include <utils/iwelcomepage.h>
#include <utils/networkaccessmanager.h> #include <utils/networkaccessmanager.h>
#ifdef Q_OS_WIN
#include <utils/winutils.h>
#endif
#include <QScrollArea> #include <QScrollArea>
#include <QDesktopServices> #include <QDesktopServices>
#include <QPainter> #include <QPainter>