diff options
author | auriamg <auria.mg@gmail.com> | 2020-01-17 06:34:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-17 06:34:37 +0300 |
commit | 3be4532735f84cd88f55a5cda93d4d562f8cdfcf (patch) | |
tree | f9a480d1ccedcf1048026a41c8122c887c787b8c | |
parent | 86bcbd3441d3cebaee78da6298c787ff03200231 (diff) | |
parent | 63b13daf4fb796dbc1490f6ebea5c86aafaa8664 (diff) |
Merge pull request #50 from SCG82/otool_l
Use otool -l to collect dylib dependencies instead of otool -L
-rw-r--r-- | src/DylibBundler.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/DylibBundler.cpp b/src/DylibBundler.cpp index 90d3792..e7bf46b 100644 --- a/src/DylibBundler.cpp +++ b/src/DylibBundler.cpp @@ -198,8 +198,8 @@ void addDependency(std::string path, std::string filename) */ void collectDependencies(std::string filename, std::vector<std::string>& lines) { - // execute "otool -L" on the given file and collect the command's output - std::string cmd = "otool -L " + filename; + // execute "otool -l" on the given file and collect the command's output + std::string cmd = "otool -l " + filename; std::string output = system_get_output(cmd); if(output.find("can't open file")!=std::string::npos or output.find("No such file")!=std::string::npos or output.size()<1) @@ -209,8 +209,30 @@ void collectDependencies(std::string filename, std::vector<std::string>& lines) } // split output - tokenize(output, "\n", &lines); - deps_collected[filename] = true; + std::vector<std::string> raw_lines; + tokenize(output, "\n", &raw_lines); + + bool searching = false; + for(const auto& line : raw_lines) { + if (line.find("cmd LC_LOAD_DYLIB") != std::string::npos) + { + if (searching) + { + std::cerr << "\n\n/!\\ ERROR: Failed to find name before next cmd" << std::endl; + exit(1); + } + searching = true; + } + else if (searching) + { + size_t found = line.find("name "); + if (found != std::string::npos) + { + lines.push_back('\t' + line.substr(found+5, std::string::npos)); + searching = false; + } + } + } } @@ -237,6 +259,7 @@ void collectDependencies(std::string filename) addDependency(dep_path, filename); } + deps_collected[filename] = true; } void collectSubDependencies() { |