Add system command; correct makefile

This commit is contained in:
John Alanbrook 2024-03-24 12:44:35 -05:00
parent ecb2882e7e
commit 3023a12184
7 changed files with 41 additions and 11 deletions

16
Info.plist Normal file
View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>Prosperon</string>
<key>CFBundleIdentifier</key>
<string>pockle.world.prosperon</string>
<key>CFBundleName</key>
<string>Prosperon</string>
<key>CFBundleVersion</key>
<string>0.5</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2024 Pockle World. All rights reserved.</string>
</dict>
</plist>

View file

@ -173,6 +173,7 @@ SHADERS = $(shell ls source/shaders/*.sglsl)
SHADERS := $(patsubst %.sglsl, %.sglsl.h, $(SHADERS))
install: $(NAME)
@echo Copying to destination
cp -f $(NAME) $(DESTDIR)/$(APP)
$(NAME): libengine$(INFO).a libquickjs$(INFO).a
@ -181,13 +182,14 @@ $(NAME): libengine$(INFO).a libquickjs$(INFO).a
@echo Finished build
libengine$(INFO).a: $(OBJS)
@echo Archiving $@
$(AR) rcs $@ $(OBJS)
QUICKJS := source/engine/thirdparty/quickjs
libquickjs$(INFO).a: $(QUICKJS)/libregexp$(INFO).o $(QUICKJS)/quickjs$(INFO).o $(QUICKJS)/libunicode$(INFO).o $(QUICKJS)/cutils$(INFO).o $(QUICKJS)/libbf$(INFO).o
$(AR) rcs $@ $^
%$(INFO).o: %.c $(SHADERS) source/engine/core.cdb.h
%$(INFO).o: %.c $(SHADERS)
@echo Making C object $@
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
@ -206,6 +208,10 @@ shaders: $(SHADERS)
@echo Creating shader $^
./sokol-shdc --ifdef -i $^ --slang=glsl330:hlsl5:metal_macos:metal_ios:metal_sim:glsl300es -o $@
SCRIPTS := $(shell ls scripts/*.js*)
CORE != (ls icons/* fonts/*)
CORE := $(CORE) $(SCRIPTS)
CDB = source/engine/thirdparty/tinycdb
CDB_C != find $(CDB) -name *.c
CDB_O := $(patsubst %.c, %.o, $(CDB_C))
@ -223,19 +229,15 @@ packer: tools/packer.c tools/libcdb.a
cc $^ -I$(CDB) -o packer
core.cdb: packer $(CORE)
@echo Packing core.cdb
./packer $(CORE)
chmod 644 out.cdb
mv out.cdb core.cdb
source/engine/core.cdb.h: core.cdb
@echo Packing core.cdb.h
@echo Making $@
xxd -i $< > $@
SCRIPTS := $(shell ls scripts/*.js*)
SCRIPT_O := $(addsuffix o, $(SCRIPTS))
CORE != (ls icons/* fonts/*)
CORE := $(CORE) $(SCRIPTS)
jsc: tools/jso.c tools/libquickjs.a
$(CC) $^ -lm -Iquickjs -o $@

View file

@ -37,6 +37,13 @@ os.prefpath = function() {
return otherpath[os.sys()] + "/" + (game.title ? game.title : "Untitled Prosperon Game");
}
os.openurl = function(url) {
if (os.sys() === 'windows')
os.system(`start ${url}`);
else
os.system(`open ${url}`);
}
var projectfile = ".prosperon/project.json";
Resources.is_sound = function(path) {

View file

@ -809,11 +809,16 @@ JSC_SCALL(os_make_texture,
JS_SetPropertyStr(js, ret, "path", JS_DupValue(js,argv[0]));
)
JSC_SCALL(os_system,
system(str);
)
static const JSCFunctionListEntry js_os_funcs[] = {
MIST_FUNC_DEF(os,sprite,1),
MIST_FUNC_DEF(os, cwd, 0),
MIST_FUNC_DEF(os, env, 1),
MIST_FUNC_DEF(os, sys, 0),
MIST_FUNC_DEF(os, system, 1),
MIST_FUNC_DEF(os, quit, 0),
MIST_FUNC_DEF(os, reindex_static, 0),
MIST_FUNC_DEF(os, gc, 0),