mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 11:17:20 +02:00
Merge branch 'bugfix/fix_windows_path_case_sensitivity_v4.4' into 'release/v4.4'
bugfix: Fix windows path case sensitivity (v4.4) See merge request espressif/esp-idf!22076
This commit is contained in:
12
tools/idf.py
12
tools/idf.py
@ -33,7 +33,7 @@ sys.dont_write_bytecode = True
|
|||||||
|
|
||||||
import python_version_checker # noqa: E402
|
import python_version_checker # noqa: E402
|
||||||
from idf_py_actions.errors import FatalError # noqa: E402
|
from idf_py_actions.errors import FatalError # noqa: E402
|
||||||
from idf_py_actions.tools import executable_exists, idf_version, merge_action_lists, realpath # noqa: E402
|
from idf_py_actions.tools import executable_exists, idf_version, merge_action_lists # noqa: E402
|
||||||
|
|
||||||
# Use this Python interpreter for any subprocesses we launch
|
# Use this Python interpreter for any subprocesses we launch
|
||||||
PYTHON = sys.executable
|
PYTHON = sys.executable
|
||||||
@ -69,9 +69,9 @@ def check_environment():
|
|||||||
|
|
||||||
# verify that IDF_PATH env variable is set
|
# verify that IDF_PATH env variable is set
|
||||||
# find the directory idf.py is in, then the parent directory of this, and assume this is IDF_PATH
|
# find the directory idf.py is in, then the parent directory of this, and assume this is IDF_PATH
|
||||||
detected_idf_path = realpath(os.path.join(os.path.dirname(__file__), '..'))
|
detected_idf_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
if 'IDF_PATH' in os.environ:
|
if 'IDF_PATH' in os.environ:
|
||||||
set_idf_path = realpath(os.environ['IDF_PATH'])
|
set_idf_path = os.path.realpath(os.environ['IDF_PATH'])
|
||||||
if set_idf_path != detected_idf_path:
|
if set_idf_path != detected_idf_path:
|
||||||
print_warning(
|
print_warning(
|
||||||
'WARNING: IDF_PATH environment variable is set to %s but %s path indicates IDF directory %s. '
|
'WARNING: IDF_PATH environment variable is set to %s but %s path indicates IDF directory %s. '
|
||||||
@ -655,7 +655,7 @@ def init_cli(verbose_output=None):
|
|||||||
)
|
)
|
||||||
@click.option('-C', '--project-dir', default=os.getcwd(), type=click.Path())
|
@click.option('-C', '--project-dir', default=os.getcwd(), type=click.Path())
|
||||||
def parse_project_dir(project_dir):
|
def parse_project_dir(project_dir):
|
||||||
return realpath(project_dir)
|
return os.path.realpath(project_dir)
|
||||||
|
|
||||||
# Set `complete_var` to not existing environment variable name to prevent early cmd completion
|
# Set `complete_var` to not existing environment variable name to prevent early cmd completion
|
||||||
project_dir = parse_project_dir(standalone_mode=False, complete_var='_IDF.PY_COMPLETE_NOT_EXISTING')
|
project_dir = parse_project_dir(standalone_mode=False, complete_var='_IDF.PY_COMPLETE_NOT_EXISTING')
|
||||||
@ -663,11 +663,11 @@ def init_cli(verbose_output=None):
|
|||||||
all_actions = {}
|
all_actions = {}
|
||||||
# Load extensions from components dir
|
# Load extensions from components dir
|
||||||
idf_py_extensions_path = os.path.join(os.environ['IDF_PATH'], 'tools', 'idf_py_actions')
|
idf_py_extensions_path = os.path.join(os.environ['IDF_PATH'], 'tools', 'idf_py_actions')
|
||||||
extension_dirs = [realpath(idf_py_extensions_path)]
|
extension_dirs = [os.path.realpath(idf_py_extensions_path)]
|
||||||
extra_paths = os.environ.get('IDF_EXTRA_ACTIONS_PATH')
|
extra_paths = os.environ.get('IDF_EXTRA_ACTIONS_PATH')
|
||||||
if extra_paths is not None:
|
if extra_paths is not None:
|
||||||
for path in extra_paths.split(';'):
|
for path in extra_paths.split(';'):
|
||||||
path = realpath(path)
|
path = os.path.realpath(path)
|
||||||
if path not in extension_dirs:
|
if path not in extension_dirs:
|
||||||
extension_dirs.append(path)
|
extension_dirs.append(path)
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
@ -14,7 +16,7 @@ from idf_py_actions.constants import GENERATORS, PREVIEW_TARGETS, SUPPORTED_TARG
|
|||||||
from idf_py_actions.errors import FatalError
|
from idf_py_actions.errors import FatalError
|
||||||
from idf_py_actions.global_options import global_options
|
from idf_py_actions.global_options import global_options
|
||||||
from idf_py_actions.tools import (TargetChoice, ensure_build_directory, get_target, idf_version, merge_action_lists,
|
from idf_py_actions.tools import (TargetChoice, ensure_build_directory, get_target, idf_version, merge_action_lists,
|
||||||
realpath, run_target)
|
run_target)
|
||||||
|
|
||||||
|
|
||||||
def action_extensions(base_actions, project_path):
|
def action_extensions(base_actions, project_path):
|
||||||
@ -182,14 +184,14 @@ def action_extensions(base_actions, project_path):
|
|||||||
ensure_build_directory(args, ctx.info_name, True)
|
ensure_build_directory(args, ctx.info_name, True)
|
||||||
|
|
||||||
def validate_root_options(ctx, args, tasks):
|
def validate_root_options(ctx, args, tasks):
|
||||||
args.project_dir = realpath(args.project_dir)
|
args.project_dir = os.path.realpath(args.project_dir)
|
||||||
if args.build_dir is not None and args.project_dir == realpath(args.build_dir):
|
if args.build_dir is not None and args.project_dir == os.path.realpath(args.build_dir):
|
||||||
raise FatalError(
|
raise FatalError(
|
||||||
'Setting the build directory to the project directory is not supported. Suggest dropping '
|
'Setting the build directory to the project directory is not supported. Suggest dropping '
|
||||||
"--build-dir option, the default is a 'build' subdirectory inside the project directory.")
|
"--build-dir option, the default is a 'build' subdirectory inside the project directory.")
|
||||||
if args.build_dir is None:
|
if args.build_dir is None:
|
||||||
args.build_dir = os.path.join(args.project_dir, 'build')
|
args.build_dir = os.path.join(args.project_dir, 'build')
|
||||||
args.build_dir = realpath(args.build_dir)
|
args.build_dir = os.path.realpath(args.build_dir)
|
||||||
|
|
||||||
def idf_version_callback(ctx, param, value):
|
def idf_version_callback(ctx, param, value):
|
||||||
if not value or ctx.resilient_parsing:
|
if not value or ctx.resilient_parsing:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -19,16 +21,6 @@ def executable_exists(args):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def realpath(path):
|
|
||||||
"""
|
|
||||||
Return the cannonical path with normalized case.
|
|
||||||
|
|
||||||
It is useful on Windows to comparision paths in case-insensitive manner.
|
|
||||||
On Unix and Mac OS X it works as `os.path.realpath()` only.
|
|
||||||
"""
|
|
||||||
return os.path.normcase(os.path.realpath(path))
|
|
||||||
|
|
||||||
|
|
||||||
def _idf_version_from_cmake():
|
def _idf_version_from_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+)')
|
||||||
@ -240,10 +232,10 @@ def ensure_build_directory(args, prog_name, always_run_cmake=False):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
home_dir = cache['CMAKE_HOME_DIRECTORY']
|
home_dir = cache['CMAKE_HOME_DIRECTORY']
|
||||||
if realpath(home_dir) != realpath(project_dir):
|
if os.path.realpath(home_dir) != os.path.realpath(project_dir):
|
||||||
raise FatalError(
|
raise FatalError(
|
||||||
"Build directory '%s' configured for project '%s' not '%s'. Run '%s fullclean' to start again." %
|
"Build directory '%s' configured for project '%s' not '%s'. Run '%s fullclean' to start again." %
|
||||||
(build_dir, realpath(home_dir), realpath(project_dir), prog_name))
|
(build_dir, os.path.realpath(home_dir), os.path.realpath(project_dir), prog_name))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass # if cmake failed part way, CMAKE_HOME_DIRECTORY may not be set yet
|
pass # if cmake failed part way, CMAKE_HOME_DIRECTORY may not be set yet
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user