Locate glslang and spirv directories under shaderc directory.
This allows the layers build to optionally use the NDK sources.
For glslang and spirv and shaderc-
Use LOCAL_STATIC_LIBRARIES instead of LOCAL_C_INCLUDES to find headers.
Use import-module instead of PREBUILT_STATIC_LIBRARY.
brew install cmake python python3 git
```
### Build steps for Android
+
+There are two options for building the Android layers. One using the SPIRV tools
+provided as part of the Android NDK or build using upstream sources.
+To build with SPIRV tools from the NDK, remove the build-android/third_party directory created
+by running update_external_sources_android.sh, (or never run update_external_sources_android.sh).
Use the following script to build everything in the repo for Android, including validation layers, tests, demos, and APK packaging:
+This script does retrieve and use the upstream SPRIV tools.
```
cd build-android
./build_all.sh
# ${SRC_DIR}
# ${SRC_DIR}/build-android/external (for glslang, spirv-tools & shaderc )
get_filename_component(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../.." ABSOLUTE)
- set(EXTERNAL_DIR "${SRC_DIR}/build-android/external")
+ set(EXTERNAL_DIR "${SRC_DIR}/build-android/third_party")
set(SPIRV_LIB
"${EXTERNAL_DIR}/shaderc/android_test/obj/local/${ANDROID_ABI}/libSPIRV-Tools.a")
endif()
LOCAL_PATH := $(call my-dir)
SRC_DIR := ../..
LAYER_DIR := ../generated
-ANDROID_DIR := $(SRC_DIR)/build-android
include $(CLEAR_VARS)
LOCAL_MODULE := layer_utils
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SRC_DIR)/include \
$(LOCAL_PATH)/$(SRC_DIR)/layers \
$(LOCAL_PATH)/$(LAYER_DIR)/include \
- $(LOCAL_PATH)/$(SRC_DIR)/loader \
- $(LOCAL_PATH)/$(ANDROID_DIR)/external/glslang \
- $(LOCAL_PATH)/$(ANDROID_DIR)/external/spirv-tools/include
-LOCAL_STATIC_LIBRARIES += layer_utils SPIRV-Tools-prebuilt
+ $(LOCAL_PATH)/$(SRC_DIR)/loader
+LOCAL_STATIC_LIBRARIES += layer_utils glslang SPIRV-Tools
LOCAL_CPPFLAGS += -std=c++11 -Wall -Werror -Wno-unused-function -Wno-unused-const-variable -mxgot
LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -DVK_PROTOTYPES -fvisibility=hidden
LOCAL_LDLIBS := -llog
LOCAL_LDFLAGS += -Wl,--exclude-libs,ALL
include $(BUILD_SHARED_LIBRARY)
-# Pull in prebuilt shaderc
-include $(CLEAR_VARS)
-LOCAL_MODULE := shaderc-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libshaderc.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := glslang-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libglslang.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OGLCompiler-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libOGLCompiler.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := OSDependent-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libOSDependent.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := HLSL-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libHLSL.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := shaderc_util-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libshaderc_util.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := SPIRV-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libSPIRV.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := SPIRV-Tools-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libSPIRV-Tools.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := SPIRV-Tools-opt-prebuilt
-LOCAL_SRC_FILES := $(ANDROID_DIR)/external/shaderc/android_test/obj/local/$(TARGET_ARCH_ABI)/libSPIRV-Tools-opt.a
-include $(PREBUILT_STATIC_LIBRARY)
-
include $(CLEAR_VARS)
LOCAL_MODULE := VkLayerValidationTests
LOCAL_SRC_FILES += $(SRC_DIR)/tests/layer_validation_tests.cpp \
$(LOCAL_PATH)/$(LAYER_DIR)/include \
$(LOCAL_PATH)/$(SRC_DIR)/layers \
$(LOCAL_PATH)/$(SRC_DIR)/libs \
- $(LOCAL_PATH)/$(SRC_DIR)/common \
- $(LOCAL_PATH)/$(ANDROID_DIR)/external/shaderc/libshaderc/include
+ $(LOCAL_PATH)/$(SRC_DIR)/common
-LOCAL_STATIC_LIBRARIES := googletest_main layer_utils
-LOCAL_SHARED_LIBRARIES += shaderc-prebuilt glslang-prebuilt OGLCompiler-prebuilt OSDependent-prebuilt HLSL-prebuilt shaderc_util-prebuilt SPIRV-prebuilt SPIRV-Tools-prebuilt SPIRV-Tools-opt-prebuilt
+LOCAL_STATIC_LIBRARIES := googletest_main layer_utils shaderc
LOCAL_CPPFLAGS += -std=c++11 -DVK_PROTOTYPES -Wall -Werror -Wno-unused-function -Wno-unused-const-variable -mxgot
LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden --include=$(SRC_DIR)/common/vulkan_wrapper.h
LOCAL_LDLIBS := -llog
$(LOCAL_PATH)/$(LAYER_DIR)/include \
$(LOCAL_PATH)/$(SRC_DIR)/layers \
$(LOCAL_PATH)/$(SRC_DIR)/libs \
- $(LOCAL_PATH)/$(SRC_DIR)/common \
- $(LOCAL_PATH)/$(ANDROID_DIR)/external/shaderc/libshaderc/include
+ $(LOCAL_PATH)/$(SRC_DIR)/common
-LOCAL_STATIC_LIBRARIES := googletest_main layer_utils
-LOCAL_SHARED_LIBRARIES += shaderc-prebuilt glslang-prebuilt OGLCompiler-prebuilt OSDependent-prebuilt HLSL-prebuilt shaderc_util-prebuilt SPIRV-prebuilt SPIRV-Tools-prebuilt SPIRV-Tools-opt-prebuilt
+LOCAL_STATIC_LIBRARIES := googletest_main layer_utils shaderc
LOCAL_CPPFLAGS += -std=c++11 -DVK_PROTOTYPES -Wall -Werror -Wno-unused-function -Wno-unused-const-variable -mxgot
LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR -fvisibility=hidden -DVALIDATION_APK --include=$(SRC_DIR)/common/vulkan_wrapper.h
LOCAL_WHOLE_STATIC_LIBRARIES += android_native_app_glue
$(call import-module,android/native_app_glue)
$(call import-module,third_party/googletest)
+$(call import-module,third_party/shaderc)
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 vkjson_info\r
NDK_TOOLCHAIN_VERSION := clang\r
+NDK_MODULE_PATH := .\r
set errorCode=0
set ANDROID_BUILD_DIR=%~dp0
set BUILD_DIR=%ANDROID_BUILD_DIR%
-set BASE_DIR=%BUILD_DIR%\external
-set GLSLANG_DIR=%BASE_DIR%\glslang
-set SPIRV_TOOLS_DIR=%BASE_DIR%\spirv-tools
-set SPIRV_HEADERS_DIR=%BASE_DIR%\spirv-tools\external\spirv-headers
+set BASE_DIR=%BUILD_DIR%\third_party
+set GLSLANG_DIR=%BASE_DIR%\shaderc\third_party\glslang
+set SPIRV_TOOLS_DIR=%BASE_DIR%\shaderc\third_party\spirv-tools
+set SPIRV_HEADERS_DIR=%BASE_DIR%\shaderc\third_party\spirv-tools\external\spirv-headers
set SHADERC_DIR=%BASE_DIR%\shaderc
for %%X in (where.exe) do (set FOUND=%%~$PATH:X)
set sync-shaderc=1
set build-shaderc=1
+if %sync-shaderc% equ 1 (
+ if not exist %SHADERC_DIR% (
+ call:create_shaderc
+ )
+ if %errorCode% neq 0 (goto:error)
+ call:update_shaderc
+ if %errorCode% neq 0 (goto:error)
+)
+
if %sync-glslang% equ 1 (
if not exist %GLSLANG_DIR% (
call:create_glslang
if %errorCode% neq 0 (goto:error)
)
-if %sync-shaderc% equ 1 (
- if not exist %SHADERC_DIR% (
- call:create_shaderc
- )
- if %errorCode% neq 0 (goto:error)
- call:update_shaderc
- if %errorCode% neq 0 (goto:error)
-)
-
if %build-shaderc% equ 1 (
call:build_shaderc
if %errorCode% neq 0 (goto:error)
echo Building %SHADERC_DIR%
cd %SHADERC_DIR%\android_test
echo Building shaderc with Android NDK
- call ndk-build THIRD_PARTY_PATH=../.. -j 4
+ call ndk-build THIRD_PARTY_PATH=../third_party -j 4
REM Check for existence of one lib, even though we should check for all results
if not exist %SHADERC_DIR%\android_test\obj\local\x86\libshaderc.a (
echo.
ANDROIDBUILDDIR=$PWD
BUILDDIR=$ANDROIDBUILDDIR
-BASEDIR=$BUILDDIR/external
+BASEDIR=$BUILDDIR/third_party
GLSLANG_REVISION=$(cat $ANDROIDBUILDDIR/glslang_revision_android)
SPIRV_TOOLS_REVISION=$(cat $ANDROIDBUILDDIR/spirv-tools_revision_android)
fi
function create_glslang () {
- rm -rf $BASEDIR/glslang
+ rm -rf $BASEDIR/shaderc/third_party/glslang
echo "Creating local glslang repository ($BASEDIR/glslang)."
- mkdir -p $BASEDIR/glslang
- cd $BASEDIR/glslang
+ mkdir -p $BASEDIR/shaderc/third_party/glslang
+ cd $BASEDIR/shaderc/third_party/glslang
git clone $GLSLANG_URL .
git checkout $GLSLANG_REVISION
}
function update_glslang () {
- echo "Updating $BASEDIR/glslang"
- cd $BASEDIR/glslang
+ echo "Updating $BASEDIR/shaderc/third_party/glslang"
+ cd $BASEDIR/shaderc/third_party/glslang
if [[ $(git config --get remote.origin.url) != $GLSLANG_URL ]]; then
echo "glslang URL mismatch, recreating local repo"
create_glslang
}
function create_spirv-tools () {
- rm -rf $BASEDIR/spirv-tools
- echo "Creating local spirv-tools repository ($BASEDIR/spirv-tools)."
- mkdir -p $BASEDIR/spirv-tools
- cd $BASEDIR/spirv-tools
+ rm -rf $BASEDIR/shaderc/third_party/spirv-tools
+ echo "Creating local spirv-tools repository ($BASEDIR/shaderc/third_party/spirv-tools)."
+ mkdir -p $BASEDIR/shaderc/third_party/spirv-tools
+ cd $BASEDIR/shaderc/third_party/spirv-tools
git clone $SPIRV_TOOLS_URL .
git checkout $SPIRV_TOOLS_REVISION
}
function update_spirv-tools () {
- echo "Updating $BASEDIR/spirv-tools"
- cd $BASEDIR/spirv-tools
+ echo "Updating $BASEDIR/shaderc/third_party/spirv-tools"
+ cd $BASEDIR/shaderc/third_party/spirv-tools
if [[ $(git config --get remote.origin.url) != $SPIRV_TOOLS_URL ]]; then
echo "spirv-tools URL mismatch, recreating local repo"
create_spirv-tools
}
function create_spirv-headers () {
- rm -rf $BASEDIR/spirv-tools/external/spirv-headers
- echo "Creating local spirv-headers repository ($BASEDIR/spirv-tools/external/spirv-headers)."
- mkdir -p $BASEDIR/spirv-tools/external/spirv-headers
- cd $BASEDIR/spirv-tools/external/spirv-headers
+ rm -rf $BASEDIR/shaderc/third_party/spirv-tools/external/spirv-headers
+ echo "Creating local spirv-headers repository ($BASEDIR/shaderc/third_party/spirv-tools/external/spirv-headers)."
+ mkdir -p $BASEDIR/shaderc/third_party/spirv-tools/external/spirv-headers
+ cd $BASEDIR/shaderc/third_party/spirv-tools/external/spirv-headers
git clone $SPIRV_HEADERS_URL .
git checkout $SPIRV_HEADERS_REVISION
}
function update_spirv-headers () {
- echo "Updating $BASEDIR/spirv-tools/external/spirv-headers"
- cd $BASEDIR/spirv-tools/external/spirv-headers
+ echo "Updating $BASEDIR/shaderc/third_party/spirv-tools/external/spirv-headers"
+ cd $BASEDIR/shaderc/third_party/spirv-tools/external/spirv-headers
if [[ $(git config --get remote.origin.url) != $SPIRV_HEADERS_URL ]]; then
echo "spirv-headers URL mismatch, recreating local repo"
create_spirv-headers
function create_shaderc () {
rm -rf $BASEDIR/shaderc
echo "Creating local shaderc repository ($BASEDIR/shaderc)."
- cd $BASEDIR
- git clone $SHADERC_URL
- cd shaderc
+ mkdir -p $BASEDIR/shaderc
+ cd $BASEDIR/shaderc
+ git clone $SHADERC_URL .
git checkout $SHADERC_REVISION
}
echo "Building $BASEDIR/shaderc"
cd $BASEDIR/shaderc/android_test
if [[ $abi ]]; then
- ndk-build THIRD_PARTY_PATH=../.. APP_ABI=$abi -j $cores;
+ ndk-build THIRD_PARTY_PATH=../third_party APP_ABI=$abi -j $cores;
else
- ndk-build THIRD_PARTY_PATH=../.. -j $cores;
+ ndk-build THIRD_PARTY_PATH=../third_party -j $cores;
fi
}
-if [ ! -d "$BASEDIR/glslang" -o ! -d "$BASEDIR/glslang/.git" -o -d "$BASEDIR/glslang/.svn" ]; then
+if [ ! -d "$BASEDIR/shaderc" -o ! -d "$BASEDIR/shaderc/.git" ]; then
+ create_shaderc
+fi
+update_shaderc
+
+if [ ! -d "$BASEDIR/shaderc/third_party/glslang" -o ! -d "$BASEDIR/shaderc/third_party/glslang/.git" -o -d "$BASEDIR/shaderc/third_party/glslang/.svn" ]; then
create_glslang
fi
update_glslang
-
-if [ ! -d "$BASEDIR/spirv-tools" -o ! -d "$BASEDIR/spirv-tools/.git" ]; then
+if [ ! -d "$BASEDIR/shaderc/third_party/spirv-tools" -o ! -d "$BASEDIR/shaderc/third_party/spirv-tools/.git" ]; then
create_spirv-tools
fi
update_spirv-tools
-if [ ! -d "$BASEDIR/spirv-tools/external/spirv-headers" -o ! -d "$BASEDIR/spirv-tools/external/spirv-headers/.git" ]; then
+if [ ! -d "$BASEDIR/shaderc/third_party/spirv-tools/external/spirv-headers" -o ! -d "$BASEDIR/shaderc/third_party/spirv-tools/external/spirv-headers/.git" ]; then
create_spirv-headers
fi
update_spirv-headers
-if [ ! -d "$BASEDIR/shaderc" -o ! -d "$BASEDIR/shaderc/.git" ]; then
- create_shaderc
-fi
-update_shaderc
build_shaderc
echo ""