mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
idf.py: Fix Windows issue if project and IDF are on different drives
Closes https://github.com/espressif/esp-idf/issues/2753
This commit is contained in:
parent
de7daa14a9
commit
4a575d5449
15
tools/idf.py
15
tools/idf.py
@ -353,6 +353,17 @@ def fullclean(action, args):
|
||||
os.remove(f)
|
||||
|
||||
|
||||
def _safe_relpath(path, start=None):
|
||||
""" Return a relative path, same as os.path.relpath, but only if this is possible.
|
||||
|
||||
It is not possible on Windows, if the start directory and the path are on different drives.
|
||||
"""
|
||||
try:
|
||||
return os.path.relpath(path, os.curdir if start is None else start)
|
||||
except ValueError:
|
||||
return os.path.abspath(path)
|
||||
|
||||
|
||||
def print_closing_message(args):
|
||||
# print a closing message of some kind
|
||||
#
|
||||
@ -369,7 +380,7 @@ def print_closing_message(args):
|
||||
flasher_args = json.load(f)
|
||||
|
||||
def flasher_path(f):
|
||||
return os.path.relpath(os.path.join(args.build_dir, f))
|
||||
return _safe_relpath(os.path.join(args.build_dir, f))
|
||||
|
||||
if key != "project": # flashing a single item
|
||||
cmd = ""
|
||||
@ -386,7 +397,7 @@ def print_closing_message(args):
|
||||
cmd += o + " " + flasher_path(f) + " "
|
||||
|
||||
print("%s -p %s -b %s --after %s write_flash %s" % (
|
||||
os.path.relpath("%s/components/esptool_py/esptool/esptool.py" % os.environ["IDF_PATH"]),
|
||||
_safe_relpath("%s/components/esptool_py/esptool/esptool.py" % os.environ["IDF_PATH"]),
|
||||
args.port or "(PORT)",
|
||||
args.baud,
|
||||
flasher_args["extra_esptool_args"]["after"],
|
||||
|
Loading…
Reference in New Issue
Block a user