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

This commit is contained in:
2020-03-18 20:51:52 +00:00
parent 3de59d471e
commit 4f97c5b21a

View File

@@ -33,7 +33,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> [-p <qt_plugins>] [-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 << "Usage:" << Default << "\"deploy_tool [-hvfC] [--dependencies] -o <out_path> [-p <qt_plugins>] [-s <search_path>] [-S <styles>] [-l <ldd>] [-D <dpkg>] [-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";
@@ -46,6 +46,7 @@ void usage() {
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 <dpkg> " << Green << "- \"dpkg\" path, default \"/usr/bin/dpkg\"";
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\"";
@@ -54,6 +55,7 @@ void usage() {
piCout << Bold << "Output control";
piCout << "-o <out_path> " << Green << "- path for libraries copy to";
piCout << "-p <qt_plugins> " << Green << "- path for Qt plugins, default \"<out_path>/plugins\"";
piCout << "--dependencies " << Green << "- don`t copy, only search dependencies by <dpkg> and print them";
piCout << "";
piCout << Bold << "Input control";
piCout << "<file> " << Green << "- executable to process";
@@ -64,10 +66,10 @@ void usage() {
int depth = 1;
bool need_qt = false, fake = false, is_ldd = true;
PIString ldd, readelf, objdump, otool, out_dir, qt_dir, out_plugins_dir;
bool need_qt = false, fake = false, is_ldd = true, is_deps = false;
PIString ldd, readelf, objdump, otool, dpkg, out_dir, qt_dir, out_plugins_dir;
PIStringList styles, lib_dirs, add_libs, platforms;
PISet<PIString> all_libs, miss_libs, frameworks, miss_frameworks;
PISet<PIString> all_libs, miss_libs, all_deps, frameworks, miss_frameworks;
PIString findLib(const PIString & l) {
@@ -84,7 +86,7 @@ PIString findLib(const PIString & l) {
void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
++cur_depth;
if (cur_depth > depth) return;
piCout << "scan" << file << "..." << cur_depth;
piCout << "scan" << file << "...";
PISet<PIString> cur_libs;
if (ext_lib) {
if (!all_libs[file]) {
@@ -278,6 +280,28 @@ void procQt() {
}
void procDpkg(const PIString & l) {
PIString vs, cmd = dpkg + " -S " + l;
FILE * fp = popen(cmd.dataAscii(), "r");
if (fp) {
const int sz = 256;
char in[sz];
memset(in, 0, sz);
while (true) {
int r = fread(in, 1, sz, fp);
if (r <= 0) break;
vs += PIString(in, r);
}
pclose(fp);
}
if (!vs.isEmpty()) {
vs = vs.left(vs.find(":"));
if (!vs.isEmpty())
all_deps << vs;
}
}
int main(int argc, char * argv[]) {
PICLI cli(argc, argv);
//piCout << cli.rawArguments();
@@ -286,6 +310,7 @@ int main(int argc, char * argv[]) {
cli.addArgument("verbose");
cli.addArgument("Conf");
cli.addArgument("fake");
cli.addArgument("dependencies", PIChar('\0'));
cli.addArgument("output", true);
cli.addArgument("pqt_out_plugins", true);
cli.addArgument("search_path", true);
@@ -295,6 +320,7 @@ int main(int argc, char * argv[]) {
cli.addArgument("Lreadelf", true);
cli.addArgument("Wobjdump", true);
cli.addArgument("Motool", true);
cli.addArgument("Dpkg", true);
cli.addArgument("depth", true);
cli.addArgument("qtdir", true);
cli.addArgument("add_libs", true);
@@ -306,6 +332,7 @@ int main(int argc, char * argv[]) {
piDebug = cli.hasArgument("verbose");
fake = cli.hasArgument("fake");
is_deps = cli.hasArgument("dependencies");
PIString bin = cli.optionalArguments()[0];
out_dir = cli.argumentValue("output");
lib_dirs = cli.argumentValue("search_path").split(";");
@@ -315,6 +342,7 @@ int main(int argc, char * argv[]) {
readelf = cli.argumentValue("Lreadelf");
objdump = cli.argumentValue("Wobjdump");
otool = cli.argumentValue("Motool");
dpkg = cli.argumentValue("Dpkg");
out_plugins_dir = out_dir + "plugins/";
if (!cli.argumentValue("pqt_out_plugins").isEmpty()) {
out_plugins_dir = cli.argumentValue("pqt_out_plugins");
@@ -351,7 +379,7 @@ int main(int argc, char * argv[]) {
piCout << s << "->" << findLib(s);
procLdd(findLib(s), true);
}
if (need_qt)
if (need_qt && !is_deps)
procQt();
#ifdef WINDOWS
@@ -362,9 +390,13 @@ int main(int argc, char * argv[]) {
#ifdef WINDOWS
l.replaceAll("/", "\\");
#endif
piCout << "copy" << l;
if (!fake)
system(cmd_copy + "\"" + l + "\" \"" + out_dir + "\"" + cmd_suffix);
if (is_deps)
procDpkg(l);
else {
piCout << "copy" << l;
if (!fake)
system(cmd_copy + "\"" + l + "\" \"" + out_dir + "\"" + cmd_suffix);
}
}
PIVector<PIString> fwdirs = frameworks.toVector();
piForeachC (PIString & f, fwdirs) {
@@ -377,11 +409,15 @@ int main(int argc, char * argv[]) {
miss_frameworks << f;
}
piCout << "copied" << clibs.size_s() << "files";
if (!miss_libs.isEmpty())
piCout << "Missing libraries:\n - " << PIStringList(miss_libs.toVector()).join("\n - ");
if (!miss_frameworks.isEmpty())
piCout << "Missing frameworks:\n - " << PIStringList(miss_frameworks.toVector()).join("\n - ");
if (is_deps) {
PICout(PICoutManipulators::AddNewLine) << PIStringList(all_deps.toVector()).join(", ");
} else {
piCout << "copied" << clibs.size_s() << "files";
if (!miss_libs.isEmpty())
piCout << "Missing libraries:\n - " << PIStringList(miss_libs.toVector()).join("\n - ");
if (!miss_frameworks.isEmpty())
piCout << "Missing frameworks:\n - " << PIStringList(miss_frameworks.toVector()).join("\n - ");
}
return 0;
}