Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Basic compilation infrastructure + added some bindings.

  • Loading branch information...
commit c88520e3de4d20e85ce510427db8973b1f8101c4 1 parent 7170f4b
@akoprow authored
View
1  .gitignore
@@ -2,3 +2,4 @@ _build
_tracks
*.exe
*~
+*.broken
View
38 Makefile
@@ -0,0 +1,38 @@
+########################################
+# USER VARIABLES
+
+EXE = box2d-demo.exe
+PACKNAME =
+SRC =
+MAINSRC = box2d-demo.opa
+PCKDIR = ./packages/
+PCK = box2d.opx
+PLUGIN =
+PLUGINDIR =
+OTHER_DEPENDS =
+
+#Compiler variables
+OPACOMPILER = opa
+MINIMAL_VERSION = 1150
+FLAG = --minimal-version $(MINIMAL_VERSION) -v
+PORT = 8080
+
+RUNOPT ?= #-d --debug-js
+
+# Build exe
+default: exe
+
+# Generate doc ApiX
+gen: exe
+ ./$(EXE) -g $(OPALANG)/_build/stdlib
+
+# Run Server
+run: exe
+ ./$(EXE) $(RUNOPT) || exit 0 ## prevent ugly make error 130 :) ##
+
+# Upload on the server
+upload: clean exe
+ upx $(EXE)
+ scp $(EXE) production@jupiter:doc.opalang.org/
+
+include Makefile.common
View
86 Makefile.common
@@ -0,0 +1,86 @@
+########################################
+# MAKEFILE VARIABLES
+OPA = $(OPACOMPILER) $(FLAG) $(OPAOPT)
+PWD ?= $(shell pwd)
+BUILDDIR ?= $(PWD)/_build
+export BUILDDIR
+BUILDDOCDIR ?=$(PWD)/doc/
+export BUILDDOCDIR
+PACKDOC = $(BUILDDOCDIR)/$(PACKNAME:%.opx=%.doc)/
+BUILDDOC = $(PACKDOC)
+OPACOMPILER ?= opa
+OPAGENAPI ?= $(OPACOMPILER) --api-only
+OPADOC ?= opadoc-gen.exe
+DEPENDS = $(SRC) $(PCK:%=$(BUILDDIR)/%) $(PLUGIN:%=$(BUILDDIR)/%)
+
+ifdef CONF_FILE
+ CONFIG = --conf $(CONF_FILE)
+else
+ CONFIG =
+endif
+
+_ = $(shell mkdir -p $(BUILDDIR))
+
+########################################
+# MAIN RULE
+exe : $(EXE)
+pack : $(PACKNAME)
+doc : $(PACKDOC) doc.sub
+
+########################################
+# MAIN PACKAGE BUILDING
+$(PACKNAME) : $(BUILDDIR)/$(PACKNAME)
+
+$(BUILDDIR)/$(PACKNAME) : $(DEPENDS)
+ @echo "### Building package $(PACKNAME)"
+ mkdir -p $(BUILDDIR)
+ $(OPA) --autocompile $(SRC) $(PLUGIN:%=$(BUILDDIR)/%) --build-dir $(BUILDDIR) -I $(BUILDDIR) $(OPAOPT)
+ @rm -rf $(BUILDDIR)/$(PACKNAME)
+ @mv $(PACKNAME) $(BUILDDIR)/
+
+########################################
+# SUBS PACKAGE/PLUGIN BUILDING
+$(BUILDDIR)/%.opx :
+ make $(@:$(BUILDDIR)/%.opx=-C $(PCKDIR)/%) pack
+
+$(BUILDDIR)/%.opp :
+ make $(@:$(BUILDDIR)/%.opp=-C $(PLUGINDIR)/%)
+
+########################################
+# EXECUTABLE BUILDING
+$(EXE) : pack $(SRC) $(MAINSRC) $(DEPENDS) $(OTHER_DEPENDS)
+ @echo "### Building executable $(EXE) "
+ mkdir -p $(BUILDDIR)
+ $(OPA) $(COMPILOPT) $(MAINSRC) $(CONFIG) $(PLUGIN:%=$(BUILDDIR)/%) -o $@ -I $(BUILDDIR) --build-dir $(BUILDDIR)/$(EXE)
+
+$(EXE:%.exe=%.run) : $(EXE)
+ ./$(EXE) -p $(PORT)
+
+########################################
+# DOCUMENTATION BUILDING - Dirty...
+$(PACKDOC) :
+ @echo "### Building documentation $(PACKNAME:%.opx=%.doc)"
+ @mkdir -p $(BUILDDOC)
+ @$(OPACOMPILER) $(SRC) $(PLUGIN:%=$(BUILDDIR)/%) --api-only -I $(BUILDDIR)
+ @mv $(SRC:%=%.api) $(SRC:%=%.api-txt) $(BUILDDOC)
+ @cp $(SRC) $(BUILDDOC)
+ @cd $(BUILDDOC) && $(OPADOC) .
+ @mkdir -p $(PACKDOC)
+ @mv doc/*.html doc/*.css $(PACKDOC)
+
+doc.sub :
+ @if [ -n "$(PCK)" ]; then make $(PCK:%.opx=-C $(PCKDIR)/%) doc; fi
+
+########################################
+# Used by recursives makefile
+pack.depends :
+ @echo $(PCK) $(PLUGIN)
+
+########################################
+# CLEANING
+clean ::
+ @$(PCK:%.opx=make -C $(PCKDIR)/% clean &&) $(PLUGIN:%.opp=make -C $(PLUGINDIR)/% clean &&) echo "### Cleaning $(BUILDDIR)";
+ @rm -rf $(BUILDDIR) _tracks *.broken;
+ @if [ -n "$(EXE)" ]; then rm -rf $(EXE); fi
+ @if [ -n "$(PACKDOC)" ]; then rm -rf $(PACKDOC); fi
+
View
0  main.opa → box2d-demo.opa
File renamed without changes
View
10 packages/box2d/Makefile
@@ -0,0 +1,10 @@
+########################################
+# USER VARIABLES
+PACKNAME = box2d.opx
+SRC = box2d.opa
+PLUGIN = box2d.opp
+PLUGINDIR = ./
+
+all: pack
+
+include Makefile.common
View
1  packages/box2d/Makefile.common
View
13 packages/box2d/box2d.opa
@@ -0,0 +1,13 @@
+package box2d
+
+type B2d.world = external
+type B2d.bodyDef = external
+type B2d.shapeDef = external
+type B2d.vec2 = external
+type B2d.boundingBox = external
+
+module Box2D {
+
+
+
+}
View
27 packages/box2d/box2d/Makefile
@@ -0,0 +1,27 @@
+########################################
+# USER VARIABLES
+MKLIB = opa-plugin-builder
+PLUGNAME = box2d.opp
+SRC = common/b2Settings.js common/b2Settings.js common/math/b2Vec2.js common/math/b2Mat22.js common/math/b2Math.js collision/b2AABB.js collision/b2Bound.js collision/b2BoundValues.js collision/b2Pair.js collision/b2PairCallback.js collision/b2BufferedPair.js collision/b2PairManager.js collision/b2BroadPhase.js collision/b2Collision.js collision/Features.js collision/b2ContactID.js collision/b2ContactPoint.js collision/b2Distance.js collision/b2Manifold.js collision/b2OBB.js collision/b2Proxy.js collision/ClipVertex.js collision/shapes/b2Shape.js collision/shapes/b2ShapeDef.js collision/shapes/b2BoxDef.js collision/shapes/b2CircleDef.js collision/shapes/b2CircleShape.js collision/shapes/b2MassData.js collision/shapes/b2PolyDef.js collision/shapes/b2PolyShape.js dynamics/b2Body.js dynamics/b2BodyDef.js dynamics/b2CollisionFilter.js dynamics/b2Island.js dynamics/b2TimeStep.js dynamics/contacts/b2ContactNode.js dynamics/contacts/b2Contact.js dynamics/contacts/b2ContactConstraint.js dynamics/contacts/b2ContactConstraintPoint.js dynamics/contacts/b2ContactRegister.js dynamics/contacts/b2ContactSolver.js dynamics/contacts/b2CircleContact.js dynamics/contacts/b2Conservative.js dynamics/contacts/b2NullContact.js dynamics/contacts/b2PolyAndCircleContact.js dynamics/contacts/b2PolyContact.js dynamics/b2ContactManager.js dynamics/b2World.js dynamics/b2WorldListener.js dynamics/joints/b2JointNode.js dynamics/joints/b2Joint.js dynamics/joints/b2JointDef.js dynamics/joints/b2DistanceJoint.js dynamics/joints/b2DistanceJointDef.js dynamics/joints/b2Jacobian.js dynamics/joints/b2GearJoint.js dynamics/joints/b2GearJointDef.js dynamics/joints/b2MouseJoint.js dynamics/joints/b2MouseJointDef.js dynamics/joints/b2PrismaticJoint.js dynamics/joints/b2PrismaticJointDef.js dynamics/joints/b2PulleyJoint.js dynamics/joints/b2PulleyJointDef.js dynamics/joints/b2RevoluteJoint.js dynamics/joints/b2RevoluteJointDef.js b2d.js
+CONF = conf.jsconf
+
+########################################
+# MAKEFILE VARIABLES
+ifeq ($(origin BUILDDIR), undefined)
+ PWD := $(shell pwd)
+ BUILDDIR := $(PWD)/_build/
+ export BUILDDIR
+endif
+
+########################################
+# PLUGIN BUILDING
+$(PLUGNAME) : $(SRC)
+ @echo "### Building plugin $(PLUGNAME)"
+ @$(MKLIB) --js-validator-off -o $(@:%.opp=%) $? $(CONF) --build-dir $(BUILDDIR)
+
+########################################
+# CLEANING
+clean :
+ @echo "### Cleaning plugin $(PLUGNAME)"
+ @rm -rf $(BUILDDIR)/$(PLUGNAME)
+
View
97 packages/box2d/box2d/b2d.js
@@ -0,0 +1,97 @@
+##extern-type world
+##extern-type body
+##extern-type bodyDef
+##extern-type shapeDef
+
+##extern-type vec2
+ // AABB
+##extern-type boundingBox
+
+// ###############################################################################
+// #################################### world ####################################
+// ###############################################################################
+
+##register world_init : boundingBox, vec2, bool -> world
+##args(coordinates, grativity, doSleep)
+{
+ return new b2World(coordinates, grativity, doSleep);
+}
+
+##register world_createBody: world, bodyDef -> body
+##args(world, body_def)
+{
+ return world.CreateBody(body_def);
+}
+
+##register world_step : world, int, int -> void
+##args(world, delta, iterations)
+{
+ world.Step(dt, iterations);
+}
+
+// ###############################################################################
+// ################################### bodyDef ###################################
+// ###############################################################################
+
+##register bodyDef_init : -> void
+##args()
+{
+ return new b2BodyDef();
+}
+
+##register bodyDef_addShape : body, shapeDef -> void
+##args(body, shape)
+{
+ body.AddShape(shape);
+}
+
+##register bodyDef_getPosition : body -> vec2
+##args(body)
+{
+ return body.position;
+}
+
+// ###############################################################################
+// ################################### shapeDef ##################################
+// ###############################################################################
+
+##register shapeDef_initBox : -> shapeDef
+##args()
+{
+ return new b2BoxDef();
+}
+
+##register shapeDef_setDensity : shapeDef, float -> void
+##args(shape, density)
+{
+ shape.density = density;
+}
+
+##register shapeDef_setFriction : shapeDef, float -> void
+##args(shape, friction)
+{
+ shape.density = friction;
+}
+
+##register shapeDef_getExtends : shapeDef -> vec2
+##args(shape)
+{
+ return shape.extends;
+}
+
+// ###############################################################################
+// ##################################### vec2 ####################################
+// ###############################################################################
+
+##register vec2_init : -> vec2
+##args()
+{
+ return new b2Vec2();
+}
+
+##register vec2_Set : vec2, float, float -> vec2
+##args(vec, x, y)
+{
+ vec.Set(x, y);
+}
+
View
2  packages/box2d/box2d/conf.jsconf
@@ -0,0 +1,2 @@
+[b2d.js]
+verbatim: true
Please sign in to comment.
Something went wrong with that request. Please try again.