From 1b3c324ffc8f9515e46c556a0af4c041f0c976c1 Mon Sep 17 00:00:00 2001 From: Cody Northrop Date: Wed, 16 Aug 2017 17:38:15 -0600 Subject: vkjson: Add support for Android 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 | 11 +++++++++++ build-android/jni/Android.mk | 25 +++++++++++++++++++++++++ build-android/jni/Application.mk | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/BUILD.md b/BUILD.md index c5eda56f..3d02e326 100644 --- 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//vkjson_info /data/tmp/ +adb shell /data/tmp/vkjson_info +``` +The resulting json file will be found in: +``` +/sdcard/Android/.json +``` To build, install, and run the Smoke demo for Android, run the following, and any prompts that come back from the script: ``` diff --git a/build-android/jni/Android.mk b/build-android/jni/Android.mk index eabf3940..03ede702 100644 --- a/build-android/jni/Android.mk +++ b/build-android/jni/Android.mk @@ -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) diff --git a/build-android/jni/Application.mk b/build-android/jni/Application.mk index ded51693..344ede92 100644 --- a/build-android/jni/Application.mk +++ b/build-android/jni/Application.mk @@ -16,6 +16,6 @@ APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 mips mips64 APP_PLATFORM := android-22 APP_STL := gnustl_static -APP_MODULES := layer_utils VkLayer_core_validation VkLayer_parameter_validation VkLayer_object_tracker VkLayer_threading VkLayer_unique_objects VkLayerValidationTests VulkanLayerValidationTests +APP_MODULES := layer_utils VkLayer_core_validation VkLayer_parameter_validation VkLayer_object_tracker VkLayer_threading VkLayer_unique_objects VkLayerValidationTests VulkanLayerValidationTests vkjson_info APP_CPPFLAGS += -std=c++11 -DVK_PROTOTYPES -Wall -Werror -Wno-unused-function -Wno-unused-const-variable -mxgot NDK_TOOLCHAIN_VERSION := clang -- cgit v1.2.3