2017-02-06 22:21:58 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2017-10-08 21:48:29 -04:00
|
|
|
# Wrapper to run make and preprocess any paths in the output from MSYS Unix-style paths
|
2017-02-06 22:21:58 -05:00
|
|
|
# to Windows paths, for Eclipse
|
|
|
|
from __future__ import print_function, division
|
2018-12-04 07:46:48 -05:00
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import os.path
|
|
|
|
import re
|
2017-02-06 22:21:58 -05:00
|
|
|
|
|
|
|
UNIX_PATH_RE = re.compile(r'(/[^ \'"]+)+')
|
|
|
|
|
|
|
|
paths = {}
|
2018-12-04 07:46:48 -05:00
|
|
|
|
|
|
|
|
2017-02-06 22:21:58 -05:00
|
|
|
def check_path(path):
|
|
|
|
try:
|
|
|
|
return paths[path]
|
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
paths[path] = path # cache as failed, replace with success if it works
|
|
|
|
try:
|
2021-02-04 09:21:01 -05:00
|
|
|
winpath = subprocess.check_output(['cygpath', '-w', path]).decode('utf-8').strip()
|
2017-02-06 22:21:58 -05:00
|
|
|
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
|
|
|
|
|
2018-12-04 07:46:48 -05:00
|
|
|
|
2017-02-06 22:21:58 -05:00
|
|
|
def main():
|
|
|
|
print("Running make in '%s'" % check_path(os.getcwd()))
|
2017-02-10 01:38:24 -05:00
|
|
|
make = subprocess.Popen(["make"] + sys.argv[1:] + ["BATCH_BUILD=1"], stdout=subprocess.PIPE)
|
2017-02-06 22:21:58 -05:00
|
|
|
for line in iter(make.stdout.readline, ''):
|
2018-12-04 07:46:48 -05:00
|
|
|
line = re.sub(UNIX_PATH_RE, lambda m: check_path(m.group(0)), line)
|
|
|
|
print(line.rstrip())
|
2017-02-06 22:21:58 -05:00
|
|
|
sys.exit(make.wait())
|
|
|
|
|
2018-12-04 07:46:48 -05:00
|
|
|
|
2017-02-06 22:21:58 -05:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|