Merge branch 'wasm-pr403' into NetHack-3.7
This commit is contained in:
@@ -630,10 +630,10 @@ clearlocks()
|
||||
#endif
|
||||
#ifndef NO_SIGNAL
|
||||
(void) signal(SIGINT, SIG_IGN);
|
||||
#endif
|
||||
#if defined(UNIX) || defined(VMS)
|
||||
sethanguphandler((void FDECL((*), (int) )) SIG_IGN);
|
||||
#endif
|
||||
#endif /* NO_SIGNAL */
|
||||
/* can't access maxledgerno() before dungeons are created -dlc */
|
||||
for (x = (g.n_dgns ? maxledgerno() : 0); x >= 0; x--)
|
||||
delete_levelfile(x); /* not all levels need be present */
|
||||
|
||||
@@ -101,10 +101,10 @@ dosave0()
|
||||
return 0;
|
||||
fq_save = fqname(g.SAVEF, SAVEPREFIX, 1); /* level files take 0 */
|
||||
|
||||
#ifndef NO_SIGNAL
|
||||
#if defined(UNIX) || defined(VMS)
|
||||
sethanguphandler((void FDECL((*), (int) )) SIG_IGN);
|
||||
#endif
|
||||
#ifndef NO_SIGNAL
|
||||
(void) signal(SIGINT, SIG_IGN);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -555,11 +555,11 @@ whoami()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef NO_SIGNAL
|
||||
void
|
||||
sethanguphandler(handler)
|
||||
void FDECL((*handler), (int));
|
||||
{
|
||||
#ifndef NO_SIGNAL
|
||||
#ifdef SA_RESTART
|
||||
/* don't want reads to restart. If SA_RESTART is defined, we know
|
||||
* sigaction exists and can be used to ensure reads won't restart.
|
||||
@@ -581,8 +581,8 @@ void FDECL((*handler), (int));
|
||||
(void) signal(SIGXCPU, (SIG_RET_TYPE) handler);
|
||||
#endif
|
||||
#endif /* ?SA_RESTART */
|
||||
#endif /* !NO_SIGNAL */
|
||||
}
|
||||
#endif /* !NO_SIGNAL */
|
||||
|
||||
#ifdef PORT_HELP
|
||||
void
|
||||
@@ -1003,7 +1003,8 @@ void js_constants_init() {
|
||||
// copyright
|
||||
SET_CONSTANT_STRING("COPYRIGHT", COPYRIGHT_BANNER_A);
|
||||
SET_CONSTANT_STRING("COPYRIGHT", COPYRIGHT_BANNER_B);
|
||||
SET_CONSTANT_STRING("COPYRIGHT", COPYRIGHT_BANNER_C);
|
||||
// XXX: not set for cross-compile
|
||||
//SET_CONSTANT_STRING("COPYRIGHT", COPYRIGHT_BANNER_C);
|
||||
SET_CONSTANT_STRING("COPYRIGHT", COPYRIGHT_BANNER_D);
|
||||
|
||||
// glyphs
|
||||
@@ -1071,7 +1072,6 @@ void create_global (char *name, void *ptr, char *type);
|
||||
void js_globals_init() {
|
||||
// int i;
|
||||
// char buf[BUFSZ];
|
||||
printf("js_globals_init\n");
|
||||
|
||||
EM_ASM({
|
||||
globalThis.nethackGlobal = globalThis.nethackGlobal || {};
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
"description": "The original NetHack rogue-like game built as a WebAssembly module",
|
||||
"main": "src/nethackShim.js",
|
||||
"scripts": {
|
||||
"test": "node test/test.js",
|
||||
"test": "npm run build && node test/test.js",
|
||||
"clean": "rm ./build/nethack.js; rm ./build/nethack.wasm; true",
|
||||
"build": "cp ../../../src/nethack.js ../../../src/nethack.wasm ./build",
|
||||
"build": "mkdir build; cp ../../../targets/wasm/nethack.js ../../../targets/wasm/nethack.wasm ./build",
|
||||
"prepack": "npm run build"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
if [ x$1 == "xlib" ]; then
|
||||
echo Doing lib...
|
||||
make spotless
|
||||
cd sys/lib
|
||||
if [ -f Makefile ]; then
|
||||
make spotless
|
||||
fi
|
||||
cd sys/unix
|
||||
./setup.sh hints/macOS.2020
|
||||
cd ../..
|
||||
make
|
||||
make WANT_LIBNH=1
|
||||
fi
|
||||
|
||||
if [ x$1 == "xrunlib" ]; then
|
||||
@@ -19,15 +21,17 @@ fi
|
||||
|
||||
if [ x$1 == "xwasm" ]; then
|
||||
echo Doing wasm...
|
||||
make spotless
|
||||
cd sys/lib
|
||||
./setup.sh hints/wasm
|
||||
if [ -f Makefile ]; then
|
||||
make spotless
|
||||
fi
|
||||
cd sys/unix
|
||||
./setup.sh hints/macOS.2020
|
||||
cd ../..
|
||||
make
|
||||
make CROSS_TO_WASM=1
|
||||
fi
|
||||
|
||||
if [ x$1 == "xrunwasm" ]; then
|
||||
cd sys/lib/npm-package && node test/test.js
|
||||
cd sys/lib/npm-package && npm run build && node test/test.js
|
||||
fi
|
||||
|
||||
if [ x$1 == "xbin" ]; then
|
||||
|
||||
@@ -29,10 +29,12 @@ endif
|
||||
ifdef CROSS_TO_WASM
|
||||
CROSS=1
|
||||
BUILD_TARGET_LUA=1
|
||||
HACKDIR=/
|
||||
PREFIX=
|
||||
override TARGET = wasm
|
||||
override TARGETDIR=../targets/$(TARGET)
|
||||
override TARGETPFX = $(TARGETDIR)/
|
||||
override TARGET_LIBS=
|
||||
override TARGET_LIBS=
|
||||
endif
|
||||
|
||||
ifdef CROSS
|
||||
@@ -246,7 +248,7 @@ else
|
||||
override TARGET_LINK = $(TARGET_CC)
|
||||
endif
|
||||
override TARGET_LFLAGS= $(TOOLARCH)
|
||||
#override TARGET_LIBS +=
|
||||
#override TARGET_LIBS +=
|
||||
VARDATND += nhtiles.bmp
|
||||
override SYSSRC = ../outdated/sys/amiga/amidos.c ../outdated/sys/amiga/amigst.c \
|
||||
../outdated/sys/amiga/amimenu.c ../outdated/sys/amiga/amirip.c \
|
||||
@@ -298,36 +300,43 @@ ifdef CROSS_TO_WASM
|
||||
# originally from https://github.com/NetHack/NetHack/pull/385
|
||||
#===============-=================================================
|
||||
#
|
||||
WASM_DEBUG = 1
|
||||
WASM_DATA_DIR = $(TARGETPFX)wasm-data
|
||||
WASM_TARGET = $(TARGETPFX)nethack.js
|
||||
EMCC_LFLAGS =
|
||||
#EMCC_LFLAGS += -s SINGLE_FILE=1
|
||||
EMCC_LFLAGS += -DHACKDIR=\"$(HACKDIR)\"
|
||||
EMCC_LFLAGS += -s WASM=1
|
||||
EMCC_LFLAGS += -s ALLOW_TABLE_GROWTH
|
||||
EMCC_LFLAGS += -s ASYNCIFY -s ASYNCIFY_IMPORTS='["local_callback"]'
|
||||
EMCC_LFLAGS += -O3
|
||||
EMCC_LFLAGS += -s MODULARIZE
|
||||
EMCC_LFLAGS += -s EXPORTED_FUNCTIONS='["_main", "_shim_graphics_set_callback"]'
|
||||
EMCC_LFLAGS += -s EXPORTED_FUNCTIONS='["_main", "_shim_graphics_set_callback", "_mapglyph", "_display_inventory"]'
|
||||
EMCC_LFLAGS += -s EXPORTED_RUNTIME_METHODS='["cwrap", "ccall", "addFunction", \
|
||||
"removeFunction", "UTF8ToString", "getValue", "setValue"]'
|
||||
EMCC_LFLAGS += -s ERROR_ON_UNDEFINED_SYMBOLS=0
|
||||
EMCC_LFLAGS += --embed-file $(WASM_DATA_DIR)
|
||||
# XXX: the "@/" at the end of "--embed-file" tells emscripten to embed the files
|
||||
# in the root directory, otherwise they will end up in the $(WASM_DATA_DIR) path
|
||||
EMCC_LFLAGS += --embed-file $(WASM_DATA_DIR)@/
|
||||
# For a list of EMCC settings:
|
||||
# https://github.com/emscripten-core/emscripten/blob/master/src/settings.js
|
||||
#
|
||||
# WASM C flags
|
||||
EMCC_CFLAGS=
|
||||
EMCC_CFLAGS =
|
||||
EMCC_CFLAGS += -Wall
|
||||
#EMCC_CFLAGS += -Werror
|
||||
EMCC_CFLAGS += -Werror
|
||||
EMCC_CFLAGS += -DNO_SIGNAL
|
||||
#EMCC_CFLAGS += -s DISABLE_EXCEPTION_CATCHING=0
|
||||
EMCC_DEBUG_CFLAGS += -s ASSERTIONS=1
|
||||
#EMCC_DEBUG_CFLAGS += -s ASSERTIONS=2
|
||||
#EMCC_DEBUG_CFLAGS += -s ASSERTIONS=1
|
||||
EMCC_DEBUG_CFLAGS += -s ASSERTIONS=2
|
||||
EMCC_DEBUG_CFLAGS += -s STACK_OVERFLOW_CHECK=2
|
||||
EMCC_DEBUG_CFLAGS += -s SAFE_HEAP=1
|
||||
EMCC_DEBUG_CFLAGS += -s LLD_REPORT_UNDEFINED=1
|
||||
#EMCC_DEBUG_CFLAGS += -s EXCEPTION_DEBUG=1
|
||||
EMCC_DEBUG_CFLAGS += -s EXCEPTION_DEBUG=1
|
||||
#EMCC_DEBUG_CFLAGS += -fsanitize=undefined -fsanitize=address -fsanitize=leak
|
||||
#EMCC_DEBUG_CFLAGS += -s EXIT_RUNTIME
|
||||
EMCC_DEBUG_CFLAGS += -s EXIT_RUNTIME=1
|
||||
# XXX: if --profiling isn't included then any error dumps 10MB of WASM to the screen rather than a useful message
|
||||
EMCC_DEBUG_CFLAGS += --profiling
|
||||
EMCC_PROD_CFLAGS += -O3
|
||||
ifdef WASM_DEBUG
|
||||
EMCC_CFLAGS += $(EMCC_DEBUG_CFLAGS)
|
||||
|
||||
@@ -294,6 +294,7 @@ VARDIR=$(HACKDIR)
|
||||
#-INCLUDE cross-pre.2020
|
||||
#
|
||||
#-POST
|
||||
|
||||
ifdef WANT_LIBNH
|
||||
libnh.a: $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua.a
|
||||
$(AR) rcs $@ $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua.a
|
||||
|
||||
Reference in New Issue
Block a user