|
12 | 12 | */ |
13 | 13 | #ifndef VIX_RUN_SCRIPT_HELPERS_HPP |
14 | 14 | #define VIX_RUN_SCRIPT_HELPERS_HPP |
| 15 | + |
15 | 16 | #include <filesystem> |
16 | 17 | #include <optional> |
17 | 18 | #include <string> |
18 | 19 | #include <string_view> |
19 | 20 | #include <vector> |
| 21 | + |
20 | 22 | namespace vix::commands::RunCommand::detail |
21 | 23 | { |
22 | 24 | namespace fs = std::filesystem; |
| 25 | + |
| 26 | + /** |
| 27 | + * @brief Prints the watch-mode restart banner. |
| 28 | + * |
| 29 | + * @param path Path of the file that triggered the restart. |
| 30 | + * @param label Message displayed while rebuilding or restarting. |
| 31 | + */ |
23 | 32 | void print_watch_restart_banner(const fs::path &path, std::string_view label); |
24 | | - std::string sanitizer_mode_string(bool enableSanitizers, bool enableUbsanOnly); |
25 | | - bool want_sanitizers(bool enableSanitizers, bool enableUbsanOnly); |
| 33 | + |
| 34 | + /** |
| 35 | + * @brief Checks whether ASan+UBSan or UBSan-only mode is enabled. |
| 36 | + * |
| 37 | + * This helper intentionally does not include ThreadSanitizer. |
| 38 | + * For ASan, UBSan, and TSan together, use want_any_sanitizer() |
| 39 | + * from RunDetail.hpp. |
| 40 | + * |
| 41 | + * @param enableSanitizers True when ASan+UBSan mode is enabled. |
| 42 | + * @param enableUbsanOnly True when UBSan-only mode is enabled. |
| 43 | + * @return True if ASan+UBSan or UBSan-only mode is active. |
| 44 | + */ |
| 45 | + bool want_sanitizers( |
| 46 | + bool enableSanitizers, |
| 47 | + bool enableUbsanOnly); |
| 48 | + |
| 49 | + /** |
| 50 | + * @brief Returns the sanitizer mode string used by generated CMake projects. |
| 51 | + * |
| 52 | + * Possible return values: |
| 53 | + * - "asan_ubsan" |
| 54 | + * - "ubsan" |
| 55 | + * - "tsan" |
| 56 | + * - "none" |
| 57 | + * |
| 58 | + * @param enableSanitizers True when ASan+UBSan mode is enabled. |
| 59 | + * @param enableUbsanOnly True when UBSan-only mode is enabled. |
| 60 | + * @param enableThreadSanitizer True when ThreadSanitizer mode is enabled. |
| 61 | + * @return Sanitizer mode string. |
| 62 | + */ |
| 63 | + std::string sanitizer_mode_string( |
| 64 | + bool enableSanitizers, |
| 65 | + bool enableUbsanOnly, |
| 66 | + bool enableThreadSanitizer); |
| 67 | + |
| 68 | + /** |
| 69 | + * @brief Builds the configuration signature for generated script CMake projects. |
| 70 | + * |
| 71 | + * The signature is used to decide whether a cached generated CMake project |
| 72 | + * must be reconfigured. It includes every option that can affect the produced |
| 73 | + * binary, including sanitizer mode, script flags, and optional database support. |
| 74 | + * |
| 75 | + * @param useVixRuntime True if the script links against the Vix runtime. |
| 76 | + * @param enableSanitizers True when ASan+UBSan mode is enabled. |
| 77 | + * @param enableUbsanOnly True when UBSan-only mode is enabled. |
| 78 | + * @param enableThreadSanitizer True when ThreadSanitizer mode is enabled. |
| 79 | + * @param scriptFlags Compiler/linker flags forwarded to script mode. |
| 80 | + * @param withSqlite True if SQLite support is enabled. |
| 81 | + * @param withMySql True if MySQL support is enabled. |
| 82 | + * @return Stable configuration signature string. |
| 83 | + */ |
26 | 84 | std::string make_script_config_signature( |
27 | 85 | bool useVixRuntime, |
28 | 86 | bool enableSanitizers, |
29 | 87 | bool enableUbsanOnly, |
| 88 | + bool enableThreadSanitizer, |
30 | 89 | const std::vector<std::string> &scriptFlags, |
31 | 90 | bool withSqlite, |
32 | 91 | bool withMySql); |
| 92 | + |
| 93 | + /** |
| 94 | + * @brief Starts the watch-mode spinner. |
| 95 | + * |
| 96 | + * @param label Text displayed next to the spinner. |
| 97 | + */ |
33 | 98 | void watch_spinner_start(std::string label); |
| 99 | + |
| 100 | + /** |
| 101 | + * @brief Stops the watch-mode spinner. |
| 102 | + */ |
34 | 103 | void watch_spinner_stop(); |
| 104 | + |
| 105 | + /** |
| 106 | + * @brief Temporarily stops the watch spinner before printing output. |
| 107 | + */ |
35 | 108 | void watch_spinner_pause_for_output(); |
| 109 | + |
36 | 110 | #ifndef _WIN32 |
37 | | - void apply_sanitizer_env_if_needed(bool enableSanitizers, bool enableUbsanOnly); |
| 111 | + /** |
| 112 | + * @brief Applies sanitizer-related runtime environment variables. |
| 113 | + * |
| 114 | + * On POSIX systems, this configures ASan, UBSan, or TSan environment |
| 115 | + * variables so sanitizer reports are deterministic and easier for Vix |
| 116 | + * to capture and convert into friendly diagnostics. |
| 117 | + * |
| 118 | + * @param enableSanitizers True when ASan+UBSan mode is enabled. |
| 119 | + * @param enableUbsanOnly True when UBSan-only mode is enabled. |
| 120 | + * @param enableThreadSanitizer True when ThreadSanitizer mode is enabled. |
| 121 | + */ |
| 122 | + void apply_sanitizer_env_if_needed( |
| 123 | + bool enableSanitizers, |
| 124 | + bool enableUbsanOnly, |
| 125 | + bool enableThreadSanitizer); |
38 | 126 | #endif |
39 | 127 |
|
| 128 | + /** |
| 129 | + * @brief Finds a precompiled Vix header if available. |
| 130 | + * |
| 131 | + * @return Path to the PCH file, or std::nullopt if not found. |
| 132 | + */ |
40 | 133 | std::optional<fs::path> find_vix_pch(); |
| 134 | + |
| 135 | + /** |
| 136 | + * @brief Finds the installed Vix include directory. |
| 137 | + * |
| 138 | + * @return Path to the include directory, or std::nullopt if not found. |
| 139 | + */ |
41 | 140 | std::optional<fs::path> find_vix_include_dir(); |
| 141 | + |
| 142 | + /** |
| 143 | + * @brief Finds the installed Vix library. |
| 144 | + * |
| 145 | + * @return Path to the Vix library, or std::nullopt if not found. |
| 146 | + */ |
42 | 147 | std::optional<fs::path> find_vix_lib(); |
| 148 | + |
| 149 | + /** |
| 150 | + * @brief Finds all installed Vix module libraries. |
| 151 | + * |
| 152 | + * @return List of discovered Vix module library paths. |
| 153 | + */ |
43 | 154 | std::vector<fs::path> find_vix_all_module_libs(); |
44 | 155 |
|
45 | 156 | } // namespace vix::commands::RunCommand::detail |
| 157 | + |
46 | 158 | #endif |
0 commit comments