mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
makepanda: Updates for Android compilation with latest NDK
[skip ci]
This commit is contained in:
parent
c977df33a3
commit
d9e335e978
@ -795,14 +795,17 @@ def MakeInstallerAndroid(version, **kwargs):
|
|||||||
os.unlink(apk_unsigned)
|
os.unlink(apk_unsigned)
|
||||||
|
|
||||||
# Compile the Java classes into a Dalvik executable.
|
# Compile the Java classes into a Dalvik executable.
|
||||||
dx_cmd = "dx --dex --output=apkroot/classes.dex "
|
dx_cmd = "d8 --output apkroot "
|
||||||
if GetOptimize() <= 2:
|
if GetOptimize() <= 2:
|
||||||
dx_cmd += "--debug "
|
dx_cmd += "--debug "
|
||||||
if GetVerbose():
|
else:
|
||||||
dx_cmd += "--verbose "
|
dx_cmd += "--release "
|
||||||
if "ANDROID_API" in SDK:
|
if "ANDROID_API" in SDK:
|
||||||
dx_cmd += "--min-sdk-version=%d " % (SDK["ANDROID_API"])
|
dx_cmd += "--min-api %d " % (SDK["ANDROID_API"])
|
||||||
dx_cmd += os.path.join(outputdir, "classes")
|
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)
|
oscmd(dx_cmd)
|
||||||
|
|
||||||
# Copy the libraries one by one. In case of library dependencies, strip
|
# 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))
|
copy_library(source, "libpy.panda3d.{}.so".format(modname))
|
||||||
|
|
||||||
# Same for standard Python modules.
|
# Same for standard Python modules.
|
||||||
|
if CrossCompiling():
|
||||||
|
source_dir = os.path.join(GetThirdpartyDir(), "python", "lib", SDK["PYTHONVERSION"], "lib-dynload")
|
||||||
|
else:
|
||||||
import _ctypes
|
import _ctypes
|
||||||
source_dir = os.path.dirname(_ctypes.__file__)
|
source_dir = os.path.dirname(_ctypes.__file__)
|
||||||
|
|
||||||
for base in os.listdir(source_dir):
|
for base in os.listdir(source_dir):
|
||||||
if not base.endswith('.so'):
|
if not base.endswith('.so'):
|
||||||
continue
|
continue
|
||||||
|
@ -949,6 +949,8 @@ if (COMPILER=="GCC"):
|
|||||||
SmartPkgEnable("CGGL", "", ("CgGL"), "Cg/cgGL.h", thirdparty_dir = "nvidiacg")
|
SmartPkgEnable("CGGL", "", ("CgGL"), "Cg/cgGL.h", thirdparty_dir = "nvidiacg")
|
||||||
if GetTarget() != "android":
|
if GetTarget() != "android":
|
||||||
SmartPkgEnable("X11", "x11", "X11", ("X11", "X11/Xlib.h", "X11/XKBlib.h"))
|
SmartPkgEnable("X11", "x11", "X11", ("X11", "X11/Xlib.h", "X11/XKBlib.h"))
|
||||||
|
else:
|
||||||
|
PkgDisable("X11")
|
||||||
|
|
||||||
if GetHost() != "darwin":
|
if GetHost() != "darwin":
|
||||||
# Workaround for an issue where pkg-config does not include this path
|
# Workaround for an issue where pkg-config does not include this path
|
||||||
@ -1339,14 +1341,14 @@ def CompileCxx(obj,src,opts):
|
|||||||
cmd += " -Wa,--noexecstack"
|
cmd += " -Wa,--noexecstack"
|
||||||
|
|
||||||
# Do we want thumb or arm instructions?
|
# Do we want thumb or arm instructions?
|
||||||
if arch.startswith('arm'):
|
if arch != 'arm64' and arch.startswith('arm'):
|
||||||
if optlevel >= 3:
|
if optlevel >= 3:
|
||||||
cmd += ' -mthumb'
|
cmd += ' -mthumb'
|
||||||
else:
|
else:
|
||||||
cmd += ' -marm'
|
cmd += ' -marm'
|
||||||
|
|
||||||
# Enable SIMD instructions if requested
|
# 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'
|
cmd += ' -mfpu=neon'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -2421,7 +2423,6 @@ def WriteConfigSettings():
|
|||||||
dtool_config["PHAVE_GLOB_H"] = 'UNDEF'
|
dtool_config["PHAVE_GLOB_H"] = 'UNDEF'
|
||||||
dtool_config["PHAVE_LOCKF"] = 'UNDEF'
|
dtool_config["PHAVE_LOCKF"] = 'UNDEF'
|
||||||
dtool_config["HAVE_VIDEO4LINUX"] = 'UNDEF'
|
dtool_config["HAVE_VIDEO4LINUX"] = 'UNDEF'
|
||||||
dtool_config["HAVE_X11"] = 'UNDEF'
|
|
||||||
|
|
||||||
if (GetOptimize() <= 2 and GetTarget() == "windows"):
|
if (GetOptimize() <= 2 and GetTarget() == "windows"):
|
||||||
dtool_config["USE_DEBUG_PYTHON"] = '1'
|
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/
|
# 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', '')
|
DefSymbol('GLES', 'OPENGLES_1', '')
|
||||||
OPTS=['DIR:panda/src/egldisplay', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGLES', 'GLES', 'EGL', 'X11']
|
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')
|
TargetAdd('pandagles_egldisplay_composite1.obj', opts=OPTS, input='p3egldisplay_composite1.cxx')
|
||||||
@ -4831,7 +4832,7 @@ if not PkgSkip("PVIEW"):
|
|||||||
#
|
#
|
||||||
|
|
||||||
if GetTarget() == 'android':
|
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/NativeIStream.class', opts=OPTS, input='NativeIStream.java')
|
||||||
TargetAdd('org/panda3d/android/NativeOStream.class', opts=OPTS, input='NativeOStream.java')
|
TargetAdd('org/panda3d/android/NativeOStream.class', opts=OPTS, input='NativeOStream.java')
|
||||||
TargetAdd('org/panda3d/android/PandaActivity.class', opts=OPTS, input='PandaActivity.java')
|
TargetAdd('org/panda3d/android/PandaActivity.class', opts=OPTS, input='PandaActivity.java')
|
||||||
|
@ -392,15 +392,15 @@ def SetTarget(target, arch=None):
|
|||||||
else:
|
else:
|
||||||
arch = 'armv7a'
|
arch = 'armv7a'
|
||||||
|
|
||||||
if arch == 'arm64':
|
if arch == 'aarch64':
|
||||||
arch = 'aarch64'
|
arch = 'arm64'
|
||||||
|
|
||||||
# Did we specify an API level?
|
# Did we specify an API level?
|
||||||
global ANDROID_API
|
global ANDROID_API
|
||||||
target, _, api = target.partition('-')
|
target, _, api = target.partition('-')
|
||||||
if api:
|
if api:
|
||||||
ANDROID_API = int(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.
|
# 64-bit platforms were introduced in Android 21.
|
||||||
ANDROID_API = 21
|
ANDROID_API = 21
|
||||||
else:
|
else:
|
||||||
@ -415,7 +415,7 @@ def SetTarget(target, arch=None):
|
|||||||
elif arch == 'arm':
|
elif arch == 'arm':
|
||||||
ANDROID_ABI = 'armeabi'
|
ANDROID_ABI = 'armeabi'
|
||||||
ANDROID_TRIPLE = 'arm-linux-androideabi'
|
ANDROID_TRIPLE = 'arm-linux-androideabi'
|
||||||
elif arch == 'aarch64':
|
elif arch == 'arm64':
|
||||||
ANDROID_ABI = 'arm64-v8a'
|
ANDROID_ABI = 'arm64-v8a'
|
||||||
ANDROID_TRIPLE = 'aarch64-linux-android'
|
ANDROID_TRIPLE = 'aarch64-linux-android'
|
||||||
elif arch == 'mips':
|
elif arch == 'mips':
|
||||||
@ -431,7 +431,7 @@ def SetTarget(target, arch=None):
|
|||||||
ANDROID_ABI = 'x86_64'
|
ANDROID_ABI = 'x86_64'
|
||||||
ANDROID_TRIPLE = 'x86_64-linux-android'
|
ANDROID_TRIPLE = 'x86_64-linux-android'
|
||||||
else:
|
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)
|
ANDROID_TRIPLE += str(ANDROID_API)
|
||||||
TOOLCHAIN_PREFIX = ANDROID_TRIPLE + '-'
|
TOOLCHAIN_PREFIX = ANDROID_TRIPLE + '-'
|
||||||
@ -637,6 +637,7 @@ def oscmd(cmd, ignoreError = False, cwd=None):
|
|||||||
os.chdir(pwd)
|
os.chdir(pwd)
|
||||||
else:
|
else:
|
||||||
cmd = cmd.replace(';', '\\;')
|
cmd = cmd.replace(';', '\\;')
|
||||||
|
cmd = cmd.replace('$', '\\$')
|
||||||
res = subprocess.call(cmd, cwd=cwd, shell=True)
|
res = subprocess.call(cmd, cwd=cwd, shell=True)
|
||||||
sig = res & 0x7F
|
sig = res & 0x7F
|
||||||
if (GetVerbose() and res != 0):
|
if (GetVerbose() and res != 0):
|
||||||
@ -1362,7 +1363,7 @@ def GetThirdpartyDir():
|
|||||||
THIRDPARTYDIR = base + "/freebsd-libs-a/"
|
THIRDPARTYDIR = base + "/freebsd-libs-a/"
|
||||||
|
|
||||||
elif (target == 'android'):
|
elif (target == 'android'):
|
||||||
THIRDPARTYDIR = GetThirdpartyBase()+"/android-libs-%s/" % (GetTargetArch())
|
THIRDPARTYDIR = base + "/android-libs-%s/" % (target_arch)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
Warn("Unsupported platform:", target)
|
Warn("Unsupported platform:", target)
|
||||||
@ -2912,8 +2913,10 @@ def SetupBuildEnvironment(compiler):
|
|||||||
if SDK.get("MACOSX"):
|
if SDK.get("MACOSX"):
|
||||||
# The default compiler in Leopard does not respect --sysroot correctly.
|
# The default compiler in Leopard does not respect --sysroot correctly.
|
||||||
sysroot_flag = " -isysroot " + SDK["MACOSX"]
|
sysroot_flag = " -isysroot " + SDK["MACOSX"]
|
||||||
if SDK.get("SYSROOT"):
|
#if SDK.get("SYSROOT"):
|
||||||
sysroot_flag = ' --sysroot=%s -no-canonical-prefixes' % (SDK["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: ='.
|
# Extract the dirs from the line that starts with 'libraries: ='.
|
||||||
cmd = GetCXX() + " -print-search-dirs" + sysroot_flag
|
cmd = GetCXX() + " -print-search-dirs" + sysroot_flag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user