Merge remote-tracking branch 'tint/main' into HEAD

Integrates Tint repo into Dawn

KIs:
- Building docs for Tint is turned off, because it fails due to lack
  of annotations in Dawn source files.
- Dawn CQ needs to be updated to run Tint specific tests
- Significant post-merge cleanup needed

R=bclayton,cwallez
BUG=dawn:1339

Change-Id: I6c9714a0030934edd6c51f3cac4684dcd59d1ea3
fixes
Ryan Harrison 2 years ago
commit e87ac76f7d
  1. 1
      .clang-format
  2. 21
      .gitignore
  3. 5
      AUTHORS
  4. 6
      AUTHORS.dawn
  5. 8
      AUTHORS.tint
  6. 8
      BUILD.gn
  7. 404
      CMakeLists.txt
  8. 100
      CMakeSettings.json
  9. 93
      CODE_OF_CONDUCT.md
  10. 45
      CONTRIBUTING.md
  11. 1
      CPPLINT.cfg
  12. 81
      DEPS
  13. 2474
      Doxyfile
  14. 9
      OWNERS
  15. 11
      OWNERS.dawn
  16. 7
      OWNERS.tint
  17. 117
      PRESUBMIT.py
  18. 38
      PRESUBMIT.py.dawn
  19. 167
      PRESUBMIT.py.tint
  20. 107
      README.md
  21. 52
      README.md.dawn
  22. 106
      README.md.tint
  23. 2
      build_overrides/build.gni
  24. 1
      build_overrides/dawn.gni
  25. 1
      build_overrides/tint.gni
  26. 195
      docs/tint/arch.md
  27. 119
      docs/tint/compound_statements.md
  28. 24
      docs/tint/coverage-info.md
  29. 126
      docs/tint/diagnostics_guide.md
  30. 35
      docs/tint/end-to-end-tests.md
  31. 44
      docs/tint/experimental_extensions.md
  32. 133
      docs/tint/origin-trial-changes.md
  33. 267
      docs/tint/spirv-input-output-variables.md
  34. 115
      docs/tint/spirv-ptr-ref.md
  35. 47
      docs/tint/style_guide.md
  36. 187
      docs/tint/translations.md
  37. 68
      include/tint/tint.h
  38. 48
      kokoro/linux/build.sh
  39. 26
      kokoro/linux/cmake-clang-debug-asan/build.sh
  40. 3
      kokoro/linux/cmake-clang-debug-asan/presubmit.cfg
  41. 26
      kokoro/linux/cmake-clang-debug-ubsan/build.sh
  42. 3
      kokoro/linux/cmake-clang-debug-ubsan/presubmit.cfg
  43. 25
      kokoro/linux/cmake-clang-debug/build.sh
  44. 3
      kokoro/linux/cmake-clang-debug/presubmit.cfg
  45. 26
      kokoro/linux/cmake-clang-release-asan/build.sh
  46. 3
      kokoro/linux/cmake-clang-release-asan/presubmit.cfg
  47. 26
      kokoro/linux/cmake-clang-release-ubsan/build.sh
  48. 3
      kokoro/linux/cmake-clang-release-ubsan/presubmit.cfg
  49. 25
      kokoro/linux/cmake-clang-release/build.sh
  50. 3
      kokoro/linux/cmake-clang-release/presubmit.cfg
  51. 25
      kokoro/linux/cmake-gcc-debug/build.sh
  52. 3
      kokoro/linux/cmake-gcc-debug/presubmit.cfg
  53. 25
      kokoro/linux/cmake-gcc-release/build.sh
  54. 3
      kokoro/linux/cmake-gcc-release/presubmit.cfg
  55. 183
      kokoro/linux/docker.sh
  56. 167
      kokoro/windows/build.bat
  57. 18
      kokoro/windows/cmake-msvc2019-debug/build.bat
  58. 3
      kokoro/windows/cmake-msvc2019-debug/presubmit.cfg
  59. 18
      kokoro/windows/cmake-msvc2019-release/build.bat
  60. 3
      kokoro/windows/cmake-msvc2019-release/presubmit.cfg
  61. 5
      scripts/dawn_overrides_with_defaults.gni
  62. 2
      src/dawn/native/BUILD.gn
  63. 799
      src/tint/BUILD.gn
  64. 1239
      src/tint/CMakeLists.txt
  65. 43
      src/tint/ast/access.cc
  66. 46
      src/tint/ast/access.h
  67. 45
      src/tint/ast/alias.cc
  68. 54
      src/tint/ast/alias.h
  69. 45
      src/tint/ast/alias_test.cc
  70. 78
      src/tint/ast/array.cc
  71. 75
      src/tint/ast/array.h
  72. 71
      src/tint/ast/array_test.cc
  73. 48
      src/tint/ast/assignment_statement.cc
  74. 57
      src/tint/ast/assignment_statement.h
  75. 94
      src/tint/ast/assignment_statement_test.cc
  76. 41
      src/tint/ast/ast_type.cc
  77. 45
      src/tint/ast/atomic.cc
  78. 54
      src/tint/ast/atomic.h
  79. 40
      src/tint/ast/atomic_test.cc
  80. 25
      src/tint/ast/attribute.cc
  81. 71
      src/tint/ast/attribute.h
  82. 50
      src/tint/ast/binary_expression.cc
  83. 264
      src/tint/ast/binary_expression.h
  84. 95
      src/tint/ast/binary_expression_test.cc
  85. 44
      src/tint/ast/binding_attribute.cc
  86. 51
      src/tint/ast/binding_attribute.h
  87. 30
      src/tint/ast/binding_attribute_test.cc
  88. 46
      src/tint/ast/bitcast_expression.cc
  89. 57
      src/tint/ast/bitcast_expression.h
  90. 81
      src/tint/ast/bitcast_expression_test.cc
  91. 46
      src/tint/ast/block_statement.cc
  92. 60
      src/tint/ast/block_statement.h
  93. 71
      src/tint/ast/block_statement_test.cc
  94. 40
      src/tint/ast/bool.cc
  95. 56
      src/tint/ast/bool.h
  96. 39
      src/tint/ast/bool_literal_expression.cc
  97. 49
      src/tint/ast/bool_literal_expression.h
  98. 37
      src/tint/ast/bool_literal_expression_test.cc
  99. 32
      src/tint/ast/bool_test.cc
  100. 38
      src/tint/ast/break_statement.cc
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,3 +1,4 @@
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium
Standard: Cpp11

21
.gitignore vendored

@ -9,12 +9,15 @@
/testing
/third_party/abseil-cpp/
/third_party/angle
/third_party/benchmark
/third_party/binutils
/third_party/catapult
/third_party/clang-format
/third_party/cpplint
/third_party/glfw
/third_party/googletest
/third_party/gpuweb
/third_party/webgpu-cts
/third_party/gpuweb-cts
/third_party/jinja2
/third_party/jsoncpp
/third_party/llvm-build
@ -22,10 +25,11 @@
/third_party/node
/third_party/node-addon-api
/third_party/node-api-headers
/third_party/protobuf
/third_party/swiftshader
/third_party/tint
/third_party/vulkan-deps
/third_party/vulkan_memory_allocator
/third_party/webgpu-cts
/third_party/zlib
/tools/clang
/tools/cmake
@ -33,7 +37,7 @@
/tools/memory
/out
# Modified from https://www.gitignore.io/api/vim,macos,linux,emacs,windows,sublimetext,visualstudio,visualstudiocode
# Modified from https://www.gitignore.io/api/vim,macos,linux,emacs,windows,sublimetext,visualstudio,visualstudiocode,intellij
### Emacs ###
*~
@ -101,8 +105,19 @@ ehthumbs_vista.db
Desktop.ini
$RECYCLE.BIN/
### Intellij ###
.idea
### Dawn node tools binaries
src/dawn/node/tools/bin/
### Cached node transpiled tools
/.node_transpile_work_dir
# Misc inherited from Tint
/test.wgsl
coverage.summary
default.profraw
lcov.info
/cmake-build-*/
/testing

@ -1,6 +1,7 @@
# This is the list of Dawn authors for copyright purposes.
# This is the list of Dawn & Tint authors for copyright purposes.
#
# This does not necessarily list everyone who has contributed code, since in
# some cases, their employer may be the copyright holder. To see the full list
# of contributors, see the revision history in source control.
Google Inc.
Google LLC
Vasyl Teliman

@ -0,0 +1,6 @@
# This is the list of Dawn authors for copyright purposes.
#
# This does not necessarily list everyone who has contributed code, since in
# some cases, their employer may be the copyright holder. To see the full list
# of contributors, see the revision history in source control.
Google Inc.

@ -0,0 +1,8 @@
# This is the list of the Tint authors for copyright purposes.
#
# This does not necessarily list everyone who has contributed code, since in
# some cases, their employer may be the copyright holder. To see the full list
# of contributors, see the revision history in source control.
Google LLC
Vasyl Teliman

@ -21,9 +21,15 @@ group("all") {
"src/dawn/native:webgpu_dawn",
"src/dawn/tests",
"src/fuzzers/dawn:dawn_fuzzers",
"src/tint/fuzzers",
"src/tint:libtint",
"test/tint:tint_unittests",
]
if (dawn_standalone) {
deps += [ "samples/dawn:samples" ]
deps += [
"samples/dawn:samples",
"src/tint/cmd:tint",
]
}
}

@ -1,4 +1,4 @@
# Copyright 2020 The Dawn Authors
# Copyright 2022 The Dawn & Tint Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.10.2)
# When upgrading to CMake 3.11 we can remove DAWN_DUMMY_FILE because source-less add_library
# becomes available.
@ -26,13 +26,18 @@ project(
DESCRIPTION "Dawn, a WebGPU implementation"
LANGUAGES C CXX
)
enable_testing()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(NOT CMAKE_BUILD_TYPE)
message(WARNING "CMAKE_BUILD_TYPE not set, forcing it to Debug")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Build type (Debug, Release, RelWithDebInfo, MinSizeRel)" FORCE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_DEBUG_POSTFIX "")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
message(STATUS "No build type selected, default to Debug")
set(CMAKE_BUILD_TYPE "Debug")
endif()
set(DAWN_BUILD_GEN_DIR "${Dawn_BINARY_DIR}/gen")
@ -99,7 +104,7 @@ elseif(UNIX)
endif()
# GLFW is not supported in UWP
if((WIN32 AND NOT WINDOWS_STORE) OR UNIX AND NOT ANDROID)
if ((WIN32 AND NOT WINDOWS_STORE) OR UNIX AND NOT ANDROID)
set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING ON)
endif()
@ -132,7 +137,7 @@ set_if_not_defined(DAWN_GLFW_DIR "${DAWN_THIRD_PARTY_DIR}/glfw" "Directory in wh
set_if_not_defined(DAWN_JINJA2_DIR "${DAWN_THIRD_PARTY_DIR}/jinja2" "Directory in which to find Jinja2")
set_if_not_defined(DAWN_SPIRV_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-headers/src" "Directory in which to find SPIRV-Headers")
set_if_not_defined(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/src" "Directory in which to find SPIRV-Tools")
set_if_not_defined(DAWN_TINT_DIR "${DAWN_THIRD_PARTY_DIR}/tint" "Directory in which to find Tint")
set_if_not_defined(DAWN_TINT_DIR "${Dawn_SOURCE_DIR}" "Directory in which to find Tint")
set_if_not_defined(DAWN_VULKAN_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/vulkan-headers/src" "Directory in which to find Vulkan-Headers")
# Dependencies for DAWN_BUILD_NODE_BINDINGS
@ -203,11 +208,355 @@ endif()
set(CMAKE_CXX_STANDARD "17")
################################################################################
# Tint
################################################################################
# TINT_IS_SUBPROJECT is 1 if added via add_subdirectory() from another project.
get_directory_property(TINT_IS_SUBPROJECT PARENT_DIRECTORY)
if(TINT_IS_SUBPROJECT)
set(TINT_IS_SUBPROJECT 1)
# If tint is used as a subproject, default to disabling the building of
# documentation and tests. These are unlikely to be desirable, but can be
# enabled.
set(TINT_BUILD_DOCS_DEFAULT OFF)
set(TINT_BUILD_TESTS_DEFAULT OFF)
else()
set(TINT_BUILD_DOCS_DEFAULT ON)
set(TINT_BUILD_TESTS_DEFAULT ON)
endif()
# Forcing building docs off right now, since currently this will try to build docs for both Tint & Dawn, and Dawn isn't annotated yet.
set(TINT_BUILD_DOCS_DEFAULT OFF)
option_if_not_defined(TINT_BUILD_SAMPLES "Build samples" ON)
option_if_not_defined(TINT_BUILD_DOCS "Build documentation" ${TINT_BUILD_DOCS_DEFAULT})
option_if_not_defined(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF)
option_if_not_defined(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ON)
option_if_not_defined(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
option_if_not_defined(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ON)
option_if_not_defined(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ON)
option_if_not_defined(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ON)
option_if_not_defined(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ON)
option_if_not_defined(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
option_if_not_defined(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
option_if_not_defined(TINT_BUILD_SPIRV_TOOLS_FUZZER "Build SPIRV-Tools fuzzer" OFF)
option_if_not_defined(TINT_BUILD_AST_FUZZER "Build AST fuzzer" OFF)
option_if_not_defined(TINT_BUILD_REGEX_FUZZER "Build regex fuzzer" OFF)
option_if_not_defined(TINT_BUILD_BENCHMARKS "Build benchmarks" OFF)
option_if_not_defined(TINT_BUILD_TESTS "Build tests" ${TINT_BUILD_TESTS_DEFAULT})
option_if_not_defined(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF)
option_if_not_defined(TINT_BUILD_REMOTE_COMPILE "Build the remote-compile tool for validating shaders on a remote machine" OFF)
set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used")
option_if_not_defined(TINT_ENABLE_MSAN "Enable memory sanitizer" OFF)
option_if_not_defined(TINT_ENABLE_ASAN "Enable address sanitizer" OFF)
option_if_not_defined(TINT_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF)
option_if_not_defined(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF)
option_if_not_defined(TINT_EMIT_COVERAGE "Emit code coverage information" OFF)
option_if_not_defined(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF)
option_if_not_defined(TINT_SYMBOL_STORE_DEBUG_NAME "Enable storing of name in tint::ast::Symbol to help debugging the AST" OFF)
message(STATUS "Tint build samples: ${TINT_BUILD_SAMPLES}")
message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}")
message(STATUS "Tint build docs with warn as error: ${TINT_DOCS_WARN_AS_ERROR}")
message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}")
message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}")
message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}")
message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}")
message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
message(STATUS "Tint build SPIRV-Tools fuzzer: ${TINT_BUILD_SPIRV_TOOLS_FUZZER}")
message(STATUS "Tint build AST fuzzer: ${TINT_BUILD_AST_FUZZER}")
message(STATUS "Tint build regex fuzzer: ${TINT_BUILD_REGEX_FUZZER}")
message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}")
message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}")
message(STATUS "Tint build with ASAN: ${TINT_ENABLE_ASAN}")
message(STATUS "Tint build with MSAN: ${TINT_ENABLE_MSAN}")
message(STATUS "Tint build with UBSAN: ${TINT_ENABLE_UBSAN}")
message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}")
message(STATUS "Tint build remote-compile tool: ${TINT_BUILD_REMOTE_COMPILE}")
if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "")
message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}")
endif()
message(STATUS "Using python3")
find_package(PythonInterp 3 REQUIRED)
if (${TINT_BUILD_SPIRV_TOOLS_FUZZER})
message(STATUS "TINT_BUILD_SPIRV_TOOLS_FUZZER is ON - setting
TINT_BUILD_FUZZERS
TINT_BUILD_SPV_READER
TINT_BUILD_SPV_WRITER
TINT_BUILD_WGSL_READER
TINT_BUILD_WGSL_WRITER
TINT_BUILD_GLSL_WRITER
TINT_BUILD_HLSL_WRITER
TINT_BUILD_MSL_WRITER to ON")
set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE)
set(TINT_BUILD_SPV_READER ON CACHE BOOL "Build SPIR-V reader" FORCE)
set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE)
set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE)
set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE)
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
endif()
if (${TINT_BUILD_AST_FUZZER})
message(STATUS "TINT_BUILD_AST_FUZZER is ON - setting
TINT_BUILD_FUZZERS
TINT_BUILD_WGSL_READER
TINT_BUILD_WGSL_WRITER
TINT_BUILD_SPV_WRITER
TINT_BUILD_MSL_WRITER
TINT_BUILD_GLSL_WRITER
TINT_BUILD_HLSL_WRITER to ON")
set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE)
set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE)
set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE)
set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE)
set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build GLSL writer" FORCE)
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
endif()
if (${TINT_BUILD_REGEX_FUZZER})
message(STATUS "TINT_BUILD_REGEX_FUZZER is ON - setting
TINT_BUILD_FUZZERS
TINT_BUILD_WGSL_READER
TINT_BUILD_WGSL_WRITER
TINT_BUILD_SPV_WRITER
TINT_BUILD_MSL_WRITER
TINT_BUILD_GLSL_WRITER
TINT_BUILD_HLSL_WRITER to ON")
set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE)
set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE)
set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE)
set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE)
set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build GLSL writer" FORCE)
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
endif()
set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR})
# CMake < 3.15 sets /W3 in CMAKE_CXX_FLAGS. Remove it if it's there.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/18317
if (MSVC)
if (CMAKE_CXX_FLAGS MATCHES "/W3")
string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
endif()
if (${TINT_CHECK_CHROMIUM_STYLE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -add-plugin -Xclang find-bad-constructs")
endif()
if (${TINT_BUILD_SPV_READER})
include_directories("${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/include")
endif()
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
set(COMPILER_IS_CLANG_CL TRUE)
endif()
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") OR
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND
(NOT COMPILER_IS_CLANG_CL)))
set(COMPILER_IS_LIKE_GNU TRUE)
endif()
# Enable msbuild multiprocessor builds
if (MSVC AND NOT COMPILER_IS_CLANG_CL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
set(TINT_OS_CC_SUFFIX "other")
if (NOT TINT_BUILD_AS_OTHER_OS)
if(UNIX OR APPLE)
set(TINT_OS_CC_SUFFIX "posix")
set(TINT_OS_CC_SUFFIX "posix")
elseif(WIN32)
set(TINT_OS_CC_SUFFIX "windows")
set(TINT_OS_CC_SUFFIX "windows")
endif()
endif()
if(${TINT_BUILD_DOCS})
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_WARN_AS_ERROR NO)
if(TINT_DOCS_WARN_AS_ERROR)
set(DOXYGEN_WARN_AS_ERROR YES)
endif()
set(DOXYGEN_WARN_FORMAT "$file:$line: $text")
if (MSVC)
set(DOXYGEN_WARN_FORMAT "$file($line): $text")
endif()
add_custom_target(tint-docs ALL
COMMAND ${CMAKE_COMMAND}
-E env
"DOXYGEN_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/docs"
"DOXYGEN_WARN_AS_ERROR=${DOXYGEN_WARN_AS_ERROR}"
"DOXYGEN_WARN_FORMAT=${DOXYGEN_WARN_FORMAT}"
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation"
VERBATIM)
else()
message("Doxygen not found. Skipping documentation")
endif(DOXYGEN_FOUND)
endif()
function(tint_core_compile_options TARGET)
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}")
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}/include")
if (${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
target_include_directories(${TARGET} PUBLIC
"${DAWN_THIRD_PARTY_DIR}/spirv-headers/include")
endif()
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_SPV_READER=$<BOOL:${TINT_BUILD_SPV_READER}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_READER=$<BOOL:${TINT_BUILD_WGSL_READER}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_GLSL_WRITER=$<BOOL:${TINT_BUILD_GLSL_WRITER}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_HLSL_WRITER=$<BOOL:${TINT_BUILD_HLSL_WRITER}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_MSL_WRITER=$<BOOL:${TINT_BUILD_MSL_WRITER}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_SPV_WRITER=$<BOOL:${TINT_BUILD_SPV_WRITER}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_WRITER=$<BOOL:${TINT_BUILD_WGSL_WRITER}>)
if (COMPILER_IS_LIKE_GNU)
target_compile_options(${TARGET} PRIVATE
-std=c++17
-fno-exceptions
-fno-rtti
)
if (${TINT_ENABLE_MSAN})
target_compile_options(${TARGET} PRIVATE -fsanitize=memory)
target_link_options(${TARGET} PRIVATE -fsanitize=memory)
elseif (${TINT_ENABLE_ASAN})
target_compile_options(${TARGET} PRIVATE -fsanitize=address)
target_link_options(${TARGET} PRIVATE -fsanitize=address)
elseif (${TINT_ENABLE_UBSAN})
target_compile_options(${TARGET} PRIVATE -fsanitize=undefined)
target_link_options(${TARGET} PRIVATE -fsanitize=undefined)
endif()
endif(COMPILER_IS_LIKE_GNU)
if (TINT_EMIT_COVERAGE)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(${TARGET} PRIVATE "--coverage")
target_link_options(${TARGET} PRIVATE "gcov")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${TARGET} PRIVATE "-fprofile-instr-generate" "-fcoverage-mapping")
target_link_options(${TARGET} PRIVATE "-fprofile-instr-generate" "-fcoverage-mapping")
else()
message(FATAL_ERROR "Coverage generation not supported for the ${CMAKE_CXX_COMPILER_ID} toolchain")
endif()
endif(TINT_EMIT_COVERAGE)
endfunction()
function(tint_default_compile_options TARGET)
tint_core_compile_options(${TARGET})
set(COMMON_GNU_OPTIONS
-Wall
-Werror
-Wextra
-Wno-documentation-unknown-command
-Wno-padded
-Wno-switch-enum
-Wno-unknown-pragmas
)
set(COMMON_CLANG_OPTIONS
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-format-pedantic
-Wno-return-std-move-in-c++11
-Wno-unknown-warning-option
-Wno-undefined-var-template
-Wno-used-but-marked-unused
-Weverything
)
if (COMPILER_IS_LIKE_GNU)
target_compile_options(${TARGET} PRIVATE
-pedantic-errors
${COMMON_GNU_OPTIONS}
)
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"))
target_compile_options(${TARGET} PRIVATE
${COMMON_CLANG_OPTIONS}
)
endif()
endif(COMPILER_IS_LIKE_GNU)
if (MSVC)
# Specify /EHs for exception handling.
target_compile_options(${TARGET} PRIVATE
/bigobj
/EHsc
/W4
/WX
/wd4068
/wd4127
/wd4244
/wd4267
/wd4324
/wd4458
/wd4514
/wd4571
/wd4625
/wd4626
/wd4710
/wd4774
/wd4820
/wd5026
/wd5027
)
# When building with clang-cl on Windows, try to match our clang build
# options as much as possible.
if (COMPILER_IS_CLANG_CL)
target_compile_options(${TARGET} PRIVATE
${COMMON_GNU_OPTIONS}
${COMMON_CLANG_OPTIONS}
# Disable warnings that are usually disabled in downstream deps for
# gcc/clang, but aren't for clang-cl.
-Wno-global-constructors
-Wno-zero-as-null-pointer-constant
-Wno-shorten-64-to-32
-Wno-shadow-field-in-constructor
-Wno-reserved-id-macro
-Wno-language-extension-token
)
endif()
endif()
endfunction()
################################################################################
# Run on all subdirectories
################################################################################
add_subdirectory(third_party)
add_subdirectory(src/tint)
add_subdirectory(generator)
add_subdirectory(src/dawn)
@ -220,3 +569,42 @@ if (DAWN_BUILD_SAMPLES)
#add_subdirectory(src/utils)
add_subdirectory(samples/dawn)
endif()
if (TINT_BUILD_SAMPLES)
add_subdirectory(src/tint/cmd)
endif()
if (TINT_BUILD_FUZZERS)
add_subdirectory(src/tint/fuzzers)
endif()
add_custom_target(tint-lint
COMMAND ./tools/lint
WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
COMMENT "Running linter"
VERBATIM)
add_custom_target(tint-format
COMMAND ./tools/format
WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
COMMENT "Running formatter"
VERBATIM)
if (TINT_EMIT_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Generates a lcov.info file at the project root.
# This can be used by tools such as VSCode's Coverage Gutters extension to
# visualize code coverage in the editor.
get_filename_component(CLANG_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY)
set(PATH_WITH_CLANG "${CLANG_BIN_DIR}:$ENV{PATH}")
add_custom_target(tint-generate-coverage
COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH_WITH_CLANG} ./tools/tint-generate-coverage $<TARGET_FILE:tint_unittests>
DEPENDS tint_unittests
WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
COMMENT "Generating tint coverage data"
VERBATIM)
endif()
if (TINT_BUILD_REMOTE_COMPILE)
add_subdirectory(tools/src/cmd/remote-compile)
endif()

@ -0,0 +1,100 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": []
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
},
{
"name": "x86-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": []
},
{
"name": "x86-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": []
},
{
"name": "x64-Clang-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"variables": []
},
{
"name": "x64-Clang-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"variables": []
},
{
"name": "x86-Clang-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x86" ],
"variables": []
},
{
"name": "x86-Clang-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x86" ],
"variables": []
}
]
}

@ -0,0 +1,93 @@
# Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of
experience, education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
This Code of Conduct also applies outside the project spaces when the Project
Steward has a reasonable belief that an individual's behavior may have a
negative impact on the project or its community.
## Conflict Resolution
We do not believe that all conflict is bad; healthy debate and disagreement
often yield positive results. However, it is never okay to be disrespectful or
to engage in behavior that violates the project’s code of conduct.
If you see someone violating the code of conduct, you are encouraged to address
the behavior directly with those involved. Many issues can be resolved quickly
and easily, and this gives people more control over the outcome of their
dispute. If you are unable to resolve the matter for any reason, or if the
behavior is threatening or harassing, report it. We are dedicated to providing
an environment where participants feel welcome and safe.
Reports should be directed to David Neto <dneto@google.com>, the
Project Steward(s) for Tint. It is the Project Steward’s duty to
receive and address reported violations of the code of conduct. They will then
work with a committee consisting of representatives from the Open Source
Programs Office and the Google Open Source Strategy team. If for any reason you
are uncomfortable reaching out the Project Steward, please email
opensource@google.com.
We will investigate every complaint, but you may not receive a direct response.
We will use our discretion in determining when and how to follow up on reported
incidents, which may range from not taking action to permanent expulsion from
the project and project-sponsored spaces. We will notify the accused of the
report and provide them an opportunity to discuss it before any action is taken.
The identity of the reporter will be omitted from the details of the report
supplied to the accused. In potentially harmful situations, such as ongoing
harassment or threats to anyone's safety, we may take action without notice.
## Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

@ -0,0 +1,45 @@
# How to Contribute
We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.
## Contributor License Agreement
Contributions to this project must be accompanied by a Contributor License
Agreement. You (or your employer) retain the copyright to your contribution;
this simply gives us permission to use and redistribute your contributions as
part of the project. Head over to <https://cla.developers.google.com/> to see
your current agreements on file or to sign a new one.
You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.
## Code reviews
All submissions, including submissions by project members, require review. We
use [Dawn's Gerrit](https://dawn-review.googlesource.com/) for this purpose.
Submissions should follow the [Tint style guide](docs/tint/style_guide.md).
## Pushing to Gerrit
Each change requires a `Change-Id` field in the commit message, which is generated by the [Gerrit commit-msg hook](](https://gerrit-review.googlesource.com/Documentation/cmd-hook-commit-msg.html)). \
In a bash terminal, with the current path set to your tint source tree, this can be obtained by running the following:
```bash
f=`git rev-parse --git-dir`/hooks/commit-msg ; mkdir -p $(dirname $f) ; curl -Lo $f https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x $f
```
If you've already locally committed a change without the `Change-Id`, running `git commit --amend` will add the missing `Change-Id`.
To create a Gerrit change for review, type:
```bash
git push origin HEAD:refs/for/main
```
## Community Guidelines
This project follows
[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).

@ -0,0 +1 @@
set noparent

81
DEPS

@ -42,7 +42,6 @@ deps = {
'url': '{chromium_git}/external/github.com/llvm/llvm-project/clang/tools/clang-format.git@99803d74e35962f63a775f29477882afd4d57d94',
'condition': 'dawn_standalone',
},
'buildtools/linux64': {
'packages': [{
'package': 'gn/gn/linux-amd64',
@ -116,11 +115,6 @@ deps = {
'condition': 'dawn_standalone',
},
# WGSL support
'third_party/tint': {
'url': '{dawn_git}/tint@a730eb738e9f00fb52e9ac38cebe978373602a1e',
},
# GLFW for tests and samples
'third_party/glfw': {
'url': '{chromium_git}/external/github.com/glfw/glfw@94773111300fee0453844a4c9407af7e880b4df8',
@ -176,6 +170,10 @@ deps = {
'url': '{github_git}/gpuweb/gpuweb.git@881403b5fda2d9ac9ffc5daa24e34738205bf155',
'condition': 'dawn_node',
},
'third_party/gpuweb-cts': {
'url': '{chromium_git}/external/github.com/gpuweb/cts@b0291fd966b55a5efc496772555b94842bde1085',
'condition': 'dawn_standalone',
},
'tools/golang': {
'condition': 'dawn_node',
@ -194,6 +192,16 @@ deps = {
}],
'dep_type': 'cipd',
},
# Misc dependencies inherited from Tint
'third_party/benchmark': {
'url': '{chromium_git}/external/github.com/google/benchmark.git@e991355c02b93fe17713efe04cbc2e278e00fdbd',
'condition': 'dawn_standalone',
},
'third_party/protobuf': {
'url': '{chromium_git}/external/github.com/protocolbuffers/protobuf.git@fde7cf7358ec7cd69e8db9be4f1fa6a5c431386a',
'condition': 'dawn_standalone',
},
}
hooks = [
@ -253,44 +261,81 @@ hooks = [
'condition': 'dawn_standalone and host_os == "win"',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=win32',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'buildtools/win/clang-format.exe.sha1',
],
},
{
'name': 'clang_format_mac_x64',
'name': 'clang_format_mac',
'pattern': '.',
'condition': 'dawn_standalone and host_os == "mac" and host_cpu == "x64"',
'condition': 'dawn_standalone and host_os == "mac"',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=darwin',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'buildtools/mac/clang-format.x64.sha1',
'-o', 'buildtools/mac/clang-format',
'-s', 'buildtools/mac/clang-format.sha1',
],
},
{
'name': 'clang_format_mac_arm64',
'name': 'clang_format_linux',
'pattern': '.',
'condition': 'dawn_standalone and host_os == "mac" and host_cpu == "arm64"',
'condition': 'dawn_standalone and host_os == "linux"',
'action': [ 'download_from_google_storage',
'--no_resume',
'--platform=linux*',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'buildtools/mac/clang-format.arm64.sha1',
'-o', 'buildtools/mac/clang-format',
'-s', 'buildtools/linux64/clang-format.sha1',
],
},
# Pull the compilers and system libraries for hermetic builds
{
'name': 'clang_format_linux',
'name': 'sysroot_x86',
'pattern': '.',
'condition': 'dawn_standalone and host_os == "linux"',
'condition': 'checkout_linux and ((checkout_x86 or checkout_x64))',
'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py',
'--arch=x86'],
},
{
'name': 'sysroot_x64',
'pattern': '.',
'condition': 'checkout_linux and (checkout_x64)',
'action': ['python3', 'build/linux/sysroot_scripts/install-sysroot.py',
'--arch=x64'],
},
{
# Update the Mac toolchain if necessary.
'name': 'mac_toolchain',
'pattern': '.',
'condition': 'checkout_mac',
'action': ['python3', 'build/mac_toolchain.py'],
},
{
# Update the Windows toolchain if necessary. Must run before 'clang' below.
'name': 'win_toolchain',
'pattern': '.',
'condition': 'checkout_win',
'action': ['python3', 'build/vs_toolchain.py', 'update', '--force'],
},
{
# Note: On Win, this should run after win_toolchain, as it may use it.
'name': 'clang',
'pattern': '.',
'action': ['python3', 'tools/clang/scripts/update.py'],
},
{
# Pull rc binaries using checked-in hashes.
'name': 'rc_win',
'pattern': '.',
'condition': 'checkout_win and (host_os == "win")',
'action': [ 'download_from_google_storage',
'--no_resume',
'--no_auth',
'--bucket', 'chromium-clang-format',
'-s', 'buildtools/linux64/clang-format.sha1',
'--bucket', 'chromium-browser-clang/rc',
'-s', 'build/toolchain/win/rc/win/rc.exe.sha1',
],
},
# Update build/util/LASTCHANGE.

2474
Doxyfile

File diff suppressed because it is too large Load Diff

@ -9,3 +9,12 @@ kainino@chromium.org
per-file dawn.json=kainino@chromium.org
per-file DEPS=*
per-file README.md=file://docs/dawn/OWNERS
# Tint specific OWNERS
amaiorano@google.com
bclayton@chromium.org
bclayton@google.com
cwallez@chromium.org
dneto@google.com
jrprice@google.com
rharrison@chromium.org

@ -0,0 +1,11 @@
cwallez@chromium.org
enga@chromium.org
jiawei.shao@intel.com
# Backup reviewers if needed.
bclayton@google.com
kainino@chromium.org
per-file dawn.json=kainino@chromium.org
per-file DEPS=*
per-file README.md=file://docs/dawn/OWNERS

@ -0,0 +1,7 @@
amaiorano@google.com
bclayton@chromium.org
bclayton@google.com
cwallez@chromium.org
dneto@google.com
jrprice@google.com
rharrison@chromium.org

@ -1,4 +1,4 @@
# Copyright 2018 The Dawn Authors
# Copyright 2022 The Dawn & Tint Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -12,12 +12,97 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import platform
import subprocess
import re
USE_PYTHON3 = True
NONINCLUSIVE_REGEXES = [
r"(?i)black[-_]?list",
r"(?i)white[-_]?list",
r"(?i)gr[ea]y[-_]?list",
r"(?i)(first class citizen)",
r"(?i)black[-_]?hat",
r"(?i)white[-_]?hat",
r"(?i)gr[ea]y[-_]?hat",
r"(?i)master",
r"(?i)slave",
r"(?i)\bhim\b",
r"(?i)\bhis\b",
r"(?i)\bshe\b",
r"(?i)\bher\b",
r"(?i)\bguys\b",
r"(?i)\bhers\b",
r"(?i)\bman\b",
r"(?i)\bwoman\b",
r"(?i)\she\s",
r"(?i)\she$",
r"(?i)^he\s",
r"(?i)^he$",
r"(?i)\she['|\u2019]d\s",
r"(?i)\she['|\u2019]d$",
r"(?i)^he['|\u2019]d\s",
r"(?i)^he['|\u2019]d$",
r"(?i)\she['|\u2019]s\s",
r"(?i)\she['|\u2019]s$",
r"(?i)^he['|\u2019]s\s",
r"(?i)^he['|\u2019]s$",
r"(?i)\she['|\u2019]ll\s",
r"(?i)\she['|\u2019]ll$",
r"(?i)^he['|\u2019]ll\s",
r"(?i)^he['|\u2019]ll$",
r"(?i)grandfather",
r"(?i)\bmitm\b",
r"(?i)\bcrazy\b",
r"(?i)\binsane\b",
r"(?i)\bblind\sto\b",
r"(?i)\bflying\sblind\b",
r"(?i)\bblind\seye\b",
r"(?i)\bcripple\b",
r"(?i)\bcrippled\b",
r"(?i)\bdumb\b",
r"(?i)\bdummy\b",
r"(?i)\bparanoid\b",
r"(?i)\bsane\b",
r"(?i)\bsanity\b",
r"(?i)red[-_]?line",
]
NONINCLUSIVE_REGEX_LIST = []
for reg in NONINCLUSIVE_REGEXES:
NONINCLUSIVE_REGEX_LIST.append(re.compile(reg))
def _CheckNonInclusiveLanguage(input_api, output_api, source_file_filter=None):
"""Checks the files for non-inclusive language."""
matches = []
for f in input_api.AffectedFiles(include_deletes=False,
file_filter=source_file_filter):
for line_num, line in f.ChangedContents():
for reg in NONINCLUSIVE_REGEX_LIST:
match = reg.search(line)
if match:
matches.append(
"{} ({}): found non-inclusive language: {}".format(
f.LocalPath(), line_num, match.group(0)))
if len(matches):
return [
output_api.PresubmitPromptWarning('Non-inclusive language found:',
items=matches)
]
return []
def _NonInclusiveFileFilter(file):
filter_list = [
"PRESUBMIT.py", # Non-inclusive language check data
"docs/tint/spirv-input-output-variables.md", # External URL
"test/tint/samples/compute_boids.wgsl ", # External URL
]
return file in filter_list
def _DoCommonChecks(input_api, output_api):
results = []
@ -27,6 +112,30 @@ def _DoCommonChecks(input_api, output_api):
input_api.canned_checks.CheckPatchFormatted(input_api,
output_api,
check_python=True))
results.extend(
input_api.canned_checks.CheckChangeHasDescription(
input_api, output_api))
results.extend(
input_api.canned_checks.CheckGNFormatted(input_api, output_api))
results.extend(
input_api.canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol(
input_api, output_api))
results.extend(
input_api.canned_checks.CheckChangeHasNoTabs(input_api, output_api))
results.extend(
input_api.canned_checks.CheckChangeTodoHasOwner(input_api, output_api))
results.extend(
input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
input_api, output_api))
results.extend(
input_api.canned_checks.CheckDoNotSubmit(input_api, output_api))
results.extend(
input_api.canned_checks.CheckChangeLintsClean(input_api,
output_api,
lint_filters=""))
results.extend(
_CheckNonInclusiveLanguage(input_api, output_api,
_NonInclusiveFileFilter))
return results

@ -0,0 +1,38 @@
# 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 os
import platform
import subprocess
USE_PYTHON3 = True
def _DoCommonChecks(input_api, output_api):
results = []
results.extend(
input_api.canned_checks.CheckChangedLUCIConfigs(input_api, output_api))
results.extend(
input_api.canned_checks.CheckPatchFormatted(input_api,
output_api,
check_python=True))
return results
def CheckChangeOnUpload(input_api, output_api):
return _DoCommonChecks(input_api, output_api)
def CheckChangeOnCommit(input_api, output_api):
return _DoCommonChecks(input_api, output_api)

@ -0,0 +1,167 @@
# Copyright 2020 The Tint 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.
"""Presubmit script for Tint.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools.
"""
import re
USE_PYTHON3 = True
def _LicenseHeader(input_api):
"""Returns the license header regexp."""
# Accept any year number from 2019 to the current year
current_year = int(input_api.time.strftime('%Y'))
allowed_years = (str(s) for s in reversed(xrange(2019, current_year + 1)))
years_re = '(' + '|'.join(allowed_years) + ')'
license_header = (
r'.*? Copyright( \(c\))? %(year)s The Tint [Aa]uthors\n '
r'.*?\n'
r'.*? Licensed under the Apache License, Version 2.0 (the "License");\n'
r'.*? you may not use this file except in compliance with the License.\n'
r'.*? You may obtain a copy of the License at\n'
r'.*?\n'
r'.*? http://www.apache.org/licenses/LICENSE-2.0\n'
r'.*?\n'
r'.*? Unless required by applicable law or agreed to in writing, software\n'
r'.*? distributed under the License is distributed on an "AS IS" BASIS,\n'
r'.*? WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n'
r'.*? See the License for the specific language governing permissions and\n'
r'.*? limitations under the License.\n') % {
'year': years_re,
}
return license_header
REGEXES = [
r"(?i)black[-_]?list",
r"(?i)white[-_]?list",
r"(?i)gr[ea]y[-_]?list",
r"(?i)(first class citizen)",
r"(?i)black[-_]?hat",
r"(?i)white[-_]?hat",
r"(?i)gr[ea]y[-_]?hat",
r"(?i)master",
r"(?i)slave",
r"(?i)\bhim\b",
r"(?i)\bhis\b",
r"(?i)\bshe\b",
r"(?i)\bher\b",
r"(?i)\bguys\b",
r"(?i)\bhers\b",
r"(?i)\bman\b",
r"(?i)\bwoman\b",
r"(?i)\she\s",
r"(?i)\she$",
r"(?i)^he\s",
r"(?i)^he$",
r"(?i)\she['|\u2019]d\s",
r"(?i)\she['|\u2019]d$",
r"(?i)^he['|\u2019]d\s",
r"(?i)^he['|\u2019]d$",
r"(?i)\she['|\u2019]s\s",
r"(?i)\she['|\u2019]s$",
r"(?i)^he['|\u2019]s\s",
r"(?i)^he['|\u2019]s$",
r"(?i)\she['|\u2019]ll\s",
r"(?i)\she['|\u2019]ll$",
r"(?i)^he['|\u2019]ll\s",
r"(?i)^he['|\u2019]ll$",
r"(?i)grandfather",
r"(?i)\bmitm\b",
r"(?i)\bcrazy\b",
r"(?i)\binsane\b",