Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 15496:f5eba273a4f2
mx: factored out detection of JDT compilation
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 05 May 2014 13:17:32 +0200 |
parents | 5d0dd6a6f6b3 |
children | 1f28c463e452 |
comparison
equal
deleted
inserted
replaced
15495:9c66a589ef63 | 15496:f5eba273a4f2 |
---|---|
1809 | 1809 |
1810 def _defaultEcjPath(): | 1810 def _defaultEcjPath(): |
1811 return get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar')) | 1811 return get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar')) |
1812 | 1812 |
1813 class JavaCompileTask: | 1813 class JavaCompileTask: |
1814 def __init__(self, args, proj, reason, javafilelist, jdk, outputDir, deps): | 1814 def __init__(self, args, proj, reason, javafilelist, jdk, outputDir, jdtJar, deps): |
1815 self.proj = proj | 1815 self.proj = proj |
1816 self.reason = reason | 1816 self.reason = reason |
1817 self.javafilelist = javafilelist | 1817 self.javafilelist = javafilelist |
1818 self.deps = deps | 1818 self.deps = deps |
1819 self.jdk = jdk | 1819 self.jdk = jdk |
1820 self.outputDir = outputDir | 1820 self.outputDir = outputDir |
1821 self.done = False | 1821 self.done = False |
1822 self.jdtJar = jdtJar | |
1822 self.args = args | 1823 self.args = args |
1823 | 1824 |
1824 def __str__(self): | 1825 def __str__(self): |
1825 return self.proj.name | 1826 return self.proj.name |
1826 | 1827 |
1851 outputDir = self.outputDir | 1852 outputDir = self.outputDir |
1852 compliance = str(jdk.javaCompliance) | 1853 compliance = str(jdk.javaCompliance) |
1853 cp = classpath(self.proj.name, includeSelf=True) | 1854 cp = classpath(self.proj.name, includeSelf=True) |
1854 toBeDeleted = [argfileName] | 1855 toBeDeleted = [argfileName] |
1855 | 1856 |
1856 jdtJar = None | |
1857 if not args.javac and args.jdt is not None: | |
1858 if not args.jdt.endswith('.jar'): | |
1859 abort('Path for Eclipse batch compiler does not look like a jar file: ' + args.jdt) | |
1860 jdtJar = args.jdt | |
1861 if not exists(jdtJar): | |
1862 if os.path.abspath(jdtJar) == os.path.abspath(_defaultEcjPath()) and get_env('JDT', None) is None: | |
1863 # Silently ignore JDT if default location is used but does not exist | |
1864 jdtJar = None | |
1865 else: | |
1866 abort('Eclipse batch compiler jar does not exist: ' + args.jdt) | |
1867 | |
1868 try: | 1857 try: |
1869 if not jdtJar: | 1858 if not self.jdtJar: |
1870 mainJava = java() | 1859 mainJava = java() |
1871 if not args.error_prone: | 1860 if not args.error_prone: |
1872 self.logCompilation('javac') | 1861 self.logCompilation('javac') |
1873 javacCmd = [mainJava.javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] | 1862 javacCmd = [mainJava.javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir, '-bootclasspath', jdk.bootclasspath(), '-endorseddirs', jdk.endorseddirs(), '-extdirs', jdk.extdirs()] |
1874 if jdk.debug_port is not None: | 1863 if jdk.debug_port is not None: |
1889 javacArgs.append('-XDignore.symbol.file') | 1878 javacArgs.append('-XDignore.symbol.file') |
1890 run_java(javaArgs + ['-cp', os.pathsep.join([mainJava.toolsjar, args.error_prone]), 'com.google.errorprone.ErrorProneCompiler'] + javacArgs) | 1879 run_java(javaArgs + ['-cp', os.pathsep.join([mainJava.toolsjar, args.error_prone]), 'com.google.errorprone.ErrorProneCompiler'] + javacArgs) |
1891 else: | 1880 else: |
1892 self.logCompilation('JDT') | 1881 self.logCompilation('JDT') |
1893 | 1882 |
1894 jdtVmArgs = ['-Xmx1g', '-jar', jdtJar] | 1883 jdtVmArgs = ['-Xmx1g', '-jar', self.jdtJar] |
1895 | 1884 |
1896 jdtArgs = ['-' + compliance, | 1885 jdtArgs = ['-' + compliance, |
1897 '-cp', cp, '-g', '-enableJavadoc', | 1886 '-cp', cp, '-g', '-enableJavadoc', |
1898 '-d', outputDir, | 1887 '-d', outputDir, |
1899 '-bootclasspath', jdk.bootclasspath(), | 1888 '-bootclasspath', jdk.bootclasspath(), |
1957 compilerSelect = parser.add_mutually_exclusive_group() | 1946 compilerSelect = parser.add_mutually_exclusive_group() |
1958 compilerSelect.add_argument('--error-prone', dest='error_prone', help='path to error-prone.jar', metavar='<path>') | 1947 compilerSelect.add_argument('--error-prone', dest='error_prone', help='path to error-prone.jar', metavar='<path>') |
1959 compilerSelect.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler', default=_defaultEcjPath(), metavar='<path>') | 1948 compilerSelect.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler', default=_defaultEcjPath(), metavar='<path>') |
1960 compilerSelect.add_argument('--force-javac', action='store_true', dest='javac', help='use javac despite ecj.jar is found or not') | 1949 compilerSelect.add_argument('--force-javac', action='store_true', dest='javac', help='use javac despite ecj.jar is found or not') |
1961 | 1950 |
1962 | |
1963 if suppliedParser: | 1951 if suppliedParser: |
1964 parser.add_argument('remainder', nargs=REMAINDER, metavar='...') | 1952 parser.add_argument('remainder', nargs=REMAINDER, metavar='...') |
1965 | 1953 |
1966 args = parser.parse_args(args) | 1954 args = parser.parse_args(args) |
1955 | |
1956 jdtJar = None | |
1957 if not args.javac and args.jdt is not None: | |
1958 if not args.jdt.endswith('.jar'): | |
1959 abort('Path for Eclipse batch compiler does not look like a jar file: ' + args.jdt) | |
1960 jdtJar = args.jdt | |
1961 if not exists(jdtJar): | |
1962 if os.path.abspath(jdtJar) == os.path.abspath(_defaultEcjPath()) and get_env('JDT', None) is None: | |
1963 # Silently ignore JDT if default location is used but does not exist | |
1964 jdtJar = None | |
1965 else: | |
1966 abort('Eclipse batch compiler jar does not exist: ' + args.jdt) | |
1967 | 1967 |
1968 if args.only is not None: | 1968 if args.only is not None: |
1969 # N.B. This build will not include dependencies including annotation processor dependencies | 1969 # N.B. This build will not include dependencies including annotation processor dependencies |
1970 sortedProjects = [project(name) for name in args.only.split(',')] | 1970 sortedProjects = [project(name) for name in args.only.split(',')] |
1971 else: | 1971 else: |
2098 | 2098 |
2099 if len(javafilelist) == 0: | 2099 if len(javafilelist) == 0: |
2100 logv('[no Java sources for {0} - skipping]'.format(p.name)) | 2100 logv('[no Java sources for {0} - skipping]'.format(p.name)) |
2101 continue | 2101 continue |
2102 | 2102 |
2103 task = JavaCompileTask(args, p, buildReason, javafilelist, jdk, outputDir, taskDeps) | 2103 task = JavaCompileTask(args, p, buildReason, javafilelist, jdk, outputDir, jdtJar, taskDeps) |
2104 | 2104 |
2105 if args.parallelize: | 2105 if args.parallelize: |
2106 # Best to initialize class paths on main process | 2106 # Best to initialize class paths on main process |
2107 jdk.bootclasspath() | 2107 jdk.bootclasspath() |
2108 task.proc = None | 2108 task.proc = None |