switch from vector to set for rpaths_per_file
This commit is contained in:
parent
d14215f1db
commit
a18ba5fdd3
|
@ -160,13 +160,13 @@ void changeLibPathsOnFile(const std::string& file_to_fix)
|
|||
|
||||
void fixRpathsOnFile(const std::string& original_file, const std::string& file_to_fix)
|
||||
{
|
||||
std::vector<std::string> rpaths_to_fix;
|
||||
std::set<std::string> rpaths_to_fix;
|
||||
if (Settings::fileHasRpath(original_file))
|
||||
rpaths_to_fix = Settings::getRpathsForFile(original_file);
|
||||
|
||||
for (const auto& i : rpaths_to_fix) {
|
||||
for (const auto& rpath_to_fix : rpaths_to_fix) {
|
||||
std::string command = std::string("install_name_tool -rpath ");
|
||||
command += i + " " + Settings::insideLibPath() + " " + file_to_fix;
|
||||
command += rpath_to_fix + " " + Settings::insideLibPath() + " " + file_to_fix;
|
||||
if (systemp(command) != 0) {
|
||||
std::cerr << "\n\n/!\\ ERROR: An error occured while trying to fix dependencies of " << file_to_fix << "\n";
|
||||
exit(1);
|
||||
|
|
|
@ -165,9 +165,9 @@ std::string getFullPath(const std::string& rpath) { return rpath_to_fullpath[rpa
|
|||
void rpathToFullPath(const std::string& rpath, const std::string& fullpath) { rpath_to_fullpath[rpath] = fullpath; }
|
||||
bool rpathFound(const std::string& rpath) { return rpath_to_fullpath.find(rpath) != rpath_to_fullpath.end(); }
|
||||
|
||||
std::map<std::string, std::vector<std::string>> rpaths_per_file;
|
||||
std::vector<std::string> getRpathsForFile(const std::string& file) { return rpaths_per_file[file]; }
|
||||
void addRpathForFile(const std::string& file, const std::string& rpath) { rpaths_per_file[file].push_back(rpath); }
|
||||
std::map<std::string, std::set<std::string>> rpaths_per_file;
|
||||
std::set<std::string> getRpathsForFile(const std::string& file) { return rpaths_per_file[file]; }
|
||||
void addRpathForFile(const std::string& file, const std::string& rpath) { rpaths_per_file[file].insert(rpath); }
|
||||
bool fileHasRpath(const std::string& file) { return rpaths_per_file.find(file) != rpaths_per_file.end(); }
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#ifndef _settings_
|
||||
#define _settings_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -69,7 +70,7 @@ std::string getFullPath(const std::string& rpath);
|
|||
void rpathToFullPath(const std::string& rpath, const std::string& fullpath);
|
||||
bool rpathFound(const std::string& rpath);
|
||||
|
||||
std::vector<std::string> getRpathsForFile(const std::string& file);
|
||||
std::set<std::string> getRpathsForFile(const std::string& file);
|
||||
void addRpathForFile(const std::string& file, const std::string& rpath);
|
||||
bool fileHasRpath(const std::string& file);
|
||||
|
||||
|
|
|
@ -354,10 +354,9 @@ std::string searchFilenameInRpaths(const std::string& rpath_file, const std::str
|
|||
|
||||
std::string fullpath;
|
||||
std::string suffix = rpath_file.substr(rpath_file.rfind('/')+1);
|
||||
char fullpath_buffer[PATH_MAX];
|
||||
char buffer[PATH_MAX];
|
||||
|
||||
const auto check_path = [&](std::string path) {
|
||||
char buffer[PATH_MAX];
|
||||
std::string file_prefix = filePrefix(dependent_file);
|
||||
if (path.find("@executable_path") != std::string::npos || path.find("@loader_path") != std::string::npos) {
|
||||
if (path.find("@executable_path") != std::string::npos) {
|
||||
|
@ -436,8 +435,8 @@ std::string searchFilenameInRpaths(const std::string& rpath_file, const std::str
|
|||
fullpath = getUserInputDirForFile(suffix, dependent_file) + suffix;
|
||||
if (Settings::quietOutput() && fullpath.empty())
|
||||
std::cerr << "\n/!\\ WARNING: Can't get path for '" << rpath_file << "'\n";
|
||||
if (realpath(fullpath.c_str(), fullpath_buffer))
|
||||
fullpath = fullpath_buffer;
|
||||
if (realpath(fullpath.c_str(), buffer))
|
||||
fullpath = buffer;
|
||||
}
|
||||
else if (Settings::verboseOutput()) {
|
||||
std::cout << " ** rpath fullpath: " << fullpath << std::endl;
|
||||
|
|
Loading…
Reference in New Issue