From 553cc07e9d663bebc0479b391776f07f7978b7ba Mon Sep 17 00:00:00 2001 From: Gabriel Jacobo Date: Fri, 20 Jun 2014 10:59:51 -0300 Subject: [PATCH] Initialize nacl_io, removes SDL_NaClMount/Umount It's just easier to use nacl_io's mount/umount directly. --- README-nacl.txt | 20 +++++++++++++++----- build-scripts/naclbuild.sh | 2 +- include/SDL_system.h | 17 ----------------- src/main/nacl/SDL_nacl_main.c | 8 +++++--- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/README-nacl.txt b/README-nacl.txt index 0d58f2013..d868e9180 100644 --- a/README-nacl.txt +++ b/README-nacl.txt @@ -60,18 +60,17 @@ script will give you instructions on how to do that with Python). RWops and nacl_io ================================================================================ -SDL_RWops work transparently with nacl_io. Two functions are provided to control -mount points: +SDL_RWops work transparently with nacl_io. Two functions control the mount points: - int SDL_NaClMount(const char* source, const char* target, + int mount(const char* source, const char* target, const char* filesystemtype, unsigned long mountflags, const void *data); - int SDL_NaClUmount(const char *target); + int umount(const char *target); For convenience, SDL will by default mount an httpfs tree at / before calling the app's main function. Such setting can be overridden by calling: - SDL_NaClUmount("/"); + umount("/"); And then mounting a different filesystem at / @@ -85,6 +84,17 @@ connections are involved. For more information on how nacl_io and mount points work, see: https://developer.chrome.com/native-client/devguide/coding/nacl_io + https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h + +To be able to save into the directory "/save/" (like backup of game) : + + mount("", "/save", "html5fs", 0, "type=PERSISTENT"); + +And add to manifest.json : + + "permissions": [ + "unlimitedStorage" + ] ================================================================================ TODO - Known Issues diff --git a/build-scripts/naclbuild.sh b/build-scripts/naclbuild.sh index 56218061e..717e7178f 100755 --- a/build-scripts/naclbuild.sh +++ b/build-scripts/naclbuild.sh @@ -1,6 +1,6 @@ #!/bin/bash if [ -z "$1" ] && [ -z "$NACL_SDK_ROOT" ]; then - echo "Usage: ./naclbuild ~/nacl/pepper_33" + echo "Usage: ./naclbuild ~/nacl/pepper_35" echo "This will build SDL for Native Client, and testgles2.c as a demo" echo "You can set env vars CC, AR, LD and RANLIB to override the default PNaCl toolchain used" echo "You can set env var SOURCES to select a different source file than testgles2.c" diff --git a/include/SDL_system.h b/include/SDL_system.h index dcca8f3b2..78d5b0d0a 100644 --- a/include/SDL_system.h +++ b/include/SDL_system.h @@ -179,23 +179,6 @@ extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathT #endif /* __WINRT__ */ -#ifdef __NACL__ - -/** - * \name Mount/umount functions - * - * Required for RWOps on Native Client - */ -/* @{ */ -extern DECLSPEC int SDLCALL SDL_NaClMount(const char* source, const char* target, - const char* filesystemtype, - unsigned long mountflags, const void *data); - -extern DECLSPEC int SDLCALL SDL_NaClUmount(const char *target); - -#endif /* __NACL__ */ - - /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/src/main/nacl/SDL_nacl_main.c b/src/main/nacl/SDL_nacl_main.c index efa2d375f..80dea3b4e 100644 --- a/src/main/nacl/SDL_nacl_main.c +++ b/src/main/nacl/SDL_nacl_main.c @@ -24,11 +24,11 @@ /* Include the SDL main definition header */ #include "SDL_main.h" -#include "SDL_system.h" #include "ppapi_simple/ps_main.h" #include "ppapi_simple/ps_event.h" #include "ppapi_simple/ps_interface.h" +#include "nacl_io/nacl_io.h" extern void NACL_SetScreenResolution(int width, int height, Uint32 format); @@ -69,8 +69,10 @@ nacl_main(int argc, char *argv[]) * apps can override this by unmounting / * and remounting with the desired configuration */ - SDL_NaClUmount("/"); - SDL_NaClMount( + nacl_io_init_ppapi(PSGetInstanceId(), PSGetInterface); + + umount("/"); + mount( "", /* source */ "/", /* target */ "httpfs", /* filesystemtype */