mac-dependencies
Mac-dependencies is a node.js module to "walk" dependencies of an executable or dylib on Mac. It will automatically resolve the @executable_path
, @rpath
and @loader_path
paths to find dependent libraries.
Users can use it to print the dependencies, check which dependencies were missing, and build a DMG by copying dependent libraries of an executable on Mac (see its usage in GeoDa build toolchain).
Usage
1. print_deps()
: String
Example:
const macdep = ; macdep;
Output:
└─ ✔ libcurl.dylib /usr/lib/libcurl.dylib
├─ ✔ libcrypto.42.dylib /usr/lib/libcrypto.42.dylib
│ └─ ✔ libSystem.B.dylib /usr/lib/libSystem.B.dylib
├─ ✔ libssl.44.dylib /usr/lib/libssl.44.dylib
│ ├─ ✔ libcrypto.42.dylib /usr/lib/libcrypto.42.dylib
│ │ └─ ✔ libSystem.B.dylib /usr/lib/libSystem.B.dylib
│ └─ ✔ libSystem.B.dylib /usr/lib/libSystem.B.dylib
├─ ✔ libapple_nghttp2.dylib /usr/lib/libapple_nghttp2.dylib
│ └─ ✔ libSystem.B.dylib /usr/lib/libSystem.B.dylib
├─ ✔ libz.1.dylib /usr/lib/libz.1.dylib
│ └─ ✔ libSystem.B.dylib /usr/lib/libSystem.B.dylib
└─ ✔ libSystem.B.dylib /usr/lib/libSystem.B.dylib
1.1 Check missing dependencies
Any missing dependencies will be highlighed in the output with a "question mark" icon ❓.
Example:
macdep;
Output:
└─ ✔ test.dylib /Users/xun/test.dylib
├─ ❓ libpng16.16.dylib @rpath/libpng16.16.dylib
└─ ✔ libSystem.B.dylib /usr/lib/libSystem.B.dylib
search_dirs
1.2 Option: For missing dependencies, one can specify a list of search dirs as an option to tell the program to search any missing dependencies.
Example:
var opts = "search_dirs" : "/usr/lib" "/usr/local/lib";macdep;
Output:
└─ ✔ test.dylib /Users/xun/test.dylib
├─ ✔ libpng16.16.dylib /usr/local/lib/libpng16.16.dylib
└─ ✔ libSystem.B.dylib /usr/lib/libSystem.B.dylib
system_dirs
1.3 Option: Default value: ['/usr/lib/system', '/Library/System']
One can specify a list of system dirs as an option to tell the program to ignore when searching dependencies.
Example:
var opts = "system_dirs" : "/usr/lib" "search_dirs" : "/usr/lib" "/usr/local/lib";macdep;
Output:
└─ ✔ test.dylib /Users/xun/test.dylib
└─ ✔ libpng16.16.dylib /usr/local/lib/libpng16.16.dylib
2. get_deps()
: object
Example:
const macdep = ; var dep = macdep;
Returns a javascript object representing the tree structure of dependencies. For example:
dep // attributes thisfile_path = '/Users/xun/test.dylib' // thisfile_name = 'test.lib' // thisis_system = false // thisis_valid = true // thisdependencies = '/usr/local/lib/libpng16.16.dylib' // a list of dependencies as dep objects '/usr/lib/libSystem.B.dylib' thisexecutable_path = '/Users/xun' thisloader_path = '/Users/xun' thisr_path = undefined
One can traverse this tree structure starting from the return object by get_deps()
function, and looping its children in dependencies[]
.
Contact
Xun Li lixun at gmail.com