OVMS3-idf/tools/windows/eclipse_make.py
Angus Gratton f29768c404 Build system: Add new BATCH_BUILD flag to disable interactive parts of the build
Mostly useful for Eclipse (where accidentally running interactive
config hangs the build), but also good for CI and other automated
build systems.
2017-02-22 11:59:37 +11:00

37 lines
1.2 KiB
Python

#!/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:] + ["BATCH_BUILD=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()