mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'refactor/avoid_using_git_v5.2' into 'release/v5.2'
fix(tools): Avoiding crashing when Git is not present in system when acquiring IDF version (v5.2) See merge request espressif/esp-idf!31433
This commit is contained in:
commit
e5ffb3c57d
@ -80,6 +80,7 @@ def executable_exists(args: List) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def _idf_version_from_cmake() -> Optional[str]:
|
def _idf_version_from_cmake() -> Optional[str]:
|
||||||
|
"""Acquires version of ESP-IDF from version.cmake"""
|
||||||
version_path = os.path.join(os.environ['IDF_PATH'], 'tools/cmake/version.cmake')
|
version_path = os.path.join(os.environ['IDF_PATH'], 'tools/cmake/version.cmake')
|
||||||
regex = re.compile(r'^\s*set\s*\(\s*IDF_VERSION_([A-Z]{5})\s+(\d+)')
|
regex = re.compile(r'^\s*set\s*\(\s*IDF_VERSION_([A-Z]{5})\s+(\d+)')
|
||||||
ver = {}
|
ver = {}
|
||||||
@ -113,7 +114,7 @@ def idf_version() -> Optional[str]:
|
|||||||
'--work-tree=%s' % os.environ['IDF_PATH'],
|
'--work-tree=%s' % os.environ['IDF_PATH'],
|
||||||
'describe', '--tags', '--dirty', '--match', 'v*.*',
|
'describe', '--tags', '--dirty', '--match', 'v*.*',
|
||||||
]).decode('utf-8', 'ignore').strip()
|
]).decode('utf-8', 'ignore').strip()
|
||||||
except (subprocess.CalledProcessError, UnicodeError):
|
except Exception:
|
||||||
# if failed, then try to parse cmake.version file
|
# if failed, then try to parse cmake.version file
|
||||||
sys.stderr.write('WARNING: Git version unavailable, reading from source\n')
|
sys.stderr.write('WARNING: Git version unavailable, reading from source\n')
|
||||||
version = _idf_version_from_cmake()
|
version = _idf_version_from_cmake()
|
||||||
@ -148,7 +149,7 @@ def get_default_serial_port() -> Any:
|
|||||||
|
|
||||||
# function prints warning when autocompletion is not being performed
|
# function prints warning when autocompletion is not being performed
|
||||||
# set argument stream to sys.stderr for errors and exceptions
|
# set argument stream to sys.stderr for errors and exceptions
|
||||||
def print_warning(message: str, stream: TextIO=None) -> None:
|
def print_warning(message: str, stream: Optional[TextIO]=None) -> None:
|
||||||
if not SHELL_COMPLETE_RUN:
|
if not SHELL_COMPLETE_RUN:
|
||||||
print(message, file=stream or sys.stderr)
|
print(message, file=stream or sys.stderr)
|
||||||
|
|
||||||
@ -277,8 +278,9 @@ def fit_text_in_terminal(out: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
class RunTool:
|
class RunTool:
|
||||||
def __init__(self, tool_name: str, args: List, cwd: str, env: Dict=None, custom_error_handler: FunctionType=None, build_dir: str=None,
|
def __init__(self, tool_name: str, args: List, cwd: str, env: Optional[Dict]=None, custom_error_handler: Optional[FunctionType]=None,
|
||||||
hints: bool=True, force_progression: bool=False, interactive: bool=False, convert_output: bool=False) -> None:
|
build_dir: Optional[str]=None, hints: bool=True, force_progression: bool=False, interactive: bool=False, convert_output: bool=False
|
||||||
|
) -> None:
|
||||||
self.tool_name = tool_name
|
self.tool_name = tool_name
|
||||||
self.args = args
|
self.args = args
|
||||||
self.cwd = cwd
|
self.cwd = cwd
|
||||||
@ -471,7 +473,7 @@ def run_tool(*args: Any, **kwargs: Any) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None,
|
def run_target(target_name: str, args: 'PropertyDict', env: Optional[Dict]=None,
|
||||||
custom_error_handler: FunctionType=None, force_progression: bool=False, interactive: bool=False) -> None:
|
custom_error_handler: Optional[FunctionType]=None, force_progression: bool=False, interactive: bool=False) -> None:
|
||||||
"""Run target in build directory."""
|
"""Run target in build directory."""
|
||||||
if env is None:
|
if env is None:
|
||||||
env = {}
|
env = {}
|
||||||
@ -554,7 +556,7 @@ def _detect_cmake_generator(prog_name: str) -> Any:
|
|||||||
|
|
||||||
|
|
||||||
def ensure_build_directory(args: 'PropertyDict', prog_name: str, always_run_cmake: bool=False,
|
def ensure_build_directory(args: 'PropertyDict', prog_name: str, always_run_cmake: bool=False,
|
||||||
env: Dict=None) -> None:
|
env: Optional[Dict]=None) -> None:
|
||||||
"""Check the build directory exists and that cmake has been run there.
|
"""Check the build directory exists and that cmake has been run there.
|
||||||
|
|
||||||
If this isn't the case, create the build directory (if necessary) and
|
If this isn't the case, create the build directory (if necessary) and
|
||||||
@ -671,7 +673,7 @@ def merge_action_lists(*action_lists: Dict) -> Dict:
|
|||||||
return merged_actions
|
return merged_actions
|
||||||
|
|
||||||
|
|
||||||
def get_sdkconfig_filename(args: 'PropertyDict', cache_cmdl: Dict=None) -> str:
|
def get_sdkconfig_filename(args: 'PropertyDict', cache_cmdl: Optional[Dict]=None) -> str:
|
||||||
"""
|
"""
|
||||||
Get project's sdkconfig file name.
|
Get project's sdkconfig file name.
|
||||||
"""
|
"""
|
||||||
@ -720,7 +722,7 @@ def is_target_supported(project_path: str, supported_targets: List) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def _check_idf_target(args: 'PropertyDict', prog_name: str, cache: Dict,
|
def _check_idf_target(args: 'PropertyDict', prog_name: str, cache: Dict,
|
||||||
cache_cmdl: Dict, env: Dict=None) -> None:
|
cache_cmdl: Dict, env: Optional[Dict]=None) -> None:
|
||||||
"""
|
"""
|
||||||
Cross-check the three settings (sdkconfig, CMakeCache, environment) and if there is
|
Cross-check the three settings (sdkconfig, CMakeCache, environment) and if there is
|
||||||
mismatch, fail with instructions on how to fix this.
|
mismatch, fail with instructions on how to fix this.
|
||||||
|
Loading…
Reference in New Issue
Block a user