Revert "Create new src/tests BUILD.gn file."

This reverts commit 672d29d14c.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=913171

Original change's description:
> Create new src/tests BUILD.gn file.
> 
> Move all test-related build stuff into its own BUILD.gn file. This
> required moving the dawn_generator template into a common file, so it
> can be called by both BUILD.gn and src/tests/BUILD.gn.
> 
> [This is a reland of https://dawn-review.googlesource.com/c/dawn/+/2940
> with a fix for mock_dawn.]
> 
> Bug: dawn:61
> Change-Id: Id1e6d0c2b07caa2610cebe206511e972ac18fe8d
> Reviewed-on: https://dawn-review.googlesource.com/c/3020
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Commit-Queue: Stephen White <senorblanco@chromium.org>

TBR=cwallez@chromium.org,kainino@chromium.org,senorblanco@chromium.org

Change-Id: I54cdc558b128935dc8a8d22ec2b5e879271c35ae
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:61
Reviewed-on: https://dawn-review.googlesource.com/c/3080
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2018-12-08 10:35:53 +00:00 committed by Commit Bot service account
parent 672d29d14c
commit 48a1923afb
7 changed files with 225 additions and 288 deletions

230
BUILD.gn
View File

@ -15,7 +15,8 @@
import("scripts/dawn_overrides_with_defaults.gni") import("scripts/dawn_overrides_with_defaults.gni")
import("scripts/dawn_features.gni") import("scripts/dawn_features.gni")
import("//build_overrides/build.gni") import("//build_overrides/build.gni")
import("generator/dawn_generator.gni")
import("//testing/test.gni")
# Use Chromium's dcheck_always_on when available so that we respect it when # Use Chromium's dcheck_always_on when available so that we respect it when
# running tests on the GPU builders # running tests on the GPU builders
@ -25,6 +26,112 @@ if (build_with_chromium) {
dcheck_always_on = false dcheck_always_on = false
} }
###############################################################################
# Template to wrap the Dawn code generator
###############################################################################
# Template to help with invocation of the Dawn code generator, looks like this:
#
# dawn_generator("my_target_gen") {
# # Which generator target to output
# target = "my_target"
# # The list of expected outputs, generation fails if there's a mismatch
# outputs = [
# "MyTarget.cpp",
# "MyTarget.h",
# ]
# }
#
# Using the generated files is done like so:
#
# shared_library("my_target") {
# deps = [ ":my_target_gen "]
# sources = get_target_outputs(":my_target_gen")
# }
#
template("dawn_generator") {
# The base arguments for the generator: from this dawn.json, generate this
# target using templates in this directory.
generator_args = [
rebase_path("dawn.json", root_build_dir),
"--template-dir",
rebase_path("generator/templates", root_build_dir),
"--targets",
invoker.target,
]
# Use the Jinja2 version pulled from the DEPS file. We do it so we don't
# have version problems, and users don't have to install Jinja2.
jinja2_python_path = rebase_path("${dawn_jinja2_dir}/..")
generator_args += [
"--extra-python-path",
jinja2_python_path,
]
# For build parallelism GN wants to know the exact inputs and outputs of
# action targets like we use for our code generator. We avoid asking the
# generator about its inputs by using the "depfile" feature of GN/Ninja.
#
# A ninja limitation is that the depfile is a subset of Makefile that can
# contain a single target, so we output a single "JSON-tarball" instead.
json_tarball = "${target_gen_dir}/${target_name}.json_tarball"
json_tarball_depfile = "${json_tarball}.d"
generator_args += [
"--output-json-tarball",
rebase_path(json_tarball, root_build_dir),
"--depfile",
rebase_path(json_tarball_depfile, root_build_dir),
]
# After the JSON tarball is created we need an action target to extract it
# with a list of its outputs. The invoker provided a list of expected
# outputs. To make sure the list is in sync between the generator and the
# build files, we write it to a file and ask the generator to assert it is
# correct.
expected_outputs_file = "${target_gen_dir}/${target_name}.expected_outputs"
write_file(expected_outputs_file, invoker.outputs)
generator_args += [
"--expected-outputs-file",
rebase_path(expected_outputs_file, root_build_dir),
]
# The code generator invocation that will write the JSON tarball, check the
# outputs are what's expected and write a depfile for Ninja.
action("${target_name}_json_tarball") {
script = "generator/main.py"
outputs = [
json_tarball,
]
depfile = json_tarball_depfile
args = generator_args
}
# Extract the JSON tarball into the target_gen_dir
action("${target_name}") {
script = "generator/extract_json.py"
args = [
rebase_path(json_tarball, root_build_dir),
rebase_path(target_gen_dir, root_build_dir),
]
deps = [
":${target_name}_json_tarball",
]
inputs = [
json_tarball,
]
# The expected output list is relative to the target_gen_dir but action
# target outputs are from the root dir so we need to rebase them.
outputs = []
foreach(source, invoker.outputs) {
outputs += [ "${target_gen_dir}/${source}" ]
}
}
}
############################################################################### ###############################################################################
# Common dawn libraries and configs # Common dawn libraries and configs
############################################################################### ###############################################################################
@ -676,19 +783,124 @@ static_library("dawn_utils") {
# Dawn test targets # Dawn test targets
############################################################################### ###############################################################################
# FIXME: Temporary proxies until Chrome references src/tests directly. dawn_generator("mock_dawn_gen") {
group("dawn_unittests") { target = "mock_dawn"
testonly = true outputs = [
deps = [ "mock/mock_dawn.h",
"src/tests:dawn_unittests", "mock/mock_dawn.cpp",
] ]
} }
group("dawn_end2end_tests") { test("dawn_unittests") {
testonly = true configs += [ ":dawn_internal" ]
deps = [ deps = [
"src/tests:dawn_end2end_tests", ":dawn_common",
":dawn_headers",
":dawn_utils",
":libdawn",
":libdawn_native_sources",
":libdawn_wire",
":mock_dawn_gen",
"third_party:gmock_and_gtest",
] ]
# Add internal Dawn Native headers and config for internal unittests.
deps += [ ":libdawn_native_headers" ]
configs += [ ":libdawn_native_internal" ]
sources = get_target_outputs(":mock_dawn_gen")
sources += [
"src/tests/unittests/BitSetIteratorTests.cpp",
"src/tests/unittests/CommandAllocatorTests.cpp",
"src/tests/unittests/EnumClassBitmasksTests.cpp",
"src/tests/unittests/ErrorTests.cpp",
"src/tests/unittests/MathTests.cpp",
"src/tests/unittests/ObjectBaseTests.cpp",
"src/tests/unittests/PerStageTests.cpp",
"src/tests/unittests/RefCountedTests.cpp",
"src/tests/unittests/ResultTests.cpp",
"src/tests/unittests/SerialMapTests.cpp",
"src/tests/unittests/SerialQueueTests.cpp",
"src/tests/unittests/ToBackendTests.cpp",
"src/tests/unittests/WireTests.cpp",
"src/tests/unittests/validation/BindGroupValidationTests.cpp",
"src/tests/unittests/validation/BlendStateValidationTests.cpp",
"src/tests/unittests/validation/BufferValidationTests.cpp",
"src/tests/unittests/validation/CommandBufferValidationTests.cpp",
"src/tests/unittests/validation/ComputeValidationTests.cpp",
"src/tests/unittests/validation/CopyCommandsValidationTests.cpp",
"src/tests/unittests/validation/DepthStencilStateValidationTests.cpp",
"src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp",
"src/tests/unittests/validation/FenceValidationTests.cpp",
"src/tests/unittests/validation/InputStateValidationTests.cpp",
"src/tests/unittests/validation/PushConstantsValidationTests.cpp",
"src/tests/unittests/validation/QueueSubmitValidationTests.cpp",
"src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp",
"src/tests/unittests/validation/RenderPipelineValidationTests.cpp",
"src/tests/unittests/validation/ShaderModuleValidationTests.cpp",
"src/tests/unittests/validation/TextureViewValidationTests.cpp",
"src/tests/unittests/validation/ValidationTest.cpp",
"src/tests/unittests/validation/ValidationTest.h",
"src/tests/unittests/validation/VertexBufferValidationTests.cpp",
]
if (dawn_enable_d3d12) {
sources += [ "src/tests/unittests/d3d12/CopySplitTests.cpp" ]
}
# When building inside Chromium, use their gtest main function because it is
# needed to run in swarming correctly.
if (build_with_chromium) {
sources += [ "//gpu/dawn_unittests_main.cc" ]
} else {
sources += [ "src/tests/UnittestsMain.cpp" ]
}
}
test("dawn_end2end_tests") {
configs += [ ":dawn_internal" ]
deps = [
":dawn_common",
":dawn_utils",
":libdawn",
":libdawn_native",
":libdawn_wire",
"third_party:glfw",
"third_party:gmock_and_gtest",
]
sources = [
"src/tests/DawnTest.cpp",
"src/tests/DawnTest.h",
"src/tests/end2end/BasicTests.cpp",
"src/tests/end2end/BindGroupTests.cpp",
"src/tests/end2end/BlendStateTests.cpp",
"src/tests/end2end/BufferTests.cpp",
"src/tests/end2end/ComputeCopyStorageBufferTests.cpp",
"src/tests/end2end/CopyTests.cpp",
"src/tests/end2end/DepthStencilStateTests.cpp",
"src/tests/end2end/DrawElementsTests.cpp",
"src/tests/end2end/FenceTests.cpp",
"src/tests/end2end/IndexFormatTests.cpp",
"src/tests/end2end/InputStateTests.cpp",
"src/tests/end2end/PrimitiveTopologyTests.cpp",
"src/tests/end2end/PushConstantTests.cpp",
"src/tests/end2end/RenderPassLoadOpTests.cpp",
"src/tests/end2end/SamplerTests.cpp",
"src/tests/end2end/ScissorTests.cpp",
"src/tests/end2end/TextureViewTests.cpp",
"src/tests/end2end/ViewportOrientationTests.cpp",
]
# When building inside Chromium, use their gtest main function because it is
# needed to run in swarming correctly.
if (build_with_chromium) {
sources += [ "//gpu/dawn_end2end_tests_main.cc" ]
} else {
sources += [ "src/tests/End2EndTestsMain.cpp" ]
}
} }
############################################################################### ###############################################################################

View File

@ -1,122 +0,0 @@
# Copyright 2018 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("//build_overrides/dawn.gni")
import("../scripts/dawn_overrides_with_defaults.gni")
###############################################################################
# Template to wrap the Dawn code generator
###############################################################################
# Template to help with invocation of the Dawn code generator, looks like this:
#
# dawn_generator("my_target_gen") {
# # Which generator target to output
# target = "my_target"
# # The list of expected outputs, generation fails if there's a mismatch
# outputs = [
# "MyTarget.cpp",
# "MyTarget.h",
# ]
# }
#
# Using the generated files is done like so:
#
# shared_library("my_target") {
# deps = [ ":my_target_gen "]
# sources = get_target_outputs(":my_target_gen")
# }
#
template("dawn_generator") {
# The base arguments for the generator: from this dawn.json, generate this
# target using templates in this directory.
generator_args = [
rebase_path("${dawn_root}/dawn.json", root_build_dir),
"--template-dir",
rebase_path("${dawn_root}/generator/templates", root_build_dir),
"--targets",
invoker.target,
]
# Use the Jinja2 version pulled from the DEPS file. We do it so we don't
# have version problems, and users don't have to install Jinja2.
jinja2_python_path = rebase_path("${dawn_jinja2_dir}/..")
generator_args += [
"--extra-python-path",
jinja2_python_path,
]
# For build parallelism GN wants to know the exact inputs and outputs of
# action targets like we use for our code generator. We avoid asking the
# generator about its inputs by using the "depfile" feature of GN/Ninja.
#
# A ninja limitation is that the depfile is a subset of Makefile that can
# contain a single target, so we output a single "JSON-tarball" instead.
json_tarball = "${target_gen_dir}/${target_name}.json_tarball"
json_tarball_depfile = "${json_tarball}.d"
generator_args += [
"--output-json-tarball",
rebase_path(json_tarball, root_build_dir),
"--depfile",
rebase_path(json_tarball_depfile, root_build_dir),
]
# After the JSON tarball is created we need an action target to extract it
# with a list of its outputs. The invoker provided a list of expected
# outputs. To make sure the list is in sync between the generator and the
# build files, we write it to a file and ask the generator to assert it is
# correct.
expected_outputs_file = "${target_gen_dir}/${target_name}.expected_outputs"
write_file(expected_outputs_file, invoker.outputs)
generator_args += [
"--expected-outputs-file",
rebase_path(expected_outputs_file, root_build_dir),
]
# The code generator invocation that will write the JSON tarball, check the
# outputs are what's expected and write a depfile for Ninja.
action("${target_name}_json_tarball") {
script = "${dawn_root}/generator/main.py"
outputs = [
json_tarball,
]
depfile = json_tarball_depfile
args = generator_args
}
# Extract the JSON tarball into the target_gen_dir
action("${target_name}") {
script = "${dawn_root}/generator/extract_json.py"
args = [
rebase_path(json_tarball, root_build_dir),
rebase_path(target_gen_dir, root_build_dir),
]
deps = [
":${target_name}_json_tarball",
]
inputs = [
json_tarball,
]
# The expected output list is relative to the target_gen_dir but action
# target outputs are from the root dir so we need to rebase them.
outputs = []
foreach(source, invoker.outputs) {
outputs += [ "${target_gen_dir}/${source}" ]
}
}
}

View File

@ -450,8 +450,8 @@ def get_renders_for_targets(api_params, targets):
renders.append(FileRender('apicpp.cpp', 'dawn/dawncpp.cpp', [base_params, api_params, cpp_params])) renders.append(FileRender('apicpp.cpp', 'dawn/dawncpp.cpp', [base_params, api_params, cpp_params]))
if 'mock_dawn' in targets: if 'mock_dawn' in targets:
renders.append(FileRender('mock_api.h', 'mock/mock_dawn_.h', [base_params, api_params, c_params])) renders.append(FileRender('mock_api.h', 'mock/mock_dawn.h', [base_params, api_params, c_params]))
renders.append(FileRender('mock_api.cpp', 'mock/mock_dawn_.cpp', [base_params, api_params, c_params])) renders.append(FileRender('mock_api.cpp', 'mock/mock_dawn.cpp', [base_params, api_params, c_params]))
if 'dawn_native_utils' in targets: if 'dawn_native_utils' in targets:
frontend_params = [ frontend_params = [

View File

@ -12,7 +12,7 @@
//* See the License for the specific language governing permissions and //* See the License for the specific language governing permissions and
//* limitations under the License. //* limitations under the License.
#include "mock_dawn_.h" #include "mock_dawn.h"
namespace { namespace {
{% for type in by_category["object"] %} {% for type in by_category["object"] %}

View File

@ -24,10 +24,6 @@ if (!defined(dawn_standalone)) {
dawn_standalone = false dawn_standalone = false
} }
if (!defined(dawn_root)) {
dawn_root = get_path_info("..", "abspath")
}
if (!defined(dawn_jinja2_dir)) { if (!defined(dawn_jinja2_dir)) {
dawn_jinja2_dir = "//third_party/jinja2" dawn_jinja2_dir = "//third_party/jinja2"
} }

View File

@ -1,149 +0,0 @@
# Copyright 2018 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("//build_overrides/build.gni")
import("../../scripts/dawn_overrides_with_defaults.gni")
import("${dawn_root}/scripts/dawn_features.gni")
import("${dawn_root}/generator/dawn_generator.gni")
import("//testing/test.gni")
config("mock_dawn_public") {
include_dirs = [ target_gen_dir ]
}
dawn_generator("mock_dawn_gen") {
target = "mock_dawn"
outputs = [
# TODO once stale versions of "mock_dawn" target are gone from bots,
# these can be renamed "mock_dawn.*".
"mock/mock_dawn_.h",
"mock/mock_dawn_.cpp",
]
}
test("dawn_unittests") {
configs += [
"${dawn_root}:dawn_internal",
":mock_dawn_public",
]
deps = [
":mock_dawn_gen",
"${dawn_root}:dawn_common",
"${dawn_root}:dawn_headers",
"${dawn_root}:dawn_utils",
"${dawn_root}:libdawn",
"${dawn_root}:libdawn_native_sources",
"${dawn_root}:libdawn_wire",
"${dawn_root}/third_party:gmock_and_gtest",
]
# Add internal Dawn Native headers and config for internal unittests.
deps += [ "${dawn_root}:libdawn_native_headers" ]
configs += [ "${dawn_root}:libdawn_native_internal" ]
sources = get_target_outputs(":mock_dawn_gen")
sources += [
"unittests/BitSetIteratorTests.cpp",
"unittests/CommandAllocatorTests.cpp",
"unittests/EnumClassBitmasksTests.cpp",
"unittests/ErrorTests.cpp",
"unittests/MathTests.cpp",
"unittests/ObjectBaseTests.cpp",
"unittests/PerStageTests.cpp",
"unittests/RefCountedTests.cpp",
"unittests/ResultTests.cpp",
"unittests/SerialMapTests.cpp",
"unittests/SerialQueueTests.cpp",
"unittests/ToBackendTests.cpp",
"unittests/WireTests.cpp",
"unittests/validation/BindGroupValidationTests.cpp",
"unittests/validation/BlendStateValidationTests.cpp",
"unittests/validation/BufferValidationTests.cpp",
"unittests/validation/CommandBufferValidationTests.cpp",
"unittests/validation/ComputeValidationTests.cpp",
"unittests/validation/CopyCommandsValidationTests.cpp",
"unittests/validation/DepthStencilStateValidationTests.cpp",
"unittests/validation/DynamicStateCommandValidationTests.cpp",
"unittests/validation/FenceValidationTests.cpp",
"unittests/validation/InputStateValidationTests.cpp",
"unittests/validation/PushConstantsValidationTests.cpp",
"unittests/validation/QueueSubmitValidationTests.cpp",
"unittests/validation/RenderPassDescriptorValidationTests.cpp",
"unittests/validation/RenderPipelineValidationTests.cpp",
"unittests/validation/ShaderModuleValidationTests.cpp",
"unittests/validation/TextureViewValidationTests.cpp",
"unittests/validation/ValidationTest.cpp",
"unittests/validation/ValidationTest.h",
"unittests/validation/VertexBufferValidationTests.cpp",
]
if (dawn_enable_d3d12) {
sources += [ "unittests/d3d12/CopySplitTests.cpp" ]
}
# When building inside Chromium, use their gtest main function because it is
# needed to run in swarming correctly.
if (build_with_chromium) {
sources += [ "//gpu/dawn_unittests_main.cc" ]
} else {
sources += [ "UnittestsMain.cpp" ]
}
}
test("dawn_end2end_tests") {
configs += [ "${dawn_root}:dawn_internal" ]
deps = [
"${dawn_root}:dawn_common",
"${dawn_root}:dawn_utils",
"${dawn_root}:libdawn",
"${dawn_root}:libdawn_native",
"${dawn_root}:libdawn_wire",
"${dawn_root}/third_party:glfw",
"${dawn_root}/third_party:gmock_and_gtest",
]
sources = [
"DawnTest.cpp",
"DawnTest.h",
"end2end/BasicTests.cpp",
"end2end/BindGroupTests.cpp",
"end2end/BlendStateTests.cpp",
"end2end/BufferTests.cpp",
"end2end/ComputeCopyStorageBufferTests.cpp",
"end2end/CopyTests.cpp",
"end2end/DepthStencilStateTests.cpp",
"end2end/DrawElementsTests.cpp",
"end2end/FenceTests.cpp",
"end2end/IndexFormatTests.cpp",
"end2end/InputStateTests.cpp",
"end2end/PrimitiveTopologyTests.cpp",
"end2end/PushConstantTests.cpp",
"end2end/RenderPassLoadOpTests.cpp",
"end2end/SamplerTests.cpp",
"end2end/ScissorTests.cpp",
"end2end/TextureViewTests.cpp",
"end2end/ViewportOrientationTests.cpp",
]
# When building inside Chromium, use their gtest main function because it is
# needed to run in swarming correctly.
if (build_with_chromium) {
sources += [ "//gpu/dawn_end2end_tests_main.cc" ]
} else {
sources += [ "End2EndTestsMain.cpp" ]
}
}

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "mock/mock_dawn_.h" #include "mock/mock_dawn.h"
#include "common/Assert.h" #include "common/Assert.h"
#include "dawn_wire/Wire.h" #include "dawn_wire/Wire.h"