Commit bbdd08e0b29ac08a6cb4ff83e209d3298b711a51

Ivan Epifanov 2021-06-10T13:20:39

Build without PIB support by default and add flag to enable it

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92ed799..83ce7b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -420,6 +420,10 @@ set(SDL_STATIC ${SDL_STATIC_ENABLED_BY_DEFAULT} CACHE BOOL "Build a static versi
 dep_option(SDL_STATIC_PIC      "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
 set_option(SDL_TEST            "Build the test directory" OFF)
 
+if(VITA)
+    set_option(VIDEO_VITA_PIB  "Build with PSVita piglet gles2 support" OFF)
+endif()
+
 # General source files
 file(GLOB SOURCE_FILES
   ${SDL2_SOURCE_DIR}/src/*.c
@@ -2142,16 +2146,22 @@ elseif(VITA)
     set(SOURCE_FILES ${SOURCE_FILES} ${VITA_VIDEO_SOURCES})
     set(HAVE_SDL_VIDEO TRUE)
 
-    check_include_file(pib.h HAVE_PIGS_IN_BLANKET_H)
 
+    if(VIDEO_VITA_PIB)
+      check_include_file(pib.h HAVE_PIGS_IN_BLANKET_H)
 
-    if(HAVE_PIGS_IN_BLANKET_H)
-      set(SDL_VIDEO_OPENGL_ES2 1)
-      list(APPEND EXTRA_LIBS
-        pib
-      )
-
+      if(HAVE_PIGS_IN_BLANKET_H)
+        set(SDL_VIDEO_OPENGL_ES2 1)
+        list(APPEND EXTRA_LIBS
+          pib
+        )
+        set(HAVE_VIDEO_VITA_PIB ON)
+        set(SDL_VIDEO_VITA_PIB 1)
+      else()
+        set(HAVE_VIDEO_VITA_PIB OFF)
+      endif()
     endif()
+
     set(SDL_VIDEO_RENDER_VITA_GXM 1)
 
     list(APPEND EXTRA_LIBS
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 8463f47..0b02cd7 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -473,6 +473,8 @@
 #cmakedefine SDL_IPHONE_KEYBOARD @SDL_IPHONE_KEYBOARD@
 #cmakedefine SDL_IPHONE_LAUNCHSCREEN @SDL_IPHONE_LAUNCHSCREEN@
 
+#cmakedefine SDL_VIDEO_VITA_PIB @SDL_VIDEO_VITA_PIB@
+
 #if !defined(__WIN32__) && !defined(__WINRT__)
 #  if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
 typedef unsigned int size_t;
diff --git a/src/video/vita/SDL_vitagl.c b/src/video/vita/SDL_vitagl.c
index 2f40e2c..ae6087b 100644
--- a/src/video/vita/SDL_vitagl.c
+++ b/src/video/vita/SDL_vitagl.c
@@ -20,8 +20,7 @@
 */
 #include "../../SDL_internal.h"
 
-#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_OPENGL_ES2
-
+#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PIB
 #include <stdlib.h>
 #include <string.h>
 
diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c
index b09ab14..5df0fe1 100644
--- a/src/video/vita/SDL_vitavideo.c
+++ b/src/video/vita/SDL_vitavideo.c
@@ -38,7 +38,7 @@
 #include "SDL_vitakeyboard.h"
 #include "SDL_vitamouse_c.h"
 #include "SDL_vitaframebuffer.h"
-#if SDL_VIDEO_OPENGL_ES2
+#if SDL_VIDEO_VITA_PIB
 #include "SDL_vitagl_c.h"
 #endif
 #include <psp2/ime_dialog.h>
@@ -62,7 +62,7 @@ VITA_Create()
 {
     SDL_VideoDevice *device;
     SDL_VideoData *phdata;
-#if SDL_VIDEO_OPENGL_ES2
+#if SDL_VIDEO_VITA_PIB
     SDL_GLDriverData *gldata;
 #endif
     /* Initialize SDL_VideoDevice structure */
@@ -79,7 +79,7 @@ VITA_Create()
         SDL_free(device);
         return NULL;
     }
-#if SDL_VIDEO_OPENGL_ES2
+#if SDL_VIDEO_VITA_PIB
 
     gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData));
     if (gldata == NULL) {
@@ -130,7 +130,7 @@ VITA_Create()
     device->DestroyWindowFramebuffer = VITA_DestroyWindowFramebuffer;
 */
 
-#if SDL_VIDEO_OPENGL_ES2
+#if SDL_VIDEO_VITA_PIB
     device->GL_LoadLibrary = VITA_GL_LoadLibrary;
     device->GL_GetProcAddress = VITA_GL_GetProcAddress;
     device->GL_UnloadLibrary = VITA_GL_UnloadLibrary;