Added Abseil as a third-party dependency (Take 2)

Another attempt at https://dawn-review.googlesource.com/c/dawn/+/63780
Depends on https://skia-review.googlesource.com/c/skia/+/451638

This version of the CL fixes the Cmake and Skia compatibility issues
from the previous CL.

Bug: dawn:563
Change-Id: I41a7ee0aef1924df08a9be41e94effb7cd0025df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64600
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Brandon Jones 2021-09-23 20:36:03 +00:00 committed by Dawn LUCI CQ
parent 0ecd67a3fa
commit a04663c13d
10 changed files with 209 additions and 4 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
/build
/buildtools
/testing
/third_party/abseil-cpp/
/third_party/angle
/third_party/clang-format
/third_party/glfw

View File

@ -94,6 +94,10 @@ option(DAWN_BUILD_EXAMPLES "Enables building Dawn's exmaples" ${BUILD_EXAMPLE})
set(DAWN_THIRD_PARTY_DIR "${Dawn_SOURCE_DIR}/third_party" CACHE STRING "Directory in which to find third-party dependencies.")
# Recommended setting for compability with future abseil releases.
set(ABSL_PROPAGATE_CXX_STD ON)
set(DAWN_ABSEIL_DIR "${DAWN_THIRD_PARTY_DIR}/abseil-cpp" CACHE STRING "Directory in which to find Abseil")
set(DAWN_GLFW_DIR "${DAWN_THIRD_PARTY_DIR}/glfw" CACHE STRING "Directory in which to find GLFW")
set(DAWN_GLM_DIR "${DAWN_THIRD_PARTY_DIR}/glm" CACHE STRING "Directory in which to find GLM")
set(DAWN_JINJA2_DIR "${DAWN_THIRD_PARTY_DIR}/jinja2" CACHE STRING "Directory in which to find Jinja2")

5
DEPS
View File

@ -135,6 +135,11 @@ deps = {
'url': '{chromium_git}/chromium/src/third_party/zlib@c29ee8c9c3824ca013479bf8115035527967fe02',
'condition': 'dawn_standalone',
},
'third_party/abseil-cpp': {
'url': '{chromium_git}/chromium/src/third_party/abseil-cpp@789af048b388657987c59d4da406859034fe310f',
'condition': 'dawn_standalone',
},
}
hooks = [

View File

@ -27,6 +27,7 @@ dawn_has_build = true
# users of Dawn don't have to set dirs if they happen to use the same as Dawn.
# The paths to Dawn's dependencies
dawn_abseil_dir = "//third_party/abseil-cpp"
dawn_angle_dir = "//third_party/angle"
dawn_jinja2_dir = "//third_party/jinja2"
dawn_glfw_dir = "//third_party/glfw"

View File

@ -76,3 +76,7 @@ if (!defined(dawn_tint_dir)) {
# Default to Tint being Dawn's DEPS
dawn_tint_dir = "${dawn_root}/third_party/tint"
}
if (!defined(dawn_abseil_dir)) {
dawn_abseil_dir = "//third_party/abseil-cpp"
}

View File

@ -53,6 +53,17 @@ if (dawn_enable_vulkan) {
dawn_enable_vulkan_loader && dawn_vulkan_loader_dir != ""
}
group("dawn_abseil") {
# When build_with_chromium=true we need to include "//third_party/abseil-cpp:absl" while
# it's beneficial to be more specific with standalone Dawn, especially when it comes to
# including it as a dependency in other projects (such as Skia).
if (build_with_chromium) {
public_deps = [ "$dawn_abseil_dir:absl" ]
} else {
public_deps = [ "${dawn_root}/third_party/gn/abseil-cpp:str_format" ]
}
}
config("dawn_native_internal") {
configs = [ "${dawn_root}/src/common:dawn_internal" ]
@ -142,6 +153,7 @@ source_set("dawn_native_headers") {
# except those that define exported symbols.
source_set("dawn_native_sources") {
deps = [
":dawn_abseil",
":dawn_native_headers",
":dawn_native_utils_gen",
"${dawn_root}/src/common",

View File

@ -186,6 +186,8 @@ target_link_libraries(dawn_native
dawn_internal_config
libtint
SPIRV-Tools-opt
absl_strings
absl_str_format_internal
)
if (DAWN_REQUIRES_SPIRV_CROSS)
@ -195,6 +197,8 @@ if (DAWN_REQUIRES_SPIRV_CROSS)
endif()
endif()
target_include_directories(dawn_native PRIVATE ${DAWN_ABSEIL_DIR})
if (DAWN_USE_X11)
find_package(X11 REQUIRED)
target_link_libraries(dawn_native PRIVATE ${X11_LIBRARIES})

View File

@ -14,6 +14,7 @@
#include "dawn_native/ShaderModule.h"
#include "absl/strings/str_format.h"
#include "common/Constants.h"
#include "common/HashUtils.h"
#include "dawn_native/BindGroupLayout.h"
@ -35,10 +36,8 @@ namespace dawn_native {
namespace {
std::string GetShaderDeclarationString(BindGroupIndex group, BindingNumber binding) {
std::ostringstream ostream;
ostream << "the shader module declaration at set " << static_cast<uint32_t>(group)
<< " binding " << static_cast<uint32_t>(binding);
return ostream.str();
return absl::StrFormat("the shader module declaration at set %u, binding %u",
static_cast<uint32_t>(group), static_cast<uint32_t>(binding));
}
tint::transform::VertexFormat ToTintVertexFormat(wgpu::VertexFormat format) {

View File

@ -59,6 +59,11 @@ if (NOT TARGET libtint)
add_subdirectory(${DAWN_TINT_DIR})
endif()
if (NOT TARGET libabsl)
message(STATUS "Dawn: using Abseil at ${DAWN_ABSEIL_DIR}")
add_subdirectory(${DAWN_ABSEIL_DIR})
endif()
# Header-only library for khrplatform.h
add_library(dawn_khronos_platform INTERFACE)
target_sources(dawn_khronos_platform INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/khronos/KHR/khrplatform.h")

170
third_party/gn/abseil-cpp/BUILD.gn vendored Normal file
View File

@ -0,0 +1,170 @@
# Copyright 2021 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("../../../scripts/dawn_overrides_with_defaults.gni")
import("${dawn_root}/scripts/dawn_features.gni")
config("absl_config") {
if (dawn_standalone && is_clang) {
cflags = [
# Allow the use of enable_if()
"-Wno-gcc-compat",
]
}
include_dirs = [ "${dawn_abseil_dir}" ]
}
template("absl_source_set") {
source_set(target_name) {
forward_variables_from(invoker, "*")
if (!defined(public_configs)) {
public_configs = []
}
public_configs += [ ":absl_config" ]
}
}
#
# absl/base
#
absl_source_set("log_severity") {
sources = [ "${dawn_abseil_dir}/absl/base/log_severity.cc" ]
public = [ "${dawn_abseil_dir}/absl/base/log_severity.h" ]
}
absl_source_set("raw_logging_internal") {
sources = [ "${dawn_abseil_dir}/absl/base/internal/raw_logging.cc" ]
public = [ "${dawn_abseil_dir}/absl/base/internal/raw_logging.h" ]
public_deps = [ ":log_severity" ]
visibility = [ ":*" ]
}
absl_source_set("throw_delegate") {
sources = [ "${dawn_abseil_dir}/absl/base/internal/throw_delegate.cc" ]
public = [ "${dawn_abseil_dir}/absl/base/internal/throw_delegate.h" ]
public_deps = [ ":raw_logging_internal" ]
visibility = [ ":*" ]
}
#
# absl/numeric
#
absl_source_set("int128") {
sources = [
"${dawn_abseil_dir}/absl/numeric/int128.cc",
"${dawn_abseil_dir}/absl/numeric/int128_have_intrinsic.inc",
"${dawn_abseil_dir}/absl/numeric/int128_no_intrinsic.inc",
]
public = [ "${dawn_abseil_dir}/absl/numeric/int128.h" ]
}
#
# absl/strings
#
absl_source_set("strings") {
sources = [
"${dawn_abseil_dir}/absl/strings/ascii.cc",
"${dawn_abseil_dir}/absl/strings/charconv.cc",
"${dawn_abseil_dir}/absl/strings/escaping.cc",
"${dawn_abseil_dir}/absl/strings/internal/charconv_bigint.cc",
"${dawn_abseil_dir}/absl/strings/internal/charconv_bigint.h",
"${dawn_abseil_dir}/absl/strings/internal/charconv_parse.cc",
"${dawn_abseil_dir}/absl/strings/internal/charconv_parse.h",
"${dawn_abseil_dir}/absl/strings/internal/memutil.cc",
"${dawn_abseil_dir}/absl/strings/internal/memutil.h",
"${dawn_abseil_dir}/absl/strings/internal/stl_type_traits.h",
"${dawn_abseil_dir}/absl/strings/internal/str_join_internal.h",
"${dawn_abseil_dir}/absl/strings/internal/str_split_internal.h",
"${dawn_abseil_dir}/absl/strings/match.cc",
"${dawn_abseil_dir}/absl/strings/numbers.cc",
"${dawn_abseil_dir}/absl/strings/str_cat.cc",
"${dawn_abseil_dir}/absl/strings/str_replace.cc",
"${dawn_abseil_dir}/absl/strings/str_split.cc",
"${dawn_abseil_dir}/absl/strings/string_view.cc",
"${dawn_abseil_dir}/absl/strings/substitute.cc",
]
public = [
"${dawn_abseil_dir}/absl/strings/ascii.h",
"${dawn_abseil_dir}/absl/strings/charconv.h",
"${dawn_abseil_dir}/absl/strings/escaping.h",
"${dawn_abseil_dir}/absl/strings/internal/string_constant.h",
"${dawn_abseil_dir}/absl/strings/match.h",
"${dawn_abseil_dir}/absl/strings/numbers.h",
"${dawn_abseil_dir}/absl/strings/str_cat.h",
"${dawn_abseil_dir}/absl/strings/str_join.h",
"${dawn_abseil_dir}/absl/strings/str_replace.h",
"${dawn_abseil_dir}/absl/strings/str_split.h",
"${dawn_abseil_dir}/absl/strings/string_view.h",
"${dawn_abseil_dir}/absl/strings/strip.h",
"${dawn_abseil_dir}/absl/strings/substitute.h",
]
deps = [
":int128",
":raw_logging_internal",
":strings_internal",
":throw_delegate",
]
}
absl_source_set("strings_internal") {
sources = [
"${dawn_abseil_dir}/absl/strings/internal/escaping.cc",
"${dawn_abseil_dir}/absl/strings/internal/ostringstream.cc",
"${dawn_abseil_dir}/absl/strings/internal/utf8.cc",
]
public = [
"${dawn_abseil_dir}/absl/strings/internal/char_map.h",
"${dawn_abseil_dir}/absl/strings/internal/escaping.h",
"${dawn_abseil_dir}/absl/strings/internal/ostringstream.h",
"${dawn_abseil_dir}/absl/strings/internal/resize_uninitialized.h",
"${dawn_abseil_dir}/absl/strings/internal/utf8.h",
]
deps = [ ":raw_logging_internal" ]
}
absl_source_set("str_format") {
public = [ "${dawn_abseil_dir}/absl/strings/str_format.h" ]
deps = [ ":str_format_internal" ]
}
absl_source_set("str_format_internal") {
sources = [
"${dawn_abseil_dir}/absl/strings/internal/str_format/arg.cc",
"${dawn_abseil_dir}/absl/strings/internal/str_format/bind.cc",
"${dawn_abseil_dir}/absl/strings/internal/str_format/extension.cc",
"${dawn_abseil_dir}/absl/strings/internal/str_format/float_conversion.cc",
"${dawn_abseil_dir}/absl/strings/internal/str_format/output.cc",
"${dawn_abseil_dir}/absl/strings/internal/str_format/parser.cc",
]
public = [
"${dawn_abseil_dir}/absl/strings/internal/str_format/arg.h",
"${dawn_abseil_dir}/absl/strings/internal/str_format/bind.h",
"${dawn_abseil_dir}/absl/strings/internal/str_format/checker.h",
"${dawn_abseil_dir}/absl/strings/internal/str_format/extension.h",
"${dawn_abseil_dir}/absl/strings/internal/str_format/float_conversion.h",
"${dawn_abseil_dir}/absl/strings/internal/str_format/output.h",
"${dawn_abseil_dir}/absl/strings/internal/str_format/parser.h",
]
visibility = [ ":*" ]
deps = [
":int128",
":strings",
]
}