From c437eb4f4bf01771031b11a460b0b4f8ae3285c0 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 22 Sep 2015 15:22:17 -0400 Subject: [PATCH] Make the engine start up in PNaCl. --- makefile | 5 +++-- quakedef.h | 4 ++++ sys_sdl.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index 1086e869..97f428b1 100644 --- a/makefile +++ b/makefile @@ -149,12 +149,13 @@ ifeq ($(DP_MAKE_TARGET), pnacl) # TODO is there a better way to get this path? # TODO is net/if.h really missing? - CFLAGS_EXTRA=-I$(HOME)/nacl_sdk/pepper_44/include/pnacl -DNOSUPPORTIPV6 + CFLAGS_EXTRA=-I$(HOME)/nacl_sdk/pepper_44/include -I$(HOME)/nacl_sdk/pepper_44/include/pnacl $(SDLCONFIG_CFLAGS) -DNOSUPPORTIPV6 CFLAGS_SSE= CFLAGS_SSE2= # TODO use pnacl-finalize and pnacl-compress - STRIP=: + CC=$(HOME)/nacl_sdk/pepper_44/toolchain/linux_pnacl/bin/pnacl-clang++ + STRIP=$(HOME)/nacl_sdk/pepper_44/toolchain/linux_pnacl/bin/pnacl-finalize --compress endif # Mac OS X configuration diff --git a/quakedef.h b/quakedef.h index 60d5db30..545d920b 100644 --- a/quakedef.h +++ b/quakedef.h @@ -431,6 +431,10 @@ extern cvar_t sessionid; # define LINK_TO_LIBVORBIS 1 # define DP_MOBILETOUCH 1 # define DP_FREETYPE_STATIC 1 +#elif defined(__native_client__) /* must come first because it also defines linux */ +# define DP_OS_NAME "NaCl" +# define DP_OS_STR "nacl" +# define USE_GLES2 1 #elif TARGET_OS_IPHONE /* must come first because it also defines MACOSX */ # define DP_OS_NAME "iPhoneOS" # define DP_OS_STR "iphoneos" diff --git a/sys_sdl.c b/sys_sdl.c index 5fd4c3af..54651b44 100644 --- a/sys_sdl.c +++ b/sys_sdl.c @@ -201,6 +201,18 @@ void Sys_InitConsole (void) { } +#ifdef __native_client__ +#include +static void NaCl_Init(void) +{ + mount("", "/dev", "dev", 0, ""); + mount("", "/.persistentfs", "html5fs", 0, "type=PERSISTENT,expected_size=8388608"); + mount("", "/.tempfs", "html5fs", 0, "type=TEMPORARY,expected_size=1073741824"); + int fd = open("/dev/console0", O_WRONLY, 0644); + outfd = fd; +} +#endif + int main (int argc, char *argv[]) { signal(SIGFPE, SIG_IGN); @@ -229,6 +241,10 @@ int main (int argc, char *argv[]) // we don't know which systems we'll want to init, yet... SDL_Init(0); +#ifdef __native_client__ + NaCl_Init(); +#endif + Host_Main(); return 0; -- 2.39.2