mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-28 02:34:34 +00:00
fix #91 added elf and pe readers
This commit is contained in:
parent
9976120671
commit
67c38112e8
@ -46,7 +46,9 @@ SOURCES += \
|
||||
pe.cpp \
|
||||
igetlibinfo.cpp \
|
||||
structs.cpp \
|
||||
dependenciesscanner.cpp
|
||||
dependenciesscanner.cpp \
|
||||
../qtTools/src/windeployqt/elfreader.cpp \
|
||||
elf.cpp
|
||||
|
||||
HEADERS += \
|
||||
deploy.h \
|
||||
@ -55,4 +57,6 @@ HEADERS += \
|
||||
pe.h \
|
||||
igetlibinfo.h \
|
||||
structs.h \
|
||||
dependenciesscanner.h
|
||||
dependenciesscanner.h \
|
||||
../qtTools/src/windeployqt/elfreader.h \
|
||||
elf.h
|
||||
|
@ -33,12 +33,15 @@ PrivateScaner DependenciesScanner::getScaner(const QString &lib) const {
|
||||
|
||||
bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) {
|
||||
|
||||
info.clear();
|
||||
auto scaner = getScaner(file);
|
||||
|
||||
switch (scaner) {
|
||||
case PrivateScaner::PE: {
|
||||
return _peScaner.getLibInfo(file, info);
|
||||
}
|
||||
case PrivateScaner::ELF:
|
||||
return _elfScaner.getLibInfo(file, info);
|
||||
|
||||
default: return false;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "deploy_global.h"
|
||||
#include "structs.h"
|
||||
#include "pe.h"
|
||||
#include "elf.h"
|
||||
|
||||
enum class PrivateScaner: unsigned char {
|
||||
UNKNOWN,
|
||||
@ -28,6 +29,7 @@ private:
|
||||
QMap<QString, QString> _EnvLibs;
|
||||
|
||||
PE _peScaner;
|
||||
ELF _elfScaner;
|
||||
|
||||
PrivateScaner getScaner(const QString& lib) const;
|
||||
|
||||
|
32
Deploy/elf.cpp
Normal file
32
Deploy/elf.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "elf.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
ELF::ELF()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ELF::getLibInfo(const QString &lib, LibInfo &info) {
|
||||
ElfReader reader(lib);
|
||||
|
||||
auto headers = reader.readHeaders();
|
||||
|
||||
if (headers.elfclass == ElfClass::Elf_ELFCLASS32) {
|
||||
info.platform = Unix32;
|
||||
} else if (headers.elfclass == ElfClass::Elf_ELFCLASS64) {
|
||||
info.platform = Unix64;
|
||||
} else {
|
||||
info.platform = UnknownPlatform;
|
||||
return false;
|
||||
}
|
||||
|
||||
info.name = QFileInfo(lib).fileName();
|
||||
info.path = QFileInfo(lib).absolutePath();
|
||||
|
||||
for (auto &i : reader.dependencies()) {
|
||||
info.dependncies.push_back(i);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
17
Deploy/elf.h
Normal file
17
Deploy/elf.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef ELF_H
|
||||
#define ELF_H
|
||||
#include "../qtTools/src/windeployqt/elfreader.h"
|
||||
|
||||
#include "igetlibinfo.h"
|
||||
|
||||
|
||||
class ELF : public IGetLibInfo
|
||||
{
|
||||
|
||||
public:
|
||||
ELF();
|
||||
|
||||
bool getLibInfo(const QString &lib, LibInfo &info);
|
||||
};
|
||||
|
||||
#endif // ELF_H
|
@ -9,6 +9,13 @@ QString LibInfo::fullPath() {
|
||||
return path + "/" + name;
|
||||
}
|
||||
|
||||
void LibInfo::clear() {
|
||||
path = "";
|
||||
name = "";
|
||||
platform = Platform::UnknownPlatform;
|
||||
dependncies.clear();
|
||||
}
|
||||
|
||||
bool LibInfo::isValid() const {
|
||||
return platform != Platform::UnknownPlatform &&
|
||||
name.size() && path.size();
|
||||
|
@ -8,7 +8,8 @@ enum Platform {
|
||||
UnknownPlatform = 0x0,
|
||||
Win32,
|
||||
Win64,
|
||||
Unix
|
||||
Unix32,
|
||||
Unix64
|
||||
};
|
||||
|
||||
struct LibInfo {
|
||||
@ -21,6 +22,8 @@ struct LibInfo {
|
||||
|
||||
QString fullPath();
|
||||
|
||||
void clear();
|
||||
|
||||
bool isValid() const;
|
||||
};
|
||||
|
||||
|
@ -42,13 +42,8 @@ void LibCreator::initLinux64() {
|
||||
"libstdc++.so.6",
|
||||
"libgcc_s.so.1",
|
||||
"libc.so.6",
|
||||
"libgcc_s.so.1",
|
||||
"libQt5Core.so.5",
|
||||
"libc.so.6",
|
||||
"libQt5Network.so.5",
|
||||
"libstdc++.so.6:",
|
||||
},
|
||||
Platform::Unix);
|
||||
Platform::Unix64);
|
||||
createLib(":/linux64.so", {
|
||||
"libQt5Core.so.5",
|
||||
"libpthread.so.0",
|
||||
@ -56,11 +51,9 @@ void LibCreator::initLinux64() {
|
||||
"libm.so.6",
|
||||
"libgcc_s.so.1",
|
||||
"libc.so.6",
|
||||
"libSignalProcessorCommon.so.1",
|
||||
"libc.so.6",
|
||||
"libQt5Core.so.5",
|
||||
|
||||
},
|
||||
Platform::Unix);
|
||||
Platform::Unix64);
|
||||
|
||||
}
|
||||
|
||||
@ -176,7 +169,7 @@ LibCreator::LibCreator(const QString &path) {
|
||||
this->path = path;
|
||||
initWin32();
|
||||
initWin64();
|
||||
//initLinux64();
|
||||
initLinux64();
|
||||
}
|
||||
|
||||
const QStringList &LibCreator::getLibs() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user