replace -DWASM with compiler internal __EMSCRIPTEN__

This commit is contained in:
Adam Powers
2020-08-27 22:15:12 -07:00
parent 18254eb291
commit c9f5bb9ac4
4 changed files with 9 additions and 13 deletions

View File

@@ -325,15 +325,15 @@ struct version_info {
unsigned long incarnation; /* actual version number */ unsigned long incarnation; /* actual version number */
unsigned long feature_set; /* bitmask of config settings */ unsigned long feature_set; /* bitmask of config settings */
unsigned long entity_count; /* # of monsters and objects */ unsigned long entity_count; /* # of monsters and objects */
#ifndef WASM #ifndef __EMSCRIPTEN__
unsigned long struct_sizes1; /* size of key structs */ unsigned long struct_sizes1; /* size of key structs */
unsigned long struct_sizes2; /* size of more key structs */ unsigned long struct_sizes2; /* size of more key structs */
#else /* WASM */ #else /* __EMSCRIPTEN__ */
/* 'long' in WASM is 4 bytes, which is too small to hold version numbers /* 'long' in WASM is 4 bytes, which is too small to hold version numbers
* such as: VERSION_SANITY2 */ * such as: VERSION_SANITY2 */
unsigned long long struct_sizes1; /* size of key structs */ unsigned long long struct_sizes1; /* size of key structs */
unsigned long long struct_sizes2; /* size of more key structs */ unsigned long long struct_sizes2; /* size of more key structs */
#endif /* !WASM */ #endif /* !__EMSCRIPTEN__ */
}; };
struct savefile_info { struct savefile_info {
@@ -397,7 +397,7 @@ struct savefile_info {
/* PANICTRACE: Always defined for NH_DEVEL_STATUS != NH_STATUS_RELEASED /* PANICTRACE: Always defined for NH_DEVEL_STATUS != NH_STATUS_RELEASED
but only for supported platforms. */ but only for supported platforms. */
#if defined(UNIX) && !defined(WASM) #if defined(UNIX) && !defined(__EMSCRIPTEN__)
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED) #if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
/* see end.c */ /* see end.c */
#ifndef PANICTRACE #ifndef PANICTRACE
@@ -412,7 +412,7 @@ struct savefile_info {
#if defined(MACOSX) #if defined(MACOSX)
#define PANICTRACE_LIBC #define PANICTRACE_LIBC
#endif #endif
#if defined(UNIX) && !defined(WASM) /* no popen in WASM */ #if defined(UNIX) && !defined(__EMSCRIPTEN__) /* no popen in WASM */
#define PANICTRACE_GDB #define PANICTRACE_GDB
#endif #endif

View File

@@ -148,9 +148,6 @@ CXX_V1 = @echo "[CXX] $<"; $(ACTUAL_CXX)
CXX = $(CXX_V$(QUIETCC)) CXX = $(CXX_V$(QUIETCC))
CFLAGS+=-I../include CFLAGS+=-I../include
ifdef WANT_WASM
CFLAGS+=-DWASM
endif
# LD and LINK might be based on invoking CC and may not be able to substitute # LD and LINK might be based on invoking CC and may not be able to substitute
# for QUIETCC, so feedback from them is handled differently (via $AT) # for QUIETCC, so feedback from them is handled differently (via $AT)

View File

@@ -17,7 +17,7 @@ EMCC_LFLAGS=-s WASM=1
EMCC_LFLAGS+=-s ALLOW_TABLE_GROWTH EMCC_LFLAGS+=-s ALLOW_TABLE_GROWTH
EMCC_LFLAGS+=-s ASYNCIFY -s ASYNCIFY_IMPORTS='["_nhmain"]' -O3 EMCC_LFLAGS+=-s ASYNCIFY -s ASYNCIFY_IMPORTS='["_nhmain"]' -O3
EMCC_LFLAGS+=-s MODULARIZE EMCC_LFLAGS+=-s MODULARIZE
EMCC_LFLAGS+=-s EXPORTED_FUNCTIONS='["_main"]' EMCC_LFLAGS+=-s EXPORTED_FUNCTIONS='["_main", "_stub_graphics_set_callback"]'
EMCC_LFLAGS+=-s EXPORTED_RUNTIME_METHODS='["cwrap", "ccall", "addFunction", "removeFunction", "UTF8ToString"]' EMCC_LFLAGS+=-s EXPORTED_RUNTIME_METHODS='["cwrap", "ccall", "addFunction", "removeFunction", "UTF8ToString"]'
EMCC_LFLAGS+=-s ERROR_ON_UNDEFINED_SYMBOLS=0 EMCC_LFLAGS+=-s ERROR_ON_UNDEFINED_SYMBOLS=0
EMCC_LFLAGS+=--embed-file wasm-data@/ EMCC_LFLAGS+=--embed-file wasm-data@/
@@ -25,7 +25,6 @@ EMCC_LFLAGS+=--embed-file wasm-data@/
# WASM C flags # WASM C flags
EMCC_CFLAGS= EMCC_CFLAGS=
EMCC_CFLAGS+=-Wall -Werror EMCC_CFLAGS+=-Wall -Werror
EMCC_CFLAGS+=-DWASM
EMCC_DEBUG_CFLAGS+=-s ASSERTIONS=1 EMCC_DEBUG_CFLAGS+=-s ASSERTIONS=1
EMCC_DEBUG_CFLAGS+=-s STACK_OVERFLOW_CHECK=2 EMCC_DEBUG_CFLAGS+=-s STACK_OVERFLOW_CHECK=2
EMCC_DEBUG_CFLAGS+=-s SAFE_HEAP=1 EMCC_DEBUG_CFLAGS+=-s SAFE_HEAP=1

View File

@@ -1218,17 +1218,17 @@ do_date()
#endif #endif
Fprintf(ofp, "#define VERSION_SANITY1 0x%08lx%s\n", version.entity_count, Fprintf(ofp, "#define VERSION_SANITY1 0x%08lx%s\n", version.entity_count,
ul_sfx); ul_sfx);
#ifndef WASM #ifndef __EMSCRIPTEN__
Fprintf(ofp, "#define VERSION_SANITY2 0x%08lx%s\n", version.struct_sizes1, Fprintf(ofp, "#define VERSION_SANITY2 0x%08lx%s\n", version.struct_sizes1,
ul_sfx); ul_sfx);
Fprintf(ofp, "#define VERSION_SANITY3 0x%08lx%s\n", version.struct_sizes2, Fprintf(ofp, "#define VERSION_SANITY3 0x%08lx%s\n", version.struct_sizes2,
ul_sfx); ul_sfx);
#else /* WASM */ #else /* __EMSCRIPTEN__ */
Fprintf(ofp, "#define VERSION_SANITY2 0x%08llx%s\n", version.struct_sizes1, Fprintf(ofp, "#define VERSION_SANITY2 0x%08llx%s\n", version.struct_sizes1,
ul_sfx); ul_sfx);
Fprintf(ofp, "#define VERSION_SANITY3 0x%08llx%s\n", version.struct_sizes2, Fprintf(ofp, "#define VERSION_SANITY3 0x%08llx%s\n", version.struct_sizes2,
ul_sfx); ul_sfx);
#endif /* !WASM */ #endif /* !__EMSCRIPTEN__ */
Fprintf(ofp, "\n"); Fprintf(ofp, "\n");
Fprintf(ofp, "#define VERSION_STRING \"%s\"\n", version_string(buf, ".")); Fprintf(ofp, "#define VERSION_STRING \"%s\"\n", version_string(buf, "."));