diff --git a/tools/android-mk-generator/android_mk_generator.py b/tools/android-mk-generator/android_mk_generator.py index 3e42d908d5..8e3386a47b 100755 --- a/tools/android-mk-generator/android_mk_generator.py +++ b/tools/android-mk-generator/android_mk_generator.py @@ -6,15 +6,27 @@ import os.path import cStringIO import re +def get_cur_dir(): + path = sys.path[0] + if os.path.isdir(path): + return path + elif os.path.isfile(path): + return os.path.dirname(path) + +CUR_DIR = get_cur_dir() +COCOS_ROOT = os.path.abspath(os.path.join(CUR_DIR, "../../")) +CONFIG = os.path.abspath(os.path.join(CUR_DIR, "./config.py")) +print 'CONFIG:' + CONFIG +print 'COCOS_ROOT:' + COCOS_ROOT + + try: import PathUtils except ImportError, e: - sys.path.append(os.path.abspath(os.path.join(os.curdir, "../pylib"))) + sys.path.append(os.path.abspath(os.path.join(CUR_DIR, "../pylib"))) import PathUtils -COCOS_ROOT = "../../" -COCOS_ROOT = os.path.abspath(os.path.join(os.curdir, COCOS_ROOT)) def gen_android_mk(mkfile, pathes, suffix = ("c", "cpp",), exclude = ()): utils = PathUtils.PathUtils(COCOS_ROOT) @@ -24,7 +36,7 @@ def gen_android_mk(mkfile, pathes, suffix = ("c", "cpp",), exclude = ()): filestrio = cStringIO.StringIO() for filename in filelst: filestrio.write(' \\\n') - filestrio.write("$(LOCAL_PATH)/"+os.path.relpath(filename, os.path.dirname(os.path.join(COCOS_ROOT, mkfile)))) + filestrio.write(os.path.relpath(filename, os.path.dirname(os.path.join(COCOS_ROOT, mkfile)))) filestrio.write('\n') # read mk file @@ -65,7 +77,7 @@ def gen_android_mk(mkfile, pathes, suffix = ("c", "cpp",), exclude = ()): mkstrio.close() def main(): - config = open("./config.py") + config = open(CONFIG) params = eval(config.read()) config.close() diff --git a/tools/android-mk-generator/config.py b/tools/android-mk-generator/config.py index f7cdc3f389..d524577587 100644 --- a/tools/android-mk-generator/config.py +++ b/tools/android-mk-generator/config.py @@ -20,9 +20,5 @@ { 'mkfile' : 'external/chipmunk/Android.mk', 'pathes' : ("external/chipmunk/",), -}, -{ - 'mkfile' : 'cocos2dx/platform/android/Android.mk', - 'pathes' : ('cocos2dx/platform/android/',), -}, +} ] \ No newline at end of file