Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 10059:4dada3ec9c58
mx checkstyle command no longer exits on first error
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 15 Jun 2013 21:27:14 +0200 |
parents | 440661cc7908 |
children | 193d5163a94a |
comparison
equal
deleted
inserted
replaced
10058:440661cc7908 | 10059:4dada3ec9c58 |
---|---|
1447 # skip building this Java project if its Java compliance level is "higher" than the configured JDK | 1447 # skip building this Java project if its Java compliance level is "higher" than the configured JDK |
1448 if javaCompliance < p.javaCompliance: | 1448 if javaCompliance < p.javaCompliance: |
1449 log('Excluding {0} from build (Java compliance level {1} required)'.format(p.name, p.javaCompliance)) | 1449 log('Excluding {0} from build (Java compliance level {1} required)'.format(p.name, p.javaCompliance)) |
1450 continue | 1450 continue |
1451 | 1451 |
1452 | |
1453 outputDir = p.output_dir() | 1452 outputDir = p.output_dir() |
1454 if exists(outputDir): | 1453 if exists(outputDir): |
1455 if args.clean: | 1454 if args.clean: |
1456 log('Cleaning {0}...'.format(outputDir)) | 1455 log('Cleaning {0}...'.format(outputDir)) |
1457 shutil.rmtree(outputDir) | 1456 shutil.rmtree(outputDir) |
1847 """run Checkstyle on the Java sources | 1846 """run Checkstyle on the Java sources |
1848 | 1847 |
1849 Run Checkstyle over the Java sources. Any errors or warnings | 1848 Run Checkstyle over the Java sources. Any errors or warnings |
1850 produced by Checkstyle result in a non-zero exit code.""" | 1849 produced by Checkstyle result in a non-zero exit code.""" |
1851 | 1850 |
1851 parser = ArgumentParser(prog='mx checkstyle') | |
1852 | |
1853 parser.add_argument('-f', action='store_true', dest='force', help='force checking (disables timestamp checking)') | |
1854 args = parser.parse_args(args) | |
1855 | |
1856 totalErrors = 0 | |
1852 for p in sorted_deps(): | 1857 for p in sorted_deps(): |
1853 if p.native: | 1858 if p.native: |
1854 continue | 1859 continue |
1855 sourceDirs = p.source_dirs() | 1860 sourceDirs = p.source_dirs() |
1856 dotCheckstyle = join(p.dir, '.checkstyle') | 1861 dotCheckstyle = join(p.dir, '.checkstyle') |
1868 | 1873 |
1869 timestampFile = join(p.suite.dir, 'mx', 'checkstyle-timestamps', sourceDir[len(p.suite.dir) + 1:].replace(os.sep, '_') + '.timestamp') | 1874 timestampFile = join(p.suite.dir, 'mx', 'checkstyle-timestamps', sourceDir[len(p.suite.dir) + 1:].replace(os.sep, '_') + '.timestamp') |
1870 if not exists(dirname(timestampFile)): | 1875 if not exists(dirname(timestampFile)): |
1871 os.makedirs(dirname(timestampFile)) | 1876 os.makedirs(dirname(timestampFile)) |
1872 mustCheck = False | 1877 mustCheck = False |
1873 if exists(timestampFile): | 1878 if not args.force and exists(timestampFile): |
1874 timestamp = os.path.getmtime(timestampFile) | 1879 timestamp = os.path.getmtime(timestampFile) |
1875 for f in javafilelist: | 1880 for f in javafilelist: |
1876 if os.path.getmtime(f) > timestamp: | 1881 if os.path.getmtime(f) > timestamp: |
1877 mustCheck = True | 1882 mustCheck = True |
1878 break | 1883 break |
1879 else: | 1884 else: |
1880 mustCheck = True | 1885 mustCheck = True |
1881 | 1886 |
1882 if not mustCheck: | 1887 if not mustCheck: |
1883 log('[all Java sources in {0} already checked - skipping]'.format(sourceDir)) | 1888 if _opts.verbose: |
1889 log('[all Java sources in {0} already checked - skipping]'.format(sourceDir)) | |
1884 continue | 1890 continue |
1885 | 1891 |
1886 dotCheckstyleXML = xml.dom.minidom.parse(dotCheckstyle) | 1892 dotCheckstyleXML = xml.dom.minidom.parse(dotCheckstyle) |
1887 localCheckConfig = dotCheckstyleXML.getElementsByTagName('local-check-config')[0] | 1893 localCheckConfig = dotCheckstyleXML.getElementsByTagName('local-check-config')[0] |
1888 configLocation = localCheckConfig.getAttribute('location') | 1894 configLocation = localCheckConfig.getAttribute('location') |
1938 break | 1944 break |
1939 | 1945 |
1940 batch = javafilelist[:i] | 1946 batch = javafilelist[:i] |
1941 javafilelist = javafilelist[i:] | 1947 javafilelist = javafilelist[i:] |
1942 try: | 1948 try: |
1943 run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-f', 'xml', '-c', config, '-o', auditfileName] + batch) | 1949 run_java(['-Xmx1g', '-jar', library('CHECKSTYLE').get_path(True), '-f', 'xml', '-c', config, '-o', auditfileName] + batch, nonZeroIsFatal=False) |
1944 finally: | 1950 finally: |
1945 if exists(auditfileName): | 1951 if exists(auditfileName): |
1946 errors = [] | 1952 errors = [] |
1947 source = None | 1953 source = None |
1948 def start_element(name, attrs): | 1954 def start_element(name, attrs): |
1956 p.StartElementHandler = start_element | 1962 p.StartElementHandler = start_element |
1957 with open(auditfileName) as fp: | 1963 with open(auditfileName) as fp: |
1958 p.ParseFile(fp) | 1964 p.ParseFile(fp) |
1959 if len(errors) != 0: | 1965 if len(errors) != 0: |
1960 map(log, errors) | 1966 map(log, errors) |
1961 return len(errors) | 1967 totalErrors = totalErrors + len(errors) |
1962 else: | 1968 else: |
1963 if exists(timestampFile): | 1969 if exists(timestampFile): |
1964 os.utime(timestampFile, None) | 1970 os.utime(timestampFile, None) |
1965 else: | 1971 else: |
1966 file(timestampFile, 'a') | 1972 file(timestampFile, 'a') |
1967 finally: | 1973 finally: |
1968 if exists(auditfileName): | 1974 if exists(auditfileName): |
1969 os.unlink(auditfileName) | 1975 os.unlink(auditfileName) |
1970 return 0 | 1976 return totalErrors |
1971 | 1977 |
1972 def clean(args, parser=None): | 1978 def clean(args, parser=None): |
1973 """remove all class files, images, and executables | 1979 """remove all class files, images, and executables |
1974 | 1980 |
1975 Removes all files created by a build, including Java class files, executables, and | 1981 Removes all files created by a build, including Java class files, executables, and |