Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to not ignore system libs #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ fixes dependencies where bundled libraries depend on each other. If this option
`-i`, `--ignore` (path)
> Dylibs in (path) will be ignored. By default, dylibbundler will ignore libraries installed in `/usr/lib` since they are assumed to be present by default on all OS X installations.*(It is usually recommend not to install additional stuff in `/usr/`, always use ` /usr/local/` or another prefix to avoid confusion between system libs and libs you added yourself)*

`-bs`, `--bundle-system-libs`
> By default, dylibbundler will ignore libraries installed in `/usr/lib` and `/System/Library`, this disables that default and searches both.

`-d`, `--dest-dir` (directory)
> Sets the name of the directory in which distribution-ready dylibs will be placed, relative to the current working directory. (Default is `./libs`) For an app bundle, it is often convenient to set it to something like `./MyApp.app/Contents/libs`.

Expand Down
1 change: 1 addition & 0 deletions src/Dependency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Dependency::Dependency(std::string path, const std::string& dependent_file)
for( int i=0; i<searchPathAmount; ++i)
{
std::string search_path = Settings::searchPath(i);
if (search_path[ search_path.size()-1 ] != '/') search_path += "/"; // Add this line to fix missing "/" from path in next line
if (fileExists( search_path+filename ))
{
std::cout << "FOUND " << filename << " in " << search_path << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/DylibBundler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void collectDependencies(const std::string& filename)

// trim useless info, keep only library name
std::string dep_path = line.substr(1, line.rfind(" (") - 1);
if (Settings::isSystemLibrary(dep_path)) continue;
if (Settings::isSystemLibrary(dep_path) && !Settings::searchSystemLib()) continue;

addDependency(dep_path, filename);
}
Expand Down
6 changes: 5 additions & 1 deletion src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ bool bundleLibs_bool = false;
bool bundleLibs(){ return bundleLibs_bool; }
void bundleLibs(bool on){ bundleLibs_bool = on; }

bool searchSystemLib_bool = false;
bool searchSystemLib(){ return searchSystemLib_bool; }
void searchSystemLib(bool on){ searchSystemLib_bool = on; }


std::string dest_folder_str = "./libs/";
std::string destFolder(){ return dest_folder_str; }
Expand Down Expand Up @@ -102,7 +106,7 @@ bool isPrefixBundled(const std::string& prefix)
{
if(prefix.find(".framework") != std::string::npos) return false;
if(prefix.find("@executable_path") != std::string::npos) return false;
if(isSystemLibrary(prefix)) return false;
if(isSystemLibrary(prefix) && !searchSystemLib()) return false;
if(isPrefixIgnored(prefix)) return false;

return true;
Expand Down
3 changes: 3 additions & 0 deletions src/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ void canCodesign(bool permission);
bool bundleLibs();
void bundleLibs(bool on);

bool searchSystemLib();
void searchSystemLib(bool on);

std::string destFolder();
void destFolder(const std::string& path);

Expand Down
15 changes: 13 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ THE SOFTWARE.

*/

const std::string VERSION = "1.0.5";
const std::string VERSION = "1.0.6";


// FIXME - no memory management is done at all (anyway the program closes immediately so who cares?)
Expand All @@ -56,6 +56,7 @@ void showHelp()

std::cout << "-x, --fix-file <file to fix (executable or app plug-in)>" << std::endl;
std::cout << "-b, --bundle-deps" << std::endl;
std::cout << "-bs, --bundle-system-libs" << std::endl;
std::cout << "-d, --dest-dir <directory to send bundled libraries (relative to cwd)>" << std::endl;
std::cout << "-p, --install-path <'inner' path of bundled libraries (usually relative to executable, by default '@executable_path/../libs/')>" << std::endl;
std::cout << "-s, --search-path <directory to add to list of locations searched>" << std::endl;
Expand Down Expand Up @@ -84,6 +85,11 @@ int main (int argc, char * const argv[])
Settings::bundleLibs(true);
continue;
}
else if(strcmp(argv[i],"-bs")==0 or strcmp(argv[i],"--bundle-system-libs")==0)
{
Settings::searchSystemLib(true);
continue;
}
else if(strcmp(argv[i],"-p")==0 or strcmp(argv[i],"--install-path")==0)
{
i++;
Expand Down Expand Up @@ -126,14 +132,19 @@ int main (int argc, char * const argv[])
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)
{
i++;
Settings::addSearchPath(argv[i]);
continue;
}
if(strcmp(argv[i],"-v")==0 or strcmp(argv[i],"--version")==0)
{
std::cout << VERSION << std::endl;
exit(0);
}
else if(i>0)
{
// if we meet an unknown flag, abort
Expand Down