From 0e66dc8712612521ce3e3b383c4fc9cfd5f55056 Mon Sep 17 00:00:00 2001 From: minggo Date: Sun, 9 Jun 2013 11:06:30 +0800 Subject: [PATCH] issue #2103: add lua files for lua multi-template project --- .../proj.android/build_native.sh | 12 +++++ .../proj.android/jni/Application.mk | 2 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../multi-platform-lua/proj.linux/Makefile | 1 + .../proj.marmalade/HelloLua.mkb | 1 + .../proj.marmalade/cccopy.py | 46 +++++++++++++++++++ 6 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 template/multi-platform-lua/proj.marmalade/cccopy.py diff --git a/template/multi-platform-lua/proj.android/build_native.sh b/template/multi-platform-lua/proj.android/build_native.sh index a800a1f035..bca05d0902 100755 --- a/template/multi-platform-lua/proj.android/build_native.sh +++ b/template/multi-platform-lua/proj.android/build_native.sh @@ -65,6 +65,18 @@ if [ -f "$file" ]; then fi done +# copy common luaScript +for file in "$APP_ROOT"/../../scripting/lua/script/* +do +if [ -d "$file" ]; then + cp -rf "$file" "$APP_ANDROID_ROOT"/assets +fi + +if [ -f "$file" ]; then + cp "$file" "$APP_ANDROID_ROOT"/assets +fi +done + if [[ "$buildexternalsfromsource" ]]; then echo "Building external dependencies from source" "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ diff --git a/template/multi-platform-lua/proj.android/jni/Application.mk b/template/multi-platform-lua/proj.android/jni/Application.mk index cb0c388b4a..76e90c2e42 100644 --- a/template/multi-platform-lua/proj.android/jni/Application.mk +++ b/template/multi-platform-lua/proj.android/jni/Application.mk @@ -1,3 +1,3 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 +APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 APP_CPPFLAGS += -fexceptions diff --git a/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id b/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id index 4280fa32e5..367ac911e3 100644 --- a/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -efa24299f7d76b23ad5728ff9161fcdb67ff1af5 \ No newline at end of file +1f1bfaa9b10bfeb0e02d367aa94e5bad6be3adc6 \ No newline at end of file diff --git a/template/multi-platform-lua/proj.linux/Makefile b/template/multi-platform-lua/proj.linux/Makefile index 3b28d2b9b3..cbd31994ca 100644 --- a/template/multi-platform-lua/proj.linux/Makefile +++ b/template/multi-platform-lua/proj.linux/Makefile @@ -15,6 +15,7 @@ include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk $(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) + cp -n ../../../scripting/lua/script/* ../../../../samples/Lua/TestLua/Resources $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) diff --git a/template/multi-platform-lua/proj.marmalade/HelloLua.mkb b/template/multi-platform-lua/proj.marmalade/HelloLua.mkb index 52860d6b76..18fbd2ddb5 100644 --- a/template/multi-platform-lua/proj.marmalade/HelloLua.mkb +++ b/template/multi-platform-lua/proj.marmalade/HelloLua.mkb @@ -42,3 +42,4 @@ files AppDelegate.cpp } +postbuild "cccopy.py -s ../../../scripting/lua/script/ -d ../Resources/ diff --git a/template/multi-platform-lua/proj.marmalade/cccopy.py b/template/multi-platform-lua/proj.marmalade/cccopy.py new file mode 100644 index 0000000000..e6f6f009c9 --- /dev/null +++ b/template/multi-platform-lua/proj.marmalade/cccopy.py @@ -0,0 +1,46 @@ +import os +import shutil +from optparse import OptionParser + +def cccopy(sourcePath, destPath): + for root, dirs, files in os.walk(sourcePath): + #figure out where we're going + dest = destPath + root.replace(sourcePath, '') + destAbsPath = os.path.abspath(destPath) + #if we're in a directory that doesn't exist in the destination folder then create a new folder + if not os.path.isdir(dest): + os.mkdir(dest) + print os.path.abspath(dest).replace(destAbsPath, '')[1:] + ' directory created.' + + #loop through all files in the directory + for f in files: + #compute current (old) & new file locations + oldLoc = root + "/" + f + newLoc = dest + "/" + f + + if not os.path.isfile(newLoc): + try: + shutil.copy2(oldLoc, newLoc) + print os.path.abspath(newLoc).replace(destAbsPath,'')[1:] + ' copied.' + except IOError: + print os.path.abspath(newLoc).replace(destAbsPath,'')[1:] + ' already exists.' + + + +# main +def main(): + # parse options + parser = OptionParser(usage="%prog [options]") + parser.add_option("-s", "--sourcePath", action="store", help="Source path", dest="sourcePath") + parser.add_option("-d", "--destPath", action="store", help="Destination path", dest="destPath") + + (options, args) = parser.parse_args() + + if options.sourcePath and options.destPath: + cccopy(options.sourcePath, options.destPath) + else: + parser.error("") + +## entry +if __name__ == "__main__": + main() \ No newline at end of file