mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Cleanup emscripten libretro build target
This commit is contained in:
parent
3c2f67a097
commit
8426b35a80
2
.gitignore
vendored
2
.gitignore
vendored
@ -117,6 +117,8 @@ debian/ppsspp/
|
|||||||
|
|
||||||
# Libretro build
|
# Libretro build
|
||||||
*.o
|
*.o
|
||||||
|
*.tmp
|
||||||
|
*.a
|
||||||
|
|
||||||
# YouCompleteMe file
|
# YouCompleteMe file
|
||||||
.ycm_extra_conf.pyc
|
.ycm_extra_conf.pyc
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
// Reference : https://stackoverflow.com/questions/6121792/how-to-check-if-a-cpu-supports-the-sse3-instruction-set
|
// Reference : https://stackoverflow.com/questions/6121792/how-to-check-if-a-cpu-supports-the-sse3-instruction-set
|
||||||
#include "ppsspp_config.h"
|
#include "ppsspp_config.h"
|
||||||
#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
#if (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)) && !defined(__EMSCRIPTEN__)
|
||||||
|
|
||||||
#include "ext/cpu_features/include/cpuinfo_x86.h"
|
#include "ext/cpu_features/include/cpuinfo_x86.h"
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
#if (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)) && !defined(__EMSCRIPTEN__)
|
||||||
#define Crash() {asm ("int $3");}
|
#define Crash() {asm ("int $3");}
|
||||||
#elif PPSSPP_PLATFORM(SWITCH)
|
#elif PPSSPP_PLATFORM(SWITCH)
|
||||||
// TODO: Implement Crash() for Switch, lets not use breakpoint for the time being
|
// TODO: Implement Crash() for Switch, lets not use breakpoint for the time being
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "ppsspp_config.h"
|
#include "ppsspp_config.h"
|
||||||
#if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64)
|
#if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64)
|
||||||
#define REAL_CPUDETECT_AVAIL 1
|
#define REAL_CPUDETECT_AVAIL 1
|
||||||
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
#elif (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)) && !defined(__EMSCRIPTEN__)
|
||||||
#define REAL_CPUDETECT_AVAIL 1
|
#define REAL_CPUDETECT_AVAIL 1
|
||||||
#elif PPSSPP_ARCH(MIPS) || PPSSPP_ARCH(MIPS64)
|
#elif PPSSPP_ARCH(MIPS) || PPSSPP_ARCH(MIPS64)
|
||||||
#define REAL_CPUDETECT_AVAIL 1
|
#define REAL_CPUDETECT_AVAIL 1
|
||||||
|
@ -52,6 +52,7 @@ bool MemArena::NeedsProbing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MemArena::GrabMemSpace(size_t size) {
|
bool MemArena::GrabMemSpace(size_t size) {
|
||||||
|
#ifndef NO_MMAP
|
||||||
constexpr mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
constexpr mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||||
|
|
||||||
// Try a few times in case multiple instances are started near each other.
|
// Try a few times in case multiple instances are started near each other.
|
||||||
@ -98,15 +99,21 @@ bool MemArena::GrabMemSpace(size_t size) {
|
|||||||
ERROR_LOG(MEMMAP, "Failed to ftruncate %d (%s) to size %08x", (int)fd, ram_temp_file.c_str(), (int)size);
|
ERROR_LOG(MEMMAP, "Failed to ftruncate %d (%s) to size %08x", (int)fd, ram_temp_file.c_str(), (int)size);
|
||||||
// Should this be a failure?
|
// Should this be a failure?
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemArena::ReleaseSpace() {
|
void MemArena::ReleaseSpace() {
|
||||||
|
#ifndef NO_MMAP
|
||||||
close(fd);
|
close(fd);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *MemArena::CreateView(s64 offset, size_t size, void *base)
|
void *MemArena::CreateView(s64 offset, size_t size, void *base)
|
||||||
{
|
{
|
||||||
|
#ifdef NO_MMAP
|
||||||
|
return (void*) base;
|
||||||
|
#else
|
||||||
void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED |
|
void *retval = mmap(base, size, PROT_READ | PROT_WRITE, MAP_SHARED |
|
||||||
// Do not sync memory to underlying file. Linux has this by default.
|
// Do not sync memory to underlying file. Linux has this by default.
|
||||||
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
@ -119,10 +126,13 @@ void *MemArena::CreateView(s64 offset, size_t size, void *base)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemArena::ReleaseView(s64 offset, void* view, size_t size) {
|
void MemArena::ReleaseView(s64 offset, void* view, size_t size) {
|
||||||
|
#ifndef NO_MMAP
|
||||||
munmap(view, size);
|
munmap(view, size);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* MemArena::Find4GBBase() {
|
u8* MemArena::Find4GBBase() {
|
||||||
@ -147,6 +157,9 @@ u8* MemArena::Find4GBBase() {
|
|||||||
// This has been known to fail lately though, see issue #12249.
|
// This has been known to fail lately though, see issue #12249.
|
||||||
return hardcoded_ptr;
|
return hardcoded_ptr;
|
||||||
}
|
}
|
||||||
|
#elif defined(NO_MMAP)
|
||||||
|
void* base = std::malloc(0x0A000000);
|
||||||
|
return static_cast<u8*>(base);
|
||||||
#else
|
#else
|
||||||
size_t size = 0x10000000;
|
size_t size = 0x10000000;
|
||||||
void* base = mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED | MAP_NORESERVE, -1, 0);
|
void* base = mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED | MAP_NORESERVE, -1, 0);
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#endif // HAVE_LIBNX
|
#endif // HAVE_LIBNX
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include <emscripten/emscripten.h>
|
||||||
|
#endif // __EMSCRIPTEN__
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "CommonWindows.h"
|
#include "CommonWindows.h"
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
@ -58,6 +62,8 @@ void sleep_ms(int ms) {
|
|||||||
Sleep(ms);
|
Sleep(ms);
|
||||||
#elif defined(HAVE_LIBNX)
|
#elif defined(HAVE_LIBNX)
|
||||||
svcSleepThread(ms * 1000000);
|
svcSleepThread(ms * 1000000);
|
||||||
|
#elif defined(__EMSCRIPTEN__)
|
||||||
|
emscripten_sleep(ms);
|
||||||
#else
|
#else
|
||||||
usleep(ms * 1000);
|
usleep(ms * 1000);
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,7 +67,7 @@ extern u32 g_PSPModel;
|
|||||||
|
|
||||||
// UWP has such limited memory management that we need to mask
|
// UWP has such limited memory management that we need to mask
|
||||||
// even in 64-bit mode. Also, when using the sanitizer, we need to mask as well.
|
// even in 64-bit mode. Also, when using the sanitizer, we need to mask as well.
|
||||||
#if PPSSPP_ARCH(32BIT) || PPSSPP_PLATFORM(UWP) || USE_ASAN || PPSSPP_PLATFORM(IOS)
|
#if PPSSPP_ARCH(32BIT) || PPSSPP_PLATFORM(UWP) || USE_ASAN || PPSSPP_PLATFORM(IOS) || defined(__EMSCRIPTEN__)
|
||||||
#define MASKED_PSP_MEMORY
|
#define MASKED_PSP_MEMORY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -300,16 +300,12 @@ else ifneq (,$(findstring armv,$(platform)))
|
|||||||
|
|
||||||
# emscripten
|
# emscripten
|
||||||
else ifeq ($(platform), emscripten)
|
else ifeq ($(platform), emscripten)
|
||||||
|
TARGET_ARCH = wasm32
|
||||||
|
GLES = 1
|
||||||
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
|
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
|
||||||
GLES := 1
|
PLATCFLAGS += -msimd128 -msse3 -mssse3 -msse4.1 -pthread -D__EMSCRIPTEN__ -DNO_MMAP
|
||||||
CPUFLAGS +=
|
PLATFORM_EXT = emscripten
|
||||||
PLATCFLAGS += -DCC_resampler=mupen_CC_resampler -Dsinc_resampler=mupen_sinc_resampler \
|
STATIC_LINKING = 1
|
||||||
-Drglgen_symbol_map=mupen_rglgen_symbol_map -Dmain_exit=mupen_main_exit \
|
|
||||||
-Dadler32=mupen_adler32 -Drarch_resampler_realloc=mupen_rarch_resampler_realloc \
|
|
||||||
-Daudio_convert_s16_to_float_C=mupen_audio_convert_s16_to_float_C -Daudio_convert_float_to_s16_C=mupen_audio_convert_float_to_s16_C \
|
|
||||||
-Daudio_convert_init_simd=mupen_audio_convert_init_simd -Drglgen_resolve_symbols_custom=mupen_rglgen_resolve_symbols_custom \
|
|
||||||
-Drglgen_resolve_symbols=mupen_rglgen_resolve_symbols
|
|
||||||
PLATFORM_EXT = unix
|
|
||||||
|
|
||||||
# Windows MSVC all architectures
|
# Windows MSVC all architectures
|
||||||
else ifneq (,$(findstring windows_msvc2019,$(platform)))
|
else ifneq (,$(findstring windows_msvc2019,$(platform)))
|
||||||
@ -435,7 +431,11 @@ else
|
|||||||
GLFLAGS += -DHAVE_OPENGL
|
GLFLAGS += -DHAVE_OPENGL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
COREFLAGS += -D__LIBRETRO__ -DPPSSPP -DUSE_FFMPEG -DWITH_UPNP -DGLEW_STATIC -DGLEW_NO_GLU -DMINIUPNP_STATICLIB
|
COREFLAGS += -D__LIBRETRO__ -DPPSSPP -DWITH_UPNP -DGLEW_STATIC -DGLEW_NO_GLU -DMINIUPNP_STATICLIB
|
||||||
|
ifneq ($(platform), emscripten)
|
||||||
|
# ffmpeg does not work with emscripten
|
||||||
|
COREFLAGS += -DUSE_FFMPEG
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
ifneq (,$(findstring msvc,$(platform)))
|
ifneq (,$(findstring msvc,$(platform)))
|
||||||
@ -445,6 +445,8 @@ ifeq ($(DEBUG), 1)
|
|||||||
CPUOPTS += -O0 -g
|
CPUOPTS += -O0 -g
|
||||||
endif
|
endif
|
||||||
CPUOPTS += -D_DEBUG
|
CPUOPTS += -D_DEBUG
|
||||||
|
else ifeq ($(platform), emscripten)
|
||||||
|
CPUOPTS += -O3 -DNDEBUG
|
||||||
else
|
else
|
||||||
CPUOPTS += -O2 -DNDEBUG
|
CPUOPTS += -O2 -DNDEBUG
|
||||||
endif
|
endif
|
||||||
@ -494,7 +496,7 @@ all: $(TARGET)
|
|||||||
|
|
||||||
$(TARGET): $(OBJECTS)
|
$(TARGET): $(OBJECTS)
|
||||||
ifeq ($(STATIC_LINKING), 1)
|
ifeq ($(STATIC_LINKING), 1)
|
||||||
$(AR) rcs $A $(OBJECTS)
|
$(AR) rcs $(TARGET) $(OBJECTS)
|
||||||
else
|
else
|
||||||
$(LD) $(LINKOUT)$@ $(OBJECTS) $(LDFLAGS) $(GL_LIB)
|
$(LD) $(LINKOUT)$@ $(OBJECTS) $(LDFLAGS) $(GL_LIB)
|
||||||
endif
|
endif
|
||||||
|
@ -474,6 +474,7 @@ static void check_variables(CoreParameter &coreParam)
|
|||||||
g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED;
|
g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
var.key = "ppsspp_cpu_core";
|
var.key = "ppsspp_cpu_core";
|
||||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||||
{
|
{
|
||||||
@ -491,6 +492,9 @@ static void check_variables(CoreParameter &coreParam)
|
|||||||
// to experiment in future iOS versions or something...
|
// to experiment in future iOS versions or something...
|
||||||
g_Config.iCpuCore = (int)CPUCore::IR_JIT;
|
g_Config.iCpuCore = (int)CPUCore::IR_JIT;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
g_Config.iCpuCore = (int)CPUCore::INTERPRETER;
|
||||||
|
#endif
|
||||||
|
|
||||||
var.key = "ppsspp_fast_memory";
|
var.key = "ppsspp_fast_memory";
|
||||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define PPSSPP_API(PPSSPP_FEATURE) (PPSSPP_API_##PPSSPP_FEATURE)
|
#define PPSSPP_API(PPSSPP_FEATURE) (PPSSPP_API_##PPSSPP_FEATURE)
|
||||||
|
|
||||||
// ARCH defines
|
// ARCH defines
|
||||||
#if defined(_M_IX86) || defined(__i386__)
|
#if defined(_M_IX86) || defined(__i386__) || defined (__EMSCRIPTEN__)
|
||||||
#define PPSSPP_ARCH_X86 1
|
#define PPSSPP_ARCH_X86 1
|
||||||
#define PPSSPP_ARCH_32BIT 1
|
#define PPSSPP_ARCH_32BIT 1
|
||||||
//TODO: Remove this compat define
|
//TODO: Remove this compat define
|
||||||
@ -17,7 +17,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)
|
#if (defined(_M_X64) || defined(__amd64__) || defined(__x86_64__)) && !defined(__EMSCRIPTEN__)
|
||||||
#define PPSSPP_ARCH_AMD64 1
|
#define PPSSPP_ARCH_AMD64 1
|
||||||
#if defined(__ILP32__)
|
#if defined(__ILP32__)
|
||||||
#define PPSSPP_ARCH_32BIT 1
|
#define PPSSPP_ARCH_32BIT 1
|
||||||
|
Loading…
Reference in New Issue
Block a user