Rename client-config.json based on CLIENTBIN

Also make viewing client.html directly use client-config.json in the
same directory so it's possible to "live edit" both the files without
having to run make.
This commit is contained in:
Zack Middleton 2024-06-10 03:14:12 -05:00
parent 7bfd5c90b8
commit c1ab47a764
2 changed files with 9 additions and 4 deletions

View File

@ -1093,8 +1093,6 @@ ifeq ($(PLATFORM),emscripten)
$(error "No files in '$(BASEGAME)' directory for emscripten to preload.") $(error "No files in '$(BASEGAME)' directory for emscripten to preload.")
endif endif
CLIENT_LDFLAGS+=--preload-file $(BASEGAME) CLIENT_LDFLAGS+=--preload-file $(BASEGAME)
else
CLIENT_EXTRA_FILES+=code/web/client-config.json
endif endif
OPTIMIZEVM = -O3 OPTIMIZEVM = -O3
@ -1230,6 +1228,9 @@ ifeq ($(PLATFORM),emscripten)
ifneq ($(BUILD_CLIENT),0) ifneq ($(BUILD_CLIENT),0)
TARGETS += $(B)/$(CLIENTBIN).html TARGETS += $(B)/$(CLIENTBIN).html
ifneq ($(EMSCRIPTEN_PRELOAD_FILE),1)
TARGETS += $(B)/$(CLIENTBIN)-config.json
endif
ifneq ($(USE_RENDERER_DLOPEN),0) ifneq ($(USE_RENDERER_DLOPEN),0)
GENERATEDTARGETS += $(B)/$(CLIENTBIN).$(ARCH).wasm GENERATEDTARGETS += $(B)/$(CLIENTBIN).$(ARCH).wasm
@ -3094,6 +3095,10 @@ $(B)/$(CLIENTBIN).html: $(WEBDIR)/client.html
$(echo_cmd) "SED $@" $(echo_cmd) "SED $@"
$(Q)sed 's/__CLIENTBIN__/$(CLIENTBIN)/g;s/__BASEGAME__/$(BASEGAME)/g;s/__EMSCRIPTEN_PRELOAD_FILE__/$(EMSCRIPTEN_PRELOAD_FILE)/g' < $< > $@ $(Q)sed 's/__CLIENTBIN__/$(CLIENTBIN)/g;s/__BASEGAME__/$(BASEGAME)/g;s/__EMSCRIPTEN_PRELOAD_FILE__/$(EMSCRIPTEN_PRELOAD_FILE)/g' < $< > $@
$(B)/$(CLIENTBIN)-config.json: $(WEBDIR)/client-config.json
$(echo_cmd) "CP $@"
$(Q)cp $< $@
############################################################################# #############################################################################
# MISC # MISC

View File

@ -20,13 +20,14 @@ let enginePath = './';
// Path or URL containing fs_game directories. // Path or URL containing fs_game directories.
let dataPath = './'; let dataPath = './';
// Path or URL for config file that specifies the files to load for each fs_game. // Path or URL for config file that specifies the files to load for each fs_game.
let configFilename = './client-config.json'; let configFilename = `./${CLIENTBIN}-config.json`;
// If displaying the unmodified HTML file, fallback to defaults. // If displaying the unmodified HTML file, fallback to defaults.
if (clientHtmlFallback) { if (clientHtmlFallback) {
CLIENTBIN='ioquake3'; CLIENTBIN='ioquake3';
BASEGAME='baseq3'; BASEGAME='baseq3';
EMSCRIPTEN_PRELOAD_FILE=0; EMSCRIPTEN_PRELOAD_FILE=0;
configFilename='./client-config.json';
} }
if (window.location.protocol === 'file:') throw new Error(`Unfortunately browser security restrictions prevent loading wasm from a file: URL. This file must be loaded from a web server. The easiest way to do this is probably to use Python\'s built-in web server by running \`python3 -m http.server\` in the top level source directory and then navigate to http://localhost:8000/build/debug-emscripten-wasm32/${CLIENTBIN}.html`); if (window.location.protocol === 'file:') throw new Error(`Unfortunately browser security restrictions prevent loading wasm from a file: URL. This file must be loaded from a web server. The easiest way to do this is probably to use Python\'s built-in web server by running \`python3 -m http.server\` in the top level source directory and then navigate to http://localhost:8000/build/debug-emscripten-wasm32/${CLIENTBIN}.html`);
@ -68,7 +69,6 @@ if (clientHtmlFallback) {
enginePath = buildPaths[buildIndex]; enginePath = buildPaths[buildIndex];
dataPath = buildPaths[buildIndex]; dataPath = buildPaths[buildIndex];
configFilename = dataPath + 'client-config.json';
} }
const dataURL = new URL(dataPath, location.origin + location.pathname); const dataURL = new URL(dataPath, location.origin + location.pathname);