diff --git a/.efrocachemap b/.efrocachemap index ac242c83..3c3b59f8 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -3940,8 +3940,8 @@ "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/44/90/8453cc086294eaf8bd15f4df8332", "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/e8/98/2363d625af50c24c6ef3d2e9c58d", "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/7a/fd/1b7ecd5d084ea0e52974e463b0be", - "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/1c/76/bb6e52f9bd7d50695d587419f0e4", - "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/74/61/d3c6283c0136cd3036da24ee7857", - "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/dc/56/9638fcadf876b2dc14ae42a4eb13", - "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/34/04/47dc06bfb943ef4c41b19394f45a" + "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/e8/88/8fe7875aa34660db68e74f25051d", + "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/23/2d/8239623b2d8745b4feb4b380b12a", + "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/c3/2f/03140734daf10cd7e46a29c5c820", + "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/26/7a/d23e25fdda6f6b1d9ed3b03040b6" } \ No newline at end of file diff --git a/src/ballistica/config/config_cmake.h b/src/ballistica/config/config_cmake.h new file mode 100644 index 00000000..c4d71dee --- /dev/null +++ b/src/ballistica/config/config_cmake.h @@ -0,0 +1,77 @@ +// Released under the MIT License. See LICENSE for details. + +#ifndef BALLISTICA_CONFIG_CONFIG_CMAKE_H_ +#define BALLISTICA_CONFIG_CONFIG_CMAKE_H_ + +// For cmake builds, attempt to figure out what architecture we're running on +// and define stuff accordingly. +#if __APPLE__ + +// Yes Apple, I know GL is deprecated. I don't need constant reminders. You're +// stressing me out. +#define GL_SILENCE_DEPRECATION + +// We currently support regular and client builds on 64 bit mac posix +#if __amd64__ +#define BA_PLATFORM_STRING "x86_64_macos" +#else +#error Unknown processor architecture. +#endif +#define BA_OSTYPE_MACOS 1 +#define HAVE_FRAMEWORK_OPENAL 1 + +#elif __linux__ + +#if __amd64__ +#define BA_PLATFORM_STRING "x86_64_linux" +#define BA_OSTYPE_LINUX 1 +#elif __i386__ +#define BA_PLATFORM_STRING "x86_32_linux" +#define BA_OSTYPE_LINUX 1 +#elif __arm__ +#define BA_PLATFORM_STRING "arm_linux" +#define BA_OSTYPE_LINUX 1 + +#else +#error unknown linux variant +#endif + +#else +#error config_cmake.h: unknown architecture +#endif + +#define dTRIMESH_ENABLED 1 + +#if !BA_HEADLESS_BUILD +#define BA_ENABLE_AUDIO 1 +#define BA_ENABLE_OPENGL 1 +#define BA_SDL_BUILD 1 +#define BA_SDL2_BUILD 1 +#define BA_ENABLE_SDL_JOYSTICKS 1 +#else +#define BA_MINSDL_BUILD 1 +#endif + +// Yup we've got that. +#define BA_ENABLE_EXECINFO_BACKTRACES 1 + +// Allow stdin commands too. +#define BA_USE_STDIN_THREAD 1 + +#define BA_DEFINE_MAIN 1 + +#if !BA_DEBUG_BUILD + +// Used by ODE. +#define dNODEBUG 1 + +// Used by assert. +#ifndef NDEBUG +#define NDEBUG +#endif +#endif // !BA_DEBUG_BUILD + +// This must always be last. +#include "ballistica/config/config_common.h" + +#endif // BALLISTICA_CONFIG_CONFIG_CMAKE_H_ diff --git a/src/ballistica/config/config_common.h b/src/ballistica/config/config_common.h new file mode 100644 index 00000000..ef5197f7 --- /dev/null +++ b/src/ballistica/config/config_common.h @@ -0,0 +1,258 @@ +// Released under the MIT License. See LICENSE for details. + +#ifndef BALLISTICA_CONFIG_CONFIG_COMMON_H_ +#define BALLISTICA_CONFIG_CONFIG_COMMON_H_ + +#ifdef __cplusplus + +#include +#include + +// This header should be included at the very END of each platform config +// header that will be directly used by a build. +namespace ballistica { + +// Default definitions for various things. Per-platform configs +// can override any of these before this is included. + +#ifndef BA_STAT +#define BA_STAT stat +#endif + +#ifndef BA_OSTYPE_WINDOWS +#define BA_OSTYPE_WINDOWS 0 +#endif + +// Are we building for macOS? +#ifndef BA_OSTYPE_MACOS +#define BA_OSTYPE_MACOS 0 +#endif + +// Are we building for iOS? (also covers iPadOS) +#ifndef BA_OSTYPE_IOS +#define BA_OSTYPE_IOS 0 +#endif + +// Are we building for tvOS? +#ifndef BA_OSTYPE_TVOS +#define BA_OSTYPE_TVOS 0 +#endif + +// Are we building for iOS OR tvOS? +#ifndef BA_OSTYPE_IOS_TVOS +#define BA_OSTYPE_IOS_TVOS 0 +#endif + +// Are we building for Android? +#ifndef BA_OSTYPE_ANDROID +#define BA_OSTYPE_ANDROID 0 +#endif + +// Are we building for Linux? +#ifndef BA_OSTYPE_LINUX +#define BA_OSTYPE_LINUX 0 +#endif + +// On windows, are we built as a console app (vs a gui app)? +#ifndef BA_WINDOWS_CONSOLE_BUILD +#define BA_WINDOWS_CONSOLE_BUILD 1 +#endif + +// Does this build support only headless mode? +#ifndef BA_HEADLESS_BUILD +#define BA_HEADLESS_BUILD 0 +#endif + +// Are we building via an XCode project? +#ifndef BA_XCODE_BUILD +#define BA_XCODE_BUILD 0 +#endif + +// Is this our android iircade build? +#ifndef BA_IIRCADE_BUILD +#define BA_IIRCADE_BUILD 0 +#endif + +// Does this build use SDL 1.x? (old mac only) +#ifndef BA_SDL_BUILD +#define BA_SDL_BUILD 0 +#endif + +// Does this build use SDL 2.x? +#ifndef BA_SDL2_BUILD +#define BA_SDL2_BUILD 0 +#endif + +// Does this build use our 'min-sdl' types? +// (basic SDL types we define ourself; no actual SDL dependency) +#ifndef BA_MINSDL_BUILD +#define BA_MINSDL_BUILD 0 +#endif + +// Is this a debug build? +#ifndef BA_DEBUG_BUILD +#define BA_DEBUG_BUILD 0 +#endif + +// Is this a test build? +#ifndef BA_TEST_BUILD +#define BA_TEST_BUILD 0 +#endif + +#ifndef BA_ENABLE_SDL_JOYSTICKS +#define BA_ENABLE_SDL_JOYSTICKS 0 +#endif + +#ifndef BA_USE_ICLOUD +#define BA_USE_ICLOUD 0 +#endif + +#ifndef BA_USE_STORE_KIT +#define BA_USE_STORE_KIT 0 +#endif + +#ifndef BA_USE_GAME_CENTER +#define BA_USE_GAME_CENTER 0 +#endif + +#ifndef BA_PLATFORM_STRING +#error platform string undefined +#endif + +#ifndef BA_USE_STDIN_THREAD +#define BA_USE_STDIN_THREAD 0 +#endif + +#ifndef BA_HARDWARE_CURSOR +#define BA_HARDWARE_CURSOR 0 +#endif + +#ifndef BA_ENABLE_OS_FONT_RENDERING +#define BA_ENABLE_OS_FONT_RENDERING 0 +#endif + +// Does this build support vr mode? (does not mean vr mode is always on) +#ifndef BA_VR_BUILD +#define BA_VR_BUILD 0 +#endif + +// Is this the Google VR build? (Cardboard/Daydream) +#ifndef BA_CARDBOARD_BUILD +#define BA_CARDBOARD_BUILD 0 +#endif + +#ifndef BA_GEARVR_BUILD +#define BA_GEARVR_BUILD 0 +#endif + +#ifndef BA_RIFT_BUILD +#define BA_RIFT_BUILD 0 +#endif + +#ifndef BA_AMAZON_BUILD +#define BA_AMAZON_BUILD 0 +#endif + +#ifndef BA_GOOGLE_BUILD +#define BA_GOOGLE_BUILD 0 +#endif + +#ifndef BA_DEMO_BUILD +#define BA_DEMO_BUILD 0 +#endif + +#ifndef BA_ARCADE_BUILD +#define BA_ARCADE_BUILD 0 +#endif + +#ifndef BA_SOCKET_SEND_DATA_TYPE +#define BA_SOCKET_SEND_DATA_TYPE uint8_t +#endif + +#ifndef BA_SOCKET_SETSOCKOPT_VAL_TYPE +#define BA_SOCKET_SETSOCKOPT_VAL_TYPE int +#endif + +#ifndef BA_SOCKET_SEND_LENGTH_TYPE +#define BA_SOCKET_SEND_LENGTH_TYPE size_t +#endif + +typedef BA_SOCKET_SEND_DATA_TYPE socket_send_data_t; +typedef BA_SOCKET_SEND_LENGTH_TYPE socket_send_length_t; + +bool InlineDebugExplicitBool(bool val); + +// Little hack so we avoid 'value is always true/false' and +// 'code will never/always be run' type warnings when using these in debug +// builds. +#if BA_DEBUG_BUILD +#define EXPBOOL_(val) InlineDebugExplicitBool(val) +#else +#define EXPBOOL_(val) val +#endif + +// We define a compile-time value g_config which contains the same config +// values as our config #defines. We should migrate towards using these values +// whenever possible instead of #if blocks, which should improve support for +// code introspection/refactoring tools and type safety while still optimizing +// out just as nicely as #ifs. (though perhaps should verify that). +// In an ideal world, we should never use #ifs/#ifdefs outside of the platform +// subdir or skipping entire files (header guards, gui stuff on headless builds, +// etc.) +class BuildConfig { + public: + const char* platform_string() const { return BA_PLATFORM_STRING; } + bool debug_build() const { return EXPBOOL_(BA_DEBUG_BUILD); } + bool test_build() const { return EXPBOOL_(BA_TEST_BUILD); } + bool headless_build() const { return EXPBOOL_(BA_HEADLESS_BUILD); } + bool windows_console_build() const { + return EXPBOOL_(BA_WINDOWS_CONSOLE_BUILD); + } + + bool sdl_build() const { return EXPBOOL_(BA_SDL_BUILD); } + bool sdl2_build() const { return EXPBOOL_(BA_SDL2_BUILD); } + bool minsdl_build() const { return EXPBOOL_(BA_MINSDL_BUILD); } + bool enable_sdl_joysticks() const { + return EXPBOOL_(BA_ENABLE_SDL_JOYSTICKS); + } + + bool ostype_windows() const { return EXPBOOL_(BA_OSTYPE_WINDOWS); } + bool ostype_macos() const { return EXPBOOL_(BA_OSTYPE_MACOS); } + bool ostype_ios() const { return EXPBOOL_(BA_OSTYPE_IOS); } + bool ostype_tvos() const { return EXPBOOL_(BA_OSTYPE_TVOS); } + bool ostype_ios_tvos() const { return EXPBOOL_(BA_OSTYPE_IOS_TVOS); } + bool ostype_android() const { return EXPBOOL_(BA_OSTYPE_ANDROID); } + bool ostype_linux() const { return EXPBOOL_(BA_OSTYPE_LINUX); } + + bool xcode_build() const { return EXPBOOL_(BA_XCODE_BUILD); } + bool vr_build() const { return EXPBOOL_(BA_VR_BUILD); } + bool cardboard_build() const { return EXPBOOL_(BA_CARDBOARD_BUILD); } + bool gearvr_build() const { return EXPBOOL_(BA_GEARVR_BUILD); } + bool rift_build() const { return EXPBOOL_(BA_RIFT_BUILD); } + bool amazon_build() const { return EXPBOOL_(BA_AMAZON_BUILD); } + bool google_build() const { return EXPBOOL_(BA_GOOGLE_BUILD); } + bool demo_build() const { return EXPBOOL_(BA_DEMO_BUILD); } + bool arcade_build() const { return EXPBOOL_(BA_ARCADE_BUILD); } + bool iircade_build() const { return EXPBOOL_(BA_IIRCADE_BUILD); } + + bool use_icloud() const { return EXPBOOL_(BA_USE_ICLOUD); } + bool use_store_kit() const { return EXPBOOL_(BA_USE_STORE_KIT); } + bool use_game_center() const { return EXPBOOL_(BA_USE_GAME_CENTER); } + bool use_stdin_thread() const { return EXPBOOL_(BA_USE_STDIN_THREAD); } + bool enable_os_font_rendering() const { + return EXPBOOL_(BA_ENABLE_OS_FONT_RENDERING); + } + bool hardware_cursor() const { return EXPBOOL_(BA_HARDWARE_CURSOR); } +}; + +#undef EXPBOOL_ + +constexpr BuildConfig g_buildconfig; + +} // namespace ballistica + +#endif // __cplusplus + +#define BA_HAVE_CONFIG + +#endif // BALLISTICA_CONFIG_CONFIG_COMMON_H_