git-svn-id: svn://db.shs.com.ru/libs@781 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -30,7 +30,7 @@ void usage() {
|
||||
piCout << "If <file> depend on QtCore library, then copy all basic Qt plugins, ";
|
||||
piCout << "<styles> and <platform>";
|
||||
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 << Bold << "Debug control";
|
||||
piCout << "-h " << Green << "- display this message and exit";
|
||||
@@ -40,8 +40,9 @@ void usage() {
|
||||
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 << "-l <ldd> " << Green << "- \"ldd\" path, default \"/usr/bin/ldd\"";
|
||||
piCout << "-L <readelf> " << Green << "- \"*-readelf\" path, overrides \"ldd\"";
|
||||
piCout << "-O <objdump> " << Green << "- \"*-objdump\" path, overrides \"ldd\"";
|
||||
piCout << "-L <readelf> " << Green << "- \"readelf\" 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 << "-q <qtdir> " << Green << "- path where Qt root dir, default takes from \"qmake -v\"";
|
||||
piCout << "-C, --Conf " << Green << "- make \"qt.conf\"";
|
||||
@@ -59,10 +60,10 @@ void usage() {
|
||||
|
||||
|
||||
int depth = 1;
|
||||
bool need_qt = false, fake = false;
|
||||
PIString ldd, readelf, objdump, out_dir, qt_dir;
|
||||
bool need_qt = false, fake = false, is_ldd = true;
|
||||
PIString ldd, readelf, objdump, otool, out_dir, qt_dir;
|
||||
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) {
|
||||
@@ -87,7 +88,7 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
|
||||
}
|
||||
}
|
||||
PIStringList lines;
|
||||
if (readelf.isEmpty() && objdump.isEmpty()) {
|
||||
if (is_ldd) {
|
||||
PIProcess proc;
|
||||
proc.setGrabOutput(true);
|
||||
piCout << "scan" << file << "...";
|
||||
@@ -99,10 +100,15 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
|
||||
if (!readelf.isEmpty()) {
|
||||
cmd = readelf + " -a " + file;
|
||||
cmd += " | grep \"Shared library:\" | grep -oG \"\\[.*\\]\"";
|
||||
} else {
|
||||
}
|
||||
if (!objdump.isEmpty()) {
|
||||
cmd = objdump + " -p " + file;
|
||||
cmd += " | grep \"DLL Name:\"";
|
||||
}
|
||||
if (!otool.isEmpty()) {
|
||||
cmd = otool + " -L " + file;
|
||||
cmd += " | grep -o \".*(\"";
|
||||
}
|
||||
//piCout << cmd;
|
||||
FILE * fp = popen(cmd.dataAscii(), "r");
|
||||
PIString vs;
|
||||
@@ -124,11 +130,23 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
|
||||
l.append('.').prepend('.');
|
||||
}
|
||||
}
|
||||
if (!otool.isEmpty()) {
|
||||
piForeach (PIString & l, lines) {
|
||||
l.trim().cutRight(1).trim();
|
||||
l.append('.').prepend('.');
|
||||
}
|
||||
}
|
||||
//piCout << "readelf:" << vs;
|
||||
}
|
||||
piForeachC (PIString & sl, lines) {
|
||||
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;
|
||||
l.cutLeft(l.find("=>") + 2);
|
||||
if (l.contains("("))
|
||||
@@ -141,6 +159,11 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
|
||||
} else {
|
||||
l.cutLeft(1).cutRight(1);
|
||||
if (l.isEmpty()) continue;
|
||||
if (!otool.isEmpty()) {
|
||||
PIFile::FileInfo fi;
|
||||
fi.path = l;
|
||||
l = fi.name();
|
||||
}
|
||||
PIString flp = findLib(l);
|
||||
if (flp.isEmpty()) {
|
||||
piCout << "Can`t find" << l;
|
||||
@@ -254,8 +277,9 @@ int main(int argc, char * argv[]) {
|
||||
cli.addArgument("Styles", true);
|
||||
cli.addArgument("Platforms", true);
|
||||
cli.addArgument("ldd", true);
|
||||
cli.addArgument("Ldd", true);
|
||||
cli.addArgument("Objdump", true);
|
||||
cli.addArgument("Lreadelf", true);
|
||||
cli.addArgument("Wobjdump", true);
|
||||
cli.addArgument("Motool", true);
|
||||
cli.addArgument("depth", true);
|
||||
cli.addArgument("qtdir", true);
|
||||
cli.addArgument("add_libs", true);
|
||||
@@ -273,12 +297,18 @@ int main(int argc, char * argv[]) {
|
||||
add_libs = cli.argumentValue("add_libs").split(";");
|
||||
qt_dir = cli.argumentValue("qtdir");
|
||||
ldd = cli.argumentValue("ldd");
|
||||
readelf = cli.argumentValue("Ldd");
|
||||
objdump = cli.argumentValue("Objdump");
|
||||
if (!readelf.isEmpty() && !objdump.isEmpty()) {
|
||||
piCout << "Can`t you both \"readelf\" and \"objdump\"!";
|
||||
readelf = cli.argumentValue("Lreadelf");
|
||||
objdump = cli.argumentValue("Wobjdump");
|
||||
otool = cli.argumentValue("Motool");
|
||||
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;
|
||||
}
|
||||
if (etcnt > 0) is_ldd = false;
|
||||
if (!cli.argumentValue("Platforms").isEmpty())
|
||||
qplatforms = cli.argumentValue("Platforms");
|
||||
platforms = qplatforms.split(",");
|
||||
|
||||
Reference in New Issue
Block a user