refine logging formatting
This commit is contained in:
parent
0c2c729ab0
commit
1ba60166f1
|
@ -84,7 +84,7 @@ Dependency::Dependency(std::string path)
|
|||
original_file = searchFilenameInRpaths(path);
|
||||
}
|
||||
else if (!realpath(rtrim(path).c_str(), original_file_buffer)) {
|
||||
warning_msg = "\n/!\\ WARNING: Cannot resolve path '" + path + "'.\n";
|
||||
warning_msg = "\n/!\\ WARNING: Cannot resolve path '" + path + "'\n";
|
||||
original_file = path;
|
||||
}
|
||||
else {
|
||||
|
@ -113,7 +113,7 @@ Dependency::Dependency(std::string path)
|
|||
// check if file is contained in one of the paths
|
||||
for (size_t i=0; i<paths.size(); ++i) {
|
||||
if (fileExists(paths[i]+filename)) {
|
||||
warning_msg += "FOUND " + filename + " in " + paths[i] + ".\n";
|
||||
warning_msg += "FOUND " + filename + " in " + paths[i] + "\n";
|
||||
prefix = paths[i];
|
||||
missing_prefixes = true;
|
||||
break;
|
||||
|
@ -127,7 +127,7 @@ Dependency::Dependency(std::string path)
|
|||
// if the location is still unknown, ask the user for search path
|
||||
if (!Settings::isPrefixIgnored(prefix) && (prefix.empty() || !fileExists(prefix+filename))) {
|
||||
if (Settings::verboseOutput())
|
||||
std::cerr << "\n/!\\ WARNING: Library " << filename << " has an incomplete name (location unknown).\n";
|
||||
std::cerr << "\n/!\\ WARNING: Library " << filename << " has an incomplete name (location unknown)\n";
|
||||
missing_prefixes = true;
|
||||
paths.push_back(getUserInputDirForFile(filename));
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void Dependency::copyYourself()
|
|||
// fix the lib's inner name
|
||||
std::string command = std::string("install_name_tool -id ") + getInnerPath() + " " + getInstallPath();
|
||||
if (systemp(command) != 0) {
|
||||
std::cerr << "\n\nError: An error occured while trying to change identity of library " << getInstallPath() << ".\n";
|
||||
std::cerr << "\n\nError: An error occured while trying to change identity of library " << getInstallPath() << "\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ 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 << ".\n";
|
||||
std::cerr << "\n\nError: An error occured while trying to fix dependencies of " << file_to_fix << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ void Dependency::fixFileThatDependsOnMe(std::string file_to_fix)
|
|||
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 << ".\n";
|
||||
std::cerr << "\n\nError: An error occured while trying to fix dependencies of " << file_to_fix << "\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ void Dependency::fixFileThatDependsOnMe(std::string file_to_fix)
|
|||
// 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 << ".\n";
|
||||
std::cerr << "\n\nError: An error occured while trying to fix dependencies of " << file_to_fix << "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ void Dependency::fixFileThatDependsOnMe(std::string file_to_fix)
|
|||
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 << ".\n";
|
||||
std::cerr << "\n\nError: An error occured while trying to fix dependencies of " << file_to_fix << "\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ bool isRpath(const std::string& path)
|
|||
void collectRpaths(const std::string& filename)
|
||||
{
|
||||
if (!fileExists(filename)) {
|
||||
std::cerr << "\n/!\\ WARNING: Can't collect rpaths for nonexistent file '" << filename << "'.\n";
|
||||
std::cerr << "\n/!\\ WARNING: Can't collect rpaths for nonexistent file '" << filename << "'\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ void collectRpaths(const std::string& filename)
|
|||
size_t start_pos = line.find("path ");
|
||||
size_t end_pos = line.find(" (");
|
||||
if (start_pos == std::string::npos || end_pos == std::string::npos) {
|
||||
std::cerr << "\n/!\\ WARNING: Unexpected LC_RPATH format.\n";
|
||||
std::cerr << "\n/!\\ WARNING: Unexpected LC_RPATH format\n";
|
||||
continue;
|
||||
}
|
||||
start_pos += 5;
|
||||
|
@ -102,10 +102,10 @@ std::string searchFilenameInRpaths(const std::string& rpath_file)
|
|||
|
||||
if (fullpath.empty()) {
|
||||
if (Settings::verboseOutput())
|
||||
std::cerr << "\n/!\\ WARNING: Can't get path for '" << rpath_file << "'.\n";
|
||||
std::cerr << "\n/!\\ WARNING: Can't get path for '" << rpath_file << "'\n";
|
||||
fullpath = getUserInputDirForFile(suffix) + suffix;
|
||||
if (!Settings::verboseOutput() && fullpath.empty())
|
||||
std::cerr << "\n/!\\ WARNING: Can't get path for '" << rpath_file << "'.\n";
|
||||
std::cerr << "\n/!\\ WARNING: Can't get path for '" << rpath_file << "'\n";
|
||||
if (realpath(fullpath.c_str(), buffer))
|
||||
fullpath = buffer;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void fixRpathsOnFile(const std::string& original_file, const std::string& file_t
|
|||
+ Settings::inside_lib_path() + " "
|
||||
+ 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";
|
||||
std::cerr << "\n\n/!\\ ERROR: An error occured while trying to fix dependencies of " << file_to_fix << "\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -152,10 +152,6 @@ void addDependency(std::string path, std::string filename)
|
|||
{
|
||||
Dependency dep(path);
|
||||
|
||||
// check if this library is in /usr/lib, /System/Library, or in ignored list
|
||||
if (!Settings::isPrefixBundled(dep.getPrefix()))
|
||||
return;
|
||||
|
||||
// check if this library was already added to |deps| to avoid duplicates
|
||||
bool in_deps = false;
|
||||
const int dep_amount = deps.size();
|
||||
|
@ -163,17 +159,20 @@ void addDependency(std::string path, std::string filename)
|
|||
if (dep.mergeIfSameAs(deps[n]))
|
||||
in_deps = true;
|
||||
|
||||
if (!in_deps)
|
||||
deps.push_back(dep);
|
||||
|
||||
std::vector<Dependency> deps_in_file = deps_per_file[filename];
|
||||
|
||||
// check if this library was already added to |deps_per_file[filename]| to avoid duplicates
|
||||
std::vector<Dependency> deps_in_file = deps_per_file[filename];
|
||||
bool in_deps_per_file = false;
|
||||
for (int n=0; n<deps_in_file.size(); n++)
|
||||
if (dep.mergeIfSameAs(deps_in_file[n]))
|
||||
in_deps_per_file = true;
|
||||
|
||||
// check if this library is in /usr/lib, /System/Library, or in ignored list
|
||||
if (!Settings::isPrefixBundled(dep.getPrefix()))
|
||||
return;
|
||||
|
||||
if (!in_deps)
|
||||
deps.push_back(dep);
|
||||
|
||||
if (!in_deps_per_file) {
|
||||
deps_in_file.push_back(dep);
|
||||
deps_per_file[filename] = deps_in_file;
|
||||
|
@ -189,7 +188,7 @@ void collectDependencies(std::string filename, std::vector<std::string>& lines)
|
|||
if (output.find("can't open file") != std::string::npos
|
||||
|| output.find("No such file") != std::string::npos
|
||||
|| output.size() < 1) {
|
||||
std::cerr << "\n\n/!\\ ERROR: Cannot find file " << filename << " to read its dependencies.\n";
|
||||
std::cerr << "\n\n/!\\ ERROR: Cannot find file " << filename << " to read its dependencies\n";
|
||||
exit(1);
|
||||
}
|
||||
// split output
|
||||
|
@ -272,7 +271,7 @@ void createDestDir()
|
|||
std::cout << "* Erasing old output directory " << dest_folder << "\n";
|
||||
std::string command = std::string("rm -r ") + dest_folder;
|
||||
if (systemp(command) != 0) {
|
||||
std::cerr << "\n\n/!\\ ERROR: An error occured while attempting to overwrite dest folder.\n";
|
||||
std::cerr << "\n\n/!\\ ERROR: An error occured while attempting to overwrite dest folder\n";
|
||||
exit(1);
|
||||
}
|
||||
dest_exists = false;
|
||||
|
@ -283,12 +282,12 @@ void createDestDir()
|
|||
std::cout << "* Creating output directory " << dest_folder << "\n";
|
||||
std::string command = std::string("mkdir -p ") + dest_folder;
|
||||
if (systemp(command) != 0) {
|
||||
std::cerr << "\n\n/!\\ ERROR: An error occured while creating dest folder.\n";
|
||||
std::cerr << "\n\n/!\\ ERROR: An error occured while creating dest folder\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cerr << "\n\n/!\\ ERROR: Dest folder does not exist. Create it or pass the appropriate flag for automatic dest dir creation.\n";
|
||||
std::cerr << "\n\n/!\\ ERROR: Dest folder does not exist. Create it or pass the appropriate flag for automatic dest dir creation\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ bool isPrefixBundled(std::string prefix)
|
|||
return false;
|
||||
if (prefix.compare("/usr/lib/") == 0)
|
||||
return false;
|
||||
if (prefix.compare("/System/Library/") == 0)
|
||||
if (prefix.find("/System/Library/") == 0)
|
||||
return false;
|
||||
if (isPrefixIgnored(prefix))
|
||||
return false;
|
||||
|
|
|
@ -51,7 +51,7 @@ void copyFile(std::string from, std::string to)
|
|||
{
|
||||
bool overwrite = Settings::canOverwriteFiles();
|
||||
if (fileExists(to) && !overwrite) {
|
||||
std::cerr << "\n\nError: File " << to << " already exists. Remove it or enable overwriting." << "\n";
|
||||
std::cerr << "\n\nError: File " << to << " already exists. Remove it or enable overwriting\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ std::string getUserInputDirForFile(const std::string& filename)
|
|||
}
|
||||
else {
|
||||
if (Settings::verboseOutput()) {
|
||||
std::cerr << (searchPath+filename) << " was found.\n"
|
||||
std::cerr << (searchPath+filename) << " was found\n"
|
||||
<< "/!\\ WARNING: dylibbundler MAY NOT CORRECTLY HANDLE THIS DEPENDENCY: Check the executable with 'otool -L'" << "\n";
|
||||
}
|
||||
return searchPath;
|
||||
|
@ -152,11 +152,11 @@ std::string getUserInputDirForFile(const std::string& filename)
|
|||
prefix += "/";
|
||||
|
||||
if (!fileExists(prefix+filename)) {
|
||||
std::cerr << (prefix+filename) << " does not exist. Try again\n";
|
||||
std::cerr << (prefix+filename) << " does not exist. Try again...\n";
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
std::cerr << (prefix+filename) << " was found.\n"
|
||||
std::cerr << (prefix+filename) << " was found\n"
|
||||
<< "/!\\ WARNINGS: dylibbundler MAY NOT CORRECTLY HANDLE THIS DEPENDENCY: Check the executable with 'otool -L'\n";
|
||||
return prefix;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue