blob: 937f3770795a8944f860a95d636d29179cfa9f10 [file]
# Copyright 2024 The Dawn & Tint Authors
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###############################################################################
# Utils library
###############################################################################
import("../../scripts/dawn_overrides_with_defaults.gni")
import("//build_overrides/build.gni")
import("${dawn_root}/scripts/dawn_nocompile.gni")
config("internal_config") {
include_dirs = [ "${dawn_root}" ]
}
static_library("utils") {
sources = [
"compiler.h",
"force_crash.h",
"numeric.h",
"placeholder.cc",
"platform.h",
"underlying_type.h",
]
public_configs = [ ":internal_config" ]
}
dawn_nocompile_source_set("nocompile_sources") {
deps = [ ":utils" ]
sources = [ "numeric_nocompile.nc" ]
}
# Included in dawn_unittests.
source_set("unittests") {
testonly = true
deps = [
":gmock_and_gtest",
":nocompile_sources",
":utils",
]
sources = [ "underlying_type_tests.cpp" ]
}
###############################################################################
# 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",
]
}
} else {
# When we aren't in Chromium we define out own targets based on the location
# of the googletest repo.
googletest_dir = dawn_googletest_dir
config("gtest_config") {
include_dirs = [
"${googletest_dir}/googletest",
"${googletest_dir}/googletest/include",
]
}
static_library("gtest") {
testonly = true
sources = [ "${googletest_dir}/googletest/src/gtest-all.cc" ]
public_configs = [ ":gtest_config" ]
}
config("gmock_config") {
include_dirs = [
"${googletest_dir}/googlemock",
"${googletest_dir}/googlemock/include",
"${googletest_dir}/googletest/include",
]
if (dawn_standalone && is_clang) {
cflags = [
# gmock emits deprecated-copy-dtor warnings when using
# ::testing::Combine
"-Wno-deprecated-copy-dtor",
]
}
}
static_library("gmock") {
testonly = true
sources = [ "${googletest_dir}/googlemock/src/gmock-all.cc" ]
public_configs = [ ":gmock_config" ]
}
group("gmock_and_gtest") {
testonly = true
public_deps = [
":gmock",
":gtest",
]
}
static_library("gmock_main") {
testonly = true
sources = [ "${googletest_dir}/googlemock/src/gmock_main.cc" ]
public_deps = [ ":gmock_and_gtest" ]
}
}