First pass at conditional compilation of SDL for Stella.

For now, it's enabled for all mainline ports.
Stella doesn't absolutely need SDL (as the libretro port shows); it's less than 2000 lines in 220,000+ LOC,
This commit is contained in:
Stephen Anthony 2019-04-23 13:56:15 -02:30
parent 6c1efce278
commit 1042c4ff7f
6 changed files with 59 additions and 27 deletions

View File

@ -26,7 +26,7 @@
srcdir ?= . srcdir ?= .
DEFINES := -D_GLIBCXX_USE_CXX11_ABI=1 DEFINES := -DSDL_SUPPORT -D_GLIBCXX_USE_CXX11_ABI=1
LDFLAGS := -pthread LDFLAGS := -pthread
INCLUDES := INCLUDES :=
LIBS := LIBS :=

View File

@ -19,7 +19,9 @@
#define MEDIA_FACTORY_HXX #define MEDIA_FACTORY_HXX
#include "bspf.hxx" #include "bspf.hxx"
#if defined(SDL_SUPPORT)
#include "SDL_lib.hxx" #include "SDL_lib.hxx"
#endif
#include "OSystem.hxx" #include "OSystem.hxx"
#include "Settings.hxx" #include "Settings.hxx"
@ -54,16 +56,20 @@
#if defined(__LIB_RETRO__) #if defined(__LIB_RETRO__)
#include "EventHandlerLIBRETRO.hxx" #include "EventHandlerLIBRETRO.hxx"
#include "FrameBufferLIBRETRO.hxx" #include "FrameBufferLIBRETRO.hxx"
#else #elif defined(SDL_SUPPORT)
#include "EventHandlerSDL2.hxx" #include "EventHandlerSDL2.hxx"
#include "FrameBufferSDL2.hxx" #include "FrameBufferSDL2.hxx"
#else
#error Unsupported backend!
#endif #endif
#if defined(SOUND_SUPPORT) #if defined(SOUND_SUPPORT)
#if defined(__LIB_RETRO__) #if defined(__LIB_RETRO__)
#include "SoundLIBRETRO.hxx" #include "SoundLIBRETRO.hxx"
#else #elif defined(SDL_SUPPORT)
#include "SoundSDL2.hxx" #include "SoundSDL2.hxx"
#else
#include "SoundNull.hxx"
#endif #endif
#else #else
#include "SoundNull.hxx" #include "SoundNull.hxx"
@ -140,18 +146,22 @@ class MediaFactory
{ {
#if defined(__LIB_RETRO__) #if defined(__LIB_RETRO__)
return make_unique<FrameBufferLIBRETRO>(osystem); return make_unique<FrameBufferLIBRETRO>(osystem);
#else #elif defined(SDL_SUPPORT)
return make_unique<FrameBufferSDL2>(osystem); return make_unique<FrameBufferSDL2>(osystem);
#else
#error Unsupported platform for FrameBuffer!
#endif #endif
} }
static unique_ptr<Sound> createAudio(OSystem& osystem, AudioSettings& audioSettings) static unique_ptr<Sound> createAudio(OSystem& osystem, AudioSettings& audioSettings)
{ {
#ifdef SOUND_SUPPORT #if defined(SOUND_SUPPORT)
#if defined(__LIB_RETRO__) #if defined(__LIB_RETRO__)
return make_unique<SoundLIBRETRO>(osystem, audioSettings); return make_unique<SoundLIBRETRO>(osystem, audioSettings);
#elif defined(SOUND_SUPPORT) #elif defined(SOUND_SUPPORT) && defined(SDL_SUPPORT)
return make_unique<SoundSDL2>(osystem, audioSettings); return make_unique<SoundSDL2>(osystem, audioSettings);
#else
return make_unique<SoundNull>(osystem);
#endif #endif
#else #else
return make_unique<SoundNull>(osystem); return make_unique<SoundNull>(osystem);
@ -162,24 +172,27 @@ class MediaFactory
{ {
#if defined(__LIB_RETRO__) #if defined(__LIB_RETRO__)
return make_unique<EventHandlerLIBRETRO>(osystem); return make_unique<EventHandlerLIBRETRO>(osystem);
#else #elif defined(SDL_SUPPORT)
return make_unique<EventHandlerSDL2>(osystem); return make_unique<EventHandlerSDL2>(osystem);
#else
#error Unsupported platform for EventHandler!
#endif #endif
} }
static void cleanUp() static void cleanUp()
{ {
#if defined(SDL_SUPPORT)
SDL_Quit(); SDL_Quit();
#endif
} }
static string backendName() static string backendName()
{ {
ostringstream buf; #if defined(SDL_SUPPORT)
SDL_version ver; return SDLVersion();
SDL_GetVersion(&ver); #else
buf << "SDL " << int(ver.major) << "." << int(ver.minor) << "." << int(ver.patch); return "Custom backend";
#endif
return buf.str();
} }
private: private:

View File

@ -18,6 +18,8 @@
#ifndef SDL_LIB_HXX #ifndef SDL_LIB_HXX
#define SDL_LIB_HXX #define SDL_LIB_HXX
#include "bspf.hxx"
/* /*
* We can't control the quality of code from outside projects, so for now * We can't control the quality of code from outside projects, so for now
* just disable warnings for it. * just disable warnings for it.
@ -43,4 +45,13 @@
#undef pixel #undef pixel
#undef bool #undef bool
#endif static inline string SDLVersion()
{
ostringstream buf;
SDL_version ver;
SDL_GetVersion(&ver);
buf << "SDL " << int(ver.major) << "." << int(ver.minor) << "." << int(ver.patch);
return buf.str();
}
#endif // SDL_LIB_HXX

View File

@ -18,7 +18,9 @@
#ifndef STELLA_KEYS_HXX #ifndef STELLA_KEYS_HXX
#define STELLA_KEYS_HXX #define STELLA_KEYS_HXX
#ifdef SDL_SUPPORT
#include "SDL_lib.hxx" #include "SDL_lib.hxx"
#endif
/** /**
This class implements a thin wrapper around the SDL keysym enumerations, This class implements a thin wrapper around the SDL keysym enumerations,
@ -439,7 +441,11 @@ namespace StellaKeyName
{ {
inline const char* const forKey(StellaKey key) inline const char* const forKey(StellaKey key)
{ {
#ifdef SDL_SUPPORT
return SDL_GetScancodeName(SDL_Scancode(key)); return SDL_GetScancodeName(SDL_Scancode(key));
#else
return "";
#endif
} }
}; };

View File

@ -3026,6 +3026,7 @@
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
SDL_SUPPORT,
CHEATCODE_SUPPORT, CHEATCODE_SUPPORT,
DEBUGGER_SUPPORT, DEBUGGER_SUPPORT,
JOYSTICK_SUPPORT, JOYSTICK_SUPPORT,
@ -3080,6 +3081,7 @@
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = 3; GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
SDL_SUPPORT,
CHEATCODE_SUPPORT, CHEATCODE_SUPPORT,
DEBUGGER_SUPPORT, DEBUGGER_SUPPORT,
JOYSTICK_SUPPORT, JOYSTICK_SUPPORT,

View File

@ -157,7 +157,7 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;DEBUG_BUILD;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BSPF_WINDOWS;WIN32;DEBUG_BUILD;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@ -193,7 +193,7 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;DEBUG_BUILD;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BSPF_WINDOWS;WIN32;DEBUG_BUILD;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@ -226,7 +226,7 @@
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo> <RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader> <PrecompiledHeader>
@ -260,7 +260,7 @@
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>false</WholeProgramOptimization> <WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo> <RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader> <PrecompiledHeader>
@ -298,7 +298,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo> <RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader> <PrecompiledHeader>
@ -335,7 +335,7 @@
<InlineFunctionExpansion>Default</InlineFunctionExpansion> <InlineFunctionExpansion>Default</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers> <OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\yacc;..\emucore;..\emucore\tia;..\emucore\tia\frame-manager;..\common;..\common\tv_filters;..\gui;..\debugger\gui;..\debugger;..\windows;..\cheat;..\zlib;..\libpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BSPF_WINDOWS;WIN32;NDEBUG;SDL_SUPPORT;PNG_SUPPORT;JOYSTICK_SUPPORT;DEBUGGER_SUPPORT;WINDOWED_SUPPORT;SOUND_SUPPORT;CHEATCODE_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo> <RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader> <PrecompiledHeader>