git: 4e1ba94dcb85 - main - emulators/tic-80: support graphics/sdl2_gpu

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Thu, 18 May 2023 08:20:35 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4e1ba94dcb8507b747b02390366ee96cf70bb812

commit 4e1ba94dcb8507b747b02390366ee96cf70bb812
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-05-15 16:55:34 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-05-18 08:19:44 +0000

    emulators/tic-80: support graphics/sdl2_gpu
    
    Now that we've ported this library, wire it into the options.
    
    See also:       https://github.com/nesbox/TIC-80/issues/2189
---
 emulators/tic-80/Makefile                   |  10 ++-
 emulators/tic-80/files/patch-CMakeLists.txt | 108 +++++++++++++++++++++++++---
 2 files changed, 104 insertions(+), 14 deletions(-)

diff --git a/emulators/tic-80/Makefile b/emulators/tic-80/Makefile
index aef7b6644073..152ad29b2e60 100644
--- a/emulators/tic-80/Makefile
+++ b/emulators/tic-80/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	TIC-80
 DISTVERSIONPREFIX=	v
 DISTVERSION=	1.0.2164
+PORTREVISION=	1
 CATEGORIES=	emulators games
 
 MAINTAINER=	fuz@FreeBSD.org
@@ -45,20 +46,23 @@ USE_SDL=	sdl2
 #		nodejs:http-parser:ec8b5ee63f0e51191ea43bb0c6eac7bfbff3141d:http_parser/vendor/http-parser
 #		glennrp:libpng:dbe3e0c43e549a1602286144d94b0666549b18e6:libpng/vendor/libpng
 #		libsdl-org:SDL:b424665e0899769b200231ba943353a5fee1b6b6:sdl2/vendor/sdl2
+#		grimfang4:sdl-gpu:e3d350b325a0e0d0b3007f69ede62313df46c6ef:sdl_gpu/vendor/sdl-gpu
 
 # not actually needed
 #		smuehlst:circle-stdlib:fdb3c4a948421d47fddab8042a92f980cba43915:circle_stdlib/vendor/circle-stdlib
 #		floooh:sokol:487822d82ca79dba7b67718d962e1ba6beef01b2:sokol/vendor/sokol
-#		grimfang4:sdl-gpu:e3d350b325a0e0d0b3007f69ede62313df46c6ef:sdl_gpu/vendor/sdl-gpu
 #		mruby:mruby:0f45836b5954accf508f333f932741b925214471:mruby/vendor/mruby
 
 # the demo carts are built, but don't seem to end up being installed
 # mruby: to be decided later; not essential
 CMAKE_OFF=	BUILD_DEMO_CARTS BUILD_WITH_MRUBY BUILD_LIBRETRO
-CMAKE_ARGS=	-DLPEG_LIBRARY:STRING=${LUA_REFMODLIBDIR}/lpeg.so
 
-OPTIONS_DEFINE=	PRO
+OPTIONS_DEFINE=	PRO SDLGPU
+OPTIONS_DEFAULT=	SDLGPU
 PRO_DESC=	Build PRO Version
+SDLGPU_DESC=	Support sdl-gpu through graphics/sdl2_gpu
 PRO_CMAKE_BOOL=	BUILD_PRO
+SDLGPU_LIB_DEPENDS=	libSDL2_gpu.so:graphics/sdl2_gpu
+SDLGPU_CMAKE_BOOL=	BUILD_SDLGPU
 
 .include <bsd.port.mk>
diff --git a/emulators/tic-80/files/patch-CMakeLists.txt b/emulators/tic-80/files/patch-CMakeLists.txt
index edf75cac6331..3ae76ab51d8e 100644
--- a/emulators/tic-80/files/patch-CMakeLists.txt
+++ b/emulators/tic-80/files/patch-CMakeLists.txt
@@ -348,16 +348,88 @@
  endif()
  
  if(BUILD_PRO)
-@@ -982,7 +823,7 @@ if(ANDROID)
- endif()
+@@ -914,80 +755,6 @@ endif()
+ target_compile_definitions(tic80studio PUBLIC BUILD_EDITORS)
  
- if(NOT EMSCRIPTEN)
+ ################################
+-# SDL GPU
+-################################
+-
+-if(BUILD_SDLGPU)
+-
+-set(SDLGPU_DIR ${THIRDPARTY_DIR}/sdl-gpu/src)
+-set(SDLGPU_SRC
+-    ${SDLGPU_DIR}/renderer_GLES_2.c
+-    ${SDLGPU_DIR}/SDL_gpu.c
+-    ${SDLGPU_DIR}/SDL_gpu_matrix.c
+-    ${SDLGPU_DIR}/SDL_gpu_renderer.c
+-    ${SDLGPU_DIR}/externals/stb_image/stb_image.c
+-    ${SDLGPU_DIR}/externals/stb_image_write/stb_image_write.c
+-)
+-
+-if(NOT ANDROID)
+-    list(APPEND SDLGPU_SRC
+-        ${SDLGPU_DIR}/renderer_GLES_1.c
+-        ${SDLGPU_DIR}/renderer_GLES_3.c
+-        ${SDLGPU_DIR}/renderer_OpenGL_1.c
+-        ${SDLGPU_DIR}/renderer_OpenGL_1_BASE.c
+-        ${SDLGPU_DIR}/renderer_OpenGL_2.c
+-        ${SDLGPU_DIR}/renderer_OpenGL_3.c
+-        ${SDLGPU_DIR}/renderer_OpenGL_4.c
+-        ${SDLGPU_DIR}/SDL_gpu_shapes.c
+-        ${SDLGPU_DIR}/externals/glew/glew.c
+-    )
+-endif()
+-
+-add_library(sdlgpu STATIC ${SDLGPU_SRC})
+-
+-if(EMSCRIPTEN OR ANDROID)
+-    target_compile_definitions(sdlgpu PRIVATE GLEW_STATIC SDL_GPU_DISABLE_GLES_1 SDL_GPU_DISABLE_GLES_3 SDL_GPU_DISABLE_OPENGL)
+-else()
+-    target_compile_definitions(sdlgpu PRIVATE GLEW_STATIC SDL_GPU_DISABLE_GLES SDL_GPU_DISABLE_OPENGL_3 SDL_GPU_DISABLE_OPENGL_4)
+-endif()
+-
+-target_include_directories(sdlgpu PUBLIC ${THIRDPARTY_DIR}/sdl-gpu/include)
+-target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/glew)
+-target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/glew/GL)
+-target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/stb_image)
+-target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/stb_image_write)
+-
+-if(WIN32)
+-    target_link_libraries(sdlgpu opengl32)
+-endif()
+-
+-if(LINUX)
+-    target_link_libraries(sdlgpu GL)
+-endif()
+-
+-if(APPLE)
+-    find_library(OPENGL_LIBRARY OpenGL)
+-    target_link_libraries(sdlgpu ${OPENGL_LIBRARY})
+-endif()
+-
+-if(ANDROID)
+-    find_library( ANDROID_LOG_LIBRARY log )
+-    find_library( ANDROID_GLES2_LIBRARY GLESv2 )
+-    find_library( ANDROID_GLES1_LIBRARY GLESv1_CM )
+-    target_link_libraries(sdlgpu
+-        ${ANDROID_LOG_LIBRARY}
+-        ${ANDROID_GLES2_LIBRARY}
+-        ${ANDROID_GLES1_LIBRARY}
+-    )
+-endif()
+-
+-if(NOT EMSCRIPTEN)
 -    target_link_libraries(sdlgpu SDL2-static)
-+    target_link_libraries(sdlgpu ${SDL2_LIBRARIES})
- endif()
+-endif()
+-
+-endif()
+-
+-################################
+ # TIC-80 app
+ ################################
  
- endif()
-@@ -1028,7 +869,7 @@ if(BUILD_SDL)
+@@ -1028,7 +795,7 @@ if(BUILD_SDL)
          endif()
  
      elseif(NOT ANDROID)
@@ -366,7 +438,14 @@
      endif()
  
      target_link_libraries(tic80 tic80studio)
-@@ -1050,7 +891,7 @@ if(BUILD_SDL)
+@@ -1044,13 +811,13 @@ if(BUILD_SDL)
+     endif()
+ 
+     if(BUILD_SDLGPU)
+-        target_link_libraries(tic80 sdlgpu)
++        target_link_libraries(tic80 SDL2_gpu)
+     else()
+         if(EMSCRIPTEN)
          elseif(RPI)
              target_link_libraries(tic80 libSDL2.a bcm_host)
          else()
@@ -375,7 +454,7 @@
          endif()
      endif()
  
-@@ -1121,7 +962,7 @@ if(N3DS)
+@@ -1121,7 +888,7 @@ if(N3DS)
          ${CMAKE_SOURCE_DIR}/src)
  
      target_link_directories(tic80_n3ds PRIVATE ${DEVKITPRO}/libctru/lib ${DEVKITPRO}/portlibs/3ds/lib)
@@ -384,7 +463,7 @@
  
      add_custom_command(TARGET tic80_n3ds
             POST_BUILD
-@@ -1181,7 +1022,7 @@ if(BUILD_STUB)
+@@ -1181,7 +948,7 @@ if(BUILD_STUB)
              endif()
  
          else()
@@ -393,7 +472,14 @@
          endif()
  
          target_link_libraries(tic80${SCRIPT} tic80core${SCRIPT} argparse)
-@@ -1199,7 +1040,7 @@ if(BUILD_STUB)
+@@ -1193,13 +960,13 @@ if(BUILD_STUB)
+         endif()
+ 
+         if(BUILD_SDLGPU)
+-            target_link_libraries(tic80${SCRIPT} sdlgpu)
++            target_link_libraries(tic80${SCRIPT} SDL2_gpu)
+         else()
+             if(EMSCRIPTEN)
              elseif(RPI)
                  target_link_libraries(tic80${SCRIPT} libSDL2.a bcm_host pthread dl)
              else()