summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-02-24 11:49:56 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-03-10 16:28:59 +0100
commitd1cfcdcb8909f35cdd1591dda099a5370648bbba (patch)
tree4f8972ea6206c740220cc92d39800fb5109922f7
parentfa8c876031e4bc96c21f7f4d2f9161b1e5f64da7 (diff)
downloadjustbuild-d1cfcdcb8909f35cdd1591dda099a5370648bbba.tar.gz
ids: add generic interface function for creating a UUID
-rw-r--r--src/buildtool/execution_api/common/ids.hpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/common/ids.hpp b/src/buildtool/execution_api/common/ids.hpp
index 0c5f689a..e4076226 100644
--- a/src/buildtool/execution_api/common/ids.hpp
+++ b/src/buildtool/execution_api/common/ids.hpp
@@ -129,4 +129,12 @@ static void EncodeUUIDVariant1(std::string* uuid) {
return ss.str();
}
+/// \brief Create a UUID for the current process
+[[nodiscard]] static inline auto CreateUUID() -> std::string {
+ auto process_seed = CreateProcessUniqueId();
+ // as CreateUUIDVersion4 still uses the process-specific random number,
+ // we can afford to use a constant seed.
+ return CreateUUIDVersion4(process_seed ? *process_seed : "unknown");
+}
+
#endif // INCLUDED_SRC_BUILDTOOL_EXECUTION_API_COMMON_IDS_HPP