third_party.pigweed.src/.gn

33 lines
1.1 KiB
Plaintext
Raw Normal View History

# Copyright 2020 The Pigweed 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
#
# https://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.
buildconfig = "//BUILDCONFIG.gn"
default_args = {
pw_build_PIP_CONSTRAINTS =
[ "//pw_env_setup/py/pw_env_setup/virtualenv_setup/constraint.list" ]
# Exclude third-party headers from static analysis.
pw_toolchain: Use regexes for --source-exclude The clang-tidy.py wrapper offers a --source-exclude flag, exposed as pw_toolchain_STATIC_ANALYSIS_SKIP_SOURCES_GLOBS, that allows not running clang-tidy on some source files. This CL switches the flag from glob patterns to regular expressions. It turns out glob patterns are unsuitable for this use case because source file paths typically look like: third_party/googletest/googletest/src/gtest-death-test.cc Ideally, we would like to filter out anything under `third_party`. The comment on pw_toolchain_STATIC_ANALYSIS_SKIP_SOURCES_GLOBS suggests this can be done with globs, _but it can't_: you can't create a glob that matches all files under a top-level directory, and the example provided in the comment ("third_party/**/*") actually does not work. At best you can use subdirectories, i.e. "**/googletest/**/*" in this case. But having to match subdirectories in this way is, 1. Error-prone: what if there's a googletest subdirectory outside third_party that you _do_ want to include in the analysis? 2. Extremely verbose: for downstream projects, everything under the `pigweed` top-level directory is effectively third-party code that they don't want to run clang-tidy on. And pigweed has very many subdirectories. Unlike globs, regular expressions actually work here, as the CL demonstrates. As far as I know no downstream project uses clang-tidy yet, so this change does not require updating them. Bug: b/203828808 Change-Id: Icab776724da35d668ef38166c7cf0a3452dd316d Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66484 Reviewed-by: Rob Mohr <mohrr@google.com> Commit-Queue: Ted Pudlik <tpudlik@google.com>
2021-10-26 19:44:17 +00:00
pw_toolchain_STATIC_ANALYSIS_SKIP_SOURCES_RES = [ "third_party/.*" ]
pw_toolchain_STATIC_ANALYSIS_SKIP_INCLUDE_PATHS = [
"mbedtls/include",
"boringssl/src/include",
"boringssl",
# Code generated by third-party tool.
"pw_tls_client/generate_test_data",
]
}