Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import shutil
- import os
- Import('env')
- android_files = [
- 'os_android.cpp',
- 'godot_android.cpp',
- 'file_access_android.cpp',
- 'dir_access_android.cpp',
- 'audio_driver_opensl.cpp',
- 'file_access_jandroid.cpp',
- 'dir_access_jandroid.cpp',
- 'thread_jandroid.cpp',
- 'audio_driver_jandroid.cpp',
- 'ifaddrs_android.cpp',
- 'android_native_app_glue.c',
- 'java_glue.cpp',
- 'cpu-features.c',
- 'java_class_wrapper.cpp'
- ]
- #env.Depends('#core/math/vector3.h', 'vector3_psp.h')
- #obj = env.SharedObject('godot_android.cpp')
- env_android = env.Clone()
- print("---------------- android profile ------------",env['target'])
- print("-----------00000----- platform ------------",env['PLATFORM'])
- print("-----------00000----- HOME ------------", os.environ.get('HOME'))
- if env['target'] == "profile":
- env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
- android_objects=[]
- for x in android_files:
- android_objects.append( env_android.SharedObject( x ) )
- prog = None
- abspath=env.Dir(".").abspath
- print("-----------abspath ------------",abspath)
- pp_basein = open(abspath+"/project.properties.template","rb")
- pp_baseout = open(abspath+"/java/project.properties","wb")
- pp_baseout.write( pp_basein.read() )
- refcount=1
- LIB_NAME = "libgodot"+env["SHLIBSUFFIX"]
- LIB_PATH = "bin/"+LIB_NAME
- print("-------------- abspath: "+ abspath)
- print("-------------- LIB_NAME: "+ LIB_NAME)
- LIB_INSTALL_PATH = "platform/android/java/libs/armeabi/"
- print("-------------- LIB_INSTALL_PATH: "+ LIB_INSTALL_PATH)
- ANDROID_HOME = os.environ.get('ANDROID_HOME')
- ant_build = Dir('.').abspath+"/java/"
- ANT_TARGET = ant_build+'local.properties'
- ANT_SOURCES = ant_build+'build.xml'
- ANDROID_HOME = os.environ.get('ANDROID_HOME')
- ANT_COMMAND = 'ant release -Dsdk.dir='+ANDROID_HOME+' -f $SOURCE'
- for x in env.android_source_modules:
- pp_baseout.write("android.library.reference."+str(refcount)+"="+x+"\n")
- refcount+=1
- pp_baseout.close()
- pp_basein = open(abspath+"/AndroidManifest.xml.template","rb")
- pp_baseout = open(abspath+"/java/AndroidManifest.xml","wb")
- manifest = pp_basein.read()
- manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$",env.android_manifest_chunk)
- manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$",env.android_permission_chunk)
- manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$",env.android_appattributes_chunk)
- pp_baseout.write( manifest )
- for x in env.android_source_files:
- shutil.copy(x,abspath+"/java/src/com/android/godot")
- for x in env.android_module_libraries:
- shutil.copy(x,abspath+"/java/libs")
- env_android.SharedLibrary("#bin/libgodot",[android_objects],\
- SHLIBSUFFIX=env["SHLIBSUFFIX"])
- #---------------------------------------------------------
- # Copy android library created to LIB_INSTALL_PATH
- #---------------------------------------------------------
- lib_install = env_android.Install("#"+LIB_INSTALL_PATH, "#"+LIB_PATH)
- env_android.AlwaysBuild(lib_install)
- #---------------------------------------------------------
- # Build the Android APK
- #---------------------------------------------------------
- TEMPLATE_INSTALL_DIR_LINUX = os.environ.get('HOME')+ '/.godot/templates/'
- TEMPLATE_INSTALL_PATH_LINUX_RELEASE = \
- TEMPLATE_INSTALL_DIR_LINUX + "/android_release.apk"
- TEMPLATE_INSTALL_PATH_LINUX_DEBUG = \
- TEMPLATE_INSTALL_DIR_LINUX + "/android_debug.apk"
- TEMPLATE_INSTALL_PATH = "NOT_SET"
- APK_PATH = abspath+ '/java/bin/Godot-release-unsigned.apk'
- apk_build = env_android.Command(APK_PATH, source=ANT_SOURCES, action=ANT_COMMAND)
- env_android.AlwaysBuild(apk_build)
- env_android.Depends(apk_build, lib_install)
- #---------------------------------------------------------
- # Link apk to platform templates
- #---------------------------------------------------------
- # Set the correct LINUX install path
- if env['target'] == 'release_debug':
- TEMPLATE_INSTALL_PATH_LINUX = TEMPLATE_INSTALL_PATH_LINUX_DEBUG
- elif env['target'] == 'release':
- TEMPLATE_INSTALL_PATH_LINUX = TEMPLATE_INSTALL_PATH_LINUX_RELEASE
- else:
- print( "A valid build target wasn't specified! platorm was: " +
- env['target'])
- Exit(2)
- if env['PLATFORM'] == 'posix':
- TEMPLATE_INSTALL_PATH = TEMPLATE_INSTALL_PATH_LINUX
- TEMPLATE_INSTALL_DIR = TEMPLATE_INSTALL_DIR_LINUX
- print("------------ Link: "+ APK_PATH + " to templates dir: ",
- TEMPLATE_INSTALL_PATH)
- #inst = env_android.Install(TEMPLATE_INSTALL_DIR, APK_PATH)
- #inst = env_android.InstallAs("/home/kyle2/test/dumb.apk", APK_PATH)
- inst = env_android.Command("install", [],
- "ln -fs "+ APK_PATH +" " + TEMPLATE_INSTALL_PATH)
- #env_android.Alias("release_debug", TEMPLATE_INSTALL_DIR)
- #env_android.Alias("install", TEMPLATE_INSTALL_DIR)
- env_android.Depends(inst, lib_install)
- env_android.Depends(inst, apk_build)
- env_android.AlwaysBuild(inst)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement