vkjson: Add support for Android
authorCody Northrop <cnorthrop@google.com>
Wed, 16 Aug 2017 23:38:15 +0000 (17:38 -0600)
committerCody Northrop <cnorthrop@google.com>
Thu, 17 Aug 2017 16:53:41 +0000 (10:53 -0600)
This commit adds vkjson and vkjson_info to the Android build.
It is only generated as an executable for devices with root
access, but it could be expanded to an APK with some more
boilerplate work.

See updates to BUILD.md for how to build and run on the device.

BUILD.md
build-android/jni/Android.mk
build-android/jni/Application.mk

index c5eda56..3d02e32 100644 (file)
--- a/BUILD.md
+++ b/BUILD.md
@@ -333,7 +333,18 @@ adb install -r ../demos/android/cube-with-layers/bin/cube-with-layers.apk
 adb shell am start com.example.CubeWithLayers/android.app.NativeActivity
 adb shell am start -a android.intent.action.MAIN -c android-intent.category.LAUNCH -n com.example.CubeWithLayers/android.app.NativeActivity --es args "--validate"
 ```
+vkjson_info for Android is built as an executable for devices with root access.
 
+To use, simply push it to the device and run it:
+```
+./build_all.sh
+adb push obj/local/<abi>/vkjson_info /data/tmp/
+adb shell /data/tmp/vkjson_info
+```
+The resulting json file will be found in:
+```
+/sdcard/Android/<device_name>.json
+```
 To build, install, and run the Smoke demo for Android, run the following, and any
 prompts that come back from the script:
 ```
index eabf394..03ede70 100644 (file)
@@ -204,5 +204,30 @@ LOCAL_LDLIBS := -llog -landroid
 LOCAL_LDFLAGS := -u ANativeActivity_onCreate
 include $(BUILD_SHARED_LIBRARY)
 
+include $(CLEAR_VARS)
+LOCAL_MODULE := vkjson
+LOCAL_SRC_FILES += $(SRC_DIR)/libs/vkjson/vkjson.cc \
+                   $(SRC_DIR)/libs/vkjson/vkjson_instance.cc \
+                   $(SRC_DIR)/common/vulkan_wrapper.cpp \
+                   $(SRC_DIR)/loader/cJSON.c
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+                    $(SRC_DIR)/loader
+
+LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden --include=$(SRC_DIR)/common/vulkan_wrapper.h
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := vkjson_info
+LOCAL_SRC_FILES += $(SRC_DIR)/libs/vkjson/vkjson_info.cc \
+                   $(SRC_DIR)/common/vulkan_wrapper.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/loader \
+                    $(SRC_DIR)/include
+
+LOCAL_STATIC_LIBRARIES += vkjson
+LOCAL_CPPFLAGS += -Wno-sign-compare -DVK_USE_PLATFORM_ANDROID_KHR --include=$(SRC_DIR)/common/vulkan_wrapper.h
+LOCAL_LDLIBS := -llog
+LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL
+include $(BUILD_EXECUTABLE)
+
 $(call import-module,android/native_app_glue)
 $(call import-module,third_party/googletest)
index ded5169..344ede9 100644 (file)
@@ -16,6 +16,6 @@
 APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 mips mips64\r
 APP_PLATFORM := android-22\r
 APP_STL := gnustl_static\r
-APP_MODULES := layer_utils VkLayer_core_validation VkLayer_parameter_validation VkLayer_object_tracker VkLayer_threading VkLayer_unique_objects VkLayerValidationTests VulkanLayerValidationTests\r
+APP_MODULES := layer_utils VkLayer_core_validation VkLayer_parameter_validation VkLayer_object_tracker VkLayer_threading VkLayer_unique_objects VkLayerValidationTests VulkanLayerValidationTests vkjson_info\r
 APP_CPPFLAGS += -std=c++11 -DVK_PROTOTYPES -Wall -Werror -Wno-unused-function -Wno-unused-const-variable -mxgot\r
 NDK_TOOLCHAIN_VERSION := clang\r