feat(bin/linja): return exitcode from ninja and lean

fix #120
This commit is contained in:
Soonho Kong 2014-09-02 09:52:52 -07:00
parent 095d946937
commit 51152b011d

View file

@ -220,11 +220,8 @@ def handle_failure_for_flycheck(out, target):
print "FLYCHECK_BEGIN ERROR" print "FLYCHECK_BEGIN ERROR"
print "%s:1:0: error: failed to compile %s" % (target, failed_file) print "%s:1:0: error: failed to compile %s" % (target, failed_file)
print "FLYCHECK_END" print "FLYCHECK_END"
if failed: if failed:
proc = subprocess.Popen([g_lean_path] + g_lean_options + [target], call_lean(target)
stdout=subprocess.PIPE, stderr=None)
print proc.communicate()[0]
def call_ninja(directory, args): def call_ninja(directory, args):
targets = [] targets = []
@ -246,6 +243,13 @@ def call_ninja(directory, args):
print out print out
if len(args.targets) == 1 and args.targets[0].endswith(".lean"): if len(args.targets) == 1 and args.targets[0].endswith(".lean"):
handle_failure_for_flycheck(out, args.targets[0]) handle_failure_for_flycheck(out, args.targets[0])
return proc.returncode
def call_lean(filename):
proc = subprocess.Popen([g_lean_path] + g_lean_options + [filename],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print proc.communicate()[0]
return proc.returncode
def find_files(directory, pattern): def find_files(directory, pattern):
if "/" in pattern: if "/" in pattern:
@ -338,13 +342,13 @@ def main(argv=None):
if not "clean" in args.targets: if not "clean" in args.targets:
make_deps_all_files(project_dir, args.targets) make_deps_all_files(project_dir, args.targets)
make_build_ninja(project_dir, args.targets) make_build_ninja(project_dir, args.targets)
call_ninja(project_dir, args) return call_ninja(project_dir, args)
else: else:
for file in args.targets: returncode = 0
if os.path.isfile(file) and file.endswith(".lean"): for filename in args.targets:
proc = subprocess.Popen([g_lean_path] + g_lean_options + [file], if os.path.isfile(filename) and filename.endswith(".lean"):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT) returncode |= call_lean(filename)
print proc.communicate()[0] return returncode
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main()) sys.exit(main())