git-svn-id: svn://db.shs.com.ru/libs@779 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -5,18 +5,18 @@
|
||||
using namespace PICoutManipulators;
|
||||
|
||||
PIString cmd_copy;
|
||||
PIString qplatform;
|
||||
PIString qplatforms;
|
||||
|
||||
void setCommands() {
|
||||
#ifdef WINDOWS
|
||||
cmd_copy = "copy /y ";
|
||||
qplatform = "*windows*";
|
||||
qplatforms = "windows";
|
||||
#else
|
||||
cmd_copy = "cp -f ";
|
||||
# ifdef MAC_OS
|
||||
qplatform = "*cocoa*";
|
||||
qplatforms = "cocoa";
|
||||
# else
|
||||
qplatform = "*xcb*";
|
||||
qplatforms = "xcb";
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
@@ -25,32 +25,41 @@ void setCommands() {
|
||||
void usage() {
|
||||
piCout << Bold << "Deploy tool";
|
||||
piCout << Cyan << "Version PIP" << Bold << PIPVersion();
|
||||
piCout << Green << Bold << "Usage:" << Default << "\"deploy_tool [-hv] -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 << "";
|
||||
piCout << "Copy all dependencies of <file> to directory <out_path>";
|
||||
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 << "Details:";
|
||||
piCout << Bold << "Debug control";
|
||||
piCout << "-h " << Green << "- display this message and exit";
|
||||
piCout << "-v " << Green << "- be verbose";
|
||||
piCout << "";
|
||||
piCout << Bold << "Processing control";
|
||||
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 << "-d <depth> " << Green << "- dependepcies depth, default 1";
|
||||
piCout << "-q <qtdir> " << Green << "- path where Qt root dir, default takes from \"qmake -v\"";
|
||||
piCout << "-S <styles> " << Green << "- add Qt styles (e.g. \"oxygen,breeze\"), default \"\"";
|
||||
piCout << "-P <Platforms> " << Green << "- add Qt platform (e.g. \"windows\"), default by host system";
|
||||
piCout << "-C, --Conf " << Green << "- make \"qt.conf\"";
|
||||
//piCout << "-Q, --Qt-force " << Green << "- force add Qt root dir, default takes from \"qmake -v\"";
|
||||
piCout << "";
|
||||
piCout << Bold << "Output control";
|
||||
piCout << "-o <out_path> " << Green << "- path for libraries copy to";
|
||||
piCout << "";
|
||||
piCout << Bold << "Input control";
|
||||
piCout << "<file> " << Green << "- executable to process";
|
||||
piCout << "-a <add_libs> " << Green << "- additional libs, may be separated by \";\"";
|
||||
piCout << "-S <styles> " << Green << "- add Qt styles (e.g. \"oxygen,breeze\"), default \"\"";
|
||||
piCout << "-P <platforms> " << Green << "- add Qt platforms (e.g. \"win,mini\"), default by host system";
|
||||
piCout << "-a <add_libs> " << Green << "- additional libs, separated by \";\"";
|
||||
}
|
||||
|
||||
|
||||
int depth = 1;
|
||||
bool need_qt = false, fake = false;
|
||||
PIString ldd, readelf, objdump, out_dir, qt_dir;
|
||||
PIStringList styles, lib_dirs, add_libs, platforms;
|
||||
PISet<PIString> all_libs, miss_libs;
|
||||
@@ -140,6 +149,13 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
|
||||
l = flp;
|
||||
}
|
||||
if (all_libs[l]) continue;
|
||||
if (!need_qt) {
|
||||
PIFile::FileInfo fi;
|
||||
fi.path = l;
|
||||
PIString ln = fi.name();
|
||||
if (ln.contains("QtCore") || ln.contains("Qt5Core"))
|
||||
need_qt = true;
|
||||
}
|
||||
cur_libs << l;
|
||||
all_libs << l;
|
||||
}
|
||||
@@ -151,6 +167,7 @@ void procLdd(PIString file, bool ext_lib = false, int cur_depth = 0) {
|
||||
|
||||
void copyWildcard(const PIString & from, const PIString & to) {
|
||||
piCout << "copy" << from;
|
||||
if (fake) return;
|
||||
PIDir(to).make();
|
||||
#ifdef WINDOWS
|
||||
PIFile::FileInfo fi; fi.path = from;
|
||||
@@ -162,7 +179,7 @@ void copyWildcard(const PIString & from, const PIString & to) {
|
||||
|
||||
|
||||
void procQt() {
|
||||
piCout << "qmake ...";
|
||||
//piCout << "qmake ...";
|
||||
PIString vs;
|
||||
if (qt_dir.isEmpty()) {
|
||||
FILE * fp = popen("qmake -v", "r");
|
||||
@@ -205,7 +222,9 @@ void procQt() {
|
||||
piForeachC (PIString & p, pdirs) {
|
||||
copyWildcard(qdir + p + "/*", out_plugins_dir + p);
|
||||
}
|
||||
copyWildcard(qdir + "platforms/" + qplatform, out_plugins_dir + "platforms");
|
||||
piForeachC (PIString & s, platforms) {
|
||||
copyWildcard(qdir + "platforms/*" + s + "*", out_plugins_dir + "platforms");
|
||||
}
|
||||
piForeachC (PIString & s, styles) {
|
||||
copyWildcard(qdir + "styles/*" + s + "*", out_plugins_dir + "styles");
|
||||
}
|
||||
@@ -228,6 +247,8 @@ int main(int argc, char * argv[]) {
|
||||
cli.setOptionalArgumentsCount(-1);
|
||||
cli.addArgument("help");
|
||||
cli.addArgument("verbose");
|
||||
cli.addArgument("Conf");
|
||||
cli.addArgument("fake");
|
||||
cli.addArgument("output", true);
|
||||
cli.addArgument("search_path", true);
|
||||
cli.addArgument("Styles", true);
|
||||
@@ -245,6 +266,7 @@ int main(int argc, char * argv[]) {
|
||||
setCommands();
|
||||
|
||||
piDebug = cli.hasArgument("verbose");
|
||||
fake = cli.hasArgument("fake");
|
||||
PIString bin = cli.optionalArguments()[0];
|
||||
out_dir = cli.argumentValue("output");
|
||||
lib_dirs = cli.argumentValue("search_path").split(";");
|
||||
@@ -258,7 +280,8 @@ int main(int argc, char * argv[]) {
|
||||
return 1;
|
||||
}
|
||||
if (!cli.argumentValue("Platforms").isEmpty())
|
||||
qplatform = cli.argumentValue("Platforms");
|
||||
qplatforms = cli.argumentValue("Platforms");
|
||||
platforms = qplatforms.split(",");
|
||||
piForeach (PIString & s, lib_dirs) {
|
||||
if (!s.endsWith("/")) s += "/";
|
||||
}
|
||||
@@ -266,21 +289,25 @@ int main(int argc, char * argv[]) {
|
||||
if (!out_dir.endsWith("/")) out_dir += "/";
|
||||
if (ldd.isEmpty()) ldd = "/usr/bin/ldd";
|
||||
styles = cli.argumentValue("Styles").split(",");
|
||||
PIDir(out_dir).make();
|
||||
if (!fake)
|
||||
PIDir(out_dir).make();
|
||||
if (!cli.argumentValue("depth").isEmpty())
|
||||
depth = cli.argumentValue("depth").toInt();
|
||||
|
||||
if (depth > 0)
|
||||
procLdd(bin);
|
||||
piForeach (PIString & s, add_libs) {
|
||||
piCout << s << "->" << findLib(s);
|
||||
procLdd(findLib(s), true);
|
||||
}
|
||||
procQt();
|
||||
if (need_qt)
|
||||
procQt();
|
||||
|
||||
PIVector<PIString> clibs = all_libs.toVector();
|
||||
piForeachC (PIString & l, clibs) {
|
||||
piCout << "copy" << l;
|
||||
system(cmd_copy + "\"" + l + "\" \"" + out_dir + "\"");
|
||||
if (!fake)
|
||||
system(cmd_copy + "\"" + l + "\" \"" + out_dir + "\"");
|
||||
}
|
||||
piCout << "copied" << clibs.size_s() << "files";
|
||||
if (!miss_libs.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user