2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: Runtime.hpp
|
|
|
|
Date: 2021-6-9
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#if defined(AURORA_ENGINE_KERNEL_STATIC)
|
|
|
|
#define AUKN_SYM
|
|
|
|
#else
|
|
|
|
#if defined(AURORA_ENGINE_KERNEL_EXPORT)
|
|
|
|
#define AUKN_SYM AURORA_SYMBOL_EXPORT
|
|
|
|
#else
|
|
|
|
#define AUKN_SYM AURORA_SYMBOL_IMPORT
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2022-01-26 00:01:06 +00:00
|
|
|
#include <AuroraEnvironment.h>
|
|
|
|
#include <AuroraTypes.hpp>
|
|
|
|
|
2021-10-24 12:04:22 +00:00
|
|
|
#include <AuroraForEach.hpp>
|
|
|
|
#include <AuroraInterfaces.hpp>
|
2021-11-05 17:34:23 +00:00
|
|
|
#include <AuroraEnum.hpp>
|
2021-10-24 12:04:22 +00:00
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
#include "../AuroraMacros.hpp"
|
|
|
|
|
2022-01-18 18:59:19 +00:00
|
|
|
#include <utility>
|
2021-09-14 19:10:57 +00:00
|
|
|
#include <memory>
|
2021-06-27 21:25:29 +00:00
|
|
|
#include <optional>
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
#include "../AuroraTypedefs.hpp"
|
2022-01-26 00:01:06 +00:00
|
|
|
|
|
|
|
#define _ALLOW_AURORA_ENUM_AUENVHPP
|
|
|
|
#include <AuroraCommon.hpp>
|
|
|
|
|
2021-09-15 01:14:29 +00:00
|
|
|
#include "../AuroraUtils.hpp"
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
#if defined(_AUHAS_FMT)
|
2022-01-26 00:01:06 +00:00
|
|
|
#include <fmt/core.h>
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include <fmt/chrono.h>
|
|
|
|
#include <fmt/ranges.h>
|
2021-09-06 10:58:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(_AUHAS_UUID)
|
2022-01-26 00:01:06 +00:00
|
|
|
#error Missing stduuid library
|
2021-09-06 10:58:08 +00:00
|
|
|
#endif
|
2021-06-27 21:25:29 +00:00
|
|
|
#include <uuid.h>
|
|
|
|
|
|
|
|
#define AUKN_SHARED_API(name, type, ...) AU_SHARED_API_EX(AUKN_SYM, name, type, ## __VA_ARGS__)
|
|
|
|
|
2021-10-08 19:51:34 +00:00
|
|
|
#if defined(_AURORA_RUNTIME_BUILD_API_INTERFACES)
|
|
|
|
#define AUKN_INTERFACE AUI_INTERFACE_IMPL
|
|
|
|
#else
|
|
|
|
#define AUKN_INTERFACE AUI_INTERFACE_FWD
|
2022-01-20 13:27:45 +00:00
|
|
|
#endif
|
2021-10-08 19:51:34 +00:00
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
#include "Memory/Memory.hpp"
|
|
|
|
|
|
|
|
#include "Console/Console.hpp"
|
|
|
|
#include "Crypto/Crypto.hpp"
|
|
|
|
#include "Compression/Compression.hpp"
|
|
|
|
#include "Data/Data.hpp"
|
|
|
|
#include "Debug/Debug.hpp"
|
|
|
|
#include "Hashing/Hashing.hpp"
|
|
|
|
#include "HWInfo/HWInfo.hpp"
|
|
|
|
#include "IO/IO.hpp"
|
2022-01-24 18:37:06 +00:00
|
|
|
#include "Time/Time.hpp"
|
2021-06-27 21:25:29 +00:00
|
|
|
#include "Locale/Locale.hpp"
|
|
|
|
#include "Parse/Parse.hpp"
|
|
|
|
#include "Process/Process.hpp"
|
|
|
|
#include "Registry/Registry.hpp"
|
|
|
|
#include "RNG/RNG.hpp"
|
|
|
|
#include "Telemetry/Telemetery.hpp"
|
|
|
|
#include "Threading/Threading.hpp"
|
|
|
|
#include "Async/Async.hpp"
|
2022-01-24 18:37:06 +00:00
|
|
|
#include "Processes/Processes.hpp"
|
2021-09-14 13:13:58 +00:00
|
|
|
#include "Loop/Loop.hpp"
|
2022-01-26 00:01:06 +00:00
|
|
|
#include "SWInfo/SWInfo.hpp"
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2022-01-18 18:59:19 +00:00
|
|
|
#include "Memory/_ByteBuffer.hpp"
|
|
|
|
|
2021-10-21 10:04:29 +00:00
|
|
|
namespace AuAsync = Aurora::Async;
|
|
|
|
namespace AuBuild = Aurora::Build;
|
|
|
|
namespace AuCompression = Aurora::Compression;
|
|
|
|
namespace AuConsole = Aurora::Console;
|
|
|
|
namespace AuCrypto = Aurora::Crypto;
|
|
|
|
namespace AuData = Aurora::Data;
|
|
|
|
namespace AuDebug = Aurora::Debug;
|
|
|
|
namespace AuThreading = Aurora::Threading;
|
|
|
|
namespace AuThreadPrimitives = Aurora::Threading::Primitives;
|
2021-11-05 17:34:23 +00:00
|
|
|
namespace AuThreads = Aurora::Threading::Threads;
|
2021-10-21 10:04:29 +00:00
|
|
|
namespace AuHwInfo = Aurora::HWInfo;
|
2022-01-28 01:20:38 +00:00
|
|
|
namespace AuSwInfo = Aurora::SWInfo;
|
2021-10-21 10:04:29 +00:00
|
|
|
namespace AuIO = Aurora::IO;
|
|
|
|
namespace AuIOFS = Aurora::IO::FS;
|
|
|
|
namespace AuIONet = Aurora::IO::Net;
|
|
|
|
namespace AuLocale = Aurora::Locale;
|
|
|
|
namespace AuParse = Aurora::Parse;
|
|
|
|
namespace AuProcess = Aurora::Process;
|
|
|
|
namespace AuProcesses = Aurora::Processes;
|
|
|
|
namespace AuTelemetry = Aurora::Telemetry;
|
|
|
|
namespace AuTime = Aurora::Time;
|
|
|
|
namespace AuTypes = Aurora::Types;
|
|
|
|
namespace AuLog = Aurora::Console::Logging;
|
2021-10-24 10:19:47 +00:00
|
|
|
namespace AuMemory = Aurora::Memory;
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
using AuWorkerId_t = AuAsync::WorkerId_t;
|
|
|
|
using AuWorkerPId_t = AuAsync::WorkerPId_t;
|
|
|
|
|
2022-01-20 16:04:53 +00:00
|
|
|
using AuByteBuffer = AuMemory::ByteBuffer;
|
|
|
|
|
|
|
|
using AuMemoryViewRead = AuMemory::MemoryViewRead;
|
|
|
|
using AuMemoryViewWrite = AuMemory::MemoryViewWrite;
|
|
|
|
using AuMemoryViewStreamRead = AuMemory::MemoryViewStreamRead;
|
|
|
|
using AuMemoryViewStreamWrite = AuMemory::MemoryViewStreamWrite;
|
|
|
|
|
2022-01-19 02:49:44 +00:00
|
|
|
static bool AuIsThreadRunning()
|
|
|
|
{
|
|
|
|
return !AuThreads::GetThread()->Exiting();
|
|
|
|
}
|
|
|
|
|
2021-10-23 18:41:14 +00:00
|
|
|
static inline void AuDebugBreak()
|
|
|
|
{
|
|
|
|
AuDebug::DebugBreak();
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
namespace Aurora
|
|
|
|
{
|
|
|
|
struct LocalLogInfo
|
|
|
|
{
|
|
|
|
bool enableLogging {true};
|
|
|
|
bool autoCompressOldLogs {false};
|
|
|
|
AuUInt32 maxSizeMB {128 * 1024 * 1024}; // these numbers feel insane, but at least we have a max threshold
|
|
|
|
int maxLogs {1024}; // by default, we neither leak disk space or waste opportunities of being able to dig through old data
|
2021-11-05 17:34:23 +00:00
|
|
|
#if defined(SHIP)
|
|
|
|
bool writeLogsToUserDir {true}; // use user directory
|
|
|
|
#else
|
|
|
|
bool writeLogsToUserDir {false}; // use cwd
|
|
|
|
#endif
|
2021-06-27 21:25:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TelemetryConfigDoc
|
|
|
|
{
|
|
|
|
LocalLogInfo localLogging;
|
|
|
|
bool enabled {false};
|
|
|
|
|
|
|
|
AuString address;
|
|
|
|
AuUInt16 port {45069};
|
|
|
|
AuString serviceIdnt {"7b5f7a54-7122-4489-ac1a-3d75884b307e"};
|
|
|
|
|
|
|
|
bool wantsActiveMonitoring {false};
|
|
|
|
|
|
|
|
bool privacyNoData {false};
|
|
|
|
bool privacyNoMod {false};
|
|
|
|
bool privacyNoLog {false};
|
|
|
|
bool privacyNoWarn {false};
|
|
|
|
|
|
|
|
bool alwaysCrashdump {true};
|
|
|
|
bool alwaysDisableCrashdump {false};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TelemetryConfig
|
|
|
|
{
|
|
|
|
bool readModNameJsonConfig {};
|
|
|
|
TelemetryConfigDoc defaultConfig;
|
|
|
|
};
|
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
struct SocketConsole
|
|
|
|
{
|
|
|
|
bool enableLogging {false};
|
|
|
|
bool binaryProto {false};
|
|
|
|
AuString path;
|
|
|
|
AuIONet::ConnectionEndpoint net;
|
|
|
|
};
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
struct ConsoleConfig
|
|
|
|
{
|
2021-09-06 10:58:08 +00:00
|
|
|
/// Enables Aurora::Console::xxxStd functions; defer to enableStdXX for default logger behaviour
|
2021-11-05 17:34:23 +00:00
|
|
|
bool enableStdPassthrough {false};
|
2021-09-06 10:58:08 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
/// Enables standard, debug, and GUI consoles
|
|
|
|
bool enableConsole {true};
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
/// Attempt to force a terminal emulator host under graphical subsystems
|
2021-06-27 21:25:29 +00:00
|
|
|
bool forceConsoleWindow {};
|
2021-09-06 10:58:08 +00:00
|
|
|
|
|
|
|
/// Attempt to force a GUI console under command line targets
|
2021-06-27 21:25:29 +00:00
|
|
|
bool forceToolKitWindow {};
|
2021-09-06 10:58:08 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
/// In conjunction with enableStdPassthrough, Aurora::Console::ReadStd reads a binary stream
|
2021-09-06 10:58:08 +00:00
|
|
|
/// In conjunction with !enableStdPassthrough, enables stdout logging
|
|
|
|
bool enableStdIn {true};
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-09-13 20:11:12 +00:00
|
|
|
/// In conjunction with enableStdPassthrough, enables Aurora::Console::WriteStd to write binary, otherwise enables the console logger
|
|
|
|
/// In conjunction with !enableStdPassthrough, enables stdin cmd processing, otherwise disables stdin input
|
2021-09-06 10:58:08 +00:00
|
|
|
bool enableStdOut {true};
|
|
|
|
|
|
|
|
/// Use WxWidgets when possible
|
|
|
|
bool enableWxWidgets {true};
|
2022-01-24 18:37:06 +00:00
|
|
|
|
|
|
|
/// Delegate stdout writes to loops -> recommended for servers
|
|
|
|
bool asyncWrite {false};
|
2021-09-06 10:58:08 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
#if 1
|
2021-09-06 10:58:08 +00:00
|
|
|
/// FIO config
|
|
|
|
LocalLogInfo fio;
|
2021-11-05 17:34:23 +00:00
|
|
|
#endif
|
2021-09-06 10:58:08 +00:00
|
|
|
|
|
|
|
AuString titleBrand = "Aurora SDK Sample";
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
AuString supportPublic {"https://git.reece.sx/AuroraSupport/AuroraRuntime/issues"};
|
2021-06-27 21:25:29 +00:00
|
|
|
AuString supportInternal {"https://jira.reece.sx"};
|
|
|
|
};
|
2021-11-05 17:34:23 +00:00
|
|
|
|
|
|
|
struct LoggerConfig
|
|
|
|
{
|
|
|
|
///
|
|
|
|
bool enableStdIn {true};
|
|
|
|
|
|
|
|
///
|
|
|
|
bool enableStdOut {true};
|
|
|
|
|
|
|
|
/// FIO config
|
|
|
|
LocalLogInfo fileConfiguration;
|
|
|
|
|
|
|
|
/// Socket config
|
|
|
|
SocketConsole socketConfiguration;
|
|
|
|
};
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
struct CryptoConfig
|
|
|
|
{
|
2021-09-06 10:58:08 +00:00
|
|
|
/// Defer to the rationales in the implementation
|
2021-06-27 21:25:29 +00:00
|
|
|
bool allowChineseCerts {false};
|
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
/// Defer to the rationales in the implementation
|
2021-06-27 21:25:29 +00:00
|
|
|
bool allowRussianCerts {true};
|
2021-09-06 10:58:08 +00:00
|
|
|
|
|
|
|
/// WIP
|
|
|
|
bool allowHTTPRetrievalOfCerts {true};
|
|
|
|
|
|
|
|
///
|
|
|
|
bool enablePinning {true};
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
///
|
2021-06-27 21:25:29 +00:00
|
|
|
AuList<AuString> blacklistedCerts{};
|
|
|
|
AuList<AuString> whitelistedCerts{};
|
|
|
|
};
|
|
|
|
|
2021-07-15 16:16:23 +00:00
|
|
|
struct AsyncConfig
|
|
|
|
{
|
2021-11-05 17:34:23 +00:00
|
|
|
bool enableSchedularThread {true}; // turn this off to make your application lighter weight
|
|
|
|
AuUInt32 threadPoolDefaultStackSize {};
|
2021-09-06 10:58:08 +00:00
|
|
|
AuUInt32 schedularFrequency {2}; // * 0.5 or 1 MS depending on the platform
|
|
|
|
AuUInt32 sysPumpFrequency {25}; // x amount of schedularFrequencys
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FIOConfig
|
|
|
|
{
|
2021-11-05 17:34:23 +00:00
|
|
|
/// You can bypass branding by assigning an empty string to 'defaultBrand'
|
|
|
|
AuString defaultBrand = "Aurora";
|
2021-07-15 16:16:23 +00:00
|
|
|
};
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
struct RuntimeStartInfo
|
|
|
|
{
|
|
|
|
ConsoleConfig console;
|
|
|
|
CryptoConfig crypto;
|
|
|
|
TelemetryConfig telemetry;
|
2021-07-15 16:16:23 +00:00
|
|
|
AsyncConfig async;
|
2021-09-06 10:58:08 +00:00
|
|
|
FIOConfig fio;
|
2021-06-27 21:25:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
AUKN_SYM void RuntimeStart(const RuntimeStartInfo &info);
|
2021-10-24 10:53:14 +00:00
|
|
|
AUKN_SYM bool RuntimeHasStarted();
|
2021-09-06 10:58:08 +00:00
|
|
|
AUKN_SYM void RuntimeOverloadLocality(const AuPair<AuString, AuString> &locality);
|
2021-06-27 21:25:29 +00:00
|
|
|
AUKN_SYM void RuntimeShutdown();
|
|
|
|
AUKN_SYM void RuntimeSysPump();
|
|
|
|
}
|