Browse Source

makepanda: Android build fixes

rdb 4 years ago
parent
commit
a99a1ed991
2 changed files with 9 additions and 46 deletions
  1. 5 29
      makepanda/makepanda.py
  2. 4 17
      makepanda/makepandacore.py

+ 5 - 29
makepanda/makepanda.py

@@ -1308,10 +1308,6 @@ def CompileCxx(obj,src,opts):
         if "SYSROOT" in SDK:
         if "SYSROOT" in SDK:
             if GetTarget() != "android":
             if GetTarget() != "android":
                 cmd += ' --sysroot=%s' % (SDK["SYSROOT"])
                 cmd += ' --sysroot=%s' % (SDK["SYSROOT"])
-            else:
-                ndk_dir = SDK["ANDROID_NDK"].replace('\\', '/')
-                cmd += ' -isystem %s/sysroot/usr/include' % (ndk_dir)
-                cmd += ' -isystem %s/sysroot/usr/include/%s' % (ndk_dir, SDK["ANDROID_TRIPLE"])
             cmd += ' -no-canonical-prefixes'
             cmd += ' -no-canonical-prefixes'
 
 
         # Android-specific flags.
         # Android-specific flags.
@@ -1320,33 +1316,24 @@ def CompileCxx(obj,src,opts):
         if GetTarget() == "android":
         if GetTarget() == "android":
             # Most of the specific optimization flags here were
             # Most of the specific optimization flags here were
             # just copied from the default Android Makefiles.
             # just copied from the default Android Makefiles.
-            if "ANDROID_API" in SDK:
-                cmd += ' -D__ANDROID_API__=' + str(SDK["ANDROID_API"])
             if "ANDROID_GCC_TOOLCHAIN" in SDK:
             if "ANDROID_GCC_TOOLCHAIN" in SDK:
                 cmd += ' -gcc-toolchain ' + SDK["ANDROID_GCC_TOOLCHAIN"].replace('\\', '/')
                 cmd += ' -gcc-toolchain ' + SDK["ANDROID_GCC_TOOLCHAIN"].replace('\\', '/')
             cmd += ' -ffunction-sections -funwind-tables'
             cmd += ' -ffunction-sections -funwind-tables'
+            cmd += ' -target ' + SDK["ANDROID_TRIPLE"]
             if arch == 'armv7a':
             if arch == 'armv7a':
-                cmd += ' -target armv7-none-linux-androideabi'
                 cmd += ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16'
                 cmd += ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16'
                 cmd += ' -fno-integrated-as'
                 cmd += ' -fno-integrated-as'
             elif arch == 'arm':
             elif arch == 'arm':
-                cmd += ' -target armv5te-none-linux-androideabi'
                 cmd += ' -march=armv5te -mtune=xscale -msoft-float'
                 cmd += ' -march=armv5te -mtune=xscale -msoft-float'
                 cmd += ' -fno-integrated-as'
                 cmd += ' -fno-integrated-as'
-            elif arch == 'aarch64':
-                cmd += ' -target aarch64-none-linux-android'
             elif arch == 'mips':
             elif arch == 'mips':
-                cmd += ' -target mipsel-none-linux-android'
                 cmd += ' -mips32'
                 cmd += ' -mips32'
             elif arch == 'mips64':
             elif arch == 'mips64':
-                cmd += ' -target mips64el-none-linux-android'
                 cmd += ' -fintegrated-as'
                 cmd += ' -fintegrated-as'
             elif arch == 'x86':
             elif arch == 'x86':
-                cmd += ' -target i686-none-linux-android'
                 cmd += ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32'
                 cmd += ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32'
                 cmd += ' -mstackrealign'
                 cmd += ' -mstackrealign'
             elif arch == 'x86_64':
             elif arch == 'x86_64':
-                cmd += ' -target x86_64-none-linux-android'
                 cmd += ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel'
                 cmd += ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel'
 
 
             cmd += " -Wa,--noexecstack"
             cmd += " -Wa,--noexecstack"
@@ -1848,28 +1835,16 @@ def CompileLink(dll, obj, opts):
             if "ANDROID_GCC_TOOLCHAIN" in SDK:
             if "ANDROID_GCC_TOOLCHAIN" in SDK:
                 cmd += ' -gcc-toolchain ' + SDK["ANDROID_GCC_TOOLCHAIN"].replace('\\', '/')
                 cmd += ' -gcc-toolchain ' + SDK["ANDROID_GCC_TOOLCHAIN"].replace('\\', '/')
             cmd += " -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now"
             cmd += " -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now"
+            cmd += ' -target ' + SDK["ANDROID_TRIPLE"]
             if arch == 'armv7a':
             if arch == 'armv7a':
-                cmd += ' -target armv7-none-linux-androideabi'
                 cmd += " -march=armv7-a -Wl,--fix-cortex-a8"
                 cmd += " -march=armv7-a -Wl,--fix-cortex-a8"
-            elif arch == 'arm':
-                cmd += ' -target armv5te-none-linux-androideabi'
-            elif arch == 'aarch64':
-                cmd += ' -target aarch64-none-linux-android'
             elif arch == 'mips':
             elif arch == 'mips':
-                cmd += ' -target mipsel-none-linux-android'
                 cmd += ' -mips32'
                 cmd += ' -mips32'
-            elif arch == 'mips64':
-                cmd += ' -target mips64el-none-linux-android'
-            elif arch == 'x86':
-                cmd += ' -target i686-none-linux-android'
-            elif arch == 'x86_64':
-                cmd += ' -target x86_64-none-linux-android'
             cmd += ' -lc -lm'
             cmd += ' -lc -lm'
         else:
         else:
             cmd += " -pthread"
             cmd += " -pthread"
-
-        if "SYSROOT" in SDK:
-            cmd += " --sysroot=%s -no-canonical-prefixes" % (SDK["SYSROOT"])
+            if "SYSROOT" in SDK:
+                cmd += " --sysroot=%s -no-canonical-prefixes" % (SDK["SYSROOT"])
 
 
         if LDFLAGS != "":
         if LDFLAGS != "":
             cmd += " " + LDFLAGS
             cmd += " " + LDFLAGS
@@ -2446,6 +2421,7 @@ 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'

+ 4 - 17
makepanda/makepandacore.py

@@ -404,8 +404,8 @@ def SetTarget(target, arch=None):
             # 64-bit platforms were introduced in Android 21.
             # 64-bit platforms were introduced in Android 21.
             ANDROID_API = 21
             ANDROID_API = 21
         else:
         else:
-            # Default to the lowest API level supported by NDK r16.
-            ANDROID_API = 14
+            # Default to the lowest API level still supported by Google.
+            ANDROID_API = 19
 
 
         # Determine the prefix for our gcc tools, eg. arm-linux-androideabi-gcc
         # Determine the prefix for our gcc tools, eg. arm-linux-androideabi-gcc
         global ANDROID_ABI, ANDROID_TRIPLE
         global ANDROID_ABI, ANDROID_TRIPLE
@@ -433,6 +433,7 @@ def SetTarget(target, arch=None):
         else:
         else:
             exit('Android architecture must be arm, armv7a, aarch64, mips, mips64, x86 or x86_64')
             exit('Android architecture must be arm, armv7a, aarch64, mips, mips64, x86 or x86_64')
 
 
+        ANDROID_TRIPLE += str(ANDROID_API)
         TOOLCHAIN_PREFIX = ANDROID_TRIPLE + '-'
         TOOLCHAIN_PREFIX = ANDROID_TRIPLE + '-'
 
 
     elif target == 'linux':
     elif target == 'linux':
@@ -2540,15 +2541,6 @@ def SdkLocateAndroid():
     SDK["SYSROOT"] = os.path.join(ndk_root, 'platforms', 'android-%s' % (api), arch_dir).replace('\\', '/')
     SDK["SYSROOT"] = os.path.join(ndk_root, 'platforms', 'android-%s' % (api), arch_dir).replace('\\', '/')
     #IncDirectory("ALWAYS", os.path.join(SDK["SYSROOT"], 'usr', 'include'))
     #IncDirectory("ALWAYS", os.path.join(SDK["SYSROOT"], 'usr', 'include'))
 
 
-    # Starting with NDK r16, libc++ is the recommended STL to use.
-    stdlibc = os.path.join(ndk_root, 'sources', 'cxx-stl', 'llvm-libc++')
-    IncDirectory("ALWAYS", os.path.join(stdlibc, 'include').replace('\\', '/'))
-    LibDirectory("ALWAYS", os.path.join(stdlibc, 'libs', abi).replace('\\', '/'))
-
-    stl_lib = os.path.join(stdlibc, 'libs', abi, 'libc++_shared.so')
-    LibName("ALWAYS", stl_lib.replace('\\', '/'))
-    CopyFile(os.path.join(GetOutputDir(), 'lib', 'libc++_shared.so'), stl_lib)
-
     # The Android support library polyfills C++ features not available in the
     # The Android support library polyfills C++ features not available in the
     # STL that ships with Android.
     # STL that ships with Android.
     support = os.path.join(ndk_root, 'sources', 'android', 'support', 'include')
     support = os.path.join(ndk_root, 'sources', 'android', 'support', 'include')
@@ -2957,12 +2949,7 @@ def SetupBuildEnvironment(compiler):
 
 
         # Now extract the preprocessor's include directories.
         # Now extract the preprocessor's include directories.
         cmd = GetCXX() + " -x c++ -v -E " + os.devnull
         cmd = GetCXX() + " -x c++ -v -E " + os.devnull
-        if "ANDROID_NDK" in SDK:
-            ndk_dir = SDK["ANDROID_NDK"].replace('\\', '/')
-            cmd += ' -isystem %s/sysroot/usr/include' % (ndk_dir)
-            cmd += ' -isystem %s/sysroot/usr/include/%s' % (ndk_dir, SDK["ANDROID_TRIPLE"])
-        else:
-            cmd += sysroot_flag
+        cmd += sysroot_flag
 
 
         null = open(os.devnull, 'w')
         null = open(os.devnull, 'w')
         handle = subprocess.Popen(cmd, stdout=null, stderr=subprocess.PIPE, shell=True)
         handle = subprocess.Popen(cmd, stdout=null, stderr=subprocess.PIPE, shell=True)