From 5cc9346ff434f8d898d87a536b733597824ca8f1 Mon Sep 17 00:00:00 2001 From: Jeff Hykin Date: Sun, 30 Apr 2023 10:42:37 -0500 Subject: [PATCH 1/3] add ability to include system libs --- README.md | 3 +++ src/DylibBundler.cpp | 2 +- src/Settings.cpp | 6 +++++- src/Settings.h | 3 +++ src/main.cpp | 10 ++++++++-- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9bd2d30..9c944f1 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/src/DylibBundler.cpp b/src/DylibBundler.cpp index 5b8674e..f5662c3 100644 --- a/src/DylibBundler.cpp +++ b/src/DylibBundler.cpp @@ -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); } diff --git a/src/Settings.cpp b/src/Settings.cpp index 1d9674b..6e58642 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -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; } @@ -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; diff --git a/src/Settings.h b/src/Settings.h index c03afc5..b9ac5ac 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -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); diff --git a/src/main.cpp b/src/main.cpp index 173fc9d..a502780 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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?) @@ -56,6 +56,7 @@ void showHelp() std::cout << "-x, --fix-file " << std::endl; std::cout << "-b, --bundle-deps" << std::endl; + std::cout << "-bs, --bundle-system-libs" << std::endl; std::cout << "-d, --dest-dir " << 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 " << std::endl; @@ -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++; @@ -126,7 +132,7 @@ 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) { From 22d6e1feb4d917aa7fcd5a11f4c2e7aea776e28d Mon Sep 17 00:00:00 2001 From: Jeff Hykin Date: Sun, 30 Apr 2023 10:43:36 -0500 Subject: [PATCH 2/3] add version command --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index a502780..c66ef07 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -140,6 +140,11 @@ int main (int argc, char * const argv[]) 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 From 1eac330e5ceb3c88e85fbfb274b05b474e65ba61 Mon Sep 17 00:00:00 2001 From: Jeff Hykin Date: Sun, 30 Apr 2023 10:58:25 -0500 Subject: [PATCH 3/3] address --- src/Dependency.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Dependency.cpp b/src/Dependency.cpp index f67d06d..c71eba7 100644 --- a/src/Dependency.cpp +++ b/src/Dependency.cpp @@ -130,6 +130,7 @@ Dependency::Dependency(std::string path, const std::string& dependent_file) for( int i=0; i