From 03836f31985093ca1d2a14eb093de8c00a4bd7f2 Mon Sep 17 00:00:00 2001 From: James Gregory Date: Wed, 3 Apr 2013 18:26:55 -0700 Subject: [PATCH] Add Makefiles for Emscripten + Emscripten external --- .gitmodules | 3 + CocosDenshion/proj.emscripten/Makefile | 20 +++ cocos2dx/proj.emscripten/Makefile | 156 ++++++++++++++++++ cocos2dx/proj.emscripten/cocos2dx.mk | 116 +++++++++++++ extensions/proj.emscripten/Makefile | 77 +++++++++ external/Box2D/proj.emscripten/Makefile | 73 ++++++++ external/chipmunk/proj.emscripten/Makefile | 47 ++++++ external/emscripten | 1 + samples/Cpp/HelloCpp/proj.emscripten/Makefile | 25 +++ .../Cpp/SimpleGame/proj.emscripten/Makefile | 27 +++ samples/Cpp/TestCpp/proj.emscripten/Makefile | 130 +++++++++++++++ samples/Lua/HelloLua/proj.emscripten/Makefile | 26 +++ samples/Lua/TestLua/proj.emscripten/Makefile | 27 +++ scripting/lua/proj.emscripten/Makefile | 65 ++++++++ 14 files changed, 793 insertions(+) create mode 100644 CocosDenshion/proj.emscripten/Makefile create mode 100644 cocos2dx/proj.emscripten/Makefile create mode 100644 cocos2dx/proj.emscripten/cocos2dx.mk create mode 100644 extensions/proj.emscripten/Makefile create mode 100644 external/Box2D/proj.emscripten/Makefile create mode 100644 external/chipmunk/proj.emscripten/Makefile create mode 160000 external/emscripten create mode 100644 samples/Cpp/HelloCpp/proj.emscripten/Makefile create mode 100644 samples/Cpp/SimpleGame/proj.emscripten/Makefile create mode 100644 samples/Cpp/TestCpp/proj.emscripten/Makefile create mode 100644 samples/Lua/HelloLua/proj.emscripten/Makefile create mode 100644 samples/Lua/TestLua/proj.emscripten/Makefile create mode 100644 scripting/lua/proj.emscripten/Makefile diff --git a/.gitmodules b/.gitmodules index b3e3547623..d48150a077 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "samples/Javascript/Shared"] path = samples/Javascript/Shared url = https://github.com/minggo/cocos2d-js-tests.git +[submodule "external/emscripten"] + path = external/emscripten + url = https://github.com/kripken/emscripten.git diff --git a/CocosDenshion/proj.emscripten/Makefile b/CocosDenshion/proj.emscripten/Makefile new file mode 100644 index 0000000000..c4af3994b7 --- /dev/null +++ b/CocosDenshion/proj.emscripten/Makefile @@ -0,0 +1,20 @@ +TARGET = libcocosdenshion.so + +INCLUDES += -I.. -I../include + +SOURCES = ../emscripten/SimpleAudioEngine.cpp + +COCOS_ROOT = ../.. +include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/cocos2dx/proj.emscripten/Makefile b/cocos2dx/proj.emscripten/Makefile new file mode 100644 index 0000000000..b06dd01e65 --- /dev/null +++ b/cocos2dx/proj.emscripten/Makefile @@ -0,0 +1,156 @@ +TARGET = libcocos2d.so + +INCLUDES += \ + -I../platform/third_party/linux/libfreetype2 \ + -I../../extensions \ + -I../../extensions/CCBReader \ + -I../../extensions/GUI/CCControlExtension \ + -I../../extensions/GUI/CCControlExtension \ + -I../../external/chipmunk/include/chipmunk \ + -I../../extensions/network \ + +DEFINES += -D__CC_PLATFORM_FILEUTILS_CPP__ +DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION + +SOURCES = ../actions/CCAction.cpp \ +../actions/CCActionCamera.cpp \ +../actions/CCActionEase.cpp \ +../actions/CCActionGrid.cpp \ +../actions/CCActionGrid3D.cpp \ +../actions/CCActionInstant.cpp \ +../actions/CCActionInterval.cpp \ +../actions/CCActionManager.cpp \ +../actions/CCActionPageTurn3D.cpp \ +../actions/CCActionProgressTimer.cpp \ +../actions/CCActionTiledGrid.cpp \ +../actions/CCActionCatmullRom.cpp \ +../actions/CCActionTween.cpp \ +../base_nodes/CCAtlasNode.cpp \ +../base_nodes/CCNode.cpp \ +../cocoa/CCAffineTransform.cpp \ +../cocoa/CCAutoreleasePool.cpp \ +../cocoa/CCGeometry.cpp \ +../cocoa/CCNS.cpp \ +../cocoa/CCObject.cpp \ +../cocoa/CCSet.cpp \ +../cocoa/CCZone.cpp \ +../cocoa/CCArray.cpp \ +../cocoa/CCDictionary.cpp \ +../cocoa/CCString.cpp \ +../draw_nodes/CCDrawingPrimitives.cpp \ +../draw_nodes/CCDrawNode.cpp \ +../effects/CCGrabber.cpp \ +../effects/CCGrid.cpp \ +../keypad_dispatcher/CCKeypadDelegate.cpp \ +../keypad_dispatcher/CCKeypadDispatcher.cpp \ +../label_nodes/CCLabelAtlas.cpp \ +../label_nodes/CCLabelBMFont.cpp \ +../label_nodes/CCLabelTTF.cpp \ +../layers_scenes_transitions_nodes/CCLayer.cpp \ +../layers_scenes_transitions_nodes/CCScene.cpp \ +../layers_scenes_transitions_nodes/CCTransition.cpp \ +../layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \ +../layers_scenes_transitions_nodes/CCTransitionProgress.cpp \ +../menu_nodes/CCMenu.cpp \ +../menu_nodes/CCMenuItem.cpp \ +../misc_nodes/CCMotionStreak.cpp \ +../misc_nodes/CCProgressTimer.cpp \ +../misc_nodes/CCClippingNode.cpp \ +../misc_nodes/CCRenderTexture.cpp \ +../particle_nodes/CCParticleExamples.cpp \ +../particle_nodes/CCParticleSystem.cpp \ +../particle_nodes/CCParticleSystemQuad.cpp \ +../particle_nodes/CCParticleBatchNode.cpp \ +../platform/CCSAXParser.cpp \ +../platform/CCThread.cpp \ +../platform/platform.cpp \ +../platform/CCImageCommonWebp.cpp \ +../platform/CCEGLViewProtocol.cpp \ +../platform/CCFileUtils.cpp \ +../platform/emscripten/CCCommon.cpp \ +../platform/emscripten/CCApplication.cpp \ +../platform/emscripten/CCEGLView.cpp \ +../platform/emscripten/CCImage.cpp \ +../platform/emscripten/CCDevice.cpp \ +../script_support/CCScriptSupport.cpp \ +../sprite_nodes/CCAnimation.cpp \ +../sprite_nodes/CCAnimationCache.cpp \ +../sprite_nodes/CCSprite.cpp \ +../sprite_nodes/CCSpriteBatchNode.cpp \ +../sprite_nodes/CCSpriteFrame.cpp \ +../sprite_nodes/CCSpriteFrameCache.cpp \ +../support/ccUTF8.cpp \ +../support/CCPointExtension.cpp \ +../support/CCProfiling.cpp \ +../support/user_default/CCUserDefault.cpp \ +../support/TransformUtils.cpp \ +../support/base64.cpp \ +../support/ccUtils.cpp \ +../support/CCVertex.cpp \ +../support/CCNotificationCenter.cpp \ +../support/image_support/TGAlib.cpp \ +../support/tinyxml2/tinyxml2.cpp \ +../support/zip_support/ZipUtils.cpp \ +../support/zip_support/ioapi.cpp \ +../support/zip_support/unzip.cpp \ +../support/data_support/ccCArray.cpp \ +../text_input_node/CCIMEDispatcher.cpp \ +../text_input_node/CCTextFieldTTF.cpp \ +../textures/CCTexture2D.cpp \ +../textures/CCTextureAtlas.cpp \ +../textures/CCTextureCache.cpp \ +../textures/CCTexturePVR.cpp \ +../tilemap_parallax_nodes/CCParallaxNode.cpp \ +../tilemap_parallax_nodes/CCTMXLayer.cpp \ +../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \ +../tilemap_parallax_nodes/CCTMXTiledMap.cpp \ +../tilemap_parallax_nodes/CCTMXXMLParser.cpp \ +../tilemap_parallax_nodes/CCTileMapAtlas.cpp \ +../touch_dispatcher/CCTouchDispatcher.cpp \ +../touch_dispatcher/CCTouchHandler.cpp \ +../touch_dispatcher/CCTouch.cpp \ +../shaders/CCGLProgram.cpp \ +../shaders/ccGLStateCache.cpp \ +../shaders/CCShaderCache.cpp \ +../shaders/ccShaders.cpp \ +../kazmath/src/aabb.c \ +../kazmath/src/plane.c \ +../kazmath/src/vec2.c \ +../kazmath/src/mat3.c \ +../kazmath/src/quaternion.c \ +../kazmath/src/vec3.c \ +../kazmath/src/mat4.c \ +../kazmath/src/ray2.c \ +../kazmath/src/vec4.c \ +../kazmath/src/neon_matrix_impl.c \ +../kazmath/src/utility.c \ +../kazmath/src/GL/mat4stack.c \ +../kazmath/src/GL/matrix.c \ +../CCCamera.cpp \ +../CCConfiguration.cpp \ +../CCDirector.cpp \ +../CCScheduler.cpp \ +../cocos2d.cpp + +COCOS_ROOT = ../.. + +include cocos2dx.mk + +CXXFLAGS += -Wno-sequence-point +CCFLAGS += -Wno-sequence-point + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/cocos2dx/proj.emscripten/cocos2dx.mk b/cocos2dx/proj.emscripten/cocos2dx.mk new file mode 100644 index 0000000000..16ebbbd79b --- /dev/null +++ b/cocos2dx/proj.emscripten/cocos2dx.mk @@ -0,0 +1,116 @@ +all: + +DEFINES += -DEMSCRIPTEN + +THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +ifndef COCOS_ROOT +COCOS_ROOT ?= $(realpath $(dir $(THIS_MAKEFILE))/../..) +else +RPATH_REL = ../.. +endif +COCOS_SRC = $(COCOS_ROOT)/cocos2dx +OBJ_DIR ?= obj + +CC := $(COCOS_ROOT)/external/emscripten/emcc +CXX := $(COCOS_ROOT)/external/emscripten/em++ +AR := $(COCOS_ROOT)/external/emscripten/emar +CCFLAGS += -MMD -Wall -fPIC -Qunused-arguments +CXXFLAGS += -MMD -Wall -fPIC -Qunused-arguments +ARFLAGS = cr + +LIB_DIR = $(COCOS_SRC)/lib/linux +BIN_DIR = bin + +INCLUDES += \ + -I$(COCOS_ROOT)/external/emscripten/system/include \ + -I$(COCOS_SRC) \ + -I$(COCOS_SRC)/cocoa \ + -I$(COCOS_SRC)/include \ + -I$(COCOS_SRC)/kazmath/include \ + -I$(COCOS_SRC)/platform/emscripten \ + -I$(COCOS_SRC)/platform/third_party/linux/libpng \ + -I$(COCOS_SRC)/platform/third_party/linux/libjpeg \ + -I$(COCOS_SRC)/platform/third_party/linux/libtiff/include \ + -I$(COCOS_SRC)/platform/third_party/linux/libwebp + +LBITS := $(shell getconf LONG_BIT) +ifeq ($(LBITS),64) +INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux/include64 +else +INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux +endif + +ifeq ($(DEBUG), 1) +CCFLAGS += -g3 -O0 +CXXFLAGS += -g3 -O0 +DEFINES += -D_DEBUG -DCOCOS2D_DEBUG=1 +OBJ_DIR := $(OBJ_DIR)/debug +LIB_DIR := $(LIB_DIR)/debug +BIN_DIR := $(BIN_DIR)/debug +else +CCFLAGS += -O1 +CXXFLAGS += -O1 +DEFINES += -DNDEBUG +OBJ_DIR := $(OBJ_DIR)/release +LIB_DIR := $(LIB_DIR)/release +BIN_DIR := $(BIN_DIR)/release +endif + +ifndef V +LOG_CC = @echo " CC $@"; +LOG_CXX = @echo " CXX $@"; +LOG_AR = @echo " AR $@"; +LOG_LINK = @echo " LINK $@"; +endif + +OBJECTS := $(SOURCES:.cpp=.o) +OBJECTS := $(OBJECTS:.c=.o) +OBJECTS := $(subst ../,,$(OBJECTS)) +OBJECTS := $(subst $(COCOS_ROOT)/,,$(OBJECTS)) +OBJECTS := $(addprefix $(OBJ_DIR)/, $(OBJECTS)) +DEPS = $(OBJECTS:.o=.d) +CORE_MAKEFILE_LIST := $(MAKEFILE_LIST) +-include $(DEPS) + +ifeq ($(LBITS),64) +STATICLIBS_DIR = $(COCOS_SRC)/platform/third_party/linux/libraries/lib64 +else +STATICLIBS_DIR = $(COCOS_SRC)/platform/third_party/linux/libraries +endif +STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \ + $(STATICLIBS_DIR)/libpng.a \ + $(STATICLIBS_DIR)/libjpeg.a \ + $(STATICLIBS_DIR)/libtiff.a \ + $(STATICLIBS_DIR)/libwebp.a + +ifeq ($(LBITS),64) +FMOD_LIBDIR = $(COCOS_ROOT)/CocosDenshion/third_party/fmod/lib64/api/lib +SHAREDLIBS += -lfmodex64 +else +FMOD_LIBDIR = $(COCOS_ROOT)/CocosDenshion/third_party/fmod/api/lib +SHAREDLIBS += -lfmodex +endif + +SHAREDLIBS += -lglfw -lGLEW -lfontconfig +SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(RPATH_REL)/$(FMOD_LIBDIR) +SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR) +LIBS = -lrt -lz + +clean: + rm -rf $(OBJ_DIR) + rm -f $(TARGET) core + +.PHONY: all clean + +# If the parent Makefile defines $(EXECUTABLE) then define this as the target +# and create a 'make run' rule to run the app. +ifdef EXECUTABLE +TARGET := $(BIN_DIR)/$(EXECUTABLE) + +all: $(TARGET) + +run: $(TARGET) + cd $(dir $^) && ./$(notdir $^) + +.PHONY: run +endif diff --git a/extensions/proj.emscripten/Makefile b/extensions/proj.emscripten/Makefile new file mode 100644 index 0000000000..7db7aa939e --- /dev/null +++ b/extensions/proj.emscripten/Makefile @@ -0,0 +1,77 @@ +TARGET = libextension.a + +COCOS_ROOT=../.. + +INCLUDES = -I$(COCOS_ROOT)/external \ + -I$(COCOS_ROOT)/external/chipmunk/include/chipmunk \ + -I$(COCOS_ROOT)/CocosDenshion/include \ + -I.. \ + -I../CCBReader \ + -I../GUI/CCControlExtension \ + -I../network + +DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 +DEFINES += -D__CC_PLATFORM_IMAGE_CPP__ + +SOURCES = ../CCBReader/CCBFileLoader.cpp \ +../CCBReader/CCMenuItemImageLoader.cpp \ +../CCBReader/CCBReader.cpp \ +../CCBReader/CCMenuItemLoader.cpp \ +../CCBReader/CCControlButtonLoader.cpp \ +../CCBReader/CCNodeLoader.cpp \ +../CCBReader/CCControlLoader.cpp \ +../CCBReader/CCNodeLoaderLibrary.cpp \ +../CCBReader/CCLabelBMFontLoader.cpp \ +../CCBReader/CCParticleSystemQuadLoader.cpp \ +../CCBReader/CCLabelTTFLoader.cpp \ +../CCBReader/CCScale9SpriteLoader.cpp \ +../CCBReader/CCLayerColorLoader.cpp \ +../CCBReader/CCScrollViewLoader.cpp \ +../CCBReader/CCLayerGradientLoader.cpp \ +../CCBReader/CCSpriteLoader.cpp \ +../CCBReader/CCLayerLoader.cpp \ +../CCBReader/CCBAnimationManager.cpp \ +../CCBReader/CCBKeyframe.cpp \ +../CCBReader/CCBSequence.cpp \ +../CCBReader/CCBSequenceProperty.cpp \ +../CCBReader/CCBValue.cpp \ +../CCBReader/CCData.cpp \ +../CCBReader/CCNode+CCBRelativePositioning.cpp \ +../GUI/CCScrollView/CCScrollView.cpp \ +../GUI/CCScrollView/CCSorting.cpp \ +../GUI/CCScrollView/CCTableView.cpp \ +../GUI/CCScrollView/CCTableViewCell.cpp \ +../GUI/CCControlExtension/CCControlButton.cpp \ +../GUI/CCControlExtension/CCControlColourPicker.cpp \ +../GUI/CCControlExtension/CCControl.cpp \ +../GUI/CCControlExtension/CCControlHuePicker.cpp \ +../GUI/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ +../GUI/CCControlExtension/CCControlSlider.cpp \ +../GUI/CCControlExtension/CCControlSwitch.cpp \ +../GUI/CCControlExtension/CCControlUtils.cpp \ +../GUI/CCControlExtension/CCInvocation.cpp \ +../GUI/CCControlExtension/CCScale9Sprite.cpp \ +../GUI/CCControlExtension/CCControlPotentiometer.cpp \ +../GUI/CCControlExtension/CCControlStepper.cpp \ +../physics_nodes/CCPhysicsDebugNode.cpp \ +../physics_nodes/CCPhysicsSprite.cpp + +include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk + +CXXFLAGS += -Wno-multichar + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_AR)$(AR) $(ARFLAGS) $@ $(OBJECTS) + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/external/Box2D/proj.emscripten/Makefile b/external/Box2D/proj.emscripten/Makefile new file mode 100644 index 0000000000..ddfba9aa99 --- /dev/null +++ b/external/Box2D/proj.emscripten/Makefile @@ -0,0 +1,73 @@ +TARGET = libbox2d.a + +SOURCES = ../Collision/Shapes/b2ChainShape.cpp \ +../Collision/Shapes/b2CircleShape.cpp \ +../Collision/Shapes/b2EdgeShape.cpp \ +../Collision/Shapes/b2PolygonShape.cpp \ +../Collision/b2BroadPhase.cpp \ +../Collision/b2CollideCircle.cpp \ +../Collision/b2CollideEdge.cpp \ +../Collision/b2CollidePolygon.cpp \ +../Collision/b2Collision.cpp \ +../Collision/b2Distance.cpp \ +../Collision/b2DynamicTree.cpp \ +../Collision/b2TimeOfImpact.cpp \ +../Common/b2BlockAllocator.cpp \ +../Common/b2Draw.cpp \ +../Common/b2Math.cpp \ +../Common/b2Settings.cpp \ +../Common/b2StackAllocator.cpp \ +../Common/b2Timer.cpp \ +../Dynamics/Contacts/b2ChainAndCircleContact.cpp \ +../Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ +../Dynamics/Contacts/b2CircleContact.cpp \ +../Dynamics/Contacts/b2Contact.cpp \ +../Dynamics/Contacts/b2ContactSolver.cpp \ +../Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ +../Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ +../Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ +../Dynamics/Contacts/b2PolygonContact.cpp \ +../Dynamics/Joints/b2DistanceJoint.cpp \ +../Dynamics/Joints/b2FrictionJoint.cpp \ +../Dynamics/Joints/b2GearJoint.cpp \ +../Dynamics/Joints/b2Joint.cpp \ +../Dynamics/Joints/b2MouseJoint.cpp \ +../Dynamics/Joints/b2PrismaticJoint.cpp \ +../Dynamics/Joints/b2PulleyJoint.cpp \ +../Dynamics/Joints/b2RevoluteJoint.cpp \ +../Dynamics/Joints/b2RopeJoint.cpp \ +../Dynamics/Joints/b2WeldJoint.cpp \ +../Dynamics/Joints/b2WheelJoint.cpp \ +../Dynamics/b2Body.cpp \ +../Dynamics/b2ContactManager.cpp \ +../Dynamics/b2Fixture.cpp \ +../Dynamics/b2Island.cpp \ +../Dynamics/b2World.cpp \ +../Dynamics/b2WorldCallbacks.cpp \ +../Rope/b2Rope.cpp + +include ../../../cocos2dx/proj.emscripten/cocos2dx.mk + +INCLUDES = -I../.. + +# Unfortunetly Box2D doesn't compiler cleanly without these +CXXFLAGS += -Qunused-variable +CXXFLAGS += -Wno-uninitialized + +ifeq ($(DEBUG), 1) +DEFINES = -D_DEBUG +else +DEFINES = +endif + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(AR) $(ARFLAGS) $(TARGET) $(OBJECTS) + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/external/chipmunk/proj.emscripten/Makefile b/external/chipmunk/proj.emscripten/Makefile new file mode 100644 index 0000000000..b162669333 --- /dev/null +++ b/external/chipmunk/proj.emscripten/Makefile @@ -0,0 +1,47 @@ +SOURCES = ../src/chipmunk.c \ + ../src/cpBody.c \ + ../src/cpSpace.c \ + ../src/cpSpatialIndex.c \ + ../src/cpArbiter.c \ + ../src/cpCollision.c \ + ../src/cpSpaceComponent.c \ + ../src/cpSweep1D.c \ + ../src/cpArray.c \ + ../src/cpHashSet.c \ + ../src/cpSpaceHash.c \ + ../src/cpVect.c \ + ../src/cpBB.c \ + ../src/cpPolyShape.c \ + ../src/cpSpaceQuery.c \ + ../src/cpBBTree.c \ + ../src/cpShape.c \ + ../src/cpSpaceStep.c \ + ../src/constraints/cpConstraint.c \ + ../src/constraints/cpPivotJoint.c \ + ../src/constraints/cpDampedRotarySpring.c \ + ../src/constraints/cpRatchetJoint.c \ + ../src/constraints/cpDampedSpring.c \ + ../src/constraints/cpRotaryLimitJoint.c \ + ../src/constraints/cpGearJoint.c \ + ../src/constraints/cpSimpleMotor.c \ + ../src/constraints/cpGrooveJoint.c \ + ../src/constraints/cpSlideJoint.c \ + ../src/constraints/cpPinJoint.c \ + +include ../../../cocos2dx/proj.emscripten/cocos2dx.mk + +TARGET = $(LIB_DIR)/libchipmunk.a +INCLUDES = -I../include/chipmunk +DEFINES = -DLINUX +CCFLAGS += -std=gnu99 +OBJECTS := $(subst src/,,$(OBJECTS)) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(AR) $(ARFLAGS) $(TARGET) $(OBJECTS) + +$(OBJ_DIR)/%.o: ../src/%.c $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/external/emscripten b/external/emscripten new file mode 160000 index 0000000000..8408257cd6 --- /dev/null +++ b/external/emscripten @@ -0,0 +1 @@ +Subproject commit 8408257cd66435af849f493c10c7f0e8d1d5fa3b diff --git a/samples/Cpp/HelloCpp/proj.emscripten/Makefile b/samples/Cpp/HelloCpp/proj.emscripten/Makefile new file mode 100644 index 0000000000..0442fc6f63 --- /dev/null +++ b/samples/Cpp/HelloCpp/proj.emscripten/Makefile @@ -0,0 +1,25 @@ +EXECUTABLE = HelloCpp + +INCLUDES = -I.. -I../Classes + +SOURCES = main.cpp \ + ../Classes/AppDelegate.cpp \ + ../Classes/HelloWorldScene.cpp + +COCOS_ROOT = ../../../.. +include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk + +SHAREDLIBS += -lcocos2d +COCOS_LIBS = $(LIB_DIR)/libcocos2d.so + +$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/samples/Cpp/SimpleGame/proj.emscripten/Makefile b/samples/Cpp/SimpleGame/proj.emscripten/Makefile new file mode 100644 index 0000000000..79fe227c27 --- /dev/null +++ b/samples/Cpp/SimpleGame/proj.emscripten/Makefile @@ -0,0 +1,27 @@ +EXECUTABLE = SimpleGame + +INCLUDES = -I.. -I../Classes + +SOURCES = main.cpp \ + ../Classes/AppDelegate.cpp \ + ../Classes/HelloWorldScene.cpp \ + ../Classes/GameOverScene.cpp + +COCOS_ROOT = ../../../.. +include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk + +SHAREDLIBS += -lcocos2d -lcocosdenshion +COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so +INCLUDES += -I$(COCOS_ROOT)/CocosDenshion/include + +$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/samples/Cpp/TestCpp/proj.emscripten/Makefile b/samples/Cpp/TestCpp/proj.emscripten/Makefile new file mode 100644 index 0000000000..4833d05b5e --- /dev/null +++ b/samples/Cpp/TestCpp/proj.emscripten/Makefile @@ -0,0 +1,130 @@ +EXECUTABLE = TestCpp + +SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ + ../Classes/ActionManagerTest/ActionManagerTest.cpp \ + ../Classes/ActionsEaseTest/ActionsEaseTest.cpp \ + ../Classes/ActionsProgressTest/ActionsProgressTest.cpp \ + ../Classes/ActionsTest/ActionsTest.cpp \ + ../Classes/Box2DTest/Box2dTest.cpp \ + ../Classes/Box2DTestBed/Box2dView.cpp \ + ../Classes/Box2DTestBed/GLES-Render.cpp \ + ../Classes/Box2DTestBed/Test.cpp \ + ../Classes/Box2DTestBed/TestEntries.cpp \ + ../Classes/BugsTest/Bug-1159.cpp \ + ../Classes/BugsTest/Bug-1174.cpp \ + ../Classes/BugsTest/Bug-350.cpp \ + ../Classes/BugsTest/Bug-422.cpp \ + ../Classes/BugsTest/Bug-458/Bug-458.cpp \ + ../Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp \ + ../Classes/BugsTest/Bug-624.cpp \ + ../Classes/BugsTest/Bug-886.cpp \ + ../Classes/BugsTest/Bug-899.cpp \ + ../Classes/BugsTest/Bug-914.cpp \ + ../Classes/BugsTest/BugsTest.cpp \ + ../Classes/ChipmunkTest/ChipmunkTest.cpp \ + ../Classes/ClickAndMoveTest/ClickAndMoveTest.cpp \ + ../Classes/ClippingNodeTest/ClippingNodeTest.cpp \ + ../Classes/CocosDenshionTest/CocosDenshionTest.cpp \ + ../Classes/CurrentLanguageTest/CurrentLanguageTest.cpp \ + ../Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp \ + ../Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp \ + ../Classes/EffectsTest/EffectsTest.cpp \ + ../Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ + ../Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ + ../Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ + ../Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp \ + ../Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ + ../Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ + ../Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp \ + ../Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp \ + ../Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ + ../Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ + ../Classes/ExtensionsTest/ExtensionsTest.cpp \ + ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ + ../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ + ../Classes/FontTest/FontTest.cpp \ + ../Classes/IntervalTest/IntervalTest.cpp \ + ../Classes/KeypadTest/KeypadTest.cpp \ + ../Classes/LabelTest/LabelTest.cpp \ + ../Classes/LayerTest/LayerTest.cpp \ + ../Classes/MenuTest/MenuTest.cpp \ + ../Classes/MotionStreakTest/MotionStreakTest.cpp \ + ../Classes/MutiTouchTest/MutiTouchTest.cpp \ + ../Classes/NodeTest/NodeTest.cpp \ + ../Classes/ParallaxTest/ParallaxTest.cpp \ + ../Classes/ParticleTest/ParticleTest.cpp \ + ../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp \ + ../Classes/PerformanceTest/PerformanceParticleTest.cpp \ + ../Classes/PerformanceTest/PerformanceSpriteTest.cpp \ + ../Classes/PerformanceTest/PerformanceTest.cpp \ + ../Classes/PerformanceTest/PerformanceTextureTest.cpp \ + ../Classes/PerformanceTest/PerformanceTouchesTest.cpp \ + ../Classes/RenderTextureTest/RenderTextureTest.cpp \ + ../Classes/RotateWorldTest/RotateWorldTest.cpp \ + ../Classes/SceneTest/SceneTest.cpp \ + ../Classes/SchedulerTest/SchedulerTest.cpp \ + ../Classes/ShaderTest/ShaderTest.cpp \ + ../Classes/SpriteTest/SpriteTest.cpp \ + ../Classes/TextInputTest/TextInputTest.cpp \ + ../Classes/Texture2dTest/Texture2dTest.cpp \ + ../Classes/TextureCacheTest/TextureCacheTest.cpp \ + ../Classes/TileMapTest/TileMapTest.cpp \ + ../Classes/TouchesTest/Ball.cpp \ + ../Classes/TouchesTest/Paddle.cpp \ + ../Classes/TouchesTest/TouchesTest.cpp \ + ../Classes/TransitionsTest/TransitionsTest.cpp \ + ../Classes/UserDefaultTest/UserDefaultTest.cpp \ + ../Classes/ZwoptexTest/ZwoptexTest.cpp \ + ../Classes/FileUtilsTest/FileUtilsTest.cpp \ + ../Classes/controller.cpp \ + ../Classes/testBasic.cpp \ + ../Classes/AppDelegate.cpp \ + ../Classes/VisibleRect.cpp \ + main.cpp + +SHAREDLIBS = -lcocos2d -lcocosdenshion +COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so + +include ../../../../cocos2dx/proj.emscripten/cocos2dx.mk + + +INCLUDES += -I../ \ + -I../../ \ + -I../Classes \ + -I$(COCOS_ROOT)/CocosDenshion/include \ + -I$(COCOS_ROOT)/extensions/ \ + -I$(COCOS_ROOT)/external/ \ + -I$(COCOS_ROOT)/external/chipmunk/include/chipmunk + +STATICLIBS += \ + $(STATICLIBS_DIR)/libcurl.a \ + $(LIB_DIR)/libextension.a \ + $(LIB_DIR)/libbox2d.a \ + $(LIB_DIR)/libchipmunk.a + +DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 + +####### Build rules +$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) + +####### Compile +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: %.c $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/samples/Lua/HelloLua/proj.emscripten/Makefile b/samples/Lua/HelloLua/proj.emscripten/Makefile new file mode 100644 index 0000000000..4f563aa484 --- /dev/null +++ b/samples/Lua/HelloLua/proj.emscripten/Makefile @@ -0,0 +1,26 @@ +EXECUTABLE = HelloLua + +COCOS_ROOT = ../../../.. +INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/CocosDenshion/include \ + -I$(COCOS_ROOT)/scripting/lua/lua \ + -I$(COCOS_ROOT)/scripting/lua/tolua \ + -I$(COCOS_ROOT)/scripting/lua/cocos2dx_support + +SOURCES = main.cpp ../Classes/AppDelegate.cpp + +SHAREDLIBS += -lcocos2d -lcocosdenshion -llua +COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/liblua.so + +include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk + +$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/samples/Lua/TestLua/proj.emscripten/Makefile b/samples/Lua/TestLua/proj.emscripten/Makefile new file mode 100644 index 0000000000..e0c26bf46a --- /dev/null +++ b/samples/Lua/TestLua/proj.emscripten/Makefile @@ -0,0 +1,27 @@ +EXECUTABLE = TestLua + +COCOS_ROOT = ../../../.. +INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/CocosDenshion/include \ + -I$(COCOS_ROOT)/scripting/lua/lua \ + -I$(COCOS_ROOT)/scripting/lua/tolua \ + -I$(COCOS_ROOT)/scripting/lua/cocos2dx_support + +SOURCES = main.cpp ../Classes/AppDelegate.cpp + +SHAREDLIBS += -lcocos2d -lcocosdenshion -llua +COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/liblua.so + +include $(COCOS_ROOT)/cocos2dx/proj.emscripten/cocos2dx.mk + +$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + cp -a ../../../../samples/Cpp/TestCpp/Resources ../../../../samples/Lua/TestLua + $(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/scripting/lua/proj.emscripten/Makefile b/scripting/lua/proj.emscripten/Makefile new file mode 100644 index 0000000000..1a68cd2ae5 --- /dev/null +++ b/scripting/lua/proj.emscripten/Makefile @@ -0,0 +1,65 @@ +TARGET = liblua.so + +INCLUDES += -I.. -I../lua -I../tolua \ + -I../Classes -I../../../CocosDenshion/include + +SOURCES = ../lua/lapi.o \ + ../lua/lauxlib.c \ + ../lua/lbaselib.c \ + ../lua/lcode.c \ + ../lua/ldblib.c \ + ../lua/ldebug.c \ + ../lua/ldo.c \ + ../lua/ldump.c \ + ../lua/lfunc.c \ + ../lua/lgc.c \ + ../lua/linit.c \ + ../lua/liolib.c \ + ../lua/llex.c \ + ../lua/lmathlib.c \ + ../lua/lmem.c \ + ../lua/loadlib.c \ + ../lua/lobject.c \ + ../lua/lopcodes.c \ + ../lua/loslib.c \ + ../lua/lparser.c \ + ../lua/lstate.c \ + ../lua/lstring.c \ + ../lua/lstrlib.c \ + ../lua/ltable.c \ + ../lua/ltablib.c \ + ../lua/ltm.c \ + ../lua/lundump.c \ + ../lua/lvm.c \ + ../lua/lzio.c \ + ../lua/print.c \ + ../tolua/tolua_event.c \ + ../tolua/tolua_is.c \ + ../tolua/tolua_map.c \ + ../tolua/tolua_push.c \ + ../tolua/tolua_to.c \ + ../cocos2dx_support/tolua_fix.c \ + ../cocos2dx_support/CCLuaBridge.cpp \ + ../cocos2dx_support/CCLuaEngine.cpp \ + ../cocos2dx_support/CCLuaStack.cpp \ + ../cocos2dx_support/CCLuaValue.cpp \ + ../cocos2dx_support/Cocos2dxLuaLoader.cpp \ + ../cocos2dx_support/LuaCocos2d.cpp + +include ../../../cocos2dx/proj.emscripten/cocos2dx.mk + +TARGET := $(LIB_DIR)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(OBJECTS) -shared -o $@ $(SHAREDLIBS) $(STATICLIBS) + +$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ + +$(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST) + @mkdir -p $(@D) + $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@