From ffb7360e4699fb55c5ac0089ee0d4526e22c2096 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 20 Mar 2013 11:47:24 -0700 Subject: [PATCH] Enable easy swithing between Box2D and chipmunk in linux and nacl The ENABLE_BOX2D/ENABLE_CHIPMUNK defines were previously hardcoded in the Makefiles. Now you get chipmunk by default on both platforms and can enble Box2D by setting USE_BOX2D in your environment. Also remove erroneous -D__CC_PLATFORM_FILEUTILS_CPP__ and -D__CC_PLATFORM_IMAGE_CPP__ from linux Makefiles. These should never be defined globally like this. --- cocos2dx/proj.linux/Makefile | 3 --- cocos2dx/proj.linux/cocos2dx.mk | 6 ++++++ cocos2dx/proj.nacl/Makefile | 2 -- cocos2dx/proj.nacl/cocos2dx.mk | 16 ++++++++++++---- extensions/cocos-ext.h | 9 +-------- extensions/proj.linux/Makefile | 3 --- samples/Cpp/TestCpp/proj.linux/Makefile | 2 -- samples/Cpp/TestCpp/proj.nacl/Makefile | 2 -- 8 files changed, 19 insertions(+), 24 deletions(-) diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index ffafd6fa9e..3549cf946e 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -9,9 +9,6 @@ INCLUDES += \ -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 \ diff --git a/cocos2dx/proj.linux/cocos2dx.mk b/cocos2dx/proj.linux/cocos2dx.mk index 3ea77795e3..15839e1ed2 100644 --- a/cocos2dx/proj.linux/cocos2dx.mk +++ b/cocos2dx/proj.linux/cocos2dx.mk @@ -8,6 +8,12 @@ ARFLAGS = cr DEFINES += -DLINUX +ifdef USE_BOX2D +DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION +else +DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION +endif + THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) ifndef COCOS_ROOT COCOS_ROOT := $(realpath $(dir $(THIS_MAKEFILE))/../..) diff --git a/cocos2dx/proj.nacl/Makefile b/cocos2dx/proj.nacl/Makefile index c7722b765c..cb75af8dc4 100644 --- a/cocos2dx/proj.nacl/Makefile +++ b/cocos2dx/proj.nacl/Makefile @@ -137,8 +137,6 @@ CXXFLAGS += -Wno-sequence-point TARGET = $(LIB_DIR)/libcocos2d.a -DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION - all: $(TARGET) $(TARGET): $(OBJECTS) $(CORE_MAKEFILE_LIST) diff --git a/cocos2dx/proj.nacl/cocos2dx.mk b/cocos2dx/proj.nacl/cocos2dx.mk index 8683c301e3..a5f1245022 100644 --- a/cocos2dx/proj.nacl/cocos2dx.mk +++ b/cocos2dx/proj.nacl/cocos2dx.mk @@ -18,13 +18,15 @@ THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) # The top level of the cocos2dx-x source tree. The parent Makefile will # often define this, but in case is doesn't we can find it relative to # THIS_MAKEFILE -COCOS_ROOT ?= $(realpath $(dir $(THIS_MAKEFILE))/../..) -COCOS_SRC = $(COCOS_ROOT)/cocos2dx +ifndef COCOS_ROOT +COCOS_ROOT := $(realpath $(dir $(THIS_MAKEFILE))/../..) +endif +COCOS_SRC := $(COCOS_ROOT)/cocos2dx ifeq ($(NACL_ARCH), i686) -ARCH_DIR=$(NACL_LIBC)_x86_32 +ARCH_DIR := $(NACL_LIBC)_x86_32 else -ARCH_DIR=$(NACL_LIBC)_$(NACL_ARCH) +ARCH_DIR := $(NACL_LIBC)_$(NACL_ARCH) endif NACLPORTS_ROOT ?= $(NACL_SDK_ROOT)/ports @@ -33,6 +35,12 @@ OUT_DIR ?= obj OBJ_DIR ?= $(OUT_DIR)/$(NACL_ARCH) LIB_DIR ?= $(COCOS_ROOT)/lib/nacl/$(ARCH_DIR) +ifdef USE_BOX2D +DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION +else +DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION +endif + INCLUDES += -I$(COCOS_SRC) \ -I$(COCOS_SRC)/cocoa \ -I$(COCOS_SRC)/include \ diff --git a/extensions/cocos-ext.h b/extensions/cocos-ext.h index 87f8167fbd..f801410160 100644 --- a/extensions/cocos-ext.h +++ b/extensions/cocos-ext.h @@ -42,16 +42,9 @@ #include "network/HttpClient.h" // Physics integration -#if CC_ENABLE_CHIPMUNK_INTEGRATION +#if CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION #include "physics_nodes/CCPhysicsDebugNode.h" #include "physics_nodes/CCPhysicsSprite.h" #endif -#if CC_ENABLE_BOX2D_INTEGRATION -#include "physics_nodes/CCPhysicsDebugNode.h" -#include "physics_nodes/CCPhysicsSprite.h" -#endif - - #endif /* __COCOS2D_EXT_H__ */ - diff --git a/extensions/proj.linux/Makefile b/extensions/proj.linux/Makefile index f0ade992f5..f84c6adb0e 100644 --- a/extensions/proj.linux/Makefile +++ b/extensions/proj.linux/Makefile @@ -10,9 +10,6 @@ INCLUDES = -I$(COCOS_ROOT)/external \ -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 \ diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile index 5edb17fd6c..7fb505a79b 100644 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ b/samples/Cpp/TestCpp/proj.linux/Makefile @@ -110,8 +110,6 @@ STATICLIBS += \ $(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) diff --git a/samples/Cpp/TestCpp/proj.nacl/Makefile b/samples/Cpp/TestCpp/proj.nacl/Makefile index 4bcf36f8f2..33f6519e05 100644 --- a/samples/Cpp/TestCpp/proj.nacl/Makefile +++ b/samples/Cpp/TestCpp/proj.nacl/Makefile @@ -1,5 +1,3 @@ -DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION - COCOS_ROOT = ../../../.. COCOS2DX_PATH = $(COCOS_ROOT)/cocos2dx