git-svn-id: svn://db.shs.com.ru/libs@781 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2020-03-14 19:17:15 +00:00
parent f7fcb4987c
commit 72ab31a2e1

View File

@@ -30,7 +30,7 @@ void usage() {
piCout << "If <file> depend on QtCore library, then copy all basic Qt plugins, "; piCout << "If <file> depend on QtCore library, then copy all basic Qt plugins, ";
piCout << "<styles> and <platform>"; piCout << "<styles> and <platform>";
piCout << ""; piCout << "";
piCout << Green << Bold << "Usage:" << Default << "\"deploy_tool [-hvfC] -o <out_path> [-s <search_path>] [-S <styles>] [-l <ldd>] [-L <readelf> | -O <objdump>] [-d <depth>] [-q <qtdir>] [-a <add_libs>] [-S <styles>] [-P <platforms>] <file>\"" << NewLine; piCout << Green << Bold << "Usage:" << Default << "\"deploy_tool [-hvfC] -o <out_path> [-s <search_path>] [-S <styles>] [-l <ldd>] [-L <readelf> | -W <objdump> | -M <otool>] [-d <depth>] [-q <qtdir>] [-a <add_libs>] [-S <styles>] [-P <platforms>] <file>\"" << NewLine;
piCout << Green << Bold << "Details:"; piCout << Green << Bold << "Details:";
piCout << Bold << "Debug control"; piCout << Bold << "Debug control";
piCout << "-h " << Green << "- display this message and exit"; piCout << "-h " << Green << "- display this message and exit";
@@ -40,8 +40,9 @@ void usage() {
piCout << "-f, --fake " << Green << "- don`t copy, only print"; piCout << "-f, --fake " << Green << "- don`t copy, only print";
piCout << "-s <search_path> " << Green << "- set search pathes for system libraries, may be separated by \";\", default \"/usr/lib\""; piCout << "-s <search_path> " << Green << "- set search pathes for system libraries, may be separated by \";\", default \"/usr/lib\"";
piCout << "-l <ldd> " << Green << "- \"ldd\" path, default \"/usr/bin/ldd\""; piCout << "-l <ldd> " << Green << "- \"ldd\" path, default \"/usr/bin/ldd\"";
piCout << "-L <readelf> " << Green << "- \"*-readelf\" path, overrides \"ldd\""; piCout << "-L <readelf> " << Green << "- \"readelf\" path, overrides \"ldd\"";
piCout << "-O <objdump> " << Green << "- \"*-objdump\" path, overrides \"ldd\""; piCout << "-W <objdump> " << Green << "- \"objdump\" path, overrides \"ldd\"";
piCout << "-M <otool> " << Green << "- \"otool\" path, overrides \"ldd\"";
piCout << "-d <depth> " << Green << "- dependepcies depth, default 1"; piCout << "-d <depth> " << Green << "- dependepcies depth, default 1";
piCout << "-q <qtdir> " << Green << "- path where Qt root dir, default takes from \"qmake -v\""; piCout << "-q <qtdir> " << Green << "- path where Qt root dir, default takes from \"qmake -v\"";
piCout << "-C, --Conf " << Green << "- make \"qt.conf\""; piCout << "-C, --Conf " << Green << "- make \"qt.conf\"";
@@ -59,10 +60,10 @@ void usage() {
int depth = 1; int depth = 1;
bool need_qt = false, fake = false; bool need_qt = false, fake = false, is_ldd = true;
PIString ldd, readelf, objdump, out_dir, qt_dir; PIString ldd, readelf, objdump, otool, out_dir, qt_dir;
PIStringList styles, lib_dirs, add_libs, platforms; PIStringList styles, lib_dirs, add_libs, platforms;
PISet<PIString> all_libs, miss_libs; PISet<PIString> all_libs, miss_libs, frameworks;
PIString findLib(const PIString & l) { PIString findLib(const PIString & l) {
@@ -87,7 +88,7 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
} }
} }
PIStringList lines; PIStringList lines;
if (readelf.isEmpty() && objdump.isEmpty()) { if (is_ldd) {
PIProcess proc; PIProcess proc;
proc.setGrabOutput(true); proc.setGrabOutput(true);
piCout << "scan" << file << "..."; piCout << "scan" << file << "...";
@@ -99,10 +100,15 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
if (!readelf.isEmpty()) { if (!readelf.isEmpty()) {
cmd = readelf + " -a " + file; cmd = readelf + " -a " + file;
cmd += " | grep \"Shared library:\" | grep -oG \"\\[.*\\]\""; cmd += " | grep \"Shared library:\" | grep -oG \"\\[.*\\]\"";
} else { }
if (!objdump.isEmpty()) {
cmd = objdump + " -p " + file; cmd = objdump + " -p " + file;
cmd += " | grep \"DLL Name:\""; cmd += " | grep \"DLL Name:\"";
} }
if (!otool.isEmpty()) {
cmd = otool + " -L " + file;
cmd += " | grep -o \".*(\"";
}
//piCout << cmd; //piCout << cmd;
FILE * fp = popen(cmd.dataAscii(), "r"); FILE * fp = popen(cmd.dataAscii(), "r");
PIString vs; PIString vs;
@@ -124,11 +130,23 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
l.append('.').prepend('.'); l.append('.').prepend('.');
} }
} }
if (!otool.isEmpty()) {
piForeach (PIString & l, lines) {
l.trim().cutRight(1).trim();
l.append('.').prepend('.');
}
}
//piCout << "readelf:" << vs; //piCout << "readelf:" << vs;
} }
piForeachC (PIString & sl, lines) { piForeachC (PIString & sl, lines) {
PIString l = sl.trimmed(); PIString l = sl.trimmed();
if (readelf.isEmpty() && objdump.isEmpty()) { if (!otool.isEmpty()) {
if (l.contains(".framework/")) {
frameworks << l;
continue;
}
}
if (is_ldd) {
if (!l.contains("=>")) continue; if (!l.contains("=>")) continue;
l.cutLeft(l.find("=>") + 2); l.cutLeft(l.find("=>") + 2);
if (l.contains("(")) if (l.contains("("))
@@ -141,6 +159,11 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
} else { } else {
l.cutLeft(1).cutRight(1); l.cutLeft(1).cutRight(1);
if (l.isEmpty()) continue; if (l.isEmpty()) continue;
if (!otool.isEmpty()) {
PIFile::FileInfo fi;
fi.path = l;
l = fi.name();
}
PIString flp = findLib(l); PIString flp = findLib(l);
if (flp.isEmpty()) { if (flp.isEmpty()) {
piCout << "Can`t find" << l; piCout << "Can`t find" << l;
@@ -254,8 +277,9 @@ int main(int argc, char * argv[]) {
cli.addArgument("Styles", true); cli.addArgument("Styles", true);
cli.addArgument("Platforms", true); cli.addArgument("Platforms", true);
cli.addArgument("ldd", true); cli.addArgument("ldd", true);
cli.addArgument("Ldd", true); cli.addArgument("Lreadelf", true);
cli.addArgument("Objdump", true); cli.addArgument("Wobjdump", true);
cli.addArgument("Motool", true);
cli.addArgument("depth", true); cli.addArgument("depth", true);
cli.addArgument("qtdir", true); cli.addArgument("qtdir", true);
cli.addArgument("add_libs", true); cli.addArgument("add_libs", true);
@@ -273,12 +297,18 @@ int main(int argc, char * argv[]) {
add_libs = cli.argumentValue("add_libs").split(";"); add_libs = cli.argumentValue("add_libs").split(";");
qt_dir = cli.argumentValue("qtdir"); qt_dir = cli.argumentValue("qtdir");
ldd = cli.argumentValue("ldd"); ldd = cli.argumentValue("ldd");
readelf = cli.argumentValue("Ldd"); readelf = cli.argumentValue("Lreadelf");
objdump = cli.argumentValue("Objdump"); objdump = cli.argumentValue("Wobjdump");
if (!readelf.isEmpty() && !objdump.isEmpty()) { otool = cli.argumentValue("Motool");
piCout << "Can`t you both \"readelf\" and \"objdump\"!"; int etcnt = 0;
if (!readelf.isEmpty()) ++etcnt;
if (!objdump.isEmpty()) ++etcnt;
if (!otool.isEmpty()) ++etcnt;
if (etcnt > 1) {
piCout << "Can use only one of \"readelf\", \"objdump\" and \"otool\"!";
return 1; return 1;
} }
if (etcnt > 0) is_ldd = false;
if (!cli.argumentValue("Platforms").isEmpty()) if (!cli.argumentValue("Platforms").isEmpty())
qplatforms = cli.argumentValue("Platforms"); qplatforms = cli.argumentValue("Platforms");
platforms = qplatforms.split(","); platforms = qplatforms.split(",");