Mercurial > hg > graal-compiler
comparison mx.graal/mx_graal.py @ 22031:434fbaaf53d7
moved findbugs support from mx_graal.py to mx_findbugs.py
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 19 Jun 2015 17:41:45 +0200 |
parents | 9c385c5c412a |
children | 56c50504d60d |
comparison
equal
deleted
inserted
replaced
22030:5b4a974d9ae6 | 22031:434fbaaf53d7 |
---|---|
28 | 28 |
29 import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, StringIO, socket | 29 import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, StringIO, socket |
30 from os.path import join, exists, dirname, basename | 30 from os.path import join, exists, dirname, basename |
31 from argparse import ArgumentParser, REMAINDER | 31 from argparse import ArgumentParser, REMAINDER |
32 from outputparser import OutputParser, ValuesMatcher | 32 from outputparser import OutputParser, ValuesMatcher |
33 import mx | |
34 import mx_unittest | |
35 import xml.dom.minidom | 33 import xml.dom.minidom |
36 import sanitycheck | 34 import sanitycheck |
37 import itertools | 35 import itertools |
38 import json, textwrap | 36 import json, textwrap |
37 | |
38 import mx | |
39 import mx_unittest | |
40 import mx_findbugs | |
39 import mx_graal_makefile | 41 import mx_graal_makefile |
40 | 42 |
41 _suite = mx.suite('graal') | 43 _suite = mx.suite('graal') |
42 _graal_home = _suite.dir | 44 _graal_home = _suite.dir |
43 | 45 |
1521 with Task('Checkheaders', tasks) as t: | 1523 with Task('Checkheaders', tasks) as t: |
1522 if t and checkheaders([]) != 0: | 1524 if t and checkheaders([]) != 0: |
1523 t.abort('Checkheaders warnings were found') | 1525 t.abort('Checkheaders warnings were found') |
1524 | 1526 |
1525 with Task('FindBugs', tasks) as t: | 1527 with Task('FindBugs', tasks) as t: |
1526 if t and findbugs([]) != 0: | 1528 if t and mx_findbugs.findbugs([]) != 0: |
1527 t.abort('FindBugs warnings were found') | 1529 t.abort('FindBugs warnings were found') |
1528 | 1530 |
1529 if exists('jacoco.exec'): | 1531 if exists('jacoco.exec'): |
1530 os.unlink('jacoco.exec') | 1532 os.unlink('jacoco.exec') |
1531 | 1533 |
2252 err=subprocess.STDOUT) | 2254 err=subprocess.STDOUT) |
2253 | 2255 |
2254 valueMap = parser.parse(output.getvalue()) | 2256 valueMap = parser.parse(output.getvalue()) |
2255 return valueMap | 2257 return valueMap |
2256 | 2258 |
2257 def findbugs(args): | |
2258 '''run FindBugs against non-test Java projects''' | |
2259 findBugsHome = mx.get_env('FINDBUGS_HOME', None) | |
2260 if findBugsHome: | |
2261 findbugsJar = join(findBugsHome, 'lib', 'findbugs.jar') | |
2262 else: | |
2263 findbugsLib = join(_graal_home, 'lib', 'findbugs-3.0.0') | |
2264 if not exists(findbugsLib): | |
2265 tmp = tempfile.mkdtemp(prefix='findbugs-download-tmp', dir=_graal_home) | |
2266 try: | |
2267 findbugsDist = mx.library('FINDBUGS_DIST').get_path(resolve=True) | |
2268 with zipfile.ZipFile(findbugsDist) as zf: | |
2269 candidates = [e for e in zf.namelist() if e.endswith('/lib/findbugs.jar')] | |
2270 assert len(candidates) == 1, candidates | |
2271 libDirInZip = os.path.dirname(candidates[0]) | |
2272 zf.extractall(tmp) | |
2273 shutil.copytree(join(tmp, libDirInZip), findbugsLib) | |
2274 finally: | |
2275 shutil.rmtree(tmp) | |
2276 findbugsJar = join(findbugsLib, 'findbugs.jar') | |
2277 assert exists(findbugsJar) | |
2278 nonTestProjects = [p for p in mx.projects() if not p.name.endswith('.test') and not p.name.endswith('.jtt')] | |
2279 outputDirs = map(mx._cygpathU2W, [p.output_dir() for p in nonTestProjects]) | |
2280 javaCompliance = max([p.javaCompliance for p in nonTestProjects]) | |
2281 findbugsResults = join(_graal_home, 'findbugs.results') | |
2282 | |
2283 cmd = ['-jar', mx._cygpathU2W(findbugsJar), '-textui', '-low', '-maxRank', '15'] | |
2284 if mx.is_interactive(): | |
2285 cmd.append('-progress') | |
2286 cmd = cmd + ['-auxclasspath', mx._separatedCygpathU2W(mx.classpath([d.name for d in _jdkDeployedDists] + [p.name for p in nonTestProjects])), '-output', mx._cygpathU2W(findbugsResults), '-exitcode'] + args + outputDirs | |
2287 exitcode = mx.run_java(cmd, nonZeroIsFatal=False, javaConfig=mx.java(javaCompliance)) | |
2288 if exitcode != 0: | |
2289 with open(findbugsResults) as fp: | |
2290 mx.log(fp.read()) | |
2291 os.unlink(findbugsResults) | |
2292 return exitcode | |
2293 | |
2294 def checkheaders(args): | 2259 def checkheaders(args): |
2295 """check Java source headers against any required pattern""" | 2260 """check Java source headers against any required pattern""" |
2296 failures = {} | 2261 failures = {} |
2297 for p in mx.projects(): | 2262 for p in mx.projects(): |
2298 if p.native: | 2263 if p.native: |
2331 'c1visualizer' : [c1visualizer, ''], | 2296 'c1visualizer' : [c1visualizer, ''], |
2332 'checkheaders': [checkheaders, ''], | 2297 'checkheaders': [checkheaders, ''], |
2333 'clean': [clean, ''], | 2298 'clean': [clean, ''], |
2334 'ctw': [ctw, '[-vmoptions|noinline|nocomplex|full]'], | 2299 'ctw': [ctw, '[-vmoptions|noinline|nocomplex|full]'], |
2335 'export': [export, '[-options] [zipfile]'], | 2300 'export': [export, '[-options] [zipfile]'], |
2336 'findbugs': [findbugs, ''], | |
2337 'generateZshCompletion' : [generateZshCompletion, ''], | 2301 'generateZshCompletion' : [generateZshCompletion, ''], |
2338 'hsdis': [hsdis, '[att]'], | 2302 'hsdis': [hsdis, '[att]'], |
2339 'hcfdis': [hcfdis, ''], | 2303 'hcfdis': [hcfdis, ''], |
2340 'igv' : [igv, ''], | 2304 'igv' : [igv, ''], |
2341 'jdkhome': [print_jdkhome, ''], | 2305 'jdkhome': [print_jdkhome, ''], |