Modifications for web build

This commit is contained in:
John Alanbrook 2024-04-15 07:58:23 -05:00
parent 7e04937c8b
commit 9d75b38098
4 changed files with 16 additions and 17 deletions

View file

@ -15,7 +15,7 @@ INFO :=
LD = $(CC)
STEAM = steam/sdk
STEAMAPI = steam_api
STEAMAPI =
CCC != $(CC) -v
ifneq ($(findstring clangcc , $(CCC)),)
@ -43,8 +43,7 @@ ifdef NQOA
endif
ifeq ($(CC), emcc)
LDFLAGS += #--closure 1 --emrun
CPPFLAGS += -O0
LDFLAGS += --closure 1 --emrun --preload-file game.cdb
OPT = 0
NDEBUG = 1
AR = emar
@ -118,9 +117,10 @@ else ifeq ($(OS), IOS)
INFO :=$(INFO)_ios
else ifeq ($(CC), emcc) # Then WEB
OS := Web
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -pthread -sTOTAL_MEMORY=128MB
CPPFLAGS += -pthread
LDLIBS += pthread quickjs GL openal c m dl
LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sTOTAL_MEMORY=128MB -sSTACK_SIZE=5MB
CPPFLAGS += -dNSTEAM -sASSERTIONS=2
LDLIBS += GL openal c m dl
STEAMAPI :=
EXT = .html
else
UNAME != uname -s
@ -219,13 +219,13 @@ SCRIPTS := $(shell ls scripts/*.js*)
CORE != (ls icons/* fonts/*)
CORE := $(CORE) $(SCRIPTS)
packer$(EXT): tools/packer.c source/engine/miniz.c
packer: tools/packer.c source/engine/miniz.c
@echo Making packer
$(CC) -O2 $^ -Isource/engine -o packer
core.cdb: packer$(EXT) $(CORE)
core.cdb: packer $(CORE)
@echo Packing core.cdb
./packer$(EXT) $@ $(CORE)
./packer $@ $(CORE)
source/engine/core.cdb.h: core.cdb
@echo Making $@
@ -268,10 +268,11 @@ crossmac: Prosperon.icns
crossweb:
make CC=emcc
mv $(APP)_$(ARCH).html index.html
playweb:
make crossweb
emrun $(NAME).html
emrun index.html
clean:
@echo Cleaning project

View file

@ -147,8 +147,8 @@ console.say = function(msg) {
console.transcript += msg;
};
console.log = console.say;
var say = console.say;
var print = console.print;
globalThis.say = console.say;
globalThis.print = console.print;
console.pprint = function(msg,lvl = 0) {
if (typeof msg === 'object')
@ -213,17 +213,14 @@ function use(file, env = {}, script)
if (use.cache[file]) {
var ret = use.cache[file].call(env);
profile.report(st, `CACHE eval ${file}`);
profile.addreport(profcache, file, st);
return;
}
console.info(`slurping ${file}`);
script ??= Resources.replstrs(file);
script = `(function() { var self = this; ${script}; })`;
var fn = os.eval(file,script);
use.cache[file] = fn;
var ret = fn.call(env);
profile.report(st, `eval ${file}`);
profile.addreport(profcache, file, st);
return ret;
}

View file

@ -106,6 +106,7 @@ void log_print(const char *str)
{
#ifndef NDEBUG
fprintf(writeout, str);
fprintf(stdout, str);
#endif
fflush(stdout);
}

View file

@ -229,8 +229,8 @@ sapp_desc sokol_main(int argc, char **argv) {
if (argc > i+1) strcat(cmdstr, " ");
}
while (!LOADED_GAME)
sfetch_dowork();
// while (!LOADED_GAME)
// sfetch_dowork();
script_evalf("cmd_args('%s');", cmdstr);
return start_desc;