activity_sdk_generation_worker.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #pragma once
  2. #include <array>
  3. #include <cstdint>
  4. #include <memory>
  5. #include <string_view>
  6. #include "../../../middleware/content/packages/reader/reader.h"
  7. #include "../../../state/activity_sdk/generated_world/format.h"
  8. #include "../../../state/activity_sdk/generation/definition.h"
  9. #include "../../../state/build_data/scriptables/definition.h"
  10. namespace sunrise::client::content::activity::sdk_generation {
  11. /** Result of one explicit synchronous build into an isolated artifact tree. */
  12. enum class OfflineBuildStatus : std::uint8_t {
  13. ready,
  14. cancelled,
  15. busy,
  16. invalidInput,
  17. failed,
  18. };
  19. /** Bounded progress event emitted at the same points as the in-client worker state. */
  20. struct OfflineBuildProgress final {
  21. state::activity_sdk::generation::Status status{};
  22. std::uint32_t current{};
  23. std::uint32_t total{};
  24. std::uint32_t scenarioTag{};
  25. std::string_view detail{};
  26. };
  27. using OfflineProgressSink = void (*)(void* context, const OfflineBuildProgress& progress) noexcept;
  28. using OfflineCancelProbe = bool (*)(void* context) noexcept;
  29. /** Explicit inputs required by the package-backed native generation pass. */
  30. struct OfflineBuildRequest final {
  31. state::activity_sdk::generated_world::Digest sourceFingerprint{};
  32. const middleware::content::packages::reader::BlockKeys* keys{};
  33. std::wstring_view packageDirectory{};
  34. std::wstring_view cacheArtifactDirectory{};
  35. std::wstring_view outputArtifactDirectory{};
  36. };
  37. /** Identity and counts returned with one complete isolated tree. */
  38. struct OfflineBuildResult final {
  39. std::uint32_t scenarioCount{};
  40. std::uint32_t activityRootCount{};
  41. std::uint32_t activityCount{};
  42. std::uint32_t builtScenarioCount{};
  43. std::uint32_t reusedScenarioCount{};
  44. state::activity_sdk::generated_world::Digest payloadSha256{};
  45. std::uint64_t packBytes{};
  46. std::uint32_t luaFiles{};
  47. };
  48. /** Runs the exact worker pipeline with one borrowed in-process or synthetic reader source. */
  49. [[nodiscard]] OfflineBuildStatus build_offline(const OfflineBuildRequest& request,
  50. OfflineCancelProbe cancel,
  51. void* cancelContext,
  52. OfflineProgressSink progress,
  53. void* progressContext,
  54. OfflineBuildResult& output) noexcept;
  55. /** Immutable boot policy for the live generator. Its pack backs host roster mission seeds. */
  56. struct Policy final {
  57. /** Writes the sdk/lua declaration tree, which no runtime loads. */
  58. bool luaDeclarations{};
  59. };
  60. /** Stores the artifact paths and applies the immutable boot policy. */
  61. void initialize(void* module, const Policy& policy) noexcept;
  62. /** Starts or reaps the optional full-estate package reader without blocking the caller. */
  63. void service() noexcept;
  64. /** Loads one tag-bound published shard even when generation is disabled. */
  65. [[nodiscard]] bool
  66. load_cached_scenario(std::uint32_t scenarioTag,
  67. std::string_view scenarioName,
  68. std::shared_ptr<state::build_data::scriptables::Snapshot>& output) noexcept;
  69. /** Cancels and joins generation before clearing its paths and job state. */
  70. void reset() noexcept;
  71. } // namespace sunrise::client::content::activity::sdk_generation