1
0
mirror of https://github.com/esphome/esphome.git synced 2025-07-05 06:33:31 +01:00

Run clang-tidy against ESP32 ()

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
Oxan van Leeuwen
2021-09-13 18:11:27 +02:00
committed by GitHub
parent a2d2863c72
commit 40c474cd83
74 changed files with 291 additions and 364 deletions
.clang-tidy
.github/workflows
esphome
components
ac_dimmer
airthings_ble
airthings_wave_plus
am43
anova
api
atc_mithermometer
ble_client
esp32_ble
esp32_ble_beacon
esp32_ble_server
esp32_ble_tracker
esp32_camera
esp32_improv
esp8266_pwm
ethernet
i2c
inkbird_ibsth1_mini
inkplate6
ledc
mqtt
nextion
pulse_counter
pvvx_mithermometer
remote_base
socket
spi
st7735
st7789v
uart
wifi
xiaomi_ble
xiaomi_cgd1
xiaomi_cgdk2
xiaomi_cgg1
xiaomi_cgpr1
xiaomi_gcls002
xiaomi_hhccjcy01
xiaomi_hhccpot002
xiaomi_jqjcy01ym
xiaomi_lywsd02
xiaomi_lywsd03mmc
xiaomi_lywsdcgq
xiaomi_mhoc401
xiaomi_miscale2
xiaomi_mjyd02yla
xiaomi_mue4094rt
xiaomi_wx08zm
core
platformio.ini
script

@ -16,7 +16,7 @@ import click
import pexpect
sys.path.append(os.path.dirname(__file__))
from helpers import shlex_quote, get_output, \
from helpers import shlex_quote, get_output, filter_grep, \
build_all_include, temp_header_file, git_ls_files, filter_changed, load_idedata
@ -27,13 +27,15 @@ def clang_options(idedata):
# disable built-in include directories from the host
'-nostdinc',
'-nostdinc++',
# pretend we're an Xtensa compiler, which gates some features in the headers
'-D__XTENSA__',
# allow to condition code on the presence of clang-tidy
'-DCLANG_TIDY'
]
# copy compiler flags, except those clang doesn't understand.
cmd.extend(flag for flag in idedata['cxx_flags'].split(' ')
if flag not in ('-free', '-fipa-pta', '-mlongcalls', '-mtext-section-literals'))
if flag not in ('-free', '-fipa-pta', '-fstrict-volatile-bitfields', '-mlongcalls', '-mtext-section-literals'))
# defines
cmd.extend(f'-D{define}' for define in idedata['defines'])
@ -97,6 +99,8 @@ def main():
parser.add_argument('-j', '--jobs', type=int,
default=multiprocessing.cpu_count(),
help='number of tidy instances to be run in parallel.')
parser.add_argument('-e', '--environment', default='esp8266-tidy',
help='the PlatformIO environment to run against (esp8266-tidy or esp32-tidy)')
parser.add_argument('files', nargs='*', default=[],
help='files to be processed (regex on path)')
parser.add_argument('--fix', action='store_true', help='apply fix-its')
@ -104,6 +108,7 @@ def main():
help='run clang-tidy in quiet mode')
parser.add_argument('-c', '--changed', action='store_true',
help='only run on changed files')
parser.add_argument('-g', '--grep', help='only run on files containing value')
parser.add_argument('--split-num', type=int, help='split the files into X jobs.',
default=None)
parser.add_argument('--split-at', type=int, help='which split is this? starts at 1',
@ -126,7 +131,7 @@ def main():
""")
return 1
idedata = load_idedata("esp8266-tidy")
idedata = load_idedata(args.environment)
options = clang_options(idedata)
files = []
@ -141,6 +146,9 @@ def main():
if args.changed:
files = filter_changed(files)
if args.grep:
files = filter_grep(files, args.grep)
files.sort()
if args.split_num: