2018-11-15 18:00:23 +03:00
|
|
|
#include "windependenciesscanner.h"
|
|
|
|
|
|
|
|
#include <QList>
|
2018-11-18 17:22:05 +03:00
|
|
|
#include <QDir>
|
2018-11-26 16:17:46 +03:00
|
|
|
#include <QDebug>
|
2018-11-15 18:00:23 +03:00
|
|
|
|
2018-12-01 21:04:52 +03:00
|
|
|
struct Options {
|
|
|
|
enum DebugDetection {
|
|
|
|
DebugDetectionAuto,
|
|
|
|
DebugDetectionForceDebug,
|
|
|
|
DebugDetectionForceRelease
|
|
|
|
};
|
|
|
|
|
|
|
|
enum AngleDetection {
|
|
|
|
AngleDetectionAuto,
|
|
|
|
AngleDetectionForceOn,
|
|
|
|
AngleDetectionForceOff
|
|
|
|
};
|
|
|
|
|
|
|
|
bool plugins = true;
|
|
|
|
bool libraries = true;
|
|
|
|
bool quickImports = true;
|
|
|
|
bool translations = true;
|
|
|
|
bool systemD3dCompiler = true;
|
|
|
|
bool compilerRunTime = false;
|
|
|
|
AngleDetection angleDetection = AngleDetectionAuto;
|
|
|
|
bool softwareRasterizer = true;
|
|
|
|
Platform platform = Windows;
|
|
|
|
quint64 additionalLibraries = 0;
|
|
|
|
quint64 disabledLibraries = 0;
|
|
|
|
unsigned updateFileFlags = 0;
|
|
|
|
QStringList qmlDirectories; // Project's QML files.
|
|
|
|
QString directory;
|
|
|
|
QString translationsDirectory; // Translations target directory
|
|
|
|
QString libraryDirectory;
|
|
|
|
QString pluginDirectory;
|
|
|
|
QStringList binaries;
|
|
|
|
JsonOutput *json = nullptr;
|
|
|
|
ListOption list = ListNone;
|
|
|
|
DebugDetection debugDetection = DebugDetectionAuto;
|
|
|
|
bool deployPdb = false;
|
|
|
|
bool dryRun = false;
|
|
|
|
bool patchQt = true;
|
|
|
|
|
|
|
|
inline bool isWinRt() const {
|
|
|
|
return platform == WinRtArm || platform == WinRtIntel;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-11-15 18:00:23 +03:00
|
|
|
WinDependenciesScanner::WinDependenciesScanner() {}
|
|
|
|
|
2018-11-23 14:56:55 +03:00
|
|
|
void WinDependenciesScanner::setEnvironment(const QStringList &env) {
|
2018-11-18 17:22:05 +03:00
|
|
|
QDir dir;
|
2018-11-23 14:56:55 +03:00
|
|
|
for (auto i : env) {
|
2018-11-18 17:22:05 +03:00
|
|
|
dir.setPath(i);
|
|
|
|
if (!dir.exists()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-11-23 14:56:55 +03:00
|
|
|
auto list = dir.entryInfoList(QStringList() << "*.dll",
|
2018-11-18 17:22:05 +03:00
|
|
|
QDir::Files| QDir::NoDotAndDotDot);
|
|
|
|
|
2018-11-23 14:56:55 +03:00
|
|
|
for (auto i : list) {
|
|
|
|
_EnvLibs.insert(i.fileName(), i.absoluteFilePath());
|
|
|
|
}
|
2018-11-18 17:22:05 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-26 16:17:46 +03:00
|
|
|
Platform WinDependenciesScanner::platformFromMkSpec(const QString &xSpec)
|
|
|
|
{
|
|
|
|
if (xSpec == QLatin1String("linux-g++"))
|
|
|
|
return Unix;
|
|
|
|
if (xSpec.startsWith(QLatin1String("win32-")))
|
|
|
|
return xSpec.contains(QLatin1String("g++")) ? WindowsMinGW : Windows;
|
|
|
|
if (xSpec.startsWith(QLatin1String("winrt-x")))
|
|
|
|
return WinRtIntel;
|
|
|
|
if (xSpec.startsWith(QLatin1String("winrt-arm")))
|
|
|
|
return WinRtArm;
|
|
|
|
if (xSpec.startsWith(QLatin1String("wince"))) {
|
|
|
|
if (xSpec.contains(QLatin1String("-x86-")))
|
|
|
|
return WinCEIntel;
|
|
|
|
if (xSpec.contains(QLatin1String("-arm")))
|
|
|
|
return WinCEArm;
|
|
|
|
}
|
|
|
|
return UnknownPlatform;
|
|
|
|
}
|
|
|
|
|
2018-11-26 21:53:44 +03:00
|
|
|
QStringList WinDependenciesScanner::scan(const QString &path, Platform platfr) {
|
2018-11-18 17:22:05 +03:00
|
|
|
QStringList result;
|
|
|
|
|
2018-11-26 16:17:46 +03:00
|
|
|
QString errorMessage;
|
|
|
|
|
2018-12-01 21:04:52 +03:00
|
|
|
if (platfr == Platform::UnknownPlatform) {
|
|
|
|
|
|
|
|
const QMap<QString, QString> qmakeVariables = queryQMakeAll(&errorMessage);
|
|
|
|
const QString xSpec = qmakeVariables.value(QStringLiteral("QMAKE_XSPEC"));
|
|
|
|
platfr = platformFromMkSpec(xSpec);
|
|
|
|
}
|
|
|
|
|
2018-11-26 16:17:46 +03:00
|
|
|
QStringList dep;
|
2018-11-26 21:53:44 +03:00
|
|
|
readExecutable(path, platfr, &errorMessage, &dep);
|
2018-11-26 16:17:46 +03:00
|
|
|
|
|
|
|
if (!errorMessage.isEmpty()) {
|
|
|
|
qCritical() << errorMessage;
|
|
|
|
return result;
|
|
|
|
}
|
2018-11-18 17:22:05 +03:00
|
|
|
|
2018-11-23 14:56:55 +03:00
|
|
|
for (auto i : dep) {
|
|
|
|
QString lib(i);
|
|
|
|
if (_EnvLibs.count(lib)) {
|
|
|
|
result.push_back(_EnvLibs.value(lib));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-18 17:22:05 +03:00
|
|
|
return result;
|
2018-11-15 18:00:23 +03:00
|
|
|
}
|
2018-11-23 14:56:55 +03:00
|
|
|
|
|
|
|
WinDependenciesScanner::~WinDependenciesScanner() {
|
|
|
|
|
|
|
|
}
|