fix makefile; fix yaml to json
This commit is contained in:
parent
eaa3bf00c5
commit
cb30231c2f
12
Makefile
12
Makefile
|
@ -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
|
||||
|
|
|
@ -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 = {};
|
||||
|
|
|
@ -110,12 +110,17 @@ function global_uni(uni, stage)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
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,15 +138,18 @@ render.make_shader = function(shader)
|
|||
return obj;
|
||||
}
|
||||
|
||||
var out = `${file.name()}.shader`;
|
||||
var out = `.prosperon/${file.name()}.shader`;
|
||||
|
||||
var files = [file];
|
||||
|
||||
|
||||
var incs = shader.match(/#include <.*>/g);
|
||||
if (incs)
|
||||
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);
|
||||
}
|
||||
|
@ -177,7 +185,7 @@ render.make_shader = function(shader)
|
|||
var yamlfile = `${out}_reflection.yaml`;
|
||||
console.info(`slurping ${yamlfile}`);
|
||||
var jjson = yaml.tojson(io.slurp(yamlfile));
|
||||
var obj = json.decode(jjson);
|
||||
var obj = json.decode(jjson);
|
||||
io.rm(yamlfile);
|
||||
|
||||
obj = obj.shaders[0].programs[0];
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue