use otool -l instead of otool -L to collect dynamic library dependencies
This commit is contained in:
parent
c589a4fcaf
commit
63b13daf4f
|
@ -198,8 +198,8 @@ void addDependency(std::string path, std::string filename)
|
||||||
*/
|
*/
|
||||||
void collectDependencies(std::string filename, std::vector<std::string>& lines)
|
void collectDependencies(std::string filename, std::vector<std::string>& lines)
|
||||||
{
|
{
|
||||||
// execute "otool -L" on the given file and collect the command's output
|
// execute "otool -l" on the given file and collect the command's output
|
||||||
std::string cmd = "otool -L " + filename;
|
std::string cmd = "otool -l " + filename;
|
||||||
std::string output = system_get_output(cmd);
|
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)
|
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
|
// split output
|
||||||
tokenize(output, "\n", &lines);
|
std::vector<std::string> raw_lines;
|
||||||
deps_collected[filename] = true;
|
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);
|
addDependency(dep_path, filename);
|
||||||
}
|
}
|
||||||
|
deps_collected[filename] = true;
|
||||||
}
|
}
|
||||||
void collectSubDependencies()
|
void collectSubDependencies()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue