Add option to embed validation layers in Android package
authorChris Forbes <chrisforbes@google.com>
Mon, 18 Jun 2018 23:52:10 +0000 (16:52 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 13 Jul 2018 10:36:00 +0000 (06:36 -0400)
Based on https://github.com/KhronosGroup/VK-GL-CTS/pull/103 but reworked
a bit to allow setting the path directly. This allows easy codevelopment
of layers and tests.

Components: Framework
VK-GL-CTS: 1253

Change-Id: I232e48b82119f6bc358985d39be0def3c5a75766

external/vulkancts/README.md
scripts/android/build_apk.py

index dd144d2..d42a7f8 100644 (file)
@@ -364,6 +364,11 @@ By default `VK_DEBUG_REPORT_INFORMATION_BIT_EXT` and `_DEBUG_BIT_EXT` messages
 are excluded from the log, but that can be customized by modifying
 `vkt::TestCaseExecutor::deinit()` in `vktTestPackage.cpp`.
 
+On the Android target, layers can be added to the APK during the build process
+by setting the `--layers-path` command line option to point into the NDK or to
+a locally-built layers tree. The layers are expected to be found under $abi/
+under the layers path.
+
 
 Cherry GUI
 ----------
index df5c65c..309d6b6 100644 (file)
@@ -29,6 +29,7 @@
 import os
 import re
 import sys
+import glob
 import string
 import shutil
 import argparse
@@ -168,7 +169,7 @@ class Environment:
                self.ndk                = ndk
 
 class Configuration:
-       def __init__(self, env, buildPath, abis, nativeApi, nativeBuildType, gtfTarget, verbose):
+       def __init__(self, env, buildPath, abis, nativeApi, nativeBuildType, gtfTarget, verbose, layers):
                self.env                                = env
                self.sourcePath                 = DEQP_DIR
                self.buildPath                  = buildPath
@@ -178,6 +179,7 @@ class Configuration:
                self.nativeBuildType    = nativeBuildType
                self.gtfTarget                  = gtfTarget
                self.verbose                    = verbose
+               self.layers                             = layers
                self.cmakeGenerator             = selectFirstAvailableGenerator([NINJA_GENERATOR, MAKEFILE_GENERATOR, NMAKE_GENERATOR])
 
        def check (self):
@@ -709,6 +711,17 @@ class AddNativeLibsToAPK (BuildStep):
                        shutil.copyfile(libSrcPath, libAbsPath)
                        libFiles.append(libRelPath)
 
+                       if config.layers:
+                               layersGlob = os.path.join(config.layers, abi, "libVkLayer_*.so")
+                               libVkLayers = glob.glob(layersGlob)
+                               for layer in libVkLayers:
+                                       layerFilename = os.path.basename(layer)
+                                       layerRelPath = os.path.join("lib", abi, layerFilename)
+                                       layerAbsPath = os.path.join(pkgPath, layerRelPath)
+                                       shutil.copyfile(layer, layerAbsPath)
+                                       libFiles.append(layerRelPath)
+                                       print "Adding layer binary: %s" % (layer,)
+
                shutil.copyfile(srcPath, dstPath)
                addFilesToAPK(config, dstPath, pkgPath, libFiles)
 
@@ -884,6 +897,10 @@ def parseArgs ():
                default='gles32',
                choices=['gles32', 'gles31', 'gles3', 'gles2', 'gl'],
                help="KC-CTS (GTF) target API (only used in openglcts target)")
+       parser.add_argument('--layers-path',
+               dest='layers',
+               default=None,
+               required=False)
 
        args = parser.parse_args()
 
@@ -918,7 +935,8 @@ if __name__ == "__main__":
        sdk                     = SDKEnv(os.path.realpath(args.sdkPath))
        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)
+       config          = Configuration(env, buildPath, abis=args.abis, nativeApi=args.nativeApi, nativeBuildType=args.nativeBuildType, gtfTarget=args.gtfTarget, verbose=args.verbose,
+                                                layers=args.layers)
 
        try:
                config.check()