mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
feat(tools): Improved verification of ESP-IDF project
Closes https://github.com/espressif/esp-idf/issues/18675
This commit is contained in:
@@ -47,10 +47,16 @@ def _is_valid_project_dir(directory: str) -> bool:
|
||||
if not cmakelists_path.is_file():
|
||||
return False
|
||||
|
||||
# Normalised patterns (whitespace removed) for whitespace-insensitive matching.
|
||||
# CMake treats whitespace inside include(...) as insignificant, so
|
||||
# `include( $ENV{...} )` must be accepted alongside `include($ENV{...})`.
|
||||
normalised_patterns = [''.join(p.split()) for p in CMAKE_PROJECT_LINE]
|
||||
|
||||
try:
|
||||
with open(str(cmakelists_path), encoding='utf-8') as f:
|
||||
for line in f:
|
||||
if any(proj_line in line for proj_line in CMAKE_PROJECT_LINE):
|
||||
line_normalised = ''.join(line.split())
|
||||
if any(line_normalised.startswith(pattern) for pattern in normalised_patterns):
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user