Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. import shutil
  2. import os
  3.  
  4. Import('env')
  5.  
  6. android_files = [
  7.  
  8. 'os_android.cpp',
  9. 'godot_android.cpp',
  10. 'file_access_android.cpp',
  11. 'dir_access_android.cpp',
  12. 'audio_driver_opensl.cpp',
  13. 'file_access_jandroid.cpp',
  14. 'dir_access_jandroid.cpp',
  15. 'thread_jandroid.cpp',
  16. 'audio_driver_jandroid.cpp',
  17. 'ifaddrs_android.cpp',
  18. 'android_native_app_glue.c',
  19. 'java_glue.cpp',
  20. 'cpu-features.c',
  21. 'java_class_wrapper.cpp'
  22. ]
  23.  
  24. #env.Depends('#core/math/vector3.h', 'vector3_psp.h')
  25.  
  26. #obj = env.SharedObject('godot_android.cpp')
  27.  
  28. env_android = env.Clone()
  29. print("---------------- android profile ------------",env['target'])
  30. print("-----------00000----- platform ------------",env['PLATFORM'])
  31. print("-----------00000----- HOME ------------", os.environ.get('HOME'))
  32.  
  33. if env['target'] == "profile":
  34. env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
  35.  
  36. android_objects=[]
  37. for x in android_files:
  38. android_objects.append( env_android.SharedObject( x ) )
  39.  
  40. prog = None
  41.  
  42. abspath=env.Dir(".").abspath
  43. print("-----------abspath ------------",abspath)
  44.  
  45.  
  46. pp_basein = open(abspath+"/project.properties.template","rb")
  47. pp_baseout = open(abspath+"/java/project.properties","wb")
  48. pp_baseout.write( pp_basein.read() )
  49.  
  50. refcount=1
  51.  
  52. LIB_NAME = "libgodot"+env["SHLIBSUFFIX"]
  53. LIB_PATH = "bin/"+LIB_NAME
  54. print("-------------- abspath: "+ abspath)
  55. print("-------------- LIB_NAME: "+ LIB_NAME)
  56.  
  57. LIB_INSTALL_PATH = "platform/android/java/libs/armeabi/"
  58. print("-------------- LIB_INSTALL_PATH: "+ LIB_INSTALL_PATH)
  59. ANDROID_HOME = os.environ.get('ANDROID_HOME')
  60. ant_build = Dir('.').abspath+"/java/"
  61. ANT_TARGET = ant_build+'local.properties'
  62. ANT_SOURCES = ant_build+'build.xml'
  63. ANDROID_HOME = os.environ.get('ANDROID_HOME')
  64. ANT_COMMAND = 'ant release -Dsdk.dir='+ANDROID_HOME+' -f $SOURCE'
  65.  
  66. for x in env.android_source_modules:
  67. pp_baseout.write("android.library.reference."+str(refcount)+"="+x+"\n")
  68. refcount+=1
  69.  
  70. pp_baseout.close()
  71.  
  72.  
  73. pp_basein = open(abspath+"/AndroidManifest.xml.template","rb")
  74. pp_baseout = open(abspath+"/java/AndroidManifest.xml","wb")
  75. manifest = pp_basein.read()
  76. manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$",env.android_manifest_chunk)
  77. manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$",env.android_permission_chunk)
  78. manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$",env.android_appattributes_chunk)
  79. pp_baseout.write( manifest )
  80.  
  81.  
  82. for x in env.android_source_files:
  83. shutil.copy(x,abspath+"/java/src/com/android/godot")
  84.  
  85. for x in env.android_module_libraries:
  86. shutil.copy(x,abspath+"/java/libs")
  87.  
  88.  
  89. env_android.SharedLibrary("#bin/libgodot",[android_objects],\
  90. SHLIBSUFFIX=env["SHLIBSUFFIX"])
  91.  
  92. #---------------------------------------------------------
  93. # Copy android library created to LIB_INSTALL_PATH
  94. #---------------------------------------------------------
  95. lib_install = env_android.Install("#"+LIB_INSTALL_PATH, "#"+LIB_PATH)
  96. env_android.AlwaysBuild(lib_install)
  97.  
  98. #---------------------------------------------------------
  99. # Build the Android APK
  100. #---------------------------------------------------------
  101. TEMPLATE_INSTALL_DIR_LINUX = os.environ.get('HOME')+ '/.godot/templates/'
  102. TEMPLATE_INSTALL_PATH_LINUX_RELEASE = \
  103. TEMPLATE_INSTALL_DIR_LINUX + "/android_release.apk"
  104. TEMPLATE_INSTALL_PATH_LINUX_DEBUG = \
  105. TEMPLATE_INSTALL_DIR_LINUX + "/android_debug.apk"
  106.  
  107. TEMPLATE_INSTALL_PATH = "NOT_SET"
  108. APK_PATH = abspath+ '/java/bin/Godot-release-unsigned.apk'
  109. apk_build = env_android.Command(APK_PATH, source=ANT_SOURCES, action=ANT_COMMAND)
  110. env_android.AlwaysBuild(apk_build)
  111. env_android.Depends(apk_build, lib_install)
  112.  
  113. #---------------------------------------------------------
  114. # Link apk to platform templates
  115. #---------------------------------------------------------
  116.  
  117. # Set the correct LINUX install path
  118. if env['target'] == 'release_debug':
  119. TEMPLATE_INSTALL_PATH_LINUX = TEMPLATE_INSTALL_PATH_LINUX_DEBUG
  120. elif env['target'] == 'release':
  121. TEMPLATE_INSTALL_PATH_LINUX = TEMPLATE_INSTALL_PATH_LINUX_RELEASE
  122. else:
  123. print( "A valid build target wasn't specified! platorm was: " +
  124. env['target'])
  125. Exit(2)
  126.  
  127. if env['PLATFORM'] == 'posix':
  128. TEMPLATE_INSTALL_PATH = TEMPLATE_INSTALL_PATH_LINUX
  129. TEMPLATE_INSTALL_DIR = TEMPLATE_INSTALL_DIR_LINUX
  130. print("------------ Link: "+ APK_PATH + " to templates dir: ",
  131. TEMPLATE_INSTALL_PATH)
  132. #inst = env_android.Install(TEMPLATE_INSTALL_DIR, APK_PATH)
  133. #inst = env_android.InstallAs("/home/kyle2/test/dumb.apk", APK_PATH)
  134. inst = env_android.Command("install", [],
  135. "ln -fs "+ APK_PATH +" " + TEMPLATE_INSTALL_PATH)
  136. #env_android.Alias("release_debug", TEMPLATE_INSTALL_DIR)
  137. #env_android.Alias("install", TEMPLATE_INSTALL_DIR)
  138. env_android.Depends(inst, lib_install)
  139. env_android.Depends(inst, apk_build)
  140. env_android.AlwaysBuild(inst)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement