BUILD.gn: Only expose the GLFW target on platforms that support it

Due to the way GN target discovery works, glfw would get discovered in
Fuchsia / Android / ChromeOS builds when it isn't supported causing
compilation failures. This changes third_party/BUILD.gn so that glfw
targets are only created on supported platforms. It also changes
dawn_glfw in BUILD.gn to be more robust to building on all platforms.

Bug=dawn:221
BUG=chromium:1002895

Change-Id: I8f40b06f680094406d24e9a6dea44b128e59b854
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11160
Reviewed-by: David Turner <digit@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2019-09-11 16:53:46 +00:00 committed by Commit Bot service account
parent 2a2392073b
commit fad96f6e59
2 changed files with 111 additions and 107 deletions

View File

@ -580,10 +580,17 @@ dawn_component("libdawn_wire") {
# GLFW wrapping target
###############################################################################
# GLFW does not support Android or Fuchsia, so provide a small mock library
# that can be linked into the Dawn tests on these platforms. Otherwise, use
# the real library from third_party/.
if (is_fuchsia) {
# GLFW does not support ChromeOS, Android or Fuchsia, so provide a small mock
# library that can be linked into the Dawn tests on these platforms. Otherwise,
# use the real library from third_party/.
if (is_win || is_linux || is_mac) {
group("dawn_glfw") {
public_deps = [
"third_party:glfw",
]
}
} else if (is_fuchsia) {
# The mock implementation of GLFW on Fuchsia
config("dawn_glfw_public_config") {
# Allow inclusion of <GLFW/glfw3.h>
configs = [ "third_party:glfw_public" ]
@ -610,10 +617,8 @@ if (is_fuchsia) {
]
}
} else {
# Just skip GLFW on other systems
group("dawn_glfw") {
public_deps = [
"third_party:glfw",
]
}
}
@ -815,7 +820,6 @@ source_set("dawn_end2end_tests_sources") {
testonly = true
deps = [
":dawn_glfw",
":dawn_utils",
":libdawn_native",
":libdawn_wire",

10
third_party/BUILD.gn vendored
View File

@ -231,6 +231,10 @@ if (!build_with_chromium) {
# GLFW - good enough build targets
###############################################################################
# Only expose GLFW targets on platforms where GLFW is supported: otherwise they
# might get discovered by GN when another target in this file is referenced,
# and GLFW will bbe built as part of "all" builds, causing compilation failures.
if (is_win || is_linux || is_mac) {
glfw_dir = dawn_glfw_dir
config("glfw_public") {
@ -265,10 +269,6 @@ static_library("glfw") {
]
}
# NOTE: For some unknown reason, this library gets build when is_fuchsia
# is true, even if absolutely nothing references it, as checked with
# `gn refs out/Fuchsia third_party/dawn/third_party:glfw --all`
if (!is_fuchsia) {
sources = [
"${glfw_dir}/include/GLFW/glfw3.h",
"${glfw_dir}/include/GLFW/glfw3native.h",
@ -284,7 +284,6 @@ static_library("glfw") {
"${glfw_dir}/src/vulkan.c",
"${glfw_dir}/src/window.c",
]
}
libs = []
if (is_win) {
@ -359,6 +358,7 @@ static_library("glfw") {
]
}
}
}
###############################################################################
# Header-only dependencies for samples