blob: 8a7dc95015671f133e9aac64497edd7670d71fee [file] [log] [blame]
# Copyright 2021 The Tint 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.
# GEN_BUILD:DO_NOT_GENERATE - Don't regenerate this file with `./tools run gen`
import("//build_overrides/build.gni")
import("../../scripts/dawn_overrides_with_defaults.gni")
import("../../scripts/tint_overrides_with_defaults.gni")
if (tint_build_unittests) {
import("//testing/test.gni")
}
import("tint.gni")
###############################################################################
# Common - Configs, etc. shared across targets
###############################################################################
config("tint_common_config") {
include_dirs = [
"${target_gen_dir}",
"${tint_root_dir}/",
"${tint_spirv_headers_dir}/include",
"${tint_spirv_tools_dir}/",
"${tint_spirv_tools_dir}/include",
]
}
config("tint_public_config") {
defines = []
if (tint_build_spv_reader) {
defines += [ "TINT_BUILD_SPV_READER=1" ]
} else {
defines += [ "TINT_BUILD_SPV_READER=0" ]
}
if (tint_build_spv_writer) {
defines += [ "TINT_BUILD_SPV_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_SPV_WRITER=0" ]
}
if (tint_build_wgsl_reader) {
defines += [ "TINT_BUILD_WGSL_READER=1" ]
} else {
defines += [ "TINT_BUILD_WGSL_READER=0" ]
}
if (tint_build_wgsl_writer) {
defines += [ "TINT_BUILD_WGSL_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_WGSL_WRITER=0" ]
}
if (tint_build_msl_writer) {
defines += [ "TINT_BUILD_MSL_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_MSL_WRITER=0" ]
}
if (tint_build_hlsl_writer) {
defines += [ "TINT_BUILD_HLSL_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_HLSL_WRITER=0" ]
}
if (tint_build_glsl_writer) {
defines += [ "TINT_BUILD_GLSL_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_GLSL_WRITER=0" ]
}
if (tint_build_syntax_tree_writer) {
defines += [ "TINT_BUILD_SYNTAX_TREE_WRITER=1" ]
} else {
defines += [ "TINT_BUILD_SYNTAX_TREE_WRITER=0" ]
}
if (tint_build_ir) {
defines += [ "TINT_BUILD_IR=1" ]
} else {
defines += [ "TINT_BUILD_IR=0" ]
}
include_dirs = [
"${tint_root_dir}/",
"${tint_root_dir}/include/",
"${tint_spirv_headers_dir}/include",
]
}
config("tint_config") {
include_dirs = []
if (tint_build_spv_reader || tint_build_spv_writer) {
include_dirs += [ "${tint_spirv_tools_dir}/include/" ]
}
}
source_set("thread") {
# GN doesn't appear to need to depend on any thread libraries.
}
source_set("metal") {
frameworks = [
"CoreGraphics.framework",
"Foundation.framework",
"Metal.framework",
]
}
config("tint_unittests_config") {
include_dirs = [
"${tint_googletest_dir}/googlemock/include",
"${tint_googletest_dir}/googletest/include",
]
configs = [
":tint_common_config",
":tint_public_config",
]
if (is_win && is_debug) {
# TODO(crbug.com/tint/1749): both msvc and clang builds stack overflow on debug builds.
# Increase the initial stack size to 4 MB (default is 1MB).
ldflags = [ "/STACK:4194304" ]
}
}
if (tint_build_unittests) {
###############################################################################
# Gtest Gmock - Handle building inside and outside of Chromium.
###############################################################################
# When building outside of Chromium we need to define our own targets for GTest
# and GMock. However when compiling inside of Chromium we need to reuse the
# existing targets, both because Chromium has a special harness for swarming
# and because otherwise the "gn check" fails.
if (build_with_chromium) {
# When we are in Chromium we reuse its targets, and also add some deps that
# are needed to launch the test in swarming mode.
group("gmock_and_gtest") {
testonly = true
public_deps = [
"//base",
"//base/test:test_support",
"//testing/gmock",
"//testing/gtest",
"//third_party/googletest:gmock",
]
}
} else {
# When we aren't in Chromium we define out own targets based on the location
# of the googletest repo.
config("gtest_config") {
include_dirs = [
"${tint_googletest_dir}/googletest",
"${tint_googletest_dir}/googletest/include",
]
}
static_library("gtest") {
testonly = true
sources = [ "${tint_googletest_dir}/googletest/src/gtest-all.cc" ]
public_configs = [ ":gtest_config" ]
}
config("gmock_config") {
include_dirs = [
"${tint_googletest_dir}/googlemock",
"${tint_googletest_dir}/googlemock/include",
"${tint_googletest_dir}/googletest/include",
]
}
static_library("gmock") {
testonly = true
sources = [ "${tint_googletest_dir}/googlemock/src/gmock-all.cc" ]
public_configs = [ ":gmock_config" ]
}
group("gmock_and_gtest") {
testonly = true
public_deps = [
":gmock",
":gtest",
]
}
}
}
group("abseil") {
# When build_with_chromium=true we need to include "//third_party/abseil-cpp:absl" while
# it's beneficial to be more specific with standalone Dawn, especially when it comes to
# including it as a dependency in other projects (such as Skia).
if (build_with_chromium) {
public_deps = [ "$dawn_abseil_dir:absl" ]
} else {
public_deps = [ "${dawn_root}/third_party/gn/abseil-cpp:strings" ]
}
}
source_set("winsock") {
libs = [ "ws2_32.lib" ]
}
###############################################################################
# Aliases.
###############################################################################
if (tint_build_unittests) {
group("tint_unittests") {
testonly = true
public_deps = [ "${tint_src_dir}/cmd/test" ]
}
}