Add option for Android dEQP builds to link against and embed ANGLE shared object...
authorTim Van Patten <timvp@google.com>
Fri, 5 Oct 2018 22:14:47 +0000 (16:14 -0600)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 31 Oct 2018 10:21:56 +0000 (06:21 -0400)
Add the option '--angle-path' to scripts/android/build_apk.py to point
to the directory containing ANGLE shared object libraries for the
specified ABI.   This will cause dEQP to link against and embed the ANGLE
shared object libraries and use them during the dEQP test execution.

Components: Android dEQP

Google bug: 80239516

Change-Id: I04043d03b7837601656690126296e61b8ed9e658

README.md
scripts/android/build_apk.py
targets/android/android.cmake

index 6d6dbce..0ed668a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -25,3 +25,28 @@ Khronos OpenGL / OpenGL ES Conformance Tests
 
 This repository includes Khronos OpenGL / OpenGL ES CTS under `external/openglcts` directory.
 For more information see [OpenGL / OpenGL ES CTS README](external/openglcts/README.md).
+
+ANGLE for Android
+--------------------------------
+
+ANGLE can be built for Android by following the instructions
+[here](https://chromium.googlesource.com/angle/angle.git/+/HEAD/doc/DevSetup.md#building-angle-for-android).
+
+The resulting ANGLE shared object libraries can be linked against and embedded into `dEQP.apk` with
+the `--angle-path` option.   This will cause `dEQP.apk` to use the ANGLE libraries for OpenGL ES
+calls, rather than the native drivers.
+
+An ABI must be specified and the directory structure containing the ANGLE shared objects must match
+it so the build system can find the correct `*.so` files.
+
+Assuming ANGLE shared objects are generated into `~/chromium/src/out/Release/` and `dEQP.apk` will
+be generated with `--abis arm64-v8a`, issue the following commands:
+
+       cd ~/chromium/src/out/Release/
+       mkdir arm64-v8a && cd arm64-v8a
+       cp ../lib*_angle.so .
+
+The `--angle-path ~/chromium/src/out/Release/` option can then be used to link against and embed the
+ANGLE shared object files.   The full command would be:
+
+       python scripts/android/build_apk.py --sdk <path to Android SDK> --ndk <path to Android NDK> --abis arm64-v8a --angle-path ~/chromium/src/out/Release/
\ No newline at end of file
index 309d6b6..d296211 100644 (file)
@@ -169,7 +169,7 @@ class Environment:
                self.ndk                = ndk
 
 class Configuration:
-       def __init__(self, env, buildPath, abis, nativeApi, nativeBuildType, gtfTarget, verbose, layers):
+       def __init__(self, env, buildPath, abis, nativeApi, nativeBuildType, gtfTarget, verbose, layers, angle):
                self.env                                = env
                self.sourcePath                 = DEQP_DIR
                self.buildPath                  = buildPath
@@ -180,6 +180,7 @@ class Configuration:
                self.gtfTarget                  = gtfTarget
                self.verbose                    = verbose
                self.layers                             = layers
+               self.angle                              = angle
                self.cmakeGenerator             = selectFirstAvailableGenerator([NINJA_GENERATOR, MAKEFILE_GENERATOR, NMAKE_GENERATOR])
 
        def check (self):
@@ -331,7 +332,7 @@ def buildNativeLibrary (config, abiName):
                return "r%d%s" % (version[0], minorVersionString)
 
        def getBuildArgs (config, abiName):
-               return ['-DDEQP_TARGET=android',
+               args = ['-DDEQP_TARGET=android',
                                '-DDEQP_TARGET_TOOLCHAIN=ndk-modern',
                                '-DCMAKE_C_FLAGS=-Werror',
                                '-DCMAKE_CXX_FLAGS=-Werror',
@@ -341,6 +342,11 @@ def buildNativeLibrary (config, abiName):
                                '-DDE_ANDROID_API=%s' % config.nativeApi,
                                '-DGLCTS_GTF_TARGET=%s' % config.gtfTarget]
 
+               if config.angle is not None:
+                       args.append('-DANGLE_LIBS=%s' % os.path.join(config.angle, abiName))
+
+               return args
+
        nativeBuildPath = getNativeBuildPath(config, abiName)
        buildConfig             = BuildConfig(nativeBuildPath, config.nativeBuildType, getBuildArgs(config, abiName))
 
@@ -722,6 +728,17 @@ class AddNativeLibsToAPK (BuildStep):
                                        libFiles.append(layerRelPath)
                                        print "Adding layer binary: %s" % (layer,)
 
+                       if config.angle:
+                               angleGlob = os.path.join(config.angle, abi, "lib*_angle.so")
+                               libAngle = glob.glob(angleGlob)
+                               for lib in libAngle:
+                                       libFilename = os.path.basename(lib)
+                                       libRelPath = os.path.join("lib", abi, libFilename)
+                                       libAbsPath = os.path.join(pkgPath, libRelPath)
+                                       shutil.copyfile(lib, libAbsPath)
+                                       libFiles.append(libRelPath)
+                                       print "Adding ANGLE binary: %s" % (lib,)
+
                shutil.copyfile(srcPath, dstPath)
                addFilesToAPK(config, dstPath, pkgPath, libFiles)
 
@@ -901,6 +918,10 @@ def parseArgs ():
                dest='layers',
                default=None,
                required=False)
+       parser.add_argument('--angle-path',
+               dest='angle',
+               default=None,
+               required=False)
 
        args = parser.parse_args()
 
@@ -936,7 +957,7 @@ if __name__ == "__main__":
        buildPath       = os.path.realpath(args.buildRoot)
        env                     = Environment(sdk, ndk)
        config          = Configuration(env, buildPath, abis=args.abis, nativeApi=args.nativeApi, nativeBuildType=args.nativeBuildType, gtfTarget=args.gtfTarget, verbose=args.verbose,
-                                                layers=args.layers)
+                                                layers=args.layers, angle=args.angle)
 
        try:
                config.check()
index 82eacaf..44e97c6 100644 (file)
@@ -23,18 +23,37 @@ message("*** Using Android")
 set(DEQP_TARGET_NAME   "Android")
 set(DEQP_SUPPORT_GLES1 ON)
 
+# Necessary for find_library() to search within ANGLE_LIBS
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY_OLD ${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY})
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
+
 # GLESv1 lib
-find_library(GLES1_LIBRARY GLESv1_CM PATHS /usr/lib)
+if (IS_DIRECTORY ${ANGLE_LIBS})
+       find_library(GLES1_LIBRARY NAMES GLESv1_CM_angle PATHS ${ANGLE_LIBS} NO_DEFAULT_PATH)
+
+else()
+       find_library(GLES1_LIBRARY GLESv1_CM PATHS /usr/lib)
+endif()
 set(DEQP_GLES1_LIBRARIES ${GLES1_LIBRARY})
 
 # GLESv2 lib
-find_library(GLES2_LIBRARY GLESv2 PATHS /usr/lib)
+if (IS_DIRECTORY ${ANGLE_LIBS})
+       find_library(GLES2_LIBRARY NAMES GLESv2_angle PATHS ${ANGLE_LIBS} NO_DEFAULT_PATH)
+else()
+       find_library(GLES2_LIBRARY GLESv2 PATHS /usr/lib)
+endif()
 set(DEQP_GLES2_LIBRARIES ${GLES2_LIBRARY})
 
 # EGL lib
-find_library(EGL_LIBRARY EGL PATHS /usr/lib)
+if (IS_DIRECTORY ${ANGLE_LIBS})
+       find_library(EGL_LIBRARY NAMES EGL_angle PATHS ${ANGLE_LIBS} NO_DEFAULT_PATH)
+else()
+       find_library(EGL_LIBRARY EGL PATHS /usr/lib)
+endif()
 set(DEQP_EGL_LIBRARIES ${EGL_LIBRARY})
 
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ${CMAKE_FIND_ROOT_PATH_MODE_LIBRARY_OLD})
+
 # Platform libs
 find_library(LOG_LIBRARY NAMES log PATHS /usr/lib)
 set(DEQP_PLATFORM_LIBRARIES ${DEQP_PLATFORM_LIBRARIES} ${LOG_LIBRARY})