From 722705b2e18750e507a0aad4693693ed0393fe36 Mon Sep 17 00:00:00 2001 From: peri4 Date: Sun, 18 Apr 2021 19:16:23 +0300 Subject: [PATCH] deploy_tool --- utils/deploy_tool/main.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/utils/deploy_tool/main.cpp b/utils/deploy_tool/main.cpp index 9ec517e6..4e5d5f73 100644 --- a/utils/deploy_tool/main.cpp +++ b/utils/deploy_tool/main.cpp @@ -66,7 +66,7 @@ void usage() { piCout << Green << Bold << "Usage:" << Default << "\"deploy_tool [-hvfC] [--dependencies [--prefix ]] " "[--qt-plugins-dir ] [-s ] [--ignore ] [-S ] " "[-l ] [-D ] [--dpkg-workdir ] [-L | -W | -M ] " - "[--name-tool ] [-d ] [-q ] [-a ] [-S ] " + "[--name-tool ] [--rpath ] [-d ] [-q ] [-a ] [-S ] " "[-P ] [--qt-plugins ] [--qt-modules ] [--qt-conf-dir ] -o [ ...]\"" << NewLine; piCout << Green << Bold << "Details:"; piCout << Bold << "Debug control"; @@ -85,6 +85,7 @@ void usage() { piCout << "--dpkg-workdir " << Green << "- dpkg \"admindir\" path, default \"\""; piCout << "--name-tool " << Green << "- \"install_name_tool\" path, default \"install_name_tool\""; piCout << "--strip " << Green << "- \"strip\" path, default \"strip\""; + piCout << "--rpath " << Green << "- set rpath for input files to \"rpath\" using \"patchelf\" if non-empty"; piCout << "-d " << Green << "- maximum dependepcies depth, default 8"; piCout << ""; piCout << Bold << "Qt control"; @@ -131,7 +132,7 @@ QtDep qt_deps[] = { int depth = 8; bool fake = false, is_ldd = true, is_deps = false, need_qt = false, make_qt_format = true; PIString ldd, readelf, objdump, otool, dpkg, nametool, strip, out_dir, qt_dir, dpkg_workdir; -PIString qt_pref, qt_suff, qt_conf_dir, qt_plugins_dir; +PIString qt_pref, qt_suff, qt_conf_dir, qt_plugins_dir, rpath; PIStringList styles, lib_dirs, add_libs, platforms, sqldrivers, input_files, plugin_libs, qt_add_libs; PISet all_libs, miss_libs, all_deps, frameworks, framework_libs, miss_frameworks, qt_plugins, ignore_libs, qt_libs; PIMap qt_filters; @@ -489,6 +490,13 @@ void patchNameTool() { } +void patchRPath(const PIString & file) { + PIString cmd = "patchelf --set-rpath \"" + rpath + "\" \"" + file + "\""; + piCout << "set rpath" << file << cmd; + execute(cmd); +} + + int main(int argc, char * argv[]) { PICLI cli(argc, argv); //piCout << cli.rawArguments(); @@ -513,6 +521,7 @@ int main(int argc, char * argv[]) { cli.addArgument("Wobjdump", true); cli.addArgument("Motool", true); cli.addArgument("name-tool", PIChar('\0'), true); + cli.addArgument("rpath", PIChar('\0'), true); cli.addArgument("strip", PIChar('\0'), true); cli.addArgument("Dpkg", true); cli.addArgument("dpkg-workdir", PIChar('\0'), true); @@ -539,6 +548,7 @@ int main(int argc, char * argv[]) { otool = cli.argumentValue("Motool"); nametool = cli.argumentValue("name-tool"); strip = cli.argumentValue("strip"); + rpath = cli.argumentValue("rpath"); if (nametool.isEmpty()) nametool = "install_name_tool"; if (strip.isEmpty()) @@ -642,6 +652,13 @@ int main(int argc, char * argv[]) { input_files << a; } }); + + if (!rpath.isEmpty()) { + input_files.forEach([&](const PIString & f){ + patchRPath(f); + }); + } + //piCout << files; if (depth > 0) { input_files.forEach([&](const PIString & f){procLdd(f);});