makepanda: Updates for Android compilation with latest NDK

[skip ci]
This commit is contained in:
rdb 2021-12-05 17:12:44 +01:00
parent c977df33a3
commit d9e335e978
3 changed files with 31 additions and 20 deletions

View File

@ -795,14 +795,17 @@ def MakeInstallerAndroid(version, **kwargs):
os.unlink(apk_unsigned)
# Compile the Java classes into a Dalvik executable.
dx_cmd = "dx --dex --output=apkroot/classes.dex "
dx_cmd = "d8 --output apkroot "
if GetOptimize() <= 2:
dx_cmd += "--debug "
if GetVerbose():
dx_cmd += "--verbose "
else:
dx_cmd += "--release "
if "ANDROID_API" in SDK:
dx_cmd += "--min-sdk-version=%d " % (SDK["ANDROID_API"])
dx_cmd += os.path.join(outputdir, "classes")
dx_cmd += "--min-api %d " % (SDK["ANDROID_API"])
if "ANDROID_JAR" in SDK:
dx_cmd += "--lib %s " % (SDK["ANDROID_JAR"])
dx_cmd += " ".join(glob.glob(os.path.join(outputdir, "classes", "org", "panda3d", "android", "*.class")))
oscmd(dx_cmd)
# Copy the libraries one by one. In case of library dependencies, strip
@ -887,8 +890,12 @@ def MakeInstallerAndroid(version, **kwargs):
copy_library(source, "libpy.panda3d.{}.so".format(modname))
# Same for standard Python modules.
import _ctypes
source_dir = os.path.dirname(_ctypes.__file__)
if CrossCompiling():
source_dir = os.path.join(GetThirdpartyDir(), "python", "lib", SDK["PYTHONVERSION"], "lib-dynload")
else:
import _ctypes
source_dir = os.path.dirname(_ctypes.__file__)
for base in os.listdir(source_dir):
if not base.endswith('.so'):
continue

View File

@ -949,6 +949,8 @@ if (COMPILER=="GCC"):
SmartPkgEnable("CGGL", "", ("CgGL"), "Cg/cgGL.h", thirdparty_dir = "nvidiacg")
if GetTarget() != "android":
SmartPkgEnable("X11", "x11", "X11", ("X11", "X11/Xlib.h", "X11/XKBlib.h"))
else:
PkgDisable("X11")
if GetHost() != "darwin":
# Workaround for an issue where pkg-config does not include this path
@ -1339,14 +1341,14 @@ def CompileCxx(obj,src,opts):
cmd += " -Wa,--noexecstack"
# Do we want thumb or arm instructions?
if arch.startswith('arm'):
if arch != 'arm64' and arch.startswith('arm'):
if optlevel >= 3:
cmd += ' -mthumb'
else:
cmd += ' -marm'
# Enable SIMD instructions if requested
if arch.startswith('arm') and PkgSkip("NEON") == 0:
if arch != 'arm64' and arch.startswith('arm') and PkgSkip("NEON") == 0:
cmd += ' -mfpu=neon'
else:
@ -2421,7 +2423,6 @@ def WriteConfigSettings():
dtool_config["PHAVE_GLOB_H"] = 'UNDEF'
dtool_config["PHAVE_LOCKF"] = 'UNDEF'
dtool_config["HAVE_VIDEO4LINUX"] = 'UNDEF'
dtool_config["HAVE_X11"] = 'UNDEF'
if (GetOptimize() <= 2 and GetTarget() == "windows"):
dtool_config["USE_DEBUG_PYTHON"] = '1'
@ -4606,7 +4607,7 @@ elif not PkgSkip("EGL") and not PkgSkip("GL") and GetTarget() not in ('windows',
# DIRECTORY: panda/src/egldisplay/
#
if not PkgSkip("EGL") and not PkgSkip("GLES"):
if GetTarget() != 'android' and not PkgSkip("EGL") and not PkgSkip("GLES"):
DefSymbol('GLES', 'OPENGLES_1', '')
OPTS=['DIR:panda/src/egldisplay', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGLES', 'GLES', 'EGL', 'X11']
TargetAdd('pandagles_egldisplay_composite1.obj', opts=OPTS, input='p3egldisplay_composite1.cxx')
@ -4831,7 +4832,7 @@ if not PkgSkip("PVIEW"):
#
if GetTarget() == 'android':
OPTS=['DIR:panda/src/android']
OPTS=['DIR:panda/src/android', 'PNG']
TargetAdd('org/panda3d/android/NativeIStream.class', opts=OPTS, input='NativeIStream.java')
TargetAdd('org/panda3d/android/NativeOStream.class', opts=OPTS, input='NativeOStream.java')
TargetAdd('org/panda3d/android/PandaActivity.class', opts=OPTS, input='PandaActivity.java')

View File

@ -392,15 +392,15 @@ def SetTarget(target, arch=None):
else:
arch = 'armv7a'
if arch == 'arm64':
arch = 'aarch64'
if arch == 'aarch64':
arch = 'arm64'
# Did we specify an API level?
global ANDROID_API
target, _, api = target.partition('-')
if api:
ANDROID_API = int(api)
elif arch in ('mips64', 'aarch64', 'x86_64'):
elif arch in ('mips64', 'arm64', 'x86_64'):
# 64-bit platforms were introduced in Android 21.
ANDROID_API = 21
else:
@ -415,7 +415,7 @@ def SetTarget(target, arch=None):
elif arch == 'arm':
ANDROID_ABI = 'armeabi'
ANDROID_TRIPLE = 'arm-linux-androideabi'
elif arch == 'aarch64':
elif arch == 'arm64':
ANDROID_ABI = 'arm64-v8a'
ANDROID_TRIPLE = 'aarch64-linux-android'
elif arch == 'mips':
@ -431,7 +431,7 @@ def SetTarget(target, arch=None):
ANDROID_ABI = 'x86_64'
ANDROID_TRIPLE = 'x86_64-linux-android'
else:
exit('Android architecture must be arm, armv7a, aarch64, mips, mips64, x86 or x86_64')
exit('Android architecture must be arm, armv7a, arm64, mips, mips64, x86 or x86_64')
ANDROID_TRIPLE += str(ANDROID_API)
TOOLCHAIN_PREFIX = ANDROID_TRIPLE + '-'
@ -637,6 +637,7 @@ def oscmd(cmd, ignoreError = False, cwd=None):
os.chdir(pwd)
else:
cmd = cmd.replace(';', '\\;')
cmd = cmd.replace('$', '\\$')
res = subprocess.call(cmd, cwd=cwd, shell=True)
sig = res & 0x7F
if (GetVerbose() and res != 0):
@ -1362,7 +1363,7 @@ def GetThirdpartyDir():
THIRDPARTYDIR = base + "/freebsd-libs-a/"
elif (target == 'android'):
THIRDPARTYDIR = GetThirdpartyBase()+"/android-libs-%s/" % (GetTargetArch())
THIRDPARTYDIR = base + "/android-libs-%s/" % (target_arch)
else:
Warn("Unsupported platform:", target)
@ -2912,8 +2913,10 @@ def SetupBuildEnvironment(compiler):
if SDK.get("MACOSX"):
# The default compiler in Leopard does not respect --sysroot correctly.
sysroot_flag = " -isysroot " + SDK["MACOSX"]
if SDK.get("SYSROOT"):
sysroot_flag = ' --sysroot=%s -no-canonical-prefixes' % (SDK["SYSROOT"])
#if SDK.get("SYSROOT"):
# sysroot_flag = ' --sysroot=%s -no-canonical-prefixes' % (SDK["SYSROOT"])
if GetTarget() == "android":
sysroot_flag = " -target " + ANDROID_TRIPLE
# Extract the dirs from the line that starts with 'libraries: ='.
cmd = GetCXX() + " -print-search-dirs" + sysroot_flag