Include/AuroraEnvironment.hpp

321 lines
9.9 KiB
C++

/***
Copyright (©) 2020 Reece Wilson (a/k/a "Reece").
All rights reserved.
File: AuroraEnvironment.hpp
Date: 2020-6-9
Originator: Reece
Purpose:
***/
#pragma once
extern "C"
{
#include "AuroraEnvironment.h"
}
#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
namespace Aurora::Build
{
AUENVHPP_START_ENUM(ECompiler,
eMSVC,
eClang,
eGCC,
eIntelInside
);
#if defined(AURORA_COMPILER_CLANG)
static const ECompiler kCurrentCompiler = ECompiler::eClang;
#elif defined(AURORA_COMPILER_MSVC)
static const ECompiler kCurrentCompiler = ECompiler::eMSVC;
#elif defined(AURORA_COMPILER_GCC)
static const ECompiler kCurrentCompiler = ECompiler::eGCC;
#elif defined(AURORA_COMPILER_INTEL)
static const ECompiler kCurrentCompiler = ECompiler::eIntelInside;
#else
static const ECompiler kCurrentCompiler = ECompiler::eEnumInvalid;
#endif
enum class EPlatformLTS
{
eInvalid = -1,
eKernelLinux,
eKernelBsd,
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,
};
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
)
#if defined(AURORA_PLATFORM_KERNEL_LINUX)
static const EPlatform kCurrentPlatform = EPlatform::eKernelLinux;
#elif defined(AURORA_PLATFORM_NTOS)
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;
#elif defined(AURORA_PLATFORM_WIN32)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformWin32;
#elif defined(AURORA_PLATFORM_ANDROID)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformAndroid;
#elif defined(AURORA_PLATFORM_LINUX)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformLinux;
#elif defined(AURORA_PLATFORM_APPLE)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformAppleMacOS;
#elif defined(AURORA_PLATFORM_IOS)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformIos;
#elif defined(AURORA_PLATFORM_SWITCH)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformSwitch;
#elif defined(AURORA_PLATFORM_PS4)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformPS4;
#elif defined(AURORA_PLATFORM_PS5)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformPS5;
#elif defined(AURORA_PLATFORM_XBONE)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformXbone;
#elif defined(AURORA_PLATFORM_WII)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformWii;
#elif defined(AURORA_PLATFORM_WII_U)
static const EPlatform kCurrentPlatform = EPlatform::ePlatformWiiU;
#else
static const EPlatform kCurrentPlatform = EPlatform::eEnumInvalid;
#endif
AUENVHPP_START_ENUM(EVendor,
eUnknown,
eConsoleMicrosft,
eConsoleSony,
eConsoleNintendo,
eGenericApple,
eGenericMicrosoft
)
#if defined(VENDOR_CONSOLE_MICROSOFT)
static const EVendor kCurrentVendor = EVendor::eConsoleMicrosft;
#elif defined(VENDOR_GENERIC_APPLE)
static const EVendor kCurrentVendor = EVendor::eGenericApple;
#elif defined(VENDOR_CONSOLE_SONY)
static const EVendor kCurrentVendor = EVendor::eConsoleSony;
#elif defined(VENDOR_CONSOLE_NINTENDO)
static const EVendor kCurrentVendor = EVendor::eConsoleNintendo;
#elif defined(VENDOR_GENERIC_MICROSOFT)
static const EVendor kCurrentVendor = EVendor::eGenericMicrosoft;
#elif defined(VENDOR_UNKNOWN)
static const EVendor kCurrentVendor = EVendor::eUnknown;
#else
static const EVendor kCurrentVendor = EVendor::eEnumInvalid;
#endif
AUENVHPP_START_ENUM(EArchitecture,
eX86_32,
eX86_64,
eAArch64
)
#if defined(AURORA_ARCH_X86)
static const EArchitecture kCurrentArchitecture = EArchitecture::eX86_32;
#elif defined(AURORA_ARCH_X64)
static const EArchitecture kCurrentArchitecture = EArchitecture::eX86_64;
#elif defined(AURORA_ARCH_ARM)
static const EArchitecture kCurrentArchitecture = EArchitecture::eAArch64;
#else
static const EArchitecture kCurrentArchitecture = EArchitecture::eEnumInvalid;
#endif
static bool constexpr IsPlatformX32()
{
return kCurrentArchitecture == EArchitecture::eX86_32;
}
AUENVHPP_START_ENUM(EABI,
// MSFTs in house amd64 abi
eMSFT64,
// MSFTs in house aarch64 abi
eMSFTArm,
// x86 sysv and microsoft only deviate with fastcall and thiscall :(
eCdeclIntel,
// x86_64 others
eSysV,
// M1
eAppleArm,
// Microsoft made a new aarch ABI that makes it easier for them to JIT x86
eMSFTAArchIntelBridge,
// other arm EPlatforms...
eLLVMArm
);
#if defined(AURORA_ABI_MSFT_64)
static const EABI kCurrentABI = EABI::eMSFT64;
#elif defined(AURORA_ABI_MS_ARM)
static const EABI kCurrentABI = EABI::eMSFTArm;
#elif defined(AURORA_ABI_LLVM_ARM)
static const EABI kCurrentABI = EABI::eLLVMArm;
#elif defined(AURORA_ABI_CDECL)
static const EABI kCurrentABI = EABI::eCdeclIntel;
#elif defined(AURORA_ABI_SYSV)
static const EABI kCurrentABI = EABI::eSysV;
#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;
#else
static const bool kIsLinuxDerived = false;
#endif
#if defined(AURORA_IS_MODERNNT_DERIVED)
static const bool kIsNtDerived = true;
#else
static const bool kIsNtDerived = false;
#endif
}