mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 20:19:38 +00:00
Fix web build and add export path
This commit is contained in:
11
AerofoilWeb/BuildAerofoilPortable.bat
Normal file
11
AerofoilWeb/BuildAerofoilPortable.bat
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
set INPUT_DIR=../AerofoilPortable
|
||||||
|
set OUTPUT_DIR=obj
|
||||||
|
|
||||||
|
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||||
|
set DEBUG_LEVEL_FLAGS=-O3
|
||||||
|
|
||||||
|
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../Common/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS% -DGP_DEBUG_CONFIG=0
|
||||||
|
|
||||||
|
emcc -c %INPUT_DIR%/GpAllocator_C.cpp -o %OUTPUT_DIR%/AerofoilPortable_Combined.o %FLAGS%
|
||||||
|
|
||||||
|
pause
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
set INPUT_DIR=.
|
set INPUT_DIR=.
|
||||||
set OUTPUT_DIR=obj
|
set OUTPUT_DIR=obj
|
||||||
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -I../GpShell/ -s ASYNCIFY -O3 -DGP_DEBUG_CONFIG=0
|
|
||||||
|
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||||
|
set DEBUG_LEVEL_FLAGS=-O3
|
||||||
|
|
||||||
|
set FLAGS=-s USE_SDL=2 -flto -I../GpCommon/ -I../PortabilityLayer/ -I../Common/ -I../AerofoilPortable/ -I../GpShell/ -s ASYNCIFY %DEBUG_LEVEL_FLAGS% -DGP_DEBUG_CONFIG=0
|
||||||
|
|
||||||
emcc -c %INPUT_DIR%/AerofoilWeb_Combined.cpp -o %OUTPUT_DIR%/AerofoilWeb_Combined.o %FLAGS%
|
emcc -c %INPUT_DIR%/AerofoilWeb_Combined.cpp -o %OUTPUT_DIR%/AerofoilWeb_Combined.o %FLAGS%
|
||||||
|
|
||||||
|
|||||||
@@ -386,7 +386,8 @@ bool GpFileSystem_Web::ms_fsStateDirty;
|
|||||||
|
|
||||||
bool GpFileSystem_Web::ResolvePath(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, bool trailingSlash, std::string &resolution)
|
bool GpFileSystem_Web::ResolvePath(PortabilityLayer::VirtualDirectory_t virtualDirectory, char const* const* paths, size_t numPaths, bool trailingSlash, std::string &resolution)
|
||||||
{
|
{
|
||||||
const char *prefsAppend = nullptr;
|
const char *pathAppend = nullptr;
|
||||||
|
const std::string *rootPath = nullptr;
|
||||||
std::string unsanitized;
|
std::string unsanitized;
|
||||||
|
|
||||||
switch (virtualDirectory)
|
switch (virtualDirectory)
|
||||||
@@ -401,24 +402,32 @@ bool GpFileSystem_Web::ResolvePath(PortabilityLayer::VirtualDirectory_t virtualD
|
|||||||
unsanitized = std::string("Resources");
|
unsanitized = std::string("Resources");
|
||||||
break;
|
break;
|
||||||
case PortabilityLayer::VirtualDirectories::kHighScores:
|
case PortabilityLayer::VirtualDirectories::kHighScores:
|
||||||
prefsAppend = "HighScores";
|
pathAppend = "HighScores";
|
||||||
|
rootPath = &m_basePath;
|
||||||
break;
|
break;
|
||||||
case PortabilityLayer::VirtualDirectories::kUserData:
|
case PortabilityLayer::VirtualDirectories::kUserData:
|
||||||
prefsAppend = "Houses";
|
pathAppend = "Houses";
|
||||||
|
rootPath = &m_basePath;
|
||||||
break;
|
break;
|
||||||
case PortabilityLayer::VirtualDirectories::kUserSaves:
|
case PortabilityLayer::VirtualDirectories::kUserSaves:
|
||||||
prefsAppend = "SavedGames";
|
pathAppend = "SavedGames";
|
||||||
|
rootPath = &m_basePath;
|
||||||
break;
|
break;
|
||||||
case PortabilityLayer::VirtualDirectories::kPrefs:
|
case PortabilityLayer::VirtualDirectories::kPrefs:
|
||||||
prefsAppend = "Prefs";
|
pathAppend = "Prefs";
|
||||||
|
rootPath = &m_basePath;
|
||||||
|
break;
|
||||||
|
case PortabilityLayer::VirtualDirectories::kSourceExport:
|
||||||
|
pathAppend = "Export";
|
||||||
|
rootPath = &m_exportPath;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (prefsAppend)
|
if (pathAppend)
|
||||||
{
|
{
|
||||||
unsanitized = prefsAppend;
|
unsanitized = pathAppend;
|
||||||
|
|
||||||
for (size_t i = 0; i < numPaths; i++)
|
for (size_t i = 0; i < numPaths; i++)
|
||||||
{
|
{
|
||||||
@@ -448,7 +457,7 @@ bool GpFileSystem_Web::ResolvePath(PortabilityLayer::VirtualDirectory_t virtualD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resolution = m_prefsPath + "/" + sanitized;
|
resolution = (*rootPath) + "/" + sanitized;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -478,6 +487,7 @@ GpFileSystem_Web::~GpFileSystem_Web()
|
|||||||
void GpFileSystem_Web::Init()
|
void GpFileSystem_Web::Init()
|
||||||
{
|
{
|
||||||
m_prefsPath = "/aerofoil";
|
m_prefsPath = "/aerofoil";
|
||||||
|
m_exportPath = "/aerofoil_memfs";
|
||||||
|
|
||||||
char *baseDir = SDL_GetBasePath();
|
char *baseDir = SDL_GetBasePath();
|
||||||
m_basePath = baseDir;
|
m_basePath = baseDir;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ private:
|
|||||||
|
|
||||||
std::string m_prefsPath;
|
std::string m_prefsPath;
|
||||||
std::string m_basePath;
|
std::string m_basePath;
|
||||||
|
std::string m_exportPath;
|
||||||
static bool ms_fsStateDirty;
|
static bool ms_fsStateDirty;
|
||||||
|
|
||||||
static GpFileSystem_Web ms_instance;
|
static GpFileSystem_Web ms_instance;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "SDL_main.h"
|
#include "SDL_main.h"
|
||||||
|
|
||||||
#include "GpMain.h"
|
#include "GpMain.h"
|
||||||
|
#include "GpAllocator_C.h"
|
||||||
#include "GpAudioDriverFactory.h"
|
#include "GpAudioDriverFactory.h"
|
||||||
#include "GpDisplayDriverFactory.h"
|
#include "GpDisplayDriverFactory.h"
|
||||||
#include "GpGlobalConfig.h"
|
#include "GpGlobalConfig.h"
|
||||||
@@ -28,9 +29,12 @@ IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &pr
|
|||||||
IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties);
|
IGpInputDriver *GpDriver_CreateInputDriver_SDL2_Gamepad(const GpInputDriverProperties &properties);
|
||||||
|
|
||||||
EM_JS(void, InitFileSystem, (), {
|
EM_JS(void, InitFileSystem, (), {
|
||||||
Asyncify.handleSleep(wakeUp => {
|
Asyncify.handleSleep(wakeUp => {
|
||||||
FS.mkdir('/aerofoil');
|
FS.mkdir('/aerofoil');
|
||||||
|
//FS.mkdir('/aerofoil_memfs');
|
||||||
FS.mount(IDBFS, {}, '/aerofoil');
|
FS.mount(IDBFS, {}, '/aerofoil');
|
||||||
|
//FS.mount(MEMFS, {}, '/aerofoil_memfs');
|
||||||
|
//FS.mkdir('/aerofoil_memfs/Export');
|
||||||
FS.syncfs(true, function (err) {
|
FS.syncfs(true, function (err) {
|
||||||
assert(!err);
|
assert(!err);
|
||||||
wakeUp();
|
wakeUp();
|
||||||
@@ -40,6 +44,8 @@ EM_JS(void, InitFileSystem, (), {
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
IGpAllocator *alloc = GpAllocator_C::GetInstance();
|
||||||
|
|
||||||
InitFileSystem();
|
InitFileSystem();
|
||||||
|
|
||||||
GpLogDriver_Web::Init();
|
GpLogDriver_Web::Init();
|
||||||
@@ -65,6 +71,7 @@ int main(int argc, char* argv[])
|
|||||||
drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Web::GetInstance());
|
drivers->SetDriver<GpDriverIDs::kFileSystem>(GpFileSystem_Web::GetInstance());
|
||||||
drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Web::GetInstance());
|
drivers->SetDriver<GpDriverIDs::kSystemServices>(GpSystemServices_Web::GetInstance());
|
||||||
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Web::GetInstance());
|
drivers->SetDriver<GpDriverIDs::kLog>(GpLogDriver_Web::GetInstance());
|
||||||
|
drivers->SetDriver<GpDriverIDs::kAlloc>(alloc);
|
||||||
|
|
||||||
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2;
|
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2;
|
||||||
|
|
||||||
@@ -83,6 +90,7 @@ int main(int argc, char* argv[])
|
|||||||
g_gpGlobalConfig.m_osGlobals = &g_gpXGlobals;
|
g_gpGlobalConfig.m_osGlobals = &g_gpXGlobals;
|
||||||
g_gpGlobalConfig.m_logger = logger;
|
g_gpGlobalConfig.m_logger = logger;
|
||||||
g_gpGlobalConfig.m_systemServices = GpSystemServices_Web::GetInstance();
|
g_gpGlobalConfig.m_systemServices = GpSystemServices_Web::GetInstance();
|
||||||
|
g_gpGlobalConfig.m_allocator = alloc;
|
||||||
|
|
||||||
GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_SDL_GL2, GpDriver_CreateDisplayDriver_SDL_GL2);
|
GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_SDL_GL2, GpDriver_CreateDisplayDriver_SDL_GL2);
|
||||||
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL);
|
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL);
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
set INPUT_DIR=.
|
set INPUT_DIR=.
|
||||||
set OUTPUT_DIR=bin
|
set OUTPUT_DIR=bin
|
||||||
set FLAGS=-flto -O3 -s USE_SDL=2 -s USE_ZLIB=1 -s ASYNCIFY -s ASYNCIFY_IGNORE_INDIRECT -s INITIAL_MEMORY=33554432 -s ASYNCIFY_ADVISE -lidbfs.js -s ASYNCIFY_IMPORTS=['InitFileSystem','FlushFileSystem'] --shell-file shell_minimal.html
|
|
||||||
emcc obj/AerofoilWeb_Combined.o obj/AerofoilWeb_Resources.o obj/GpShell_Combined.o obj/AerofoilSDL_Combined.o obj/GpApp_Combined.o obj/PortabilityLayer_Combined.o obj/MacRomanConversion.o -o %OUTPUT_DIR%/aerofoil.html %FLAGS%
|
rem set DEBUG_LEVEL_FLAGS=-g4 -O0
|
||||||
|
set DEBUG_LEVEL_FLAGS=-O3
|
||||||
|
|
||||||
|
set FLAGS=-flto %DEBUG_LEVEL_FLAGS% -s USE_SDL=2 -s USE_ZLIB=1 -s ASYNCIFY -s ASYNCIFY_IGNORE_INDIRECT -s INITIAL_MEMORY=33554432 -s ASYNCIFY_ADVISE -lidbfs.js -s ASYNCIFY_IMPORTS=['InitFileSystem','FlushFileSystem'] --shell-file shell_minimal.html
|
||||||
|
emcc obj/AerofoilWeb_Combined.o obj/AerofoilWeb_Resources.o obj/GpShell_Combined.o obj/AerofoilSDL_Combined.o obj/AerofoilPortable_Combined.o obj/GpApp_Combined.o obj/PortabilityLayer_Combined.o obj/MacRomanConversion.o -o %OUTPUT_DIR%/aerofoil.html %FLAGS%
|
||||||
|
|||||||
Reference in New Issue
Block a user