diff --git a/make-all-linux-project.sh b/make-all-linux-project.sh index 678567d8fe..5663b169ae 100755 --- a/make-all-linux-project.sh +++ b/make-all-linux-project.sh @@ -92,6 +92,16 @@ make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux release check_make_result cp $COCOS2DX20_TRUNK/CocosDenshion/proj.linux/libcocosdenshion.so $OUTPUT_RELEASE +make -C $COCOS2DX20_TRUNK/scripting/lua/proj.linux clean +make -C $COCOS2DX20_TRUNK/scripting/lua/proj.linux debug +check_make_result +cp $COCOS2DX20_TRUNK/scripting/lua/proj.linux/liblua.so $OUTPUT_DEBUG + +make -C $COCOS2DX20_TRUNK/scripting/lua/proj.linux clean +make -C $COCOS2DX20_TRUNK/scripting/lua/proj.linux release +check_make_result +cp $COCOS2DX20_TRUNK/scripting/lua/proj.linux/liblua.so $OUTPUT_RELEASE + make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux clean make -C $COCOS2DX20_TRUNK/samples/TestCpp/proj.linux debug check_make_result @@ -105,3 +115,18 @@ check_make_result make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux clean make -C $COCOS2DX20_TRUNK/samples/HelloCpp/proj.linux release check_make_result + +make -C $COCOS2DX20_TRUNK/samples/TestLua/proj.linux clean +make -C $COCOS2DX20_TRUNK/samples/TestLua/proj.linux debug +check_make_result +make -C $COCOS2DX20_TRUNK/samples/TestLua/proj.linux clean +make -C $COCOS2DX20_TRUNK/samples/TestLua/proj.linux release +check_make_result + +make -C $COCOS2DX20_TRUNK/samples/HelloLua/proj.linux clean +make -C $COCOS2DX20_TRUNK/samples/HelloLua/proj.linux debug +check_make_result +make -C $COCOS2DX20_TRUNK/samples/HelloLua/proj.linux clean +make -C $COCOS2DX20_TRUNK/samples/HelloLua/proj.linux release +check_make_result + diff --git a/samples/HelloLua/proj.linux/.cproject b/samples/HelloLua/proj.linux/.cproject new file mode 100644 index 0000000000..c01d627a23 --- /dev/null +++ b/samples/HelloLua/proj.linux/.cproject @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/HelloLua/proj.linux/.project b/samples/HelloLua/proj.linux/.project new file mode 100644 index 0000000000..31ca58204c --- /dev/null +++ b/samples/HelloLua/proj.linux/.project @@ -0,0 +1,42 @@ + + + HelloLua + + + libcocos2d + libCocosDenshion + liblua + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + Classes + 2 + PARENT-1-PROJECT_LOC/Classes + + + cocos2dx_support + 2 + PARENT-3-PROJECT_LOC/scripting/lua/cocos2dx_support + + + diff --git a/samples/HelloLua/proj.linux/Makefile b/samples/HelloLua/proj.linux/Makefile new file mode 100644 index 0000000000..acac34fa72 --- /dev/null +++ b/samples/HelloLua/proj.linux/Makefile @@ -0,0 +1,95 @@ +CC = gcc +CXX = g++ +TARGET = HelloLua +CCFLAGS = -Wall +CXXFLAGS = -Wall +VISIBILITY = + +COCOS2DX_PATH = ../../../cocos2dx +INCLUDES = -I../ \ + -I../Classes \ + -I$(COCOS2DX_PATH) \ + -I$(COCOS2DX_PATH)/platform/third_party/linux \ + -I$(COCOS2DX_PATH)/platform/third_party/linux/libfreetype2 \ + -I$(COCOS2DX_PATH)/cocoa \ + -I$(COCOS2DX_PATH)/include \ + -I$(COCOS2DX_PATH)/platform \ + -I$(COCOS2DX_PATH)/platform/linux \ + -I$(COCOS2DX_PATH)/platform/third_party/linux/glew-1.7.0/glew-1.7.0/include/ \ + -I$(COCOS2DX_PATH)/kazmath/include \ + -I$(COCOS2DX_PATH)/platform/third_party/linux/libxml2 \ + -I$(COCOS2DX_PATH)/platform/third_party/linux/libjpeg \ + -I../../../CocosDenshion/include \ + -I../../../scripting/lua/lua \ + -I../../../scripting/lua/tolua \ + -I../../../scripting/lua/cocos2dx_support + +DEFINES = -DLINUX + +OBJECTS = ./main.o \ + ../Classes/AppDelegate.o \ + ../../../scripting/lua/cocos2dx_support/CCLuaEngine.o \ + ../../../scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.o \ + ../../../scripting/lua/cocos2dx_support/LuaCocos2d.o \ + ../../../scripting/lua/cocos2dx_support/tolua_fix.o + +LBITS := $(shell getconf LONG_BIT) +ifeq ($(LBITS),64) +STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries/lib64 +else +STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries +endif + +STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \ + $(STATICLIBS_DIR)/libxml2.a \ + $(STATICLIBS_DIR)/libpng.a \ + $(STATICLIBS_DIR)/libjpeg.a \ + $(STATICLIBS_DIR)/libtiff.a \ +# $(STATICLIBS_DIR)/libGLEW.a \ + +SHAREDLIBS += -lglfw -lcurl -llua +SHAREDLIBS += -Wl,-rpath,../../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib +SHAREDLIBS += -L../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW +SHAREDLIBS += -Wl,-rpath,../../../../../lib/linux/Debug + +ifeq ($(LBITS),64) +SHAREDLIBS += -L../../../CocosDenshion/third_party/fmod/lib64/api/lib -lfmodex64 -Wl,-rpath,../../../../../CocosDenshion/third_party/fmod/lib64/api/lib +else +SHAREDLIBS += -L../../../CocosDenshion/third_party/fmod/api/lib -lfmodex -Wl,-rpath,../../../../../CocosDenshion/third_party/fmod/api/lib +endif + +#$(shell ../../build-linux.sh $<) + +BIN_DIR_ROOT=bin +BIN_DIR = $(BIN_DIR_ROOT) + +debug: BIN_DIR = $(BIN_DIR_ROOT)/debug +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion +debug: SHAREDLIBS += -Wl,-rpath,../../../../../lib/linux/Debug/ +debug: DEFINES += -DDEBUG +debug: $(TARGET) + +release: BIN_DIR = $(BIN_DIR_ROOT)/release +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: SHAREDLIBS += -L../../../lib/linux/Release -lcocos2d -lrt -lz -lcocosdenshion +release: SHAREDLIBS += -Wl,-rpath,../../../../../lib/linux/Release/ +release: DEFINES += -DNDEBUG +release: $(TARGET) + +####### Build rules +$(TARGET): $(OBJECTS) + mkdir -p $(BIN_DIR) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS) + +####### Compile +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +%.o: %.c + $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +clean: + rm -f $(OBJECTS) $(TARGET) core diff --git a/samples/HelloLua/proj.linux/main.cpp b/samples/HelloLua/proj.linux/main.cpp new file mode 100644 index 0000000000..bb6061e8fe --- /dev/null +++ b/samples/HelloLua/proj.linux/main.cpp @@ -0,0 +1,34 @@ +#include "main.h" +#include "../Classes/AppDelegate.h" +#include "cocos2d.h" + + +#include +#include +#include +#include + +USING_NS_CC; + +// 500 is enough? +#define MAXPATHLEN 500 + +int main(int argc, char **argv) +{ + // get application path + int length; + char fullpath[MAXPATHLEN]; + length = readlink("/proc/self/exe", fullpath, sizeof(fullpath)); + fullpath[length] = '\0'; + + std::string resourcePath = fullpath; + resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/")); + resourcePath += "/../../../Resources/"; + + // create the application instance + AppDelegate app; + CCApplication::sharedApplication()->setResourceRootPath(resourcePath.c_str()); + CCEGLView* eglView = CCEGLView::sharedOpenGLView(); + eglView->setFrameSize(960, 640); + return CCApplication::sharedApplication()->run(); +} diff --git a/samples/HelloLua/proj.linux/main.h b/samples/HelloLua/proj.linux/main.h new file mode 100644 index 0000000000..952830d1ac --- /dev/null +++ b/samples/HelloLua/proj.linux/main.h @@ -0,0 +1,7 @@ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __MAIN_H__ diff --git a/samples/TestLua/proj.linux/.cproject b/samples/TestLua/proj.linux/.cproject new file mode 100644 index 0000000000..d272887964 --- /dev/null +++ b/samples/TestLua/proj.linux/.cproject @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/TestLua/proj.linux/.project b/samples/TestLua/proj.linux/.project new file mode 100644 index 0000000000..9b6bf99e14 --- /dev/null +++ b/samples/TestLua/proj.linux/.project @@ -0,0 +1,44 @@ + + + TestLua + + + libBox2D + libChipmunk + libcocos2d + libCocosDenshion + liblua + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + Classes + 2 + PARENT-1-PROJECT_LOC/Classes + + + cocos2dx_support + 2 + PARENT-3-PROJECT_LOC/scripting/lua/cocos2dx_support + + + diff --git a/samples/TestLua/proj.linux/Makefile b/samples/TestLua/proj.linux/Makefile new file mode 100644 index 0000000000..2c349b90b2 --- /dev/null +++ b/samples/TestLua/proj.linux/Makefile @@ -0,0 +1,100 @@ +CC = gcc +CXX = g++ +TARGET = TestLua +CCFLAGS = -Wall +CXXFLAGS = -Wall +VISIBILITY = + +COCOS2DX_PATH = ../../../cocos2dx +INCLUDES = -I../ \ + -I../Classes \ + -I$(COCOS2DX_PATH) \ + -I$(COCOS2DX_PATH)/platform/third_party/linux \ + -I$(COCOS2DX_PATH)/platform/third_party/linux/libfreetype2 \ + -I$(COCOS2DX_PATH)/cocoa \ + -I$(COCOS2DX_PATH)/include \ + -I$(COCOS2DX_PATH)/platform \ + -I$(COCOS2DX_PATH)/platform/linux \ + -I$(COCOS2DX_PATH)/platform/third_party/linux/glew-1.7.0/glew-1.7.0/include/ \ + -I$(COCOS2DX_PATH)/kazmath/include \ + -I$(COCOS2DX_PATH)/platform/third_party/linux/libxml2 \ + -I$(COCOS2DX_PATH)/platform/third_party/linux/libjpeg \ + -I../../../CocosDenshion/include \ + -I../../../scripting/lua/lua \ + -I../../../scripting/lua/tolua \ + -I../../../scripting/lua/cocos2dx_support + + +DEFINES = -DLINUX + +OBJECTS = ./main.o \ + ../Classes/AppDelegate.o \ + ../../../scripting/lua/cocos2dx_support/CCLuaEngine.o \ + ../../../scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.o \ + ../../../scripting/lua/cocos2dx_support/LuaCocos2d.o \ + ../../../scripting/lua/cocos2dx_support/tolua_fix.o \ + +LBITS := $(shell getconf LONG_BIT) +ifeq ($(LBITS),64) +STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries/lib64 +else +STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries +endif + +STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \ + $(STATICLIBS_DIR)/libcurl.a \ + $(STATICLIBS_DIR)/libxml2.a \ + $(STATICLIBS_DIR)/libpng.a \ + $(STATICLIBS_DIR)/libjpeg.a \ + $(STATICLIBS_DIR)/libtiff.a \ +# $(STATICLIBS_DIR)/libGLEW.a \ + ../../../lib/linux/Debug/libbox2d.a \ + ../../../lib/linux/Debug/libchipmunk.a + +SHAREDLIBS += -lglfw -lcurl -llua +SHAREDLIBS += -Wl,-rpath,../../../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib +SHAREDLIBS += -L../../../cocos2dx/platform/third_party/linux/glew-1.7.0/glew-1.7.0/lib -lGLEW +SHAREDLIBS += -Wl,-rpath,../../../../../lib/linux/Debug + +ifeq ($(LBITS),64) +SHAREDLIBS += -L../../../CocosDenshion/third_party/fmod/lib64/api/lib -lfmodex64 -Wl,-rpath,../../../../../CocosDenshion/third_party/fmod/lib64/api/lib +else +SHAREDLIBS += -L../../../CocosDenshion/third_party/fmod/api/lib -lfmodex -Wl,-rpath,../../../../../CocosDenshion/third_party/fmod/api/lib +endif + +#$(shell ../../build-linux.sh $<) + +BIN_DIR_ROOT=bin +BIN_DIR = $(BIN_DIR_ROOT) + +debug: BIN_DIR = $(BIN_DIR_ROOT)/debug +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion +debug: SHAREDLIBS += -Wl,-rpath,../../../../../lib/linux/Debug/ +debug: DEFINES += -DDEBUG +debug: $(TARGET) + +release: BIN_DIR = $(BIN_DIR_ROOT)/release +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: SHAREDLIBS += -L../../../lib/linux/Release -lcocos2d -lrt -lz -lcocosdenshion +release: SHAREDLIBS += -Wl,-rpath,../../../../../lib/linux/Release/ +release: DEFINES += -DNDEBUG +release: $(TARGET) + +####### Build rules +$(TARGET): $(OBJECTS) + mkdir -p $(BIN_DIR) + cp -R ../../../samples/TestCpp/Resources ../../../samples/TestLua/ + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS) + +####### Compile +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +%.o: %.c + $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +clean: + rm -f $(OBJECTS) $(TARGET) core diff --git a/samples/TestLua/proj.linux/main.cpp b/samples/TestLua/proj.linux/main.cpp new file mode 100644 index 0000000000..71776a9eba --- /dev/null +++ b/samples/TestLua/proj.linux/main.cpp @@ -0,0 +1,35 @@ +#include "main.h" + +#include "../Classes/AppDelegate.h" +#include "cocos2d.h" +#include "CCEGLView.h" + +#include +#include +#include +#include + +USING_NS_CC; + +// 500 is enough? +#define MAXPATHLEN 500 + +int main(int argc, char **argv) +{ + // get application path + int length; + char fullpath[MAXPATHLEN]; + length = readlink("/proc/self/exe", fullpath, sizeof(fullpath)); + fullpath[length] = '\0'; + + std::string resourcePath = fullpath; + resourcePath = resourcePath.substr(0, resourcePath.find_last_of("/")); + resourcePath += "/../../../Resources/"; + + // create the application instance + AppDelegate app; + CCApplication::sharedApplication()->setResourceRootPath(resourcePath.c_str()); + CCEGLView* eglView = CCEGLView::sharedOpenGLView(); + eglView->setFrameSize(480, 320); + return CCApplication::sharedApplication()->run(); +} diff --git a/samples/TestLua/proj.linux/main.h b/samples/TestLua/proj.linux/main.h new file mode 100644 index 0000000000..86022e430a --- /dev/null +++ b/samples/TestLua/proj.linux/main.h @@ -0,0 +1,13 @@ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Windows Header Files: +//#include +//#include + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __MAIN_H__ diff --git a/scripting/lua/proj.linux/.cproject b/scripting/lua/proj.linux/.cproject new file mode 100644 index 0000000000..5a09d65ece --- /dev/null +++ b/scripting/lua/proj.linux/.cproject @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripting/lua/proj.linux/.project b/scripting/lua/proj.linux/.project new file mode 100644 index 0000000000..ac1d4603ee --- /dev/null +++ b/scripting/lua/proj.linux/.project @@ -0,0 +1,40 @@ + + + liblua + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + lua + 2 + PARENT-1-PROJECT_LOC/lua + + + tolua + 2 + PARENT-1-PROJECT_LOC/tolua + + + + diff --git a/scripting/lua/proj.linux/Makefile b/scripting/lua/proj.linux/Makefile new file mode 100644 index 0000000000..ca4f3f0120 --- /dev/null +++ b/scripting/lua/proj.linux/Makefile @@ -0,0 +1,75 @@ +CC = gcc +CXX = g++ +TARGET = liblua.so +CCFLAGS = -Wall -fPIC +CXXFLAGS = -Wall -fPIC +VISIBILITY = + +LBITS := $(shell getconf LONG_BIT) +INCLUDES = -I../lua \ + -I../tolua \ + +DEFINES = -DLINUX + +OBJECTS = ../lua/lapi.o \ + ../lua/lauxlib.o \ + ../lua/lbaselib.o \ + ../lua/lcode.o \ + ../lua/ldblib.o \ + ../lua/ldebug.o \ + ../lua/ldo.o \ + ../lua/ldump.o \ + ../lua/lfunc.o \ + ../lua/lgc.o \ + ../lua/linit.o \ + ../lua/liolib.o \ + ../lua/llex.o \ + ../lua/lmathlib.o \ + ../lua/lmem.o \ + ../lua/loadlib.o \ + ../lua/lobject.o \ + ../lua/lopcodes.o \ + ../lua/loslib.o \ + ../lua/lparser.o \ + ../lua/lstate.o \ + ../lua/lstring.o \ + ../lua/lstrlib.o \ + ../lua/ltable.o \ + ../lua/ltablib.o \ + ../lua/ltm.o \ + ../lua/lua.o \ + ../lua/lundump.o \ + ../lua/lvm.o \ + ../lua/lzio.o \ + ../lua/print.o \ + ../tolua/tolua_event.o \ + ../tolua/tolua_is.o \ + ../tolua/tolua_map.o \ + ../tolua/tolua_push.o \ + ../tolua/tolua_to.o + +STATICLIBS = + +debug: CCFLAGS += -g3 -O0 +debug: CXXFLAGS += -g3 -O0 +debug: DEFINES += -DDEBUG +debug: $(TARGET) + +release: CCFLAGS += -O3 +release: CXXFLAGS += -O3 +release: DEFINES += -DNDEBUG +release: $(TARGET) + +####### Build rules +$(TARGET): $(OBJECTS) + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -shared -o $(TARGET) $(SHAREDLIBS) $(STATICLIBS) + +####### Compile +%.o: %.cpp + $(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +%.o: %.c + $(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ + +clean: + rm -f $(OBJECTS) $(TARGET) core diff --git a/tools/tolua++/build.php b/tools/tolua++/build.php index 177000e462..13f441685e 100644 --- a/tools/tolua++/build.php +++ b/tools/tolua++/build.php @@ -12,7 +12,14 @@ defined('DS') or define('DS', DIRECTORY_SEPARATOR); define('SRC_DIR', __DIR__ . DS); define('OUT_DIR', dirname(__DIR__) . '/../scripting/lua/cocos2dx_support/'); -define('TOLUA_BIN', (DS == '\\') ? 'tolua++.exe' : '/usr/local/bin/tolua++'); +if (PHP_OS == 'Linux') +{ + define('TOLUA_BIN', '/usr/bin/tolua++5.1'); +} +else +{ + define('TOLUA_BIN', (DS == '\\') ? 'tolua++.exe' : '/usr/local/bin/tolua++'); +} class Builder {