blob: 4e63c97415f8325b554482f112379d7f2944109d [file] [log] [blame]
# Copyright 2014-2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# import the use_x11 variable
import("//build/config/dcheck_always_on.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/ui.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("gni/angle.gni")
if (is_android) {
# android/rules.gni can only be imported for Android targets
import("//build/config/android/rules.gni")
}
declare_args() {
# Use the PCI lib to collect GPU information on Linux.
use_libpci = is_linux && (!is_chromecast || is_cast_desktop_build) &&
(use_x11 || use_ozone)
# Link in system libGL, to work with apitrace. See doc/DebuggingTips.md.
angle_link_glx = false
}
if (!build_with_chromium) {
group("all") {
testonly = true
deps = [
":angle_shader_translator",
":translator_fuzzer",
"//samples:all",
"//src/tests:all",
]
}
}
if (ozone_platform_gbm) {
pkg_config("libdrm") {
packages = [ "libdrm" ]
}
}
angle_git_is_present = exec_script("src/commit_id.py",
[
"check",
rebase_path(".", root_build_dir),
],
"value")
angle_use_commit_id = angle_git_is_present == 1
gles_gypi = exec_script("//build/gypi_to_gn.py",
[ rebase_path("src/libGLESv2.gypi") ],
"scope",
[ "src/libGLESv2.gypi" ])
compiler_gypi = exec_script("//build/gypi_to_gn.py",
[ rebase_path("src/compiler.gypi") ],
"scope",
[ "src/compiler.gypi" ])
# This config is exported to dependent targets (and also applied to internal
# ones).
config("external_config") {
include_dirs = [ "include" ]
}
# This config is applied to internal Angle targets (not pushed to dependents).
config("internal_config") {
include_dirs = [
"include",
"src",
]
# Prevent the GL headers from redeclaring ANGLE entry points.
defines = [
"GL_GLEXT_PROTOTYPES",
"EGL_EGLEXT_PROTOTYPES",
]
if (angle_64bit_current_cpu) {
defines += [ "ANGLE_IS_64_BIT_CPU" ]
} else {
defines += [ "ANGLE_IS_32_BIT_CPU" ]
}
}
config("extra_warnings") {
cflags = []
# Enable more default warnings on Windows.
if (is_win) {
cflags += [
"/we4244", # Conversion: possible loss of data.
"/we4456", # Variable shadowing.
"/we4458", # declaration hides class member.
"/we4800", # forcing value to bool.
"/we4838", # narrowing conversion.
]
}
if (is_clang) {
cflags += [
# Remove when crbug.com/428099 is resolved.
"-Winconsistent-missing-override",
"-Wunneeded-internal-declaration",
"-Wnon-virtual-dtor",
]
}
}
# This config adds build-ids to the associated library.
# -Wl is a special option that indicates that clang should pass the associated
# option --build-id to the linker. This will cause a build-id section to be added
# to the associated library. The build-id makes it possible for a debugger to
# find the right symbol file to use.
config("build_id_config") {
ldflags = [ "-Wl,--build-id" ]
}
if (is_win) {
copy("copy_compiler_dll") {
sources = [
"$windows_sdk_path/Redist/D3D/$target_cpu/d3dcompiler_47.dll",
]
outputs = [
"$root_out_dir/d3dcompiler_47.dll",
]
}
}
angle_undefine_configs = [ "//build/config/compiler:default_include_dirs" ]
# Holds the shared includes so we only need to list them once.
source_set("includes") {
sources = rebase_path(gles_gypi.libangle_includes, ".", "src")
}
static_library("preprocessor") {
sources = rebase_path(compiler_gypi.angle_preprocessor_sources, ".", "src")
configs -= angle_undefine_configs
configs += [
":extra_warnings",
":internal_config",
]
public_deps = [
":angle_common",
]
}
config("translator_disable_pool_alloc") {
defines = [ "ANGLE_TRANSLATOR_DISABLE_POOL_ALLOC" ]
}
config("debug_annotations_config") {
if (is_debug) {
defines = [ "ANGLE_ENABLE_DEBUG_ANNOTATIONS" ]
}
}
config("angle_release_asserts_config") {
if (dcheck_always_on) {
defines = [ "ANGLE_ENABLE_RELEASE_ASSERTS" ]
}
}
config("angle_common_config") {
include_dirs = [ "src/common/third_party/base" ]
if (is_android) {
libs = [ "log" ]
}
}
static_library("angle_common") {
sources = rebase_path(gles_gypi.libangle_common_sources, ".", "src")
if (is_linux || is_android || is_fuchsia) {
sources += rebase_path(gles_gypi.libangle_common_linux_sources, ".", "src")
}
if (is_mac) {
sources += rebase_path(gles_gypi.libangle_common_mac_sources, ".", "src")
}
if (is_win) {
sources += rebase_path(gles_gypi.libangle_common_win_sources, ".", "src")
}
configs -= angle_undefine_configs
configs += [
":angle_common_config",
":debug_annotations_config",
":extra_warnings",
":internal_config",
]
public_deps = [
":commit_id",
":includes",
]
public_configs = [ ":angle_common_config" ]
all_dependent_configs = [ ":angle_release_asserts_config" ]
}
config("angle_image_util_config") {
include_dirs = [
"include",
"src",
]
}
static_library("angle_image_util") {
sources = rebase_path(gles_gypi.libangle_image_util_sources, ".", "src")
configs -= angle_undefine_configs
configs += [
":internal_config",
":extra_warnings",
]
public_configs = [ ":angle_image_util_config" ]
public_deps = [
":angle_common",
]
}
config("angle_gpu_info_util_config") {
include_dirs = [
"include",
"src",
]
}
static_library("angle_gpu_info_util") {
configs -= angle_undefine_configs
configs += [
":internal_config",
":extra_warnings",
]
public_configs = [ ":angle_gpu_info_util_config" ]
public_deps = [
":angle_common",
]
sources = rebase_path(gles_gypi.libangle_gpu_info_util_sources, ".", "src")
deps = []
libs = []
defines = []
if (is_android) {
sources += [ "src/gpu_info_util/SystemInfo_android.cpp" ]
}
if (is_win) {
sources +=
rebase_path(gles_gypi.libangle_gpu_info_util_win_sources, ".", "src")
libs += [ "setupapi.lib" ]
defines += [ "GPU_INFO_USE_SETUPAPI" ]
}
if (is_linux) {
sources +=
rebase_path(gles_gypi.libangle_gpu_info_util_linux_sources, ".", "src")
if (use_x11) {
sources +=
rebase_path(gles_gypi.libangle_gpu_info_util_x11_sources, ".", "src")
deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
defines += [ "GPU_INFO_USE_X11" ]
libs += [
"X11",
"Xi",
"Xext",
]
}
}
if (use_libpci) {
sources +=
rebase_path(gles_gypi.libangle_gpu_info_util_libpci_sources, ".", "src")
defines += [ "GPU_INFO_USE_LIBPCI" ]
libs += [ "pci" ]
}
if (is_mac) {
sources +=
rebase_path(gles_gypi.libangle_gpu_info_util_mac_sources, ".", "src")
libs += [
"IOKit.framework",
"CoreFoundation.framework",
"CoreGraphics.framework",
]
}
}
static_library("translator") {
sources = rebase_path(compiler_gypi.angle_translator_sources, ".", "src")
defines = []
if (angle_enable_essl || use_fuzzing_engine) {
sources +=
rebase_path(compiler_gypi.angle_translator_essl_sources, ".", "src")
defines += [ "ANGLE_ENABLE_ESSL" ]
}
if (angle_enable_glsl || use_fuzzing_engine) {
sources +=
rebase_path(compiler_gypi.angle_translator_glsl_sources, ".", "src")
defines += [ "ANGLE_ENABLE_GLSL" ]
}
if (angle_enable_hlsl || use_fuzzing_engine) {
sources +=
rebase_path(compiler_gypi.angle_translator_hlsl_sources, ".", "src")
defines += [ "ANGLE_ENABLE_HLSL" ]
}
if (angle_enable_vulkan || use_fuzzing_engine) {
sources += rebase_path(compiler_gypi.angle_translator_lib_vulkan_sources,
".",
"src")
defines += [ "ANGLE_ENABLE_VULKAN" ]
}
configs -= angle_undefine_configs
configs += [
":internal_config",
":extra_warnings",
]
public_configs = [ ":external_config" ]
if (use_fuzzing_engine) {
all_dependent_configs = [ ":translator_disable_pool_alloc" ]
}
deps = [
":includes",
":preprocessor",
]
public_deps = [
":angle_common",
]
if (is_win) {
# Necessary to suppress some system header xtree warnigns in Release.
# For some reason this warning doesn't get triggered in Chromium
cflags = [ "/wd4718" ]
}
}
source_set("translator_fuzzer") {
sources = [
"src/compiler/fuzz/translator_fuzzer.cpp",
]
include_dirs = [
"include",
"src",
]
deps = [
":translator",
]
}
config("commit_id_config") {
include_dirs = [ "$root_gen_dir/angle" ]
}
commit_id_output_file = "$root_gen_dir/angle/id/commit.h"
if (angle_use_commit_id) {
action("commit_id") {
script = "src/commit_id.py"
outputs = [
commit_id_output_file,
]
# commit id should depend on angle's HEAD revision
inputs = [ ".git/HEAD" ]
args = [
"gen",
rebase_path(".", root_build_dir),
rebase_path(commit_id_output_file, root_build_dir),
]
public_configs = [ ":commit_id_config" ]
}
} else {
copy("commit_id") {
sources = [
"src/commit.h",
]
outputs = [
commit_id_output_file,
]
public_configs = [ ":commit_id_config" ]
}
}
config("libANGLE_config") {
cflags = []
defines = []
if (angle_enable_d3d9) {
defines += [ "ANGLE_ENABLE_D3D9" ]
}
if (angle_enable_d3d11) {
defines += [ "ANGLE_ENABLE_D3D11" ]
}
if (angle_enable_gl) {
defines += [ "ANGLE_ENABLE_OPENGL" ]
if (use_x11) {
defines += [ "ANGLE_USE_X11" ]
}
if (angle_enable_gl_null) {
defines += [ "ANGLE_ENABLE_OPENGL_NULL" ]
}
}
if (angle_enable_vulkan) {
defines += [ "ANGLE_ENABLE_VULKAN" ]
}
if (angle_enable_null) {
defines += [ "ANGLE_ENABLE_NULL" ]
}
defines += [ "LIBANGLE_IMPLEMENTATION" ]
if (is_win) {
cflags += [ "/wd4530" ] # C++ exception handler used, but unwind semantics are not enabled.
}
}
if (angle_enable_vulkan) {
# Use this target to include everything ANGLE needs for Vulkan.
group("angle_vulkan") {
deps = [
"$angle_root/third_party/glslang:glslang",
]
public_deps = [
"$angle_root/third_party/vulkan-headers:vulkan_headers",
]
public_configs = [
"$angle_root/third_party/glslang:glslang_config",
"$angle_root/third_party/vulkan-validation-layers:vulkan_config",
]
data_deps = []
if (!is_android) {
deps += [ "$angle_root/third_party/vulkan-loader:libvulkan" ]
data_deps += [ "$angle_root/third_party/vulkan-tools:VkICD_mock_icd" ]
public_configs +=
[ "$angle_root/third_party/vulkan-loader:vulkan_loader_config" ]
}
if (angle_enable_vulkan_validation_layers) {
data_deps += [ "$angle_root/third_party/vulkan-validation-layers:vulkan_validation_layers" ]
if (!is_android) {
data_deps += [ "$angle_root/third_party/vulkan-validation-layers:vulkan_gen_json_files" ]
}
}
}
}
static_library("libANGLE") {
sources = rebase_path(gles_gypi.libangle_sources, ".", "src")
include_dirs = []
libs = []
defines = []
if (angle_link_glx) {
libs += [ "GL" ]
defines += [ "ANGLE_LINK_GLX" ]
}
public_deps = [
":angle_common",
]
deps = [
":angle_gpu_info_util",
":angle_image_util",
":commit_id",
":includes",
":translator",
]
# Shared D3D sources.
if (angle_enable_d3d9 || angle_enable_d3d11) {
sources += rebase_path(gles_gypi.libangle_d3d_shared_sources, ".", "src")
defines += [ "ANGLE_PRELOADED_D3DCOMPILER_MODULE_NAMES={ " + "\"d3dcompiler_47.dll\", \"d3dcompiler_46.dll\", \"d3dcompiler_43.dll\" }" ]
}
if (angle_enable_d3d9) {
sources += rebase_path(gles_gypi.libangle_d3d9_sources, ".", "src")
libs += [ "d3d9.lib" ]
}
if (angle_enable_d3d11) {
sources += rebase_path(gles_gypi.libangle_d3d11_sources, ".", "src")
sources += rebase_path(gles_gypi.libangle_d3d11_win32_sources, ".", "src")
libs += [ "dxguid.lib" ]
}
if (angle_enable_gl) {
sources += rebase_path(gles_gypi.libangle_gl_sources, ".", "src")
include_dirs += [ "src/third_party/khronos" ]
if (angle_enable_gl_null) {
sources += rebase_path(gles_gypi.libangle_gl_null_sources, ".", "src")
}
if (is_win) {
sources += rebase_path(gles_gypi.libangle_gl_wgl_sources, ".", "src")
}
if (use_x11) {
sources += rebase_path(gles_gypi.libangle_gl_glx_sources, ".", "src")
deps += [ "src/third_party/libXNVCtrl:libXNVCtrl" ]
libs += [
"X11",
"Xi",
"Xext",
]
}
if (is_mac) {
sources += rebase_path(gles_gypi.libangle_gl_cgl_sources, ".", "src")
libs += [
"Cocoa.framework",
"IOSurface.framework",
"OpenGL.framework",
"QuartzCore.framework",
]
}
if (is_android) {
sources += rebase_path(gles_gypi.libangle_gl_egl_sources, ".", "src")
sources += rebase_path(gles_gypi.libangle_gl_egl_dl_sources, ".", "src")
sources +=
rebase_path(gles_gypi.libangle_gl_egl_android_sources, ".", "src")
if (ndk_supports_nativewindow) {
libs += [ "nativewindow" ]
} else {
libs += [ "android" ]
}
libs += [ "log" ]
}
if (ozone_platform_gbm) {
configs += [ ":libdrm" ]
defines += [ "ANGLE_USE_OZONE" ]
deps += [ "//third_party/minigbm" ]
sources += rebase_path(gles_gypi.libangle_gl_egl_sources, ".", "src")
sources += rebase_path(gles_gypi.libangle_gl_egl_dl_sources, ".", "src")
sources += rebase_path(gles_gypi.libangle_gl_ozone_sources, ".", "src")
}
}
if (angle_enable_vulkan) {
sources += rebase_path(gles_gypi.libangle_vulkan_sources, ".", "src")
if (is_win) {
sources +=
rebase_path(gles_gypi.libangle_vulkan_win32_sources, ".", "src")
}
if (is_linux) {
sources += rebase_path(gles_gypi.libangle_vulkan_xcb_sources, ".", "src")
}
if (is_android) {
sources +=
rebase_path(gles_gypi.libangle_vulkan_android_sources, ".", "src")
}
deps += [ ":angle_vulkan" ]
public_deps += [ "$angle_root/third_party/vulkan-headers:vulkan_headers" ]
# Include generated shaders.
import("src/libANGLE/renderer/vulkan/vk_internal_shaders_autogen.gni")
sources += angle_vulkan_internal_shaders
}
if (angle_enable_null) {
sources += rebase_path(gles_gypi.libangle_null_sources, ".", "src")
}
if (is_debug) {
defines += [ "ANGLE_GENERATE_SHADER_DEBUG_INFO" ]
}
configs -= angle_undefine_configs
configs += [
":commit_id_config",
":debug_annotations_config",
":extra_warnings",
":internal_config",
]
public_configs = [ ":libANGLE_config" ]
if (is_win) {
data_deps = [
":copy_compiler_dll",
]
}
}
config("shared_library_public_config") {
if (is_mac && !is_component_build) {
# Executable targets that depend on the shared libraries below need to have
# the rpath setup in non-component build configurations.
ldflags = [
"-rpath",
"@executable_path/",
]
}
}
# This config controls export definitions on ANGLE API calls.
config("angle_static") {
defines = [
"ANGLE_EXPORT=",
"EGLAPI=",
"GL_APICALL=",
"GL_API=",
]
}
shared_library("libGLESv2${angle_libs_suffix}") {
sources = rebase_path(gles_gypi.libglesv2_sources, ".", "src")
if (is_android) {
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
configs += [ ":build_id_config" ]
}
if (is_win) {
ldflags = [ "/DEF:" + rebase_path("src/libGLESv2/libGLESv2_autogen.def",
root_build_dir) ]
}
if (is_mac && !is_component_build) {
ldflags = [
"-install_name",
"@rpath/${target_name}.dylib",
]
public_configs = [ ":shared_library_public_config" ]
}
configs -= angle_undefine_configs
configs += [
":commit_id_config",
":debug_annotations_config",
":extra_warnings",
":internal_config",
]
defines = [ "LIBGLESV2_IMPLEMENTATION" ]
if (is_win) {
defines += [
"GL_APICALL=",
"GL_API=",
]
} else {
defines += [
"GL_APICALL=__attribute__((visibility(\"default\")))",
"GL_API=__attribute__((visibility(\"default\")))",
]
}
deps = [
":includes",
":libANGLE",
]
}
static_library("libGLESv2_static") {
sources = rebase_path(gles_gypi.libglesv2_sources, ".", "src")
configs -= angle_undefine_configs
configs += [
":commit_id_config",
":debug_annotations_config",
":extra_warnings",
":internal_config",
]
public_configs = [ ":angle_static" ]
deps = [
":includes",
":libANGLE",
]
}
shared_library("libGLESv1_CM${angle_libs_suffix}") {
sources = rebase_path(gles_gypi.libglesv1_cm_sources, ".", "src")
if (is_android) {
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
configs += [ ":build_id_config" ]
}
if (is_mac && !is_component_build) {
ldflags = [
"-install_name",
"@rpath/${target_name}.dylib",
]
public_configs = [ ":shared_library_public_config" ]
}
configs -= angle_undefine_configs
configs += [
":commit_id_config",
":debug_annotations_config",
":extra_warnings",
":internal_config",
]
defines = []
if (is_win) {
defines += [
"GL_APICALL=",
"GL_API=",
]
} else {
defines += [
"GL_APICALL=__attribute__((visibility(\"default\")))",
"GL_API=__attribute__((visibility(\"default\")))",
]
}
deps = [
":includes",
":libGLESv2${angle_libs_suffix}",
]
}
static_library("libGLESv1_CM_static") {
sources = rebase_path(gles_gypi.libglesv1_cm_sources, ".", "src")
configs -= angle_undefine_configs
configs += [
":commit_id_config",
":debug_annotations_config",
":extra_warnings",
":internal_config",
]
public_configs = [ ":angle_static" ]
deps = [
":includes",
":libGLESv2_static",
]
}
shared_library("libEGL${angle_libs_suffix}") {
sources = rebase_path(gles_gypi.libegl_sources, ".", "src")
if (is_android) {
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
configs += [ ":build_id_config" ]
}
configs -= angle_undefine_configs
configs += [
":commit_id_config",
":debug_annotations_config",
":extra_warnings",
":internal_config",
]
defines = [ "LIBEGL_IMPLEMENTATION" ]
if (is_win) {
defines += [ "EGLAPI=" ]
} else {
defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ]
}
if (is_win) {
ldflags = [ "/DEF:" + rebase_path("src/libEGL/libEGL.def", root_build_dir) ]
}
if (is_mac && !is_component_build) {
ldflags = [
"-install_name",
"@rpath/${target_name}.dylib",
]
public_configs = [ ":shared_library_public_config" ]
}
deps = [
":includes",
":libGLESv2${angle_libs_suffix}",
]
}
static_library("libEGL_static") {
sources = rebase_path(gles_gypi.libegl_sources, ".", "src")
configs -= angle_undefine_configs
configs += [
":commit_id_config",
":debug_annotations_config",
":extra_warnings",
":internal_config",
]
public_configs = [ ":angle_static" ]
deps = [
":includes",
":libGLESv2_static",
]
}
util_gypi = exec_script("//build/gypi_to_gn.py",
[ rebase_path("util/util.gyp") ],
"scope",
[ "util/util.gyp" ])
config("angle_util_config") {
include_dirs = [ "util" ]
if (is_linux && use_x11) {
libs = [ "X11" ]
}
}
foreach(is_shared_library,
[
true,
false,
]) {
if (is_shared_library) {
library_type = "shared_library"
library_name = "angle_util"
dep_suffix = "${angle_libs_suffix}"
} else {
library_type = "static_library"
library_name = "angle_util_static"
dep_suffix = "_static"
}
target(library_type, library_name) {
sources = rebase_path(util_gypi.util_sources, ".", "util")
if (is_win) {
sources += rebase_path(util_gypi.util_win32_sources, ".", "util")
}
libs = []
if (is_linux) {
sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
libs += [
"rt",
"dl",
]
}
if (is_mac) {
sources += rebase_path(util_gypi.util_osx_sources, ".", "util")
libs += [
"AppKit.framework",
"QuartzCore.framework",
]
}
if (use_x11) {
sources += rebase_path(util_gypi.util_x11_sources, ".", "util")
}
if (is_android) {
if (is_shared_library) {
configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
}
# To prevent linux sources filtering on android
set_sources_assignment_filter([])
sources += rebase_path(util_gypi.util_linux_sources, ".", "util")
sources += rebase_path(util_gypi.util_android_sources, ".", "util")
libs += [
"android",
"log",
]
}
if (use_ozone) {
sources += rebase_path(util_gypi.util_ozone_sources, ".", "util")
}
configs += [
":debug_annotations_config",
":extra_warnings",
]
public_configs = [
":angle_util_config",
":internal_config",
]
deps = [
":angle_common",
":libEGL${dep_suffix}",
":libGLESv2${dep_suffix}",
]
if (is_shared_library) {
defines = [ "LIBANGLE_UTIL_IMPLEMENTATION" ]
if (is_mac && !is_component_build) {
ldflags = [
"-install_name",
"@rpath/lib${target_name}.dylib",
]
public_configs += [ ":shared_library_public_config" ]
}
}
}
}
# Convenience targets for some of the samples so they can be built
# with Chromium's toolchain.
executable("angle_shader_translator") {
testonly = true
sources = [
"samples/shader_translator/shader_translator.cpp",
]
deps = [
":translator",
]
}
if (is_android) {
# Package ANGLE libraries for pre-installed system image
android_apk("angle_apk") {
if (build_apk_secondary_abi && android_64bit_target_cpu) {
secondary_abi_shared_libraries = [
"//third_party/angle:libEGL${angle_libs_suffix}($android_secondary_abi_toolchain)",
"//third_party/angle:libGLESv1_CM${angle_libs_suffix}($android_secondary_abi_toolchain)",
"//third_party/angle:libGLESv2${angle_libs_suffix}($android_secondary_abi_toolchain)",
]
}
android_manifest = "AndroidManifest.xml"
# requires_sdk_api_level_23 tells the apk tool that this apk is only
# supported on M or later releases (which is true for Vulkan).
# Allows tool to optimize for that.
requires_sdk_api_level_23 = true
apk_name = "ANGLEPrebuilt"
uncompress_shared_libraries = true
shared_libraries = [
"//third_party/angle:libEGL${angle_libs_suffix}",
"//third_party/angle:libGLESv1_CM${angle_libs_suffix}",
"//third_party/angle:libGLESv2${angle_libs_suffix}",
]
}
}