Compilation targets of WIN, WEB, and LINUX; ftw to nftw for emscripten [2deca9ddb9]

This commit is contained in:
John Alanbrook 2023-08-31 22:23:24 +00:00
parent a58da54994
commit 1b1d080528
9 changed files with 42 additions and 27 deletions

View file

@ -7,6 +7,7 @@ UNAME != uname
# DBG --- build with debugging symbols and logging
# ED --- build with or without editor
# OPT --- Optimize
# OS --- Set to WIN, WEB, MAC, IOS, LINUX
QFLAGS :=
@ -17,7 +18,6 @@ ifdef DBG
ifeq ($(CC),tcc)
QFLAGS +=
endif
else
QFLAGS += -O2
INFO = rel
@ -34,9 +34,25 @@ endif
QFLAGS += -DHAVE_CEIL -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF
PTYPE != uname -m
ifeq ($(OS), WIN)
LINKER_FLAGS += $(QFLAGS) -static
ELIBS = engine d3d11 dxgi quickjs gdi32 ws2_32 ole32 winmm setupapi m
CLIBS =
EXT = .exe
CC = x86_64-w64-mingw32-gcc
else ifeq ($(OS), WEB)
LINKER_FLAGS += $(QFLAGS) -static -sFULL_ES3
ELIBS = engine pthread quickjs GL c m dl
CLIBS =
CC = emcc
else
LINKER_FLAGS += $(QFLAGS) -L/usr/local/lib -pthread -rdynamic
ELIBS = engine pthread quickjs GL c m dl X11 Xi Xcursor EGL asound
CLIBS =
endif
BIN = bin/$(CC)/$(INFO)/
objprefix = $(BIN)obj
@ -70,7 +86,7 @@ includeflag != find source -type d -name include
includeflag += $(engincs) source/engine/thirdparty/Nuklear
includeflag := $(addprefix -I, $(includeflag))
WARNING_FLAGS = -Wall -Wno-incompatible-function-pointer-types -Wno-unused-function# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function
WARNING_FLAGS = -Wall -Wno-incompatible-function-pointer-types -Wno-unused-function# -pedantic -Wextra -Wwrite-strings -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types -Wno-unused-function -Wno-int-conversion
SEM = 0.0.1
COM != fossil describe
@ -80,17 +96,6 @@ COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -I. -DCP_USE_DOUB
LIBPATH = -L$(BIN)
ifeq ($(OS), WIN32)
LINKER_FLAGS = $(QFLAGS) -static
ELIBS = engine glfw3 opengl32 quickjs gdi32 ws2_32 ole32 winmm setupapi m
CLIBS =
EXT = .exe
else
LINKER_FLAGS = $(QFLAGS) -L/usr/local/lib -pthread -rdynamic
ELIBS = engine pthread yughc quickjs GL c m dl X11 Xi Xcursor EGL asound
CLIBS =
endif
NAME = yugine$(EXT)
ELIBS != $(call prefix, $(ELIBS), -l)
@ -154,10 +159,6 @@ $(objprefix)/%.o:%.c
@echo Making C object $@
@$(CC) $(COMPILER_FLAGS)
.PHONY: docs
docs:
asciidoctor docs/*.adoc
.PHONY: clean
clean:
@echo Cleaning project

View file

@ -568,7 +568,7 @@ JSValue dukext2paths(char *ext) {
dukext = ext;
dukarr = JS_NewArray(js);
dukidx = 0;
ftw(".", duk2path, 10);
nftw(".", duk2path, 10,0);
return dukarr;
}

View file

@ -8,6 +8,7 @@
#include "stb_ds.h"
#include "time.h"
#include <stdio.h>
#include <ctype.h>
#include "stb_ds.h"

View file

@ -14,6 +14,8 @@
#include "model.h"
#include "stb_ds.h"
#include "sokol/sokol_app.h"
#include "HandmadeMath.h"
int renderMode = LIT;

View file

@ -19,7 +19,7 @@
char *DATA_PATH = NULL;
char *PREF_PATH = NULL;
char *prefabs;
char **prefabs;
const char *EXT_PREFAB = ".prefab";
const char *EXT_LEVEL = ".level";
@ -89,7 +89,7 @@ static int ext_check(const char *path, const struct stat *sb, int typeflag) {
void fill_extensions(char *paths, const char *path, const char *ext) {
cur_ext = ext;
arrfree(paths);
ftw(".", ext_check, 10);
nftw(".", ext_check, 10, 0);
}
void findPrefabs() {

View file

@ -13,7 +13,7 @@ extern int stemlen;
void resources_init();
extern char *prefabs;
extern char **prefabs;
void findPrefabs();
void fill_extensions(char *paths, const char *path, const char *ext);
char *get_filename_from_path(char *path, int extension);

View file

@ -87,7 +87,7 @@ struct sprite *id2sprite(int id) {
return &sprites[id];
}
static sprite_count = 0;
static int sprite_count = 0;
void sprite_flush() {
sprite_count = 0;

View file

@ -6,6 +6,8 @@
#include "input.h"
#include "openglrender.h"
#include "window.h"
#include "sound.h"
#include "resources.h"
#include "datastream.h"
@ -33,7 +35,15 @@
#define SOKOL_TRACE_HOOKS
#define SOKOL_IMPL
#if defined __linux__
#define SOKOL_GLCORE33
#elif __EMSCRIPTEN__
#define SOKOL_GLES3
#elif __WIN32
#define SOKOL_D3D11
#endif
#include "sokol/sokol_gfx.h"
#include "sokol/sokol_app.h"
#include "sokol/sokol_audio.h"
@ -140,6 +150,7 @@ static char **args;
void c_init() {
int logout = 0;
#if DBG
#if __linux
if (logout) {
time_t now = time(NULL);
char fname[100];
@ -161,8 +172,9 @@ void c_init() {
signal(SIGABRT, seghandle);
signal(SIGFPE, seghandle);
signal(SIGBUS, seghandle);
#endif
#endif
resources_init();
phys2d_init();
sound_init();
@ -196,8 +208,6 @@ void c_frame()
double elapsed = sapp_frame_duration();
appTime += elapsed;
nuke_input_begin();
// if (sim_playing())
input_poll(fmax(0, renderMS-elapsed));
// else

View file

@ -14,6 +14,7 @@ void print_stacktrace();
const char *engine_info();
int frame_fps();
double get_timescale();
extern double appTime;
extern double renderMS;