# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//device/vr/buildflags/buildflags.gni")
declare_args() {
# Used to determine whether or not the OpenXR loader is allowed to consider
# paths specified by a ContentProvider on Android as valid paths to load an
# OpenXR runtime from. It is more secure, albeit potentially not spec
# compliant, to set this to false, but more spec compliant to set it to true.
# When set to true, ContentProvider paths will be considered as valid paths to
# load an OpenXR runtime from.
# When set to false, ContentProvider paths will be ignored.
# For more details see the "Android Active Runtime Location" section from:
# https://registry.khronos.org/OpenXR/specs/1.0/loader.html#active-runtime-information
allow_openxr_content_providers = false
}
if (enable_openxr) {
source_set("openxr_headers") {
# This visibility is done to help enforce the dependency that
# openxr_platform.h requires platform headers to be included before it.
# If you'd like to expand this visibility, you will need to make similar
# DEPS rules for it as are present in the below locations.
visibility = [
"//chrome/browser/vr/*",
"//components/webxr/*",
"//device/vr/*",
]
sources = [
"dev/xr_android.h",
"src/include/openxr/openxr.h",
"src/include/openxr/openxr_platform.h",
"src/include/openxr/openxr_platform_defines.h",
"src/src/common/hex_and_handles.h",
"src/src/common/loader_interfaces.h",
]
public_configs = [ ":config" ]
}
if (is_android) {
# On Android, the loader comes with a couple more external dependencies.
source_set("jnipp") {
sources = [
"src/src/external/jnipp/jnipp.cpp",
"src/src/external/jnipp/jnipp.h",
]
cflags_cc = [ "-Wno-shadow" ]
# JNIPP uses exceptions to communicate failures:
configs += [ "//build/config/compiler:exceptions" ]
}
config("android-jni-wrappers-config") {
include_dirs = [ "src/src/external/jnipp" ]
}
source_set("android-jni-wrappers") {
sources = [
"src/src/external/android-jni-wrappers/wrap/ObjectWrapperBase.h",
"src/src/external/android-jni-wrappers/wrap/android.content.cpp",
"src/src/external/android-jni-wrappers/wrap/android.content.h",
"src/src/external/android-jni-wrappers/wrap/android.content.impl.h",
"src/src/external/android-jni-wrappers/wrap/android.database.cpp",
"src/src/external/android-jni-wrappers/wrap/android.database.h",
"src/src/external/android-jni-wrappers/wrap/android.database.impl.h",
"src/src/external/android-jni-wrappers/wrap/android.net.cpp",
"src/src/external/android-jni-wrappers/wrap/android.net.h",
"src/src/external/android-jni-wrappers/wrap/android.net.impl.h",
]
# android-jni-wrappers assume jnipp headers are in the include path and
# they also do so in the headers that are intended to be included by the
# consumer of this target, so let's add them to public_configs to
# propagate the include dirs to our consumers:
public_configs = [ ":android-jni-wrappers-config" ]
public_deps = [ ":jnipp" ]
}
}
source_set("openxr") {
# This visibility is done to help enforce the dependency that
# openxr_platform.h requires platform headers to be included before it.
# If you'd like to expand this visibility, you will need to make similar
# DEPS rules for it as are present in the below locations.
visibility = [
"//chrome/browser/vr/*",
"//components/webxr/*",
"//device/vr/*",
]
sources = [
"dev/xr_android.h",
"src/include/openxr/openxr.h",
"src/include/openxr/openxr_platform.h",
"src/include/openxr/openxr_platform_defines.h",
"src/src/common/extra_algorithms.h",
"src/src/common/filesystem_utils.cpp",
"src/src/common/filesystem_utils.hpp",
"src/src/common/hex_and_handles.h",
"src/src/common/loader_interfaces.h",
"src/src/common/object_info.cpp",
"src/src/common/object_info.h",
"src/src/common/platform_utils.hpp",
"src/src/common/xr_dependencies.h",
"src/src/common/xr_linear.h",
"src/src/loader/api_layer_interface.cpp",
"src/src/loader/api_layer_interface.hpp",
"src/src/loader/exception_handling.hpp",
"src/src/loader/loader_core.cpp",
"src/src/loader/loader_instance.cpp",
"src/src/loader/loader_instance.hpp",
"src/src/loader/loader_logger.cpp",
"src/src/loader/loader_logger.hpp",
"src/src/loader/loader_logger_recorders.cpp",
"src/src/loader/loader_logger_recorders.hpp",
"src/src/loader/loader_platform.hpp",
"src/src/loader/manifest_file.hpp",
"src/src/loader/runtime_interface.cpp",
"src/src/loader/runtime_interface.hpp",
"src/src/loader/xr_generated_loader.cpp",
"src/src/loader/xr_generated_loader.hpp",
"src/src/xr_generated_dispatch_table_core.c",
"src/src/xr_generated_dispatch_table_core.h",
"src_overrides/src/loader/manifest_file.cpp",
]
include_dirs = [
"src/include",
"src/src/common",
"src/src",
"src/src/loader",
]
deps = [ "//third_party/jsoncpp" ]
public_configs = [ ":config" ]
defines = [
"OPENXR_NON_CMAKE_BUILD",
"DISABLE_STD_FILESYSTEM",
]
if (!allow_openxr_content_providers) {
defines += [ "XRLOADER_DISABLE_CONTENT_PROVIDERS" ]
}
cflags_cc = [
"-Wno-format",
"-Wno-microsoft-cast",
"-Wno-microsoft-include",
"-Wno-unused-function",
"-Wno-extra-semi",
]
if (is_android) {
sources += [
"dev/xr_android.h",
"src/src/loader/android_utilities.h",
"src_overrides/src/loader/android_utilities.cpp",
]
deps += [ ":android-jni-wrappers" ]
# OpenXR loader on Android assumes that android-jni-wrappers are in the
# include path:
include_dirs += [ "src/src/external/android-jni-wrappers" ]
# OpenXR loader on Android has a bug where there is unconditional try-catch block
# (in android_utilities.cpp) even when built without exceptions support.
configs += [ "//build/config/compiler:exceptions" ]
}
}
config("config") {
# These build define flags need to be set for openxr.h to define
# constants related to Windows and D3D.
if (is_win) {
defines = [
"XRLOADER_DISABLE_EXCEPTION_HANDLING",
"XR_OS_WINDOWS",
"XR_USE_PLATFORM_WIN32",
"XR_USE_GRAPHICS_API_D3D11",
]
} else {
defines = [
"XRLOADER_DISABLE_EXCEPTION_HANDLING",
"XR_OS_ANDROID",
"XR_USE_PLATFORM_ANDROID",
"XR_USE_GRAPHICS_API_OPENGL_ES",
]
}
}
}