blob: e34df5710461ad4dcc5d963f385c9c394ee54f91 [file] [log] [blame]
# Copyright 2019 The Dawn Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("../../scripts/dawn_overrides_with_defaults.gni")
import("//build_overrides/build.gni")
import("${dawn_root}/scripts/dawn_features.gni")
# Use Chromium's dcheck_always_on when available so that we respect it when
# running tests on the GPU builders
if (build_with_chromium) {
import("//build/config/dcheck_always_on.gni")
} else {
dcheck_always_on = false
}
if (build_with_chromium) {
import("//build/config/sanitizers/sanitizers.gni")
} else {
use_fuzzing_engine = false
}
###############################################################################
# Common dawn configs
###############################################################################
config("dawn_public_include_dirs") {
include_dirs = [
"${target_gen_dir}/../../src/include",
"${dawn_root}/src/include",
]
}
config("dawn_internal") {
include_dirs = [
"${target_gen_dir}/../../src",
"${dawn_root}/src",
]
defines = []
if (dawn_always_assert || dcheck_always_on || is_debug ||
use_fuzzing_engine) {
defines += [ "DAWN_ENABLE_ASSERTS" ]
}
if (use_fuzzing_engine) {
# Does a hard abort when an assertion fails so that fuzzers catch and parse the failure.
defines += [ "DAWN_ABORT_ON_ASSERT" ]
}
if (dawn_enable_d3d12) {
defines += [ "DAWN_ENABLE_BACKEND_D3D12" ]
}
if (dawn_enable_metal) {
defines += [ "DAWN_ENABLE_BACKEND_METAL" ]
}
if (dawn_enable_null) {
defines += [ "DAWN_ENABLE_BACKEND_NULL" ]
}
if (dawn_enable_opengl) {
defines += [ "DAWN_ENABLE_BACKEND_OPENGL" ]
}
if (dawn_enable_desktop_gl) {
defines += [ "DAWN_ENABLE_BACKEND_DESKTOP_GL" ]
}
if (dawn_enable_opengles) {
defines += [ "DAWN_ENABLE_BACKEND_OPENGLES" ]
}
if (dawn_enable_vulkan) {
defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ]
}
if (dawn_use_x11) {
defines += [ "DAWN_USE_X11" ]
}
if (dawn_enable_error_injection) {
defines += [ "DAWN_ENABLE_ERROR_INJECTION" ]
}
# Only internal Dawn targets can use this config, this means only targets in
# this BUILD.gn file and related subdirs.
visibility = [ "../*" ]
cflags = []
# Enable more warnings that were found when using Dawn in other projects.
# Add them only when building in standalone because we control which clang
# version we use. Otherwise we risk breaking projects depending on Dawn when
# the use a different clang version.
if (dawn_standalone && is_clang) {
cflags += [
"-Wconditional-uninitialized",
"-Wcstring-format-directive",
"-Wc++11-narrowing",
"-Wdeprecated-copy",
"-Wdeprecated-copy-dtor",
"-Wduplicate-enum",
"-Wextra-semi-stmt",
"-Wimplicit-fallthrough",
"-Winconsistent-missing-destructor-override",
"-Winvalid-offsetof",
"-Wmissing-field-initializers",
"-Wnon-c-typedef-for-linkage",
"-Wpessimizing-move",
"-Wrange-loop-analysis",
"-Wredundant-move",
"-Wshadow-field",
"-Wstrict-prototypes",
"-Wtautological-unsigned-zero-compare",
"-Wunreachable-code-aggressive",
]
if (is_win) {
cflags += [
# clang-cl doesn't know -pedantic, pass it explicitly to the clang driver
"/clang:-pedantic",
# Allow the use of __uuidof()
"-Wno-language-extension-token",
]
} else {
cflags += [ "-pedantic" ]
}
}
if (!is_clang && is_win) {
# Dawn extends wgpu enums with internal enums.
# MSVC considers these invalid switch values. crbug.com/dawn/397.
cflags += [ "/wd4063" ]
if (dawn_is_winuwp) {
# /ZW makes sure we don't add calls that are forbidden in UWP.
# and /EHsc is required to be used in combination with it,
# even if it is already added by the windows GN defaults,
# we still add it to make every /ZW paired with a /EHsc
cflags_cc = [
"/ZW:nostdlib",
"/EHsc",
]
}
}
}
###############################################################################
# Common dawn library
###############################################################################
# This GN file is discovered by all Chromium builds, but common doesn't support
# all of Chromium's OSes so we explicitly make the target visible only on
# systems we know Dawn is able to compile on.
if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android) {
static_library("common") {
sources = [
"Alloc.h",
"Assert.cpp",
"Assert.h",
"BitSetIterator.h",
"Compiler.h",
"Constants.h",
"CoreFoundationRef.h",
"DynamicLib.cpp",
"DynamicLib.h",
"GPUInfo.cpp",
"GPUInfo.h",
"HashUtils.h",
"IOKitRef.h",
"LinkedList.h",
"Log.cpp",
"Log.h",
"Math.cpp",
"Math.h",
"NSRef.h",
"NonCopyable.h",
"PlacementAllocated.h",
"Platform.h",
"Preprocessor.h",
"RefBase.h",
"RefCounted.cpp",
"RefCounted.h",
"Result.cpp",
"Result.h",
"SerialMap.h",
"SerialQueue.h",
"SerialStorage.h",
"SlabAllocator.cpp",
"SlabAllocator.h",
"StackContainer.h",
"SwapChainUtils.h",
"SystemUtils.cpp",
"SystemUtils.h",
"TypeTraits.h",
"TypedInteger.h",
"UnderlyingType.h",
"VertexFormatUtils.cpp",
"VertexFormatUtils.h",
"ityp_array.h",
"ityp_bitset.h",
"ityp_span.h",
"ityp_stack_vec.h",
"ityp_vector.h",
"vulkan_platform.h",
"xlib_with_undefs.h",
]
public_configs = [ ":dawn_internal" ]
deps = [
"${dawn_root}/src/dawn:dawn_headers",
"${dawn_root}/src/dawn:dawncpp_headers",
]
if (is_win) {
sources += [
"WindowsUtils.cpp",
"WindowsUtils.h",
"windows_with_undefs.h",
]
}
if (dawn_enable_vulkan) {
public_deps = [ "${dawn_root}/third_party/khronos:vulkan_headers" ]
}
if (is_android) {
libs = [ "log" ]
}
}
}