HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
core_utils.cpp
Go to the documentation of this file.
2 
3 namespace hal
4 {
6  {
7  auto py_core_utils = m.def_submodule("CoreUtils", R"(
8  HAL Core Utility functions.
9  )");
10 
11  py_core_utils.def("get_binary_directory", &utils::get_binary_directory, R"(
12  Get the path to the executable of HAL.
13 
14  :returns: The path.
15  :rtype: pathlib.Path
16  )");
17 
18  py_core_utils.def("get_base_directory", &utils::get_base_directory, R"(
19  Get the base path to the HAL installation.
20  1. Use Environment Variable HAL_BASE_PATH
21  2. If current executable is hal (not e.g. python3 interpreter) use it's path to determine base path.
22  3. Try to find hal executable in path and use its base path.
23 
24  :returns: The path.
25  :rtype: pathlib.Path
26  )");
27 
28  py_core_utils.def("get_library_directory", &utils::get_library_directory, R"(
29  Get the path to the shared and static libraries of HAL.
30  The resulting path is relative to the binary directory.
31 
32  :returns: The path.
33  :rtype: pathlib.Path
34  )");
35 
36  py_core_utils.def("get_share_directory", &utils::get_share_directory, R"(
37  Get the path to the shared objects of HAL.
38  The resulting path is relative to the binary directory.
39 
40  :returns: The path.
41  :rtype: pathlib.Path
42  )");
43 
44  py_core_utils.def("get_user_share_directory", &utils::get_user_share_directory, R"(
45  Get the path to shared objects and files provided by the user.
46  This is ``~/.local/share/hal`` on Unix.
47 
48  :returns: The path.
49  :rtype: pathlib.Path
50  )");
51 
52  py_core_utils.def("get_user_config_directory", &utils::get_user_config_directory, R"(
53  Get the path to the configuration directory of the user.
54  This is ``~/.config/hal`` on Unix.
55 
56  :returns: The path.
57  :rtype: pathlib.Path
58  )");
59 
60  py_core_utils.def("get_default_log_directory", &utils::get_default_log_directory, py::arg("source_file") = "", R"(
61  Get the path to the default directory for log files.
62  If a netlist source file is provided, the function returns the parent directory, otherwise ``get_user_share_directory() / "log"``.
63 
64  :param pathlib.Path source_file: The netlist source file.
65  :returns: The path.
66  :rtype: pathlib.Path
67  )");
68 
69  py_core_utils.def("get_gate_library_directories", &utils::get_gate_library_directories, R"(
70  Get the paths to the locations where gate libraries are searched.
71  Contains the share and user share directories.
72 
73  :returns: A list of paths.
74  :rtype: list[pathlib.Path]
75  )");
76 
77  py_core_utils.def("get_plugin_directories", &utils::get_plugin_directories, R"(
78  Get the paths to the locations where plugins are searched.
79  Contains the library and user share directories.
80 
81  :returns: A list of paths.
82  :rtype: list[pathlib.Path]
83  )");
84  }
85 } // namespace hal
void core_utils_init(py::module &m)
Definition: core_utils.cpp:5
const Module * module(const Gate *g, const NodeBoxes &boxes)
std::filesystem::path get_share_directory()
Definition: utils.cpp:149
std::filesystem::path get_library_directory()
Definition: utils.cpp:129
std::filesystem::path get_default_log_directory(std::filesystem::path source_file="")
Definition: utils.cpp:179
std::filesystem::path get_base_directory()
Definition: utils.cpp:100
std::filesystem::path get_binary_directory()
Definition: utils.cpp:70
std::vector< std::filesystem::path > get_plugin_directories()
Definition: utils.cpp:195
std::vector< std::filesystem::path > get_gate_library_directories()
Definition: utils.cpp:186
std::filesystem::path get_user_share_directory()
Definition: utils.cpp:157
std::filesystem::path get_user_config_directory()
Definition: utils.cpp:172
Definition: defines.h:45