Add SDL headers and PhysFS to libretro builds

I don't think I'll be needing SDL. Pretty sure about 100% of the
functionality of SDL that's currently being used here is either trivial
to reimplement or needs to be replaced for the libretro core to work in
the first place. For example, I already know I'm going to need to
completely replace the SDL input handling with libretro's input API.
Also, I'll need to get rid of the use of SDL threads in the audio code
later because libretro cores need to render audio synchronously with the
video rendering.

I'm including the SDL headers, though, to reduce the number of
compilation errors.
This commit is contained in:
刘皓 2025-01-24 23:56:00 -05:00
parent afed16f086
commit a44f3b16b3
No known key found for this signature in database
GPG key ID: 7901753DB465B711
4 changed files with 24 additions and 12 deletions

View file

@ -98,6 +98,15 @@ if get_option('retro') == true
'ENABLE_ZSTD': true, 'ENABLE_ZSTD': true,
}) })
physfs_options = cmake.subproject_options()
physfs_options.add_cmake_defines({
'CMAKE_POSITION_INDEPENDENT_CODE': get_option('b_staticpic'),
'PHYSFS_BUILD_STATIC': true,
'PHYSFS_BUILD_SHARED': false,
'PHYSFS_BUILD_TEST': false,
'PHYSFS_BUILD_DOCS': false,
})
openal_options = cmake.subproject_options() openal_options = cmake.subproject_options()
openal_options.add_cmake_defines({ openal_options.add_cmake_defines({
'CMAKE_POSITION_INDEPENDENT_CODE': get_option('b_staticpic'), 'CMAKE_POSITION_INDEPENDENT_CODE': get_option('b_staticpic'),
@ -174,6 +183,7 @@ if get_option('retro') == true
cmake.subproject('liblzma', options: liblzma_options).dependency('liblzma'), cmake.subproject('liblzma', options: liblzma_options).dependency('liblzma'),
cmake.subproject('zstd', options: zstd_options).dependency('libzstd_static'), cmake.subproject('zstd', options: zstd_options).dependency('libzstd_static'),
cmake.subproject('libzip', options: libzip_options).dependency('zip'), cmake.subproject('libzip', options: libzip_options).dependency('zip'),
cmake.subproject('physfs', options: physfs_options).dependency('physfs-static'),
cmake.subproject('openal-soft', options: openal_options).dependency('OpenAL'), cmake.subproject('openal-soft', options: openal_options).dependency('OpenAL'),
], ],
c_args: [ c_args: [
@ -200,6 +210,7 @@ if get_option('retro') == true
include_directories(retro_phase1), include_directories(retro_phase1),
include_directories(join_paths(retro_phase1, 'wasm2c')), include_directories(join_paths(retro_phase1, 'wasm2c')),
include_directories(join_paths(retro_phase1, 'mkxp-retro-ruby')), include_directories(join_paths(retro_phase1, 'mkxp-retro-ruby')),
include_directories(join_paths(retro_phase1, 'sdl/include')),
], ],
sources: [ sources: [
'src/core.cpp', 'src/core.cpp',

View file

@ -6,6 +6,7 @@ LIBYAML_VERSION ?= 0.2.5
ZLIB_VERSION ?= 1.3.1 ZLIB_VERSION ?= 1.3.1
OPENSSL_VERSION ?= 3.2.0 OPENSSL_VERSION ?= 3.2.0
WASM_RT_VERSION ?= 1.0.36 WASM_RT_VERSION ?= 1.0.36
SDL_VERSION ?= 2.30.11
P7ZIP_VERSION ?= 17.06 P7ZIP_VERSION ?= 17.06
TARGET ?= wasm32-wasip1 TARGET ?= wasm32-wasip1
WASI_SDK ?= /opt/wasi-sdk WASI_SDK ?= /opt/wasi-sdk
@ -51,7 +52,7 @@ ruby-dist: $(OUTDIR)/mkxp-retro-dist.zip.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-
ruby-bindings: $(OUTDIR)/mkxp-sandbox-bindgen.cpp $(OUTDIR)/mkxp-sandbox-bindgen.h ruby-bindings: $(OUTDIR)/mkxp-sandbox-bindgen.cpp $(OUTDIR)/mkxp-sandbox-bindgen.h
deps: $(OUTDIR)/libretro.h $(OUTDIR)/wasm2c/wasm-rt.h $(OUTDIR)/wasm2c/wasm-rt-impl.c $(OUTDIR)/wasm2c/wasm-rt-mem-impl.c deps: $(OUTDIR)/libretro.h $(OUTDIR)/wasm2c/wasm-rt.h $(OUTDIR)/wasm2c/wasm-rt-impl.c $(OUTDIR)/wasm2c/wasm-rt-mem-impl.c $(OUTDIR)/sdl/include/SDL.h
clean: clean-ruby-dist clean-ruby-bindings clean-deps clean: clean-ruby-dist clean-ruby-bindings clean-deps
rm -rf $(LIBDIR)/* rm -rf $(LIBDIR)/*
@ -70,6 +71,7 @@ clean-ruby-bindings:
clean-deps: clean-deps:
rm -f $(OUTDIR)/libretro.h rm -f $(OUTDIR)/libretro.h
rm -rf $(OUTDIR)/wasm2c rm -rf $(OUTDIR)/wasm2c
rm -rf $(OUTDIR)/sdl
rm -rf $(DOWNLOADS)/wabt rm -rf $(DOWNLOADS)/wabt
$(OUTDIR)/libretro.h: $(OUTDIR)/libretro.h:
@ -77,11 +79,16 @@ $(OUTDIR)/libretro.h:
$(CURL) -s -L -o $(OUTDIR)/libretro.h https://raw.githubusercontent.com/libretro/libretro-common/$(LIBRETRO_REF)/include/libretro.h $(CURL) -s -L -o $(OUTDIR)/libretro.h https://raw.githubusercontent.com/libretro/libretro-common/$(LIBRETRO_REF)/include/libretro.h
$(OUTDIR)/wasm2c/wasm-rt.h $(OUTDIR)/wasm2c/wasm-rt-impl.c $(OUTDIR)/wasm2c/wasm-rt-mem-impl.c &: $(OUTDIR)/wasm2c/wasm-rt.h $(OUTDIR)/wasm2c/wasm-rt-impl.c $(OUTDIR)/wasm2c/wasm-rt-mem-impl.c &:
mkdir -p $(DOWNLOADS)
mkdir -p $(OUTDIR) mkdir -p $(OUTDIR)
$(CLONE) $(GITHUB)/WebAssembly/wabt $(DOWNLOADS)/wabt -b $(WASM_RT_VERSION) $(CLONE) $(GITHUB)/WebAssembly/wabt $(DOWNLOADS)/wabt -b $(WASM_RT_VERSION)
$(SED) -i 's/# *define * WASM_RT_C11_AVAILABLE//g' $(DOWNLOADS)/wabt/wasm2c/wasm-rt.h # Stop wasm-rt from trying to use threads because it causes compiler errors on some game console toolchains, and also because OpenAL Soft defines a header file named "threads.h" which conflicts with the C11 threads.h that this file tries to include $(SED) -i 's/# *define * WASM_RT_C11_AVAILABLE//g' $(DOWNLOADS)/wabt/wasm2c/wasm-rt.h # Stop wasm-rt from trying to use threads because it causes compiler errors on some game console toolchains, and also because OpenAL Soft defines a header file named "threads.h" which conflicts with the C11 threads.h that this file tries to include
cp -r $(DOWNLOADS)/wabt/wasm2c $(OUTDIR) cp -r $(DOWNLOADS)/wabt/wasm2c $(OUTDIR)
$(OUTDIR)/sdl/include/SDL.h:
mkdir -p $(OUTDIR)
$(CLONE) $(GITHUB)/libsdl-org/SDL $(OUTDIR)/sdl -b release-$(SDL_VERSION)
# Cross Ruby (targets WASI) # Cross Ruby (targets WASI)
$(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_0.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_1.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_2.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_3.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_4.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_5.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_6.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_7.c &: $(LIBDIR)/mkxp-retro-dist/bin/ruby $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_0.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_1.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_2.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_3.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_4.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_5.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_6.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_7.c &: $(LIBDIR)/mkxp-retro-dist/bin/ruby

View file

@ -24,17 +24,7 @@
#include "util.h" #include "util.h"
#ifdef MKXPZ_RETRO
struct SDL_Rect
{
int x;
int y;
int w;
int h;
};
#else
#include <SDL_rect.h> #include <SDL_rect.h>
#endif // MKXPZ_RETRO
struct Vec2 struct Vec2
{ {

4
subprojects/physfs.wrap Normal file
View file

@ -0,0 +1,4 @@
[wrap-git]
url = https://github.com/icculus/physfs
revision = release-3.2.0
depth = 1