diff options
author | auriamg <auria.mg@gmail.com> | 2020-01-17 06:31:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-17 06:31:38 +0300 |
commit | 86bcbd3441d3cebaee78da6298c787ff03200231 (patch) | |
tree | 71cff018d3f68752b97e5a083b18a95beddc69fd | |
parent | c589a4fcaf704cfc247b454fa881ae2853a0d467 (diff) | |
parent | 02ce7f927eea3ab49a1eb5c436339095bafe02fb (diff) |
Merge pull request #51 from SCG82/change-name
create changeInstallName function
-rw-r--r-- | src/Dependency.cpp | 43 | ||||
-rw-r--r-- | src/Utils.cpp | 10 | ||||
-rw-r--r-- | src/Utils.h | 1 |
3 files changed, 17 insertions, 37 deletions
diff --git a/src/Dependency.cpp b/src/Dependency.cpp index 32efff0..033d766 100644 --- a/src/Dependency.cpp +++ b/src/Dependency.cpp @@ -210,55 +210,24 @@ void Dependency::copyYourself() void Dependency::fixFileThatDependsOnMe(std::string file_to_fix) { // for main lib file - std::string command = std::string("install_name_tool -change ") + - getOriginalPath() + " " + getInnerPath() + " " + file_to_fix; - - if( systemp( command ) != 0 ) - { - std::cerr << "\n\nError : An error occured while trying to fix dependencies of " << file_to_fix << std::endl; - exit(1); - } - + changeInstallName(file_to_fix, getOriginalPath(), getInnerPath()); // for symlinks const int symamount = symlinks.size(); for(int n=0; n<symamount; n++) { - command = std::string("install_name_tool -change ") + - symlinks[n] + " " + getInnerPath() + " " + file_to_fix; - - if( systemp( command ) != 0 ) - { - std::cerr << "\n\nError : An error occured while trying to fix dependencies of " << file_to_fix << std::endl; - exit(1); - } + changeInstallName(file_to_fix, symlinks[n], getInnerPath()); } - // FIXME - hackish if(missing_prefixes) { // for main lib file - command = std::string("install_name_tool -change ") + - filename + " " + getInnerPath() + " " + file_to_fix; - - if( systemp( command ) != 0 ) - { - std::cerr << "\n\nError : An error occured while trying to fix dependencies of " << file_to_fix << std::endl; - exit(1); - } - + changeInstallName(file_to_fix, filename, getInnerPath()); // for symlinks const int symamount = symlinks.size(); for(int n=0; n<symamount; n++) { - command = std::string("install_name_tool -change ") + - symlinks[n] + " " + getInnerPath() + " " + file_to_fix; - - if( systemp( command ) != 0 ) - { - std::cerr << "\n\nError : An error occured while trying to fix dependencies of " << file_to_fix << std::endl; - exit(1); - } - }//next - }// end if(missing_prefixes) + changeInstallName(file_to_fix, symlinks[n], getInnerPath()); + } + } } diff --git a/src/Utils.cpp b/src/Utils.cpp index 68d23a7..564adcf 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -167,6 +167,16 @@ int systemp(std::string& cmd) return system(cmd.c_str()); } +void changeInstallName(const std::string& binary_file, const std::string& old_name, const std::string& new_name) +{ + std::string command = std::string("install_name_tool -change ") + old_name + " " + new_name + " " + binary_file; + if( systemp( command ) != 0 ) + { + std::cerr << "\n\nError: An error occured while trying to fix dependencies of " << binary_file << std::endl; + exit(1); + } +} + std::string getUserInputDirForFile(const std::string& filename) { const int searchPathAmount = Settings::searchPathAmount(); diff --git a/src/Utils.h b/src/Utils.h index 6599471..dc76431 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -41,6 +41,7 @@ std::string system_get_output(std::string cmd); // like 'system', runs a command on the system shell, but also prints the command to stdout. int systemp(std::string& cmd); +void changeInstallName(const std::string& binary_file, const std::string& old_name, const std::string& new_name); std::string getUserInputDirForFile(const std::string& filename); #endif |