mirror of https://github.com/grpc/grpc.git
The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)
https://grpc.io/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.9 KiB
52 lines
1.9 KiB
#!/bin/sh |
|
# Copyright 2017 gRPC 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. |
|
|
|
set -ex |
|
|
|
cd ${IWYU_ROOT} |
|
|
|
export PATH=${PATH}:${IWYU_ROOT}/iwyu_build/bin |
|
|
|
rm -rf iwyu || true |
|
git clone https://github.com/include-what-you-use/include-what-you-use.git iwyu |
|
# latest commit on the clang 11 branch |
|
cd ${IWYU_ROOT}/iwyu && git checkout fbd921d6640bf1b18fe5a8a895636215367eb6b9 |
|
mkdir -p ${IWYU_ROOT}/iwyu_build && cd ${IWYU_ROOT}/iwyu_build && cmake -G "Unix Makefiles" ${IWYU_ROOT}/iwyu && make |
|
cd ${IWYU_ROOT} |
|
|
|
cat compile_commands.json | sed "s,\"file\": \",\"file\": \"${IWYU_ROOT}/,g" > compile_commands_for_iwyu.json |
|
|
|
# figure out which files to include |
|
cat compile_commands.json | jq -r '.[].file' \ |
|
| grep -E "^src/core/lib/(config|promise|uri)/" \ |
|
| grep -v -E "/upb-generated/|/upbdefs-generated/" \ |
|
| sort \ |
|
| tee iwyu_files.txt |
|
|
|
# run iwyu, filtering out changes to port_platform.h |
|
xargs -a iwyu_files.txt -I FILES ${IWYU_ROOT}/iwyu/iwyu_tool.py -p compile_commands_for_iwyu.json -j 16 FILES -- -Xiwyu --no_fwd_decls \ |
|
| grep -v -E "port_platform.h" \ |
|
| tee iwyu.out |
|
|
|
# apply the suggested changes |
|
${IWYU_ROOT}/iwyu/fix_includes.py --nocomments < iwyu.out || true |
|
|
|
# reformat sources, since iwyu gets this wrong |
|
xargs -a iwyu_files.txt ${CLANG_FORMAT:-clang-format} -i |
|
|
|
# TODO(ctiller): expand this to match the clang-tidy directories: |
|
# | grep -E "(^include/|^src/core/|^src/cpp/|^test/core/|^test/cpp/)" |
|
|
|
git diff --exit-code > /dev/null
|
|
|