Mercurial > hg > truffle
comparison mxtool/mx.py @ 15386:1439685d06e4
mx: log reason why Java classes are being (re)built
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 25 Apr 2014 14:43:56 +0200 |
parents | dea98caac669 |
children | 5dcf0ae606f3 a9df38ce8fb7 |
comparison
equal
deleted
inserted
replaced
15385:63aad7e1c867 | 15386:1439685d06e4 |
---|---|
1886 | 1886 |
1887 outputDir = prepareOutputDirs(p, args.clean) | 1887 outputDir = prepareOutputDirs(p, args.clean) |
1888 | 1888 |
1889 cp = classpath(p.name, includeSelf=True) | 1889 cp = classpath(p.name, includeSelf=True) |
1890 sourceDirs = p.source_dirs() | 1890 sourceDirs = p.source_dirs() |
1891 mustBuild = args.force | 1891 buildReason = 'forced build' if args.force else None |
1892 if not mustBuild: | 1892 if not buildReason: |
1893 for dep in p.all_deps([], False): | 1893 for dep in p.all_deps([], False): |
1894 if dep.name in built: | 1894 if dep.name in built: |
1895 mustBuild = True | 1895 buildReason = dep.name + ' rebuilt' |
1896 | |
1897 | 1896 |
1898 jasminAvailable = None | 1897 jasminAvailable = None |
1899 javafilelist = [] | 1898 javafilelist = [] |
1900 for sourceDir in sourceDirs: | 1899 for sourceDir in sourceDirs: |
1901 for root, _, files in os.walk(sourceDir): | 1900 for root, _, files in os.walk(sourceDir): |
1940 if not exists(dirname(dst)): | 1939 if not exists(dirname(dst)): |
1941 os.makedirs(dirname(dst)) | 1940 os.makedirs(dirname(dst)) |
1942 if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) < os.path.getmtime(src)): | 1941 if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) < os.path.getmtime(src)): |
1943 shutil.copyfile(src, dst) | 1942 shutil.copyfile(src, dst) |
1944 | 1943 |
1945 if not mustBuild: | 1944 if not buildReason: |
1946 for javafile in javafiles: | 1945 for javafile in javafiles: |
1947 classfile = TimeStampFile(outputDir + javafile[len(sourceDir):-len('java')] + 'class') | 1946 classfile = TimeStampFile(outputDir + javafile[len(sourceDir):-len('java')] + 'class') |
1948 if not classfile.exists() or classfile.isOlderThan(javafile): | 1947 if not classfile.exists() or classfile.isOlderThan(javafile): |
1949 mustBuild = True | 1948 buildReason = 'class file(s) out of date' |
1950 break | 1949 break |
1951 | 1950 |
1952 aps = p.annotation_processors() | 1951 aps = p.annotation_processors() |
1953 apsOutOfDate = p.update_current_annotation_processors_file() | 1952 apsOutOfDate = p.update_current_annotation_processors_file() |
1954 if apsOutOfDate: | 1953 if apsOutOfDate: |
1955 logv('[annotation processors for {0} changed]'.format(p.name)) | 1954 buildReason = 'annotation processor(s) changed' |
1956 mustBuild = True | 1955 |
1957 | 1956 if not buildReason: |
1958 if not mustBuild: | |
1959 logv('[all class files for {0} are up to date - skipping]'.format(p.name)) | 1957 logv('[all class files for {0} are up to date - skipping]'.format(p.name)) |
1960 continue | 1958 continue |
1961 | 1959 |
1962 if len(javafilelist) == 0: | 1960 if len(javafilelist) == 0: |
1963 logv('[no Java sources for {0} - skipping]'.format(p.name)) | 1961 logv('[no Java sources for {0} - skipping]'.format(p.name)) |
1985 else: | 1983 else: |
1986 processorArgs += ['-proc:none'] | 1984 processorArgs += ['-proc:none'] |
1987 | 1985 |
1988 toBeDeleted = [argfileName] | 1986 toBeDeleted = [argfileName] |
1989 try: | 1987 try: |
1988 | |
1989 def logCompilation(p, compiler, reason): | |
1990 log('Compiling Java sources for {} with {}... [{}]'.format(p.name, compiler, reason)) | |
1991 | |
1990 if not jdtJar: | 1992 if not jdtJar: |
1991 mainJava = java() | 1993 mainJava = java() |
1992 if not args.error_prone: | 1994 if not args.error_prone: |
1993 log('Compiling Java sources for {0} with javac...'.format(p.name)) | 1995 logCompilation(p, 'javac', buildReason) |
1994 javacCmd = [mainJava.javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] | 1996 javacCmd = [mainJava.javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] |
1995 if jdk.debug_port is not None: | 1997 if jdk.debug_port is not None: |
1996 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] | 1998 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] |
1997 javacCmd += processorArgs | 1999 javacCmd += processorArgs |
1998 javacCmd += ['@' + argfile.name] | 2000 javacCmd += ['@' + argfile.name] |
1999 | 2001 |
2000 if not args.warnAPI: | 2002 if not args.warnAPI: |
2001 javacCmd.append('-XDignore.symbol.file') | 2003 javacCmd.append('-XDignore.symbol.file') |
2002 run(javacCmd) | 2004 run(javacCmd) |
2003 else: | 2005 else: |
2004 log('Compiling Java sources for {0} with javac (with error-prone)...'.format(p.name)) | 2006 logCompilation(p, 'javac (with error-prone)', buildReason) |
2005 javaArgs = ['-Xmx1g'] | 2007 javaArgs = ['-Xmx1g'] |
2006 javacArgs = ['-g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] | 2008 javacArgs = ['-g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] |
2007 javacArgs += processorArgs | 2009 javacArgs += processorArgs |
2008 javacArgs += ['@' + argfile.name] | 2010 javacArgs += ['@' + argfile.name] |
2009 if not args.warnAPI: | 2011 if not args.warnAPI: |
2010 javacArgs.append('-XDignore.symbol.file') | 2012 javacArgs.append('-XDignore.symbol.file') |
2011 run_java(javaArgs + ['-cp', os.pathsep.join([mainJava.toolsjar, args.error_prone]), 'com.google.errorprone.ErrorProneCompiler'] + javacArgs) | 2013 run_java(javaArgs + ['-cp', os.pathsep.join([mainJava.toolsjar, args.error_prone]), 'com.google.errorprone.ErrorProneCompiler'] + javacArgs) |
2012 else: | 2014 else: |
2013 log('Compiling Java sources for {0} with JDT...'.format(p.name)) | 2015 logCompilation(p, 'JDT', buildReason) |
2014 | 2016 |
2015 jdtVmArgs = ['-Xmx1g', '-jar', jdtJar] | 2017 jdtVmArgs = ['-Xmx1g', '-jar', jdtJar] |
2016 | 2018 |
2017 jdtArgs = ['-' + compliance, | 2019 jdtArgs = ['-' + compliance, |
2018 '-cp', cp, '-g', '-enableJavadoc', | 2020 '-cp', cp, '-g', '-enableJavadoc', |