mirror of
https://github.com/espressif/openthread.git
synced 2026-10-04 06:47:36 +00:00
[style] apply IWYU to public headers (#11580)
It would be easier to use OpenThread public headers if they are self-contained and follows the IWYU style guide. This commit fixes some style issues to make the public headers self-contained and IWYU. The existing pretty check is also extended to verify the OpenThread public headers are self-contained and follows IWYU.
This commit is contained in:
@@ -48,6 +48,8 @@ install_packages_pretty_format()
|
||||
|
||||
# add shfmt for shell pretty
|
||||
command -v shfmt || sudo apt-get install shfmt || echo 'WARNING: could not install shfmt, which is useful if you plan to contribute shell scripts to the OpenThread project.'
|
||||
|
||||
sudo apt-get --no-install-recommends install -y iwyu || echo 'WARNING: iwyu, which is useful to ensure applying the IWYU rules.'
|
||||
}
|
||||
|
||||
install_packages_apt()
|
||||
@@ -122,6 +124,8 @@ install_packages_brew()
|
||||
|
||||
# add yapf for pretty
|
||||
python3 -m pip install yapf || echo 'Failed to install python code formatter yapf. Install it manually if you need.'
|
||||
|
||||
brew install include-what-you-use || echo 'WARNING: iwyu, which is useful to ensure applying the IWYU rules.'
|
||||
}
|
||||
|
||||
install_packages_source()
|
||||
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2025, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
#
|
||||
# Run this command on parent directory of openthread
|
||||
#
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
main()
|
||||
{
|
||||
find include -name '*.h' -exec iwyu -I include {} \; 2>&1 \
|
||||
| fix_include -n --nosafe_headers \
|
||||
| tee >(cat 1>&2) \
|
||||
| grep 'IWYU edited 0 files on your behalf.'
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user