Eclipse: Process Windows paths correctly using cygpath

Includes splitting the Windows Eclipse setup doc into a separate page,
as it has so many additional steps.

Addresses github #17 and #166
https://github.com/espressif/esp-idf/issues/17
https://github.com/espressif/esp-idf/issues/166
This commit is contained in:
Angus Gratton
2017-02-07 14:21:58 +11:00
parent d28ee9a25e
commit 8dede8f8a4
4 changed files with 144 additions and 23 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env python
#
# Wrapper to run make and preprocess any paths in the output from MSYS/Cygwin paths
# to Windows paths, for Eclipse
from __future__ import print_function, division
import sys, subprocess, os.path, re
UNIX_PATH_RE = re.compile(r'(/[^ \'"]+)+')
paths = {}
def check_path(path):
try:
return paths[path]
except KeyError:
pass
paths[path] = path # cache as failed, replace with success if it works
try:
winpath = subprocess.check_output(["cygpath", "-w", path]).strip()
except subprocess.CalledProcessError:
return path # something went wrong running cygpath, assume this is not a path!
if not os.path.exists(winpath):
return path # not actually a valid path
winpath = winpath.replace("\\", "/") # make consistent with forward-slashes used elsewhere
paths[path] = winpath
return winpath
def main():
print("Running make in '%s'" % check_path(os.getcwd()))
make = subprocess.Popen(["make"] + sys.argv[1:] + ["V=1"], stdout=subprocess.PIPE)
for line in iter(make.stdout.readline, ''):
line = re.sub(UNIX_PATH_RE, lambda m: check_path(m.group(0)), line)
print(line.rstrip())
sys.exit(make.wait())
if __name__ == "__main__":
main()
+3 -9
View File
@@ -1,10 +1,4 @@
#!/bin/bash
# A wrapper for make on Windows with Eclipse
#
# Eclipse's output parser expects to see output of the form C:/dir/dir/file but our Make
# process uses MinGW paths of the form /c/dir/dir/file. So parse these out...
#
# A little hacky as it looks for any single character of form /X/something.
#
echo "Running make in $(pwd)"
make $@ V=1 | sed -E "s@/([a-z])/([^/+])@\1:/\2@g"
echo "eclipse_make.sh has been replaced with eclipse_make.py. Check the Windows Eclipse docs for the new command."
echo "This shell script will continue to work until the next major release."
python ${IDF_PATH}/tools/windows/eclipse_make.py $@