Merge branch 'bugfix/idf_py_windows_relpath' into 'master'
idf.py: Fix Windows issue if project and IDF are on different drives Closes IDFGH-478 See merge request idf/esp-idf!4404
This commit is contained in:
commit
f02ceb747e
1 changed files with 13 additions and 2 deletions
15
tools/idf.py
15
tools/idf.py
|
@ -353,6 +353,17 @@ def fullclean(action, args):
|
||||||
os.remove(f)
|
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):
|
def print_closing_message(args):
|
||||||
# print a closing message of some kind
|
# print a closing message of some kind
|
||||||
#
|
#
|
||||||
|
@ -369,7 +380,7 @@ def print_closing_message(args):
|
||||||
flasher_args = json.load(f)
|
flasher_args = json.load(f)
|
||||||
|
|
||||||
def flasher_path(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
|
if key != "project": # flashing a single item
|
||||||
cmd = ""
|
cmd = ""
|
||||||
|
@ -386,7 +397,7 @@ def print_closing_message(args):
|
||||||
cmd += o + " " + flasher_path(f) + " "
|
cmd += o + " " + flasher_path(f) + " "
|
||||||
|
|
||||||
print("%s -p %s -b %s --after %s write_flash %s" % (
|
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.port or "(PORT)",
|
||||||
args.baud,
|
args.baud,
|
||||||
flasher_args["extra_esptool_args"]["after"],
|
flasher_args["extra_esptool_args"]["after"],
|
||||||
|
|
Loading…
Reference in a new issue