Make Dawn "gn check" by default (except SPIRV-Tools)

This required adding some missing dependencies, splitting public headers
of libdawn_[native|wire] so they aren't hidden in the
libdawn_[native|wire]_sources targets, and making unittests depend on
sources directly instead of static libraries (which is almost equivalent).

As a byproduct, Empty.cpp is no longer needed and is removed.
This commit is contained in:
Corentin Wallez 2018-08-12 21:07:46 +02:00 committed by Corentin Wallez
parent a5696c7aa5
commit d2969a7d3d
4 changed files with 70 additions and 52 deletions

7
.gn
View File

@ -19,3 +19,10 @@ default_args = {
clang_use_chrome_plugins = false clang_use_chrome_plugins = false
use_sysroot = true use_sysroot = true
} }
check_targets = [
# Everything in BUILD.gn
"//:*",
# Everything in third_party/BUILD.gn
"//third_party/:*",
]

View File

@ -201,6 +201,9 @@ static_library("dawn_common") {
] ]
configs += [ ":dawn_internal" ] configs += [ ":dawn_internal" ]
deps = [
":dawn_headers",
]
} }
############################################################################### ###############################################################################
@ -212,6 +215,11 @@ dawn_generator("dawn_headers") {
target_type = "source_set" target_type = "source_set"
public_configs = [ ":libdawn_public" ] public_configs = [ ":libdawn_public" ]
sources = [
"src/include/dawn/EnumClassBitmasks.h",
"src/include/dawn/dawn_export.h",
"src/include/dawn/dawn_wsi.h",
]
} }
dawn_generator("libdawn") { dawn_generator("libdawn") {
@ -219,11 +227,6 @@ dawn_generator("libdawn") {
target_type = "shared_library" target_type = "shared_library"
defines = [ "DAWN_IMPLEMENTATION" ] defines = [ "DAWN_IMPLEMENTATION" ]
sources = [
"src/include/dawn/EnumClassBitmasks.h",
"src/include/dawn/dawn_export.h",
"src/include/dawn/dawn_wsi.h",
]
public_deps = [ public_deps = [
":dawn_headers", ":dawn_headers",
@ -342,17 +345,43 @@ dawn_generator("libdawn_native_utils") {
] ]
} }
# Public libdawn_native headers so they can be publically visible for
# dependencies of libdawn_native
source_set("libdawn_native_headers") {
public_deps = [
":dawn_headers",
]
sources = [
"src/include/dawn_native/DawnNative.h",
"src/include/dawn_native/dawn_native_export.h",
# Include all backend's public headers so that dependencies can include
# them even when the backends are disabled.
"src/include/dawn_native/D3D12Backend.h",
"src/include/dawn_native/MetalBackend.h",
"src/include/dawn_native/NullBackend.h",
"src/include/dawn_native/OpenGLBackend.h",
"src/include/dawn_native/VulkanBackend.h",
]
}
# The meat of the compilation for libdawn_native so that we can cheaply have # The meat of the compilation for libdawn_native so that we can cheaply have
# shared_library / static_library / component versions of it. # shared_library / static_library / component versions of it.
source_set("libdawn_native_sources") { source_set("libdawn_native_sources") {
deps = [ deps = [
":dawn_common", ":dawn_common",
":dawn_headers",
":libdawn_native_utils", ":libdawn_native_utils",
":spirv_cross", ":spirv_cross",
] ]
configs += [ ":libdawn_native_internal" ] # Put the internal config public so that unittests can see internal headers
public_configs = [ ":libdawn_native_internal" ]
# Set the headers as a public dependency so they are visible to unittests
public_deps = [
":libdawn_native_headers",
]
libs = [] libs = []
sources = [ sources = [
@ -413,16 +442,6 @@ source_set("libdawn_native_sources") {
"src/dawn_native/Texture.h", "src/dawn_native/Texture.h",
"src/dawn_native/ToBackend.h", "src/dawn_native/ToBackend.h",
"src/dawn_native/dawn_platform.h", "src/dawn_native/dawn_platform.h",
"src/include/dawn_native/DawnNative.h",
"src/include/dawn_native/dawn_native_export.h",
# Include all backend's public headers so that dependencies can include
# them even when the backends are disabled.
"src/include/dawn_native/D3D12Backend.h",
"src/include/dawn_native/MetalBackend.h",
"src/include/dawn_native/NullBackend.h",
"src/include/dawn_native/OpenGLBackend.h",
"src/include/dawn_native/VulkanBackend.h",
] ]
if (dawn_enable_d3d12) { if (dawn_enable_d3d12) {
@ -630,6 +649,11 @@ shared_library("libdawn_native") {
deps = [ deps = [
":libdawn_native_sources", ":libdawn_native_sources",
] ]
#Make headers publically visible
public_deps = [
":libdawn_native_headers",
]
public_configs = [ ":libdawn_public" ] public_configs = [ ":libdawn_public" ]
# Tell dependents where to find this shared library # Tell dependents where to find this shared library
@ -642,24 +666,22 @@ shared_library("libdawn_native") {
} }
} }
# The static library for libdawn_native for use by unittests
static_library("libdawn_native_static") {
deps = [
":libdawn_native_sources",
]
sources = [
"src/Empty.cpp",
]
# Put the internal config public so that unittests can see internal headers
public_configs = [ ":libdawn_native_internal" ]
}
############################################################################### ###############################################################################
# libdawn_wire.so # libdawn_wire.so
############################################################################### ###############################################################################
# Public libdawn_wire headers so they can be publically visible for
# dependencies of libdawn_wire
source_set("libdawn_wire_headers") {
public_deps = [
":dawn_headers",
]
sources = [
"src/include/dawn_wire/Wire.h",
"src/include/dawn_wire/dawn_wire_export.h",
]
}
# The meat of the compilation for libdawn_wire so that we can cheaply have # The meat of the compilation for libdawn_wire so that we can cheaply have
# shared_library / static_library / component versions of it. # shared_library / static_library / component versions of it.
dawn_generator("libdawn_wire_sources") { dawn_generator("libdawn_wire_sources") {
@ -669,13 +691,11 @@ dawn_generator("libdawn_wire_sources") {
configs = [ ":dawn_internal" ] configs = [ ":dawn_internal" ]
deps = [ deps = [
":dawn_common", ":dawn_common",
":dawn_headers", ":libdawn_wire_headers",
] ]
defines = [ "DAWN_WIRE_IMPLEMENTATION" ] defines = [ "DAWN_WIRE_IMPLEMENTATION" ]
sources = [ sources = [
"src/dawn_wire/WireCmd.h", "src/dawn_wire/WireCmd.h",
"src/include/dawn_wire/Wire.h",
"src/include/dawn_wire/dawn_wire_export.h",
] ]
} }
@ -683,6 +703,11 @@ shared_library("libdawn_wire") {
deps = [ deps = [
":libdawn_wire_sources", ":libdawn_wire_sources",
] ]
#Make headers publically visible
public_deps = [
":libdawn_wire_headers",
]
public_configs = [ ":libdawn_public" ] public_configs = [ ":libdawn_public" ]
# Tell dependents where to find this shared library # Tell dependents where to find this shared library
@ -716,6 +741,7 @@ static_library("dawn_utils") {
deps = [ deps = [
":dawn_common", ":dawn_common",
":libdawn_native", ":libdawn_native",
":libdawn_wire",
"third_party:glfw", "third_party:glfw",
"third_party:libshaderc", "third_party:libshaderc",
] ]
@ -775,9 +801,10 @@ test("dawn_unittests") {
} }
deps = [ deps = [
":dawn_common",
":dawn_utils", ":dawn_utils",
":libdawn", ":libdawn",
":libdawn_native_static", ":libdawn_native_sources",
":libdawn_wire", ":libdawn_wire",
":mock_dawn", ":mock_dawn",
"third_party:gmock", "third_party:gmock",
@ -828,6 +855,7 @@ test("dawn_end2end_tests") {
} }
deps = [ deps = [
":dawn_common",
":dawn_utils", ":dawn_utils",
":libdawn", ":libdawn",
":libdawn_native", ":libdawn_native",

View File

@ -1,16 +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.
// This is an empty file used as a workaround for OSX's libtool requiring that a response file
// contains at least one file.

View File

@ -283,7 +283,6 @@ static_library("glfw") {
"${glfw_dir}/include/GLFW/glfw3.h", "${glfw_dir}/include/GLFW/glfw3.h",
"${glfw_dir}/include/GLFW/glfw3native.h", "${glfw_dir}/include/GLFW/glfw3native.h",
"${glfw_dir}/src/context.c", "${glfw_dir}/src/context.c",
"${glfw_dir}/src/glfw_config.h",
"${glfw_dir}/src/init.c", "${glfw_dir}/src/init.c",
"${glfw_dir}/src/input.c", "${glfw_dir}/src/input.c",
"${glfw_dir}/src/internal.h", "${glfw_dir}/src/internal.h",