add pthread_exit

This commit is contained in:
SCG82 2019-12-12 01:33:45 -08:00
parent 103f116e0e
commit 37042f6366
4 changed files with 34 additions and 17 deletions

View File

@ -246,6 +246,7 @@ void Dependency::fixFileThatDependsOnMe(std::string file_to_fix)
exit(1);
}
}
pthread_exit(NULL);
});
// FIXME - hackish
@ -272,6 +273,7 @@ void Dependency::fixFileThatDependsOnMe(std::string file_to_fix)
exit(1);
}
}
pthread_exit(NULL);
});
}
}

View File

@ -52,6 +52,7 @@ void changeLibPathsOnFile(std::string file_to_fix)
{
deps[i].fixFileThatDependsOnMe(file_to_fix);
}
pthread_exit(NULL);
});
}
@ -163,6 +164,7 @@ void fixRpathsOnFile(const std::string& original_file, const std::string& file_t
exit(1);
}
}
pthread_exit(NULL);
});
}
@ -179,6 +181,7 @@ void addDependency(std::string path)
if(dep.mergeIfSameAs(deps[i]))
return;
}
pthread_exit(NULL);
});
if(!Settings::isPrefixBundled(dep.getPrefix())) return;
@ -232,6 +235,7 @@ void collectDependencies(std::string filename)
addDependency(dep_path);
}
pthread_exit(NULL);
});
}
@ -275,8 +279,10 @@ void collectSubDependencies()
addDependency(dep_path);
}
pthread_exit(NULL);
});
}
pthread_exit(NULL);
});
if(deps.size() == dep_amount)
@ -351,6 +357,7 @@ void doneWithDeps_go()
changeLibPathsOnFile(deps[i].getInstallPath());
fixRpathsOnFile(deps[i].getOriginalPath(), deps[i].getInstallPath());
}
pthread_exit(NULL);
});
}
@ -362,6 +369,7 @@ void doneWithDeps_go()
changeLibPathsOnFile(Settings::fileToFix(i));
fixRpathsOnFile(Settings::fileToFix(i), Settings::fileToFix(i));
}
pthread_exit(NULL);
});
}

View File

@ -53,6 +53,7 @@ static void parallel_for(unsigned nb_elements,
std::cout << "Error:unable to create thread," << rc << std::endl;
exit(-1);
}
std::cout << "pthread created" << std::endl;
}
// free attribute and wait for the other threads

View File

@ -31,14 +31,15 @@ THE SOFTWARE.
#include "Utils.h"
#include "DylibBundler.h"
#include "ParallelFor.h"
/*
TODO
- what happens if a library is not remembered by full path but only name? (support improved, still not perfect)
- could get mixed up if symlink and original are not in the same location (won't happen for UNIX prefixes like /usr/, but in random directories?)
FIXME: why does it copy plugins i try to fix to the libs directory?
*/
const std::string VERSION = "git";
@ -53,7 +54,7 @@ void showHelp()
{
std::cout << "dylibbundler " << VERSION << std::endl;
std::cout << "dylibbundler is a utility that helps bundle dynamic libraries inside macOS app bundles.\n" << std::endl;
std::cout << "-x, --fix-file <file to fix (executable or app plug-in)>" << std::endl;
std::cout << "-b, --bundle-deps" << std::endl;
std::cout << "-d, --dest-dir <directory to send bundled libraries (relative to cwd)>" << std::endl;
@ -69,8 +70,8 @@ void showHelp()
int main (int argc, char * const argv[])
{
// parse arguments
// parse arguments
for(int i=0; i<argc; i++)
{
if(strcmp(argv[i],"-x")==0 or strcmp(argv[i],"--fix-file")==0)
@ -82,7 +83,7 @@ int main (int argc, char * const argv[])
else if(strcmp(argv[i],"-b")==0 or strcmp(argv[i],"--bundle-deps")==0)
{
Settings::bundleLibs(true);
continue;
continue;
}
else if(strcmp(argv[i],"-p")==0 or strcmp(argv[i],"--install-path")==0)
{
@ -105,23 +106,23 @@ int main (int argc, char * const argv[])
else if(strcmp(argv[i],"-of")==0 or strcmp(argv[i],"--overwrite-files")==0)
{
Settings::canOverwriteFiles(true);
continue;
continue;
}
else if(strcmp(argv[i],"-od")==0 or strcmp(argv[i],"--overwrite-dir")==0)
{
Settings::canOverwriteDir(true);
Settings::canCreateDir(true);
continue;
continue;
}
else if(strcmp(argv[i],"-cd")==0 or strcmp(argv[i],"--create-dir")==0)
{
Settings::canCreateDir(true);
continue;
continue;
}
else if(strcmp(argv[i],"-h")==0 or strcmp(argv[i],"--help")==0)
{
showHelp();
exit(0);
exit(0);
}
if(strcmp(argv[i],"-s")==0 or strcmp(argv[i],"--search-path")==0)
{
@ -143,21 +144,26 @@ int main (int argc, char * const argv[])
exit(1);
}
}
if(not Settings::bundleLibs() and Settings::fileToFixAmount()<1)
{
showHelp();
exit(0);
}
std::cout << "* Collecting dependencies"; fflush(stdout);
const int amount = Settings::fileToFixAmount();
for(int n=0; n<amount; n++)
collectDependencies(Settings::fileToFix(n));
parallel_for(amount, [&](int start, int end)
{
for(int i=start; i<end; ++i)
collectDependencies(Settings::fileToFix(i));
pthread_exit(NULL);
});
collectSubDependencies();
doneWithDeps_go();
return 0;
}