Add support for running [chromium-style] checks in CMake builds
Adds a new option to insert the needed flags, as well instructions on how to run the checks to README.md. BUG=tint:62 Change-Id: Id154555c4846f1dea29bad1fba5a3cd73ac7fb04 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20540 Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
parent
a5bba6037a
commit
563d3e9975
|
@ -31,12 +31,14 @@ option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ON)
|
|||
option(TINT_BUILD_WGSL_READER "Builde the WGSL input reader" ON)
|
||||
option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ON)
|
||||
option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
||||
|
||||
option(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
|
||||
|
||||
option(TINT_ENABLE_MSAN "Enable memory sanitizer" OFF)
|
||||
option(TINT_ENABLE_ASAN "Enable address sanitizer" OFF)
|
||||
option(TINT_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF)
|
||||
|
||||
option(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF)
|
||||
|
||||
message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}")
|
||||
message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}")
|
||||
message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}")
|
||||
|
@ -46,10 +48,15 @@ message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
|
|||
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 "Using python3")
|
||||
find_package(PythonInterp 3 REQUIRED)
|
||||
|
||||
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("${PROJECT_SOURCE_DIR}/third_party/spirv-tools/include")
|
||||
endif()
|
||||
|
|
27
README.md
27
README.md
|
@ -53,6 +53,13 @@ cmake ../..
|
|||
make # -j N for N-way parallel build
|
||||
```
|
||||
|
||||
### Compiling using gn + ninja
|
||||
```sh
|
||||
mkdir -p out/Debug
|
||||
gn gen out/Debug
|
||||
autoninja -C out/Debug
|
||||
```
|
||||
|
||||
### Fuzzers on MacOS
|
||||
If you are attempting fuzz, using `TINT_BUILD_FUZZERS=ON`, the version of llvm
|
||||
in the XCode SDK does not have the needed libfuzzer functionality included.
|
||||
|
@ -67,6 +74,26 @@ The solution to this problem is to use a full version llvm, like what you would
|
|||
get via homebrew, `brew install llvm`, and use something like `CC=<path to full
|
||||
clang> cmake ..` to setup a build using that toolchain.
|
||||
|
||||
### Checking [chromium-style] issues in CMake builds
|
||||
The gn based work flow uses the Chromium toolchain for building in anticipation
|
||||
of integration of Tint into Chromium based projects. This toolchain has
|
||||
additional plugins for checking for style issues, which are marked with
|
||||
[chromium-style] in log messages. This means that this toolchain is more strict
|
||||
then the default clang toolchain.
|
||||
|
||||
In the future we will have a CQ that will build this work flow and flag issues
|
||||
automatically. Until that is in place, to avoid causing breakages you can run
|
||||
the [chromium-style] checks using the CMake based work flows. This requires
|
||||
setting `CC` to the version of clang checked out by `gclient sync` and setting
|
||||
the `TINT_CHECK_CHROMIUM_STYLE` to `ON`.
|
||||
|
||||
```sh
|
||||
mkdir -p out/style
|
||||
cd out/style
|
||||
cmake ../..
|
||||
CC=../../third_party/llvm-build/Release+Asserts/bin/clang cmake -DTINT_CHECK_CHROMIUM_STYLE=ON ../../ # add -GNinja for ninja builds
|
||||
```
|
||||
|
||||
## Issues
|
||||
Please file any issues or feature requests at
|
||||
https://bugs.chromium.org/p/tint/issues/entry
|
||||
|
|
Loading…
Reference in New Issue