fix makefile; fix yaml to json

This commit is contained in:
John Alanbrook 2024-05-30 17:12:32 -05:00
parent eaa3bf00c5
commit cb30231c2f
4 changed files with 25 additions and 12 deletions

View file

@ -176,17 +176,19 @@ ifndef VERBOSE
.SILENT: .SILENT:
endif endif
DEPFLAGS = -MT $(@:.d=.o) -MM -MG $< -o $@
%$(INFO).d: %.c %$(INFO).d: %.c
@echo Making deps $@ @echo Making deps $@
$(CROSS)$(CC) $(CPPFLAGS) -MT $@ -MM -MG $^ -o $@ $(CROSS)$(CC) $(CPPFLAGS) $(DEPFLAGS)
%$(INFO).d: %.cpp %$(INFO).d: %.cpp
@echo Making deps $@ @echo Making deps $@
$(CROSS)$(CXX) $(CPPFLAGS) -MT $@ -MM -MG $^ -o $@ $(CROSS)$(CXX) $(CPPFLAGS) $(DEPFLAGS)
%$(INFO).d: %.m %$(INFO).d: %.m
@echo Making deps $@ @echo Making deps $@
$(CROSS)$(CC) $(CPPFLAGS) -MT $@ -MM -MG $^ -o $@ $(CROSS)$(CC) $(CPPFLAGS) $(DEPFLAGS)
ifneq ($(MAKECMDGOALS), clean) ifneq ($(MAKECMDGOALS), clean)
include $(DEPENDS) include $(DEPENDS)
@ -213,9 +215,7 @@ $(NAME): $(OBJS) $(DEPS)
@echo Making Objective-C object $@ @echo Making Objective-C object $@
$(CROSS)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(CROSS)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
SCRIPTS := $(shell ls scripts/*.js*) CORE != (ls icons/* fonts/* shaders/*.cg scripts/*.js*)
CORE != (ls icons/* fonts/*)
CORE := $(CORE) $(SCRIPTS)
packer: tools/packer.c source/engine/miniz.c packer: tools/packer.c source/engine/miniz.c
@echo Making packer @echo Making packer

View file

@ -1556,8 +1556,9 @@ Math.sortpointsccw = function(points)
var yaml = {}; var yaml = {};
yaml.tojson = function(yaml) yaml.tojson = function(yaml)
{ {
// Replace key value pairs that are strings with quotation marks around them
yaml = yaml.replace(/(\w+):/g, '"$1":'); yaml = yaml.replace(/(\w+):/g, '"$1":');
yaml = yaml.replace(/: ([\w\.]+)/g, ': "$1"'); yaml = yaml.replace(/: ([\w\.\/]+)/g, ': "$1"'); // TODO: make this more general
yaml = yaml.split("\n"); yaml = yaml.split("\n");
var cont = {}; var cont = {};

View file

@ -115,7 +115,12 @@ render.make_shader = function(shader)
{ {
var file = shader; var file = shader;
shader = io.slurp(shader); shader = io.slurp(shader);
var writejson = `${file.name()}_c.json`; console.info(shader);
if (!shader) {
console.info(`not found! slurping shaders/${file}`);
shader = io.slurp(`shaders/${file}`);
}
var writejson = `.prosperon/${file.name()}.shader.json`;
var st = profile.now(); var st = profile.now();
breakme: if (io.exists(writejson)) { breakme: if (io.exists(writejson)) {
@ -133,7 +138,7 @@ render.make_shader = function(shader)
return obj; return obj;
} }
var out = `${file.name()}.shader`; var out = `.prosperon/${file.name()}.shader`;
var files = [file]; var files = [file];
@ -142,6 +147,9 @@ render.make_shader = function(shader)
for (var inc of incs) { for (var inc of incs) {
var filez = inc.match(/#include <(.*)>/)[1]; var filez = inc.match(/#include <(.*)>/)[1];
var macro = io.slurp(filez); var macro = io.slurp(filez);
if (!macro)
macro = io.slurp(`shaders/${filez}`);
shader = shader.replace(inc, macro); shader = shader.replace(inc, macro);
files.push(filez); files.push(filez);
} }

View file

@ -1219,6 +1219,10 @@ JSValue js_io_slurpbytes(JSContext *js, JSValue self, int argc, JSValue *argv)
char *f = js2str(argv[0]); char *f = js2str(argv[0]);
size_t len; size_t len;
unsigned char *d = slurp_file(f,&len); unsigned char *d = slurp_file(f,&len);
if (!d) {
JS_FreeCString(js,f);
return JS_UNDEFINED;
}
JSValue ret = JS_NewArrayBufferCopy(js,d,len); JSValue ret = JS_NewArrayBufferCopy(js,d,len);
JS_FreeCString(js,f); JS_FreeCString(js,f);
free(d); free(d);