Skip to content

Instantly share code, notes, and snippets.

@swdunlop
Created November 4, 2011 19:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swdunlop/1340255 to your computer and use it in GitHub Desktop.
Save swdunlop/1340255 to your computer and use it in GitHub Desktop.
Runs Apache's ANT, suppressing all errors except compile output. For use with XCode 4
#!/usr/bin/env python
import sys
import re
import subprocess
RULES = [
#'[javac] foo.java:6: cannot find symbol'
[r'^ *\[javac\] ([^:]+:[^:]):(.*)$', '{0}: {1}'],
]
for rule in RULES:
rule[0] = re.compile(rule[0])
def print_simplified_line(line, rules=RULES):
for test, prod in rules:
match = test.match(line)
if not match: continue
if prod:
sys.stdout.write(prod.format(*match.groups()) + '\n')
sys.stdout.flush()
return
def run_simplified_ant(args):
args = ['ant'] + args
proc = subprocess.Popen(args, stdout = subprocess.PIPE, stderr=subprocess.PIPE)
while True:
line = proc.stdout.readline()
if not line: break
print_simplified_line(line)
proc.wait()
sys.exit(proc.returncode)
if __name__ == '__main__':
run_simplified_ant(sys.argv[1:])
@swdunlop
Copy link
Author

swdunlop commented Nov 4, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment