Include/AuroraEnvironment.hpp

320 lines
9.9 KiB
C++
Raw Normal View History

2021-05-20 16:29:39 +00:00
/***
Copyright (©) 2020 Reece Wilson (a/k/a "Reece").
All rights reserved.
2021-05-21 16:34:33 +00:00
File: AuroraEnvironment.hpp
2021-05-20 16:29:39 +00:00
Date: 2020-6-9
Originator: Reece
Purpose:
***/
#pragma once
extern "C"
{
2021-05-21 16:34:33 +00:00
#include "AuroraEnvironment.h"
2021-05-20 16:29:39 +00:00
}
#if defined(_AUHAS_AURORAENUM) && defined(_ALLOW_AURORA_ENUM_AUENVHPP)
#include <AuroraForEach.hpp>
#include <AuroraEnum.hpp>
#define AUENVHPP_START_ENUM(platform, ...) \
AUE_DEFINE(platform, (__VA_ARGS__))
#else
#define AUENVHPP_START_ENUM(platform, ...) \
enum class platform \
{ \
eEnumInvalid = -1, \
__VA_ARGS__ \
};
#endif
2021-05-20 16:29:39 +00:00
namespace Aurora::Build
{
AUENVHPP_START_ENUM(ECompiler,
eMSVC,
eClang,
eGCC,
eIntelInside
);
2021-05-20 16:29:39 +00:00
#if defined(AURORA_COMPILER_CLANG)
static const ECompiler kCurrentCompiler = ECompiler::eClang;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_COMPILER_MSVC)
static const ECompiler kCurrentCompiler = ECompiler::eMSVC;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_COMPILER_GCC)
static const ECompiler kCurrentCompiler = ECompiler::eGCC;
#elif defined(AURORA_COMPILER_INTEL)
static const ECompiler kCurrentCompiler = ECompiler::eIntelInside;
2021-05-20 16:29:39 +00:00
#else
static const ECompiler kCurrentCompiler = ECompiler::eEnumInvalid;
2021-05-20 16:29:39 +00:00
#endif
enum class EPlatformLTS
2021-05-20 16:29:39 +00:00
{
eInvalid = -1,
2021-11-14 18:34:15 +00:00
eKernelLinux,
eKernelBsd,
2021-11-14 18:34:15 +00:00
eKernelNtos,
eKernelReserved1,
eKernelReserved2,
eKernelReserved3,
ePlatformWin32, // including padding for future OSes
ePlatformUWP,
ePlatformBSD,
ePlatformAndroid,
ePlatformLinux,
ePlatformAppleMacOS,
ePlatformIos,
ePlatformRTOS,
ePlatformNX,
ePlatformPS4,
ePlatformPS5,
ePlatformPS6,
ePlatformPS7,
ePlatformXbone,
ePlatformXbone2020,
ePlatformXboneReserved,
ePlatformXboneReserved2,
ePlatformXboneReserved3,
ePlatformNxPlusOne,
ePlatformNxPlusTwo,
ePlatformNxPlusThree,
ePlatformUWPAlt1,
ePlatformUWPAlt2,
ePlatformAppleAlt1,
ePlatformAppleAlt2,
ePlatformWii,
ePlatformWiiU,
ePlatformMCU = 60,
ePlatformMPU = 70,
ePlatformUserReserved1 = 100,
ePlatformUserReserved2,
ePlatformUserReserved3,
2021-05-20 16:29:39 +00:00
};
AUENVHPP_START_ENUM(EPlatform,
eKernelLinux,
eKernelBsd,
eKernelNtos,
eKernelReserved1,
eKernelReserved2,
eKernelReserved3,
ePlatformWin32,
ePlatformUWP,
ePlatformBSD,
ePlatformAndroid,
ePlatformLinux,
ePlatformAppleMacOS,
ePlatformIos,
ePlatformRTOS,
ePlatformNX,
ePlatformPS4,
ePlatformPS5,
ePlatformPS6,
ePlatformPS7,
ePlatformXbone,
ePlatformXbone2020,
ePlatformXboneReserved,
ePlatformXboneReserved2,
ePlatformXboneReserved3,
ePlatformNxPlusOne,
ePlatformNxPlusTwo,
ePlatformNxPlusThree
)
2021-05-20 16:29:39 +00:00
2021-11-14 18:34:15 +00:00
#if defined(AURORA_PLATFORM_KERNEL_LINUX)
static const EPlatform kCurrentPlatform = EPlatform::eKernelLinux;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_NTOS)
2021-11-14 18:34:15 +00:00
static const EPlatform kCurrentPlatform = EPlatform::eKernelNtos;
#elif defined(AURORA_PLATFORM_KERNEL_FREEBSD) || defined(AURORA_PLATFORM_KERNEL_LAIN)
static const EPlatform kCurrentPlatform = EPlatform::eKernelBsd;
#elif defined(AURORA_PLATFORM_BSD)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformBSD;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_WIN32)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformWin32;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_ANDROID)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformAndroid;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_LINUX)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformLinux;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_APPLE)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformAppleMacOS;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_IOS)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformIos;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_SWITCH)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformSwitch;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_PS4)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformPS4;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_PS5)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformPS5;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_XBONE)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformXbone;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_WII)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformWii;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_PLATFORM_WII_U)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformWiiU;
2021-05-20 16:29:39 +00:00
#else
static const EPlatform kCurrentPlatform = EPlatform::eEnumInvalid;
2021-05-20 16:29:39 +00:00
#endif
AUENVHPP_START_ENUM(EVendor,
eConsoleMicrosft,
eConsoleSony,
eConsoleNintendo,
eGenericApple,
eGenericMicrosoft
)
2021-05-20 16:29:39 +00:00
#if defined(VENDOR_CONSOLE_MICROSOFT)
static const EVendor kCurrentVendor = EVendor::eConsoleMicrosft;
2021-05-20 16:29:39 +00:00
#elif defined(VENDOR_GENERIC_APPLE)
static const EVendor kCurrentVendor = EVendor::eGenericApple;
2021-05-20 16:29:39 +00:00
#elif defined(VENDOR_CONSOLE_SONY)
static const EVendor kCurrentVendor = EVendor::eConsoleSony;
2021-05-20 16:29:39 +00:00
#elif defined(VENDOR_CONSOLE_NINTENDO)
static const EVendor kCurrentVendor = EVendor::eConsoleNintendo;
2021-05-20 16:29:39 +00:00
#elif defined(VENDOR_GENERIC_MICROSOFT)
static const EVendor kCurrentVendor = EVendor::eGenericMicrosoft;
2022-01-18 22:41:40 +00:00
#elif defined(VENDOR_UNKNOWN)
static const EVendor kCurrentVendor = EVendor::eUnknown;
2021-05-20 16:29:39 +00:00
#else
static const EVendor kCurrentVendor = EVendor::eEnumInvalid;
2021-05-20 16:29:39 +00:00
#endif
AUENVHPP_START_ENUM(EArchitecture,
eX86_32,
eX86_64,
eAArch64
)
2021-05-20 16:29:39 +00:00
#if defined(AURORA_ARCH_X86)
static const EArchitecture kCurrentArchitecture = EArchitecture::eX86_32;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_ARCH_X64)
static const EArchitecture kCurrentArchitecture = EArchitecture::eX86_64;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_ARCH_ARM)
static const EArchitecture kCurrentArchitecture = EArchitecture::eAArch64;
2021-05-20 16:29:39 +00:00
#else
static const EArchitecture kCurrentArchitecture = EArchitecture::eEnumInvalid;
2021-05-20 16:29:39 +00:00
#endif
static bool constexpr IsPlatformX32()
{
return kCurrentArchitecture == EArchitecture::eX86_32;
}
AUENVHPP_START_ENUM(EABI,
2021-05-20 16:29:39 +00:00
// MSFTs in house amd64 abi
eMSFT64,
2021-05-20 16:29:39 +00:00
// MSFTs in house aarch64 abi
eMSFTArm,
2021-05-20 16:29:39 +00:00
// x86 sysv and microsoft only deviate with fastcall and thiscall :(
eCdeclIntel,
2021-05-20 16:29:39 +00:00
// x86_64 others
eSysV,
// M1
eAppleArm,
// Microsoft made a new aarch ABI that makes it easier for them to JIT x86
eMSFTAArchIntelBridge,
2021-05-20 16:29:39 +00:00
// other arm EPlatforms...
eLLVMArm
);
2021-05-20 16:29:39 +00:00
#if defined(AURORA_ABI_MSFT_64)
static const EABI kCurrentABI = EABI::eMSFT64;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_ABI_MS_ARM)
static const EABI kCurrentABI = EABI::eMSFTArm;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_ABI_LLVM_ARM)
static const EABI kCurrentABI = EABI::eLLVMArm;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_ABI_CDECL)
static const EABI kCurrentABI = EABI::eCdeclIntel;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_ABI_SYSV)
static const EABI kCurrentABI = EABI::eSysV;
2021-05-20 16:29:39 +00:00
#elif defined(AURORA_ABI_APPLE)
static const EABI kCurrentABI = EABI::eAppleArm;
#else
static const EABI kCurrentABI = EABI::eEnumInvalid;
#endif
AUENVHPP_START_ENUM(ECPUEndian,
eCPUBig,
eCPULittle
);
#if defined (AU_CPU_ENDIAN_LITTLE)
static const ECPUEndian kCurrentEndian = ECPUEndian::eCPULittle;
#else
static const ECPUEndian kCurrentEndian = ECPUEndian::eCPUBig;
#endif
enum class ELanguage
{
eCpp20,
eCpp17,
eCpp14,
eC,
eRust,
eGo,
eCs,
eJava,
eJavaScript,
eKotlin,
eHLSL,
gGLSL,
eCpp20Plus = 20
};
#if defined (AU_LANG_CPP_20)
static const ELanguage kCurrentLanguage = ELanguage::eCpp20;
#elif defined (AU_LANG_CPP_17)
static const ELanguage kCurrentLanguage = ELanguage::eCpp17;
#elif defined (AU_LANG_CPP_14)
static const ELanguage kCurrentLanguage = ELanguage::eCpp14;
#elif defined (AU_LANG_C)
static const ELanguage kCurrentLanguage = ELanguage::eC;
#else
static const ELanguage kCurrentLanguage = ELanguage::eC;
#endif
#if defined(AURORA_IS_BSD_DERIVED)
static const bool kIsBSDDerived = true;
#else
static const bool kIsBSDDerived = false;
#endif
#if defined(AURORA_IS_POSIX_DERIVED)
static const bool kIsPosixDerived = true;
#else
static const bool kIsPosixDerived = false;
#endif
#if defined(AURORA_IS_BSD_DERIVED)
static const bool kIsBsdDerived = true;
#else
static const bool kIsBsdDerived = false;
#endif
#if defined(AURORA_IS_XNU_DERIVED)
static const bool kIsXnuDerived = true;
#else
static const bool kIsXnuDerived = false;
#endif
#if defined(AURORA_IS_LINUX_DERIVED)
static const bool kIsLinuxDerived = true;
2021-05-20 16:29:39 +00:00
#else
static const bool kIsLinuxDerived = false;
2021-05-20 16:29:39 +00:00
#endif
#if defined(AURORA_IS_MODERNNT_DERIVED)
static const bool kIsNtDerived = true;
#else
static const bool kIsNtDerived = false;
#endif
2021-05-20 16:29:39 +00:00
}