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

View file

@ -1556,8 +1556,9 @@ Math.sortpointsccw = function(points)
var 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"'); // TODO: make this more general
yaml = yaml.split("\n");
var cont = {};

View file

@ -115,7 +115,12 @@ render.make_shader = function(shader)
{
var file = 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();
breakme: if (io.exists(writejson)) {
@ -133,7 +138,7 @@ render.make_shader = function(shader)
return obj;
}
var out = `${file.name()}.shader`;
var out = `.prosperon/${file.name()}.shader`;
var files = [file];
@ -142,6 +147,9 @@ render.make_shader = function(shader)
for (var inc of incs) {
var filez = inc.match(/#include <(.*)>/)[1];
var macro = io.slurp(filez);
if (!macro)
macro = io.slurp(`shaders/${filez}`);
shader = shader.replace(inc, macro);
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]);
size_t len;
unsigned char *d = slurp_file(f,&len);
if (!d) {
JS_FreeCString(js,f);
return JS_UNDEFINED;
}
JSValue ret = JS_NewArrayBufferCopy(js,d,len);
JS_FreeCString(js,f);
free(d);