Fixup makefile for docker builds

This commit is contained in:
John Alanbrook 2024-03-09 18:22:06 -06:00
parent 6897f09e59
commit 7d1f19bbf5
14 changed files with 80 additions and 42 deletions

13
.gitignore vendored
View file

@ -4,10 +4,21 @@ bin/
build/
*.o
*.a
*.d
tags
Jenkinsfile
*~
*.log
*.gz
*.tar
.nova/
packer
primum
sokol-shdc
source/shaders/*.h
core.cdb
primum.exe
core.cdb.h
jsc
.DS_Store
primum.html

View file

@ -1,7 +1,6 @@
MAKEFLAGS = --jobs=4
UNAME != uname
MAKEDIR != pwd
# Options
# DBG --- build with debugging symbols and logging
@ -92,6 +91,8 @@ endif
CPPFLAGS += -DHAVE_CEIL -DCP_USE_CGTYPES=0 -DCP_USE_DOUBLES=0 -DHAVE_FLOOR -DHAVE_FMOD -DHAVE_LRINT -DHAVE_LRINTF $(includeflag) -MD $(WARNING_FLAGS) -I. -DVER=\"$(VER)\" -DCOM=\"$(COM)\" -DINFO=\"$(INFO)\" #-DENABLE_SINC_MEDIUM_CONVERTER -DENABLE_SINC_FAST_CONVERTER -DCP_COLLISION_TYPE_TYPE=uintptr_t -DCP_BITMASK_TYPE=uintptr_t
CPPFLAGS += -D_FILE_OFFSET_BITS=64 # for tinycdb
# ENABLE_SINC_[BEST|FAST|MEDIUM]_CONVERTER
# default, fast and medium available in game at runtime; best available in editor
@ -120,7 +121,7 @@ endif
ifeq ($(OS), Windows_NT)
LDFLAGS += -mwin32 -static
CPPFLAGS += -mwin32
LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m
LDLIBS += mingw32 kernel32 d3d11 user32 shell32 dxgi gdi32 ws2_32 ole32 winmm setupapi m pthread
EXT = .exe
ARCH := x86_64
PKGCMD = cd $(BIN); zip -q -r $(MAKEDIR)/$(DISTDIR)/$(DIST) . -x \*.a ./obj/\*
@ -158,8 +159,8 @@ endif
OBJDIR = $(BIN)/obj
# All other sources
OBJS != find source/engine -type f -name '*.c' | grep -vE 'test|tool|example'
CPPOBJS != find source/engine -type f -name '*.cpp' | grep -vE 'test|tool|example'
OBJS != find source/engine -type f -name '*.c' | grep -vE 'test|tool|example|fuzz|main'
CPPOBJS != find source/engine -type f -name '*.cpp' | grep -vE 'test|tool|example|fuzz|main'
OBJS += $(CPPOBJS)
OBJS += $(shell find source/engine -type f -name '*.m')
OBJS := $(patsubst %.cpp, %.o, $(OBJS))
@ -220,19 +221,17 @@ $(DISTDIR)/$(DIST): $(BIN)/$(NAME)
@mkdir -p $(DISTDIR)
@$(PKGCMD)
$(BIN)/libengine.a: source/engine/core.cdb.h $(OBJS)
$(BIN)/libengine.a: $(OBJS)
@$(AR) rcs $@ $(OBJS)
$(BIN)/libcdb.a:
mkdir -p $(BIN)
CDB_C != find $(CDB) -name *.c
CDB_O := $(patsubst %.c, %.o, $(CDB_C))
$(CDB)/libcdb.a:
rm -f $(CDB)/libcdb.a
make -C $(CDB) CC=$(CC) AR=$(AR) libcdb.a
cp $(CDB)/libcdb.a $(BIN)
tools/libcdb.a:
make -C $(CDB) libcdb.a
mv $(CDB)/libcdb.a tools
make -C $(CDB) libcdb.a
tools/libcdb.a: $(CDB)/libcdb.a
cp $(CDB)/libcdb.a tools
DOCOS = Sound gameobject Game Window physics Profile Time Player Mouse IO Log ColorMap sprite SpriteAnim Render Geometry
DOCHTML := $(addsuffix .api.html, $(DOCOS))
@ -257,20 +256,20 @@ input.md: $(INPUTMD)
@echo Printing api for $*
@./primum -d $* > $@
$(BIN)/libquickjs.a: $(QUICKJS_O)
$(BIN)/libquickjs.a:
make -C quickjs clean
make -C quickjs SYSRT=$(SYSRT) TTARGET=$(TTARGET) ARCH=$(ARCH) DBG=$(DBG) OPT=$(OPT) AR=$(AR) OS=$(OS) libquickjs.a HOST_CC=$(CC) LEAK=$(LEAK)
@mkdir -p $(BIN)
cp -rf quickjs/libquickjs.* $(BIN)
$(OBJDIR)/%.o: %.c
$(OBJDIR)/%.o: %.c source/engine/core.cdb.h $(SHADERS)
@mkdir -p $(@D)
@echo Making C object $@
@$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(@D)
@echo Making C++ object $@ with $(CXX)
@echo Making C++ object $@
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(OBJDIR)/%.o: %.m
@ -301,22 +300,20 @@ core.cdb: packer $(CORE)
chmod 644 out.cdb
mv out.cdb core.cdb
CDB_C != find $(CDB) -name *.c
packer: tools/packer.c tools/libcdb.a
cc $^ -I$(CDB) -o packer
jsc: tools/jso.c tools/libquickjs.a
$(CC) $^ -lm -Iquickjs -o $@
tools/libquickjs.a:
make -C quickjs clean
make -C quickjs OPT=$(OPT) AR=$(AR) libquickjs.a
cp -f quickjs/libquickjs.a tools
tools/libquickjs.a: $(BIN)/libquickjs.a
cp -f $(BIN)/libquickjs.a tools
WINCC = x86_64-w64-mingw32-gcc
#WINCC = i686-w64-mingw32-g++
.PHONY: crosswin
crosswin:
make packer
make CC=$(WINCC) OS=Windows_NT
crossmac:
@ -326,16 +323,24 @@ crossmac:
mv primum primum_x86_64
lipo primum_arm64 primum_x86_64 -create -output primum
crossweb:
make packer
make CC=emcc
clean:
@echo Cleaning project
@rm -rf bin dist
@rm -f shaders/*.sglsl.h shaders/*.metal core.cdb jso cdb packer TAGS
rm -rf bin dist
rm -f source/shaders/*.h core.cdb jso cdb packer TAGS source/engine/core.cdb.h tools/libcdb.a $(CDB)/libcdb.a
rm -f $(CDB)/*.o
@make -C quickjs clean
docs: doc/prosperon.org
make -C doc
mv doc/html .
test:
@echo No tests yet ...
TAGINC != find . -name "*.[chj]"
tags: $(TAGINC)
@echo Making tags.

View file

@ -106,7 +106,7 @@ Run ~prosperon~. You will see "Hello world!" in the console, and it shuts down.
Using ~config.js~ and ~game.js~, you can write an entire game, without reaching any further. When you want to populate a world with independent actors, entities are what you will reach for.
** Actors
The fundamental tool for building in Prosperon is the actor system. Actors run independently from each other. Actors are defined by a combination of code and data. All actors have a *master*[fn::I am aware of the ongoing controversy surrounding the use of this term. That is precisely why I have used it: there are a plethora of similar relationships in video games, and by using a term most teams would rather not used, I have saved left the field of avaialable ones wide open] which controls certain properties of the actor.
The fundamental tool for building in Prosperon is the actor system. Actors run independently from each other. Actors are defined by a combination of code and data. All actors have a *master* which controls certain properties of the actor.
The most masterful actor is the *Empyrean*. The first actor you create will have the Empyrean as its master. Subsequent actors can use any other actor as its master.
@ -117,7 +117,7 @@ The most masterful actor is the *Empyrean*. The first actor you create will have
| delay(fn, seconds) | Calls 'fn' after 'seconds' with the context of the actor |
*** Actor Lifetime
When an actor dies, all of the actors that have it as their master[fn::What a mouthful!] will die as well.
When an actor dies, all of the actors that have it as their master will die as well.
*** Turns
Actors get fragments of time called a *turn*. Actors which belong to different systems can have different lengths of turns.

View file

@ -527,6 +527,8 @@ component.edge2d = Object.copy(collider2d, {
sample() {
var spoints = this.spoints();
if (spoints.length === 0) return [];
if (this.type === -1) {
if (this.looped) spoints.push(spoints[0]);
return spoints;

View file

@ -383,13 +383,15 @@ var Window = {
dimensions() { return cmd(265); },
get width() { return this.dimensions().x; },
get height() { return this.dimensions().y; },
set width(x) { cmd(266, x); },
set height(x) { cmd(267,x); },
mode: {
stretch: 0,
keep: 1,
width: 2,
height: 3,
expand: 4,
full: 5
stretch: 0, // stretch to fill window
keep: 1, // keep exact dimensions
width: 2, // keep width
height: 3, // keep height
expand: 4, // expand width or height
full: 5 // expand out beyond window
},
aspect(x) { cmd(264, x); },
title(str) { cmd(134, str); },

View file

@ -234,6 +234,7 @@ var gameobject = {
},
cry(file) {
return;
this.crying = audio.sound.play(file, audio.sound.bus.sfx);
var killfn = () => {this.crying = undefined; console.warn("killed"); }
this.crying.hook = killfn;
@ -301,7 +302,8 @@ var gameobject = {
Object.mixin(ent,gameobject_impl);
ent.body = make_gameobject();
ent.warp_layer = [true];
ent.phys = 2;
ent.components = {};
ent.objects = {};
ent.timers = [];
@ -673,7 +675,7 @@ gameobject.doc = {
elasticity: `When two objects collide, their elasticities are multiplied together. Their velocities are then multiplied by this value to find their resultant velocities.`,
friction: `When one object touches another, friction slows them down.`,
mass: `The higher the mass of the object, the less forces will affect it.`,
phys: `Set to 0, 1, or 2, representing static, kinematic, and dynamic.`,
phys: `Set to 0, 1, or 2, representing dynamic, kinematic, and static.`,
worldpos: `Function returns the world position of the object.`,
set_worldpos: `Function to set the position of the object in world coordinates.`,
worldangle: `Function to get the angle of the entity in the world.`,
@ -737,6 +739,7 @@ ur {
/* u is given as */
function apply_ur(u, e)
{
say(`applying ur ${u}`);
if (typeof u !== 'string') {
console.warn("Must give u as a string.");
return;

View file

@ -70,7 +70,10 @@ physics.warp.gravity = function() { return cmd(253); }
physics.warp.damp = function() { return cmd(254); }
physics.gravity = physics.warp.gravity();
physics.gravity.mask = [true];
physics.gravity.strength = 500;
physics.damp = physics.warp.damp();
physics.damp.mask = [true];
return {
physics

View file

@ -51,12 +51,15 @@ Spline.catmull_loop = function(cp)
Spline.catmull_caps = function(cp)
{
if (cp.length < 2) return;
cp = cp.slice();
cp.unshift(cp[0].sub(cp[1]).add(cp[0]));
cp.push(cp.last().sub(cp.at(-2).add(cp.last())));
return cp;
}
Spline.catmull_caps.doc = "Given a set of control points cp, return the necessary caps added to the spline.";
Spline.catmull2bezier.doc = "Given a set of control points C for a camtull-rom type curve, return a set of cubic bezier points to give the same curve."
Spline.type = {

View file

@ -430,9 +430,9 @@ struct phys2d_edge *Make2DEdge(gameobject *go) {
new->shape.go = go;
new->shape.data = new;
new->shape.debugdraw = phys2d_dbgdrawedge;
new->shape.moi = phys2d_edge_moi;
new->shape.moi = phys2d_edge_moi;
new->shape.shape = NULL;
new->shape.apply = NULL;
new->shape.apply = NULL;
new->shape.free = phys2d_edge_free;
new->draws = 0;
phys2d_applyedge(new);

View file

@ -1458,10 +1458,17 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
break;
case 264:
aspect_mode = js2int(argv[1]);
window_resize(0,0);
break;
case 265:
ret = vec2js((HMM_Vec2){mainwin.width, mainwin.height});
break;
case 266:
mainwin.width = js2number(argv[1]);
break;
case 267:
mainwin.height = js2number(argv[1]);
break;
}
if (str) JS_FreeCString(js, str);

View file

@ -434,9 +434,9 @@ void full_2d_pass(struct window *window)
sg_apply_viewportf(left,0,pwidth, window->height,1); // keep height
break;
case MODE_FULL:
usewidth = window->width;
useheight = window->height;
break;
usewidth = window->width;
useheight = window->height;
break;
}
// 2D projection

View file

@ -284,7 +284,7 @@ SCHED_API void scheduler_stop(struct scheduler*, int doWait);
/* windows requires Windows.h even if you use mingw */
#if defined(_WIN32) || (defined(__MINGW32__) || defined(__MINGW64__))
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <windows.h>
#endif
/* make sure atomic and pointer types have correct size */

View file

@ -18,7 +18,7 @@ NSSCDB_DIR = $(sysconfdir)
DESTDIR=
CC = cc
CFLAGS = -O
CFLAGS = -O2
CDEFS = -D_FILE_OFFSET_BITS=64
LD = $(CC)
LDFLAGS =

View file

@ -23,6 +23,8 @@ struct Texture *icon = NULL;
void window_resize(int width, int height)
{
width = sapp_width();
height = sapp_height();
mainwin.dpi = sapp_dpi_scale();
mainwin.width = sapp_width();
mainwin.height = sapp_height();