Created
September 5, 2015 17:30
-
-
Save ydm/98ae86191dff6c88ef48 to your computer and use it in GitHub Desktop.
Prepares Android.mk for building a cocos2d-x application. Script should be placed inside the proj.android directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import os | |
| TEMPLATE = r'''LOCAL_PATH := $(call my-dir) | |
| include $(CLEAR_VARS) | |
| LOCAL_MODULE := cocos2dcpp_shared | |
| LOCAL_MODULE_FILENAME := libcocos2dcpp | |
| LOCAL_SRC_FILES := hellocpp/main.cpp \ | |
| {} | |
| LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes | |
| LOCAL_STATIC_LIBRARIES := cocos2dx_static | |
| include $(BUILD_SHARED_LIBRARY) | |
| $(call import-module,./prebuilt-mk) | |
| ''' | |
| def classes_dir(): | |
| return os.path.join(project_dir(), 'Classes') | |
| def list_files(directory, exts=None): | |
| dirs = [directory] | |
| files = [] | |
| while dirs: | |
| d = dirs.pop() | |
| for f in map(lambda f: os.path.join(d, f), os.listdir(d)): | |
| if os.path.isdir(f): | |
| dirs.append(f) | |
| elif exts: | |
| if any(f.lower().endswith(e) for e in exts): | |
| files.append(f) | |
| else: | |
| files.append(f) | |
| return files | |
| def project_dir(): | |
| d = os.path.dirname(__file__) | |
| p = os.path.join(d, '..') | |
| return os.path.realpath(p) | |
| def main(): | |
| files = list_files(classes_dir(), ('.c', '.cpp')) | |
| s = ' \\\n'.join(map(lambda f: os.path.relpath(f, './jni'), files)) | |
| content = TEMPLATE.format(s) | |
| with open('./jni/Android.mk', 'w') as f: | |
| f.write(content) | |
| print('Wrote to ./jni/Android.mk:\n{}'.format(content)) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment