| 15 | |
| 16 | namespace LIEF::dsc::py { |
| 17 | void init(nb::module_& m) { |
| 18 | nb::module_ mod = m.def_submodule("dsc"); |
| 19 | init_utils(m); |
| 20 | |
| 21 | mod.def("enable_cache", nb::overload_cast<>(&enable_cache), |
| 22 | R"doc( |
| 23 | Enable globally cache/memoization. One can also leverage this function |
| 24 | by setting the environment variable ``DYLDSC_ENABLE_CACHE`` to ``1`` |
| 25 | |
| 26 | By default, LIEF will use the directory specified by the environment |
| 27 | variable ``DYLDSC_CACHE_DIR`` as its cache-root directory: |
| 28 | |
| 29 | .. code-block:: console |
| 30 | |
| 31 | DYLDSC_ENABLE_CACHE=1 DYLDSC_CACHE_DIR=/tmp/my_dir python ./my-script.py |
| 32 | |
| 33 | Otherwise, if ``DYLDSC_CACHE_DIR`` is not set, LIEF will use the following |
| 34 | directory (in this priority): |
| 35 | |
| 36 | 1. System or user cache directory |
| 37 | |
| 38 | - macOS: ``DARWIN_USER_TEMP_DIR`` / ``DARWIN_USER_CACHE_DIR`` + ``/dyld_shared_cache`` |
| 39 | - Linux: ``${XDG_CACHE_HOME}/dyld_shared_cache`` |
| 40 | - Windows: ``%LOCALAPPDATA%\dyld_shared_cache`` |
| 41 | |
| 42 | 2. Home directory |
| 43 | |
| 44 | - macOS/Linux: ``$HOME/.dyld_shared_cache`` |
| 45 | - Windows: ``%USERPROFILE%\.dyld_shared_cache`` |
| 46 | |
| 47 | See :meth:`lief.dsc.DyldSharedCache.enable_caching` for a finer granularity |
| 48 | )doc"_doc |
| 49 | ); |
| 50 | |
| 51 | mod.def("enable_cache", [] (nb::PathLike path) { return enable_cache(path); }, |
| 52 | R"doc( |
| 53 | Same behavior as the other :meth:`~.enable_cache` function but using a |
| 54 | user-provided cache directory instead of an inferred one. |
| 55 | )doc"_doc, "target_cache_dir"_a |
| 56 | ); |
| 57 | |
| 58 | create<LIEF::dsc::DyldSharedCache>(mod); |
| 59 | create<LIEF::dsc::Dylib>(mod); |
| 60 | create<LIEF::dsc::SubCache>(mod); |
| 61 | create<LIEF::dsc::MappingInfo>(mod); |
| 62 | } |
| 63 | } |
nothing calls this directly
no test coverage detected