mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 09:09:10 -04:00
change: move check_deprecated_configs.py file to esp-idf-kconfig
This commit is contained in:
parent
046279155d
commit
c7993c2725
@ -72,11 +72,6 @@ repos:
|
||||
language: python
|
||||
pass_filenames: false
|
||||
always_run: true
|
||||
- id: check-deprecated-kconfigs-options
|
||||
name: Check if any Kconfig Options Deprecated
|
||||
entry: tools/ci/check_deprecated_kconfigs.py
|
||||
language: python
|
||||
files: 'sdkconfig\.ci$|sdkconfig\.rename$|sdkconfig.*$'
|
||||
- id: cmake-lint
|
||||
name: Check CMake Files Format
|
||||
entry: cmakelint --linelength=120 --spaces=4 --filter=-whitespace/indent
|
||||
@ -243,6 +238,7 @@ repos:
|
||||
name: Lint rST files in docs folder using Sphinx Lint
|
||||
files: ^(docs/en|docs/zh_CN)/.*\.(rst|inc)$
|
||||
- repo: https://github.com/espressif/esp-idf-kconfig.git
|
||||
rev: v2.4.1
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: check-kconfig-files
|
||||
- id: check-deprecated-kconfig-options
|
||||
|
@ -1,110 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from io import open
|
||||
from typing import Set, Tuple
|
||||
|
||||
from idf_ci_utils import get_submodule_dirs
|
||||
|
||||
# FILES_TO_CHECK used as "startswith" pattern to match sdkconfig.defaults variants
|
||||
FILES_TO_CHECK = ('sdkconfig.ci', 'sdkconfig.defaults')
|
||||
|
||||
# ignored directories (makes sense only when run on IDF_PATH)
|
||||
# Note: IGNORE_DIRS is a tuple in order to be able to use it directly with the startswith() built-in function which
|
||||
# accepts tuples but no lists.
|
||||
IGNORE_DIRS: Tuple = (
|
||||
)
|
||||
|
||||
|
||||
def _parse_path(path: 'os.PathLike[str]', sep: str=None) -> Set:
|
||||
ret = set()
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line.startswith('#') and len(line) > 0:
|
||||
ret.add(line.split(sep)[0])
|
||||
return ret
|
||||
|
||||
|
||||
def valid_directory(path: str) -> str:
|
||||
if not os.path.isdir(path):
|
||||
raise argparse.ArgumentTypeError('{} is not a valid directory!'.format(path))
|
||||
return path
|
||||
|
||||
|
||||
def check() -> int:
|
||||
parser = argparse.ArgumentParser(description='Kconfig options checker')
|
||||
parser.add_argument('files', nargs='*',
|
||||
help='Kconfig files')
|
||||
parser.add_argument('--includes', '-d', nargs='*',
|
||||
help='Extra paths for recursively searching Kconfig files. (for example $IDF_PATH)',
|
||||
type=valid_directory)
|
||||
parser.add_argument('--exclude-submodules', action='store_true',
|
||||
help='Exclude submodules')
|
||||
args = parser.parse_args()
|
||||
|
||||
success_counter = 0
|
||||
failure_counter = 0
|
||||
ignore_counter = 0
|
||||
|
||||
deprecated_options = set()
|
||||
|
||||
ignore_dirs = IGNORE_DIRS
|
||||
if args.exclude_submodules:
|
||||
for submodule in get_submodule_dirs(full_path=True):
|
||||
ignore_dirs = ignore_dirs + tuple(submodule)
|
||||
|
||||
files = [os.path.abspath(file_path) for file_path in args.files]
|
||||
|
||||
if args.includes:
|
||||
for directory in args.includes:
|
||||
for root, dirnames, filenames in os.walk(directory):
|
||||
for filename in filenames:
|
||||
full_path = os.path.join(root, filename)
|
||||
if filename.startswith(FILES_TO_CHECK):
|
||||
files.append(full_path)
|
||||
elif filename == 'sdkconfig.rename':
|
||||
deprecated_options |= _parse_path(full_path)
|
||||
|
||||
for full_path in files:
|
||||
if full_path.startswith(ignore_dirs):
|
||||
print('{}: Ignored'.format(full_path))
|
||||
ignore_counter += 1
|
||||
continue
|
||||
used_options = _parse_path(full_path, '=')
|
||||
used_deprecated_options = deprecated_options & used_options
|
||||
if len(used_deprecated_options) > 0:
|
||||
print('{}: The following options are deprecated: {}'
|
||||
.format(full_path, ', '.join(used_deprecated_options)))
|
||||
failure_counter += 1
|
||||
else:
|
||||
print('{}: OK'.format(full_path))
|
||||
success_counter += 1
|
||||
|
||||
if ignore_counter > 0:
|
||||
print('{} files have been ignored.'.format(ignore_counter))
|
||||
if success_counter > 0:
|
||||
print('{} files have been successfully checked.'.format(success_counter))
|
||||
if failure_counter > 0:
|
||||
print('{} files have errors. Please take a look at the log.'.format(failure_counter))
|
||||
return 1
|
||||
|
||||
if not files:
|
||||
print('WARNING: no files specified. Please specify files or use '
|
||||
'"--includes" to search Kconfig files recursively')
|
||||
return 0
|
||||
|
||||
|
||||
def main() -> None:
|
||||
sys.exit(check())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -55,7 +55,6 @@ tools/ci/check_api_violation.sh
|
||||
tools/ci/check_build_test_rules.py
|
||||
tools/ci/check_callgraph.py
|
||||
tools/ci/check_codeowners.py
|
||||
tools/ci/check_deprecated_kconfigs.py
|
||||
tools/ci/check_esp_memory_utils_headers.sh
|
||||
tools/ci/check_examples_extra_component_dirs.sh
|
||||
tools/ci/check_executables.py
|
||||
|
Loading…
x
Reference in New Issue
Block a user