| # 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") |
| |
| # 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 |
| } |
| |
| config("internal_config") { |
| include_dirs = [ "${dawn_root}" ] |
| |
| defines = [] |
| |
| if (dawn_always_assert || dcheck_always_on || is_debug || |
| use_fuzzing_engine) { |
| defines += [ "DAWN_ENABLE_ASSERTS" ] |
| } |
| |
| if (build_with_chromium || use_fuzzing_engine) { |
| # Does a hard abort when an assertion fails so that fuzzers catch and parse |
| # the failure. Also call abort() so chrome can dump crash stack in console. |
| defines += [ "DAWN_ABORT_ON_ASSERT" ] |
| } |
| |
| if (use_fuzzing_engine) { |
| # Disable logging to make fuzzing more efficient. |
| defines += [ "DAWN_DISABLE_LOGGING" ] |
| } |
| } |
| |
| static_library("utils") { |
| sources = [ |
| "assert.cc", |
| "assert.h", |
| "compiler.h", |
| "force_crash.h", |
| "log.cc", |
| "log.h", |
| "non_copyable.h", |
| "non_movable.h", |
| "numeric.h", |
| "placeholder.cc", |
| "platform.h", |
| "typed_integer.h", |
| "underlying_type.h", |
| ] |
| |
| if (is_win) { |
| sources += [ "windows_with_undefs.h" ] |
| } |
| |
| public_configs = [ ":internal_config" ] |
| } |
| |
| dawn_nocompile_source_set("nocompile_sources") { |
| deps = [ ":utils" ] |
| sources = [ |
| "numeric_nocompile.nc", |
| "typed_integer_nocompile.nc", |
| ] |
| } |
| |
| # Included in dawn_unittests. |
| source_set("unittests") { |
| testonly = true |
| |
| deps = [ |
| ":gmock_and_gtest", |
| ":nocompile_sources", |
| ":utils", |
| ] |
| |
| sources = [ |
| "assert_test.cc", |
| "numeric_test.cc", |
| "typed_integer_tests.cc", |
| "underlying_type_tests.cc", |
| ] |
| } |
| |
| ############################################################################### |
| # 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" ] |
| } |
| } |