Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 7291:a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 21 Dec 2012 10:44:31 -0800 |
parents | f938212e56ab |
children | 4974776828ec |
comparison
equal
deleted
inserted
replaced
7290:a81db08fe930 | 7291:a748e4d44694 |
---|---|
186 os.mkdir(dir) | 186 os.mkdir(dir) |
187 for s in self.source_dirs(): | 187 for s in self.source_dirs(): |
188 if not exists(s): | 188 if not exists(s): |
189 os.mkdir(s) | 189 os.mkdir(s) |
190 | 190 |
191 def all_deps(self, deps, includeLibs, includeSelf=True): | 191 def all_deps(self, deps, includeLibs, includeSelf=True, includeAnnotationProcessors=False): |
192 """ | 192 """ |
193 Add the transitive set of dependencies for this project, including | 193 Add the transitive set of dependencies for this project, including |
194 libraries if 'includeLibs' is true, to the 'deps' list. | 194 libraries if 'includeLibs' is true, to the 'deps' list. |
195 """ | 195 """ |
196 childDeps = list(self.deps) | |
197 if includeAnnotationProcessors and hasattr(self, 'annotationProcessors') and len(self.annotationProcessors) > 0: | |
198 childDeps = self.annotationProcessors + childDeps | |
196 if self in deps: | 199 if self in deps: |
197 return deps | 200 return deps |
198 for name in self.deps: | 201 for name in childDeps: |
199 assert name != self.name | 202 assert name != self.name |
200 dep = _libs.get(name, None) | 203 dep = _libs.get(name, None) |
201 if dep is not None: | 204 if dep is not None: |
202 if includeLibs and not dep in deps: | 205 if includeLibs and not dep in deps: |
203 deps.append(dep) | 206 deps.append(dep) |
206 if dep is None: | 209 if dep is None: |
207 if name in _opts.ignored_projects: | 210 if name in _opts.ignored_projects: |
208 abort('project named ' + name + ' required by ' + self.name + ' is ignored') | 211 abort('project named ' + name + ' required by ' + self.name + ' is ignored') |
209 abort('dependency named ' + name + ' required by ' + self.name + ' is not found') | 212 abort('dependency named ' + name + ' required by ' + self.name + ' is not found') |
210 if not dep in deps: | 213 if not dep in deps: |
211 dep.all_deps(deps, includeLibs) | 214 dep.all_deps(deps, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
212 if not self in deps and includeSelf: | 215 if not self in deps and includeSelf: |
213 deps.append(self) | 216 deps.append(self) |
214 return deps | 217 return deps |
215 | 218 |
216 def _compute_max_dep_distances(self, name, distances, dist): | 219 def _compute_max_dep_distances(self, name, distances, dist): |
462 | 465 |
463 for name, attrs in projsMap.iteritems(): | 466 for name, attrs in projsMap.iteritems(): |
464 srcDirs = pop_list(attrs, 'sourceDirs') | 467 srcDirs = pop_list(attrs, 'sourceDirs') |
465 deps = pop_list(attrs, 'dependencies') | 468 deps = pop_list(attrs, 'dependencies') |
466 ap = pop_list(attrs, 'annotationProcessors') | 469 ap = pop_list(attrs, 'annotationProcessors') |
467 deps += ap | 470 #deps += ap |
468 javaCompliance = attrs.pop('javaCompliance', None) | 471 javaCompliance = attrs.pop('javaCompliance', None) |
469 subDir = attrs.pop('subDir', None); | 472 subDir = attrs.pop('subDir', None); |
470 if subDir is None: | 473 if subDir is None: |
471 dir = join(self.dir, name) | 474 dir = join(self.dir, name) |
472 else: | 475 else: |
476 p.native = attrs.pop('native', '') == 'true' | 479 p.native = attrs.pop('native', '') == 'true' |
477 if not p.native and p.javaCompliance is None: | 480 if not p.native and p.javaCompliance is None: |
478 abort('javaCompliance property required for non-native project ' + name) | 481 abort('javaCompliance property required for non-native project ' + name) |
479 if len(ap) > 0: | 482 if len(ap) > 0: |
480 p.annotationProcessors = ap | 483 p.annotationProcessors = ap |
481 apc = pop_list(attrs, 'annotationProcessorClasses') | |
482 if len(apc) > 0: | |
483 p.annotationProcessorClasses = apc | |
484 p.__dict__.update(attrs) | 484 p.__dict__.update(attrs) |
485 self.projects.append(p) | 485 self.projects.append(p) |
486 | 486 |
487 for name, attrs in libsMap.iteritems(): | 487 for name, attrs in libsMap.iteritems(): |
488 path = attrs.pop('path') | 488 path = attrs.pop('path') |
727 with zipfile.ZipFile(entry, 'r') as zf: | 727 with zipfile.ZipFile(entry, 'r') as zf: |
728 for zi in zf.infolist(): | 728 for zi in zf.infolist(): |
729 entryPath = zi.filename | 729 entryPath = zi.filename |
730 yield zf, entryPath | 730 yield zf, entryPath |
731 | 731 |
732 def sorted_deps(projectNames=None, includeLibs=False): | 732 def sorted_deps(projectNames=None, includeLibs=False, includeAnnotationProcessors=False): |
733 """ | 733 """ |
734 Gets projects and libraries sorted such that dependencies | 734 Gets projects and libraries sorted such that dependencies |
735 are before the projects that depend on them. Unless 'includeLibs' is | 735 are before the projects that depend on them. Unless 'includeLibs' is |
736 true, libraries are omitted from the result. | 736 true, libraries are omitted from the result. |
737 """ | 737 """ |
740 projects = _projects.values() | 740 projects = _projects.values() |
741 else: | 741 else: |
742 projects = [project(name) for name in projectNames] | 742 projects = [project(name) for name in projectNames] |
743 | 743 |
744 for p in projects: | 744 for p in projects: |
745 p.all_deps(deps, includeLibs) | 745 p.all_deps(deps, includeLibs=includeLibs, includeAnnotationProcessors=includeAnnotationProcessors) |
746 return deps | 746 return deps |
747 | 747 |
748 class ArgParser(ArgumentParser): | 748 class ArgParser(ArgumentParser): |
749 | 749 |
750 # Override parent to append the list of available commands | 750 # Override parent to append the list of available commands |
1294 projects = args.projects.split(',') | 1294 projects = args.projects.split(',') |
1295 | 1295 |
1296 if args.only is not None: | 1296 if args.only is not None: |
1297 sortedProjects = [project(name) for name in args.only.split(',')] | 1297 sortedProjects = [project(name) for name in args.only.split(',')] |
1298 else: | 1298 else: |
1299 sortedProjects = sorted_deps(projects) | 1299 sortedProjects = sorted_deps(projects, includeAnnotationProcessors=True) |
1300 | 1300 |
1301 for p in sortedProjects: | 1301 for p in sortedProjects: |
1302 if p.native: | 1302 if p.native: |
1303 if args.native: | 1303 if args.native: |
1304 log('Calling GNU make {0}...'.format(p.dir)) | 1304 log('Calling GNU make {0}...'.format(p.dir)) |
1378 | 1378 |
1379 else: | 1379 else: |
1380 log('could not file .class directive in Jasmin source: ' + src) | 1380 log('could not file .class directive in Jasmin source: ' + src) |
1381 else: | 1381 else: |
1382 dst = join(outputDir, src[len(sourceDir) + 1:]) | 1382 dst = join(outputDir, src[len(sourceDir) + 1:]) |
1383 if not exists(dirname(dst)): | |
1384 os.makedirs(dirname(dst)) | |
1383 if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) != os.path.getmtime(src)): | 1385 if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) != os.path.getmtime(src)): |
1384 shutil.copyfile(src, dst) | 1386 shutil.copyfile(src, dst) |
1385 | 1387 |
1386 if not mustBuild: | 1388 if not mustBuild: |
1387 for javafile in javafiles: | 1389 for javafile in javafiles: |
1408 javacArgs = [] | 1410 javacArgs = [] |
1409 if java().debug_port is not None: | 1411 if java().debug_port is not None: |
1410 javacArgs += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] | 1412 javacArgs += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] |
1411 | 1413 |
1412 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 1414 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: |
1413 annotationProcessors = [] | 1415 processorPath = classpath(p.annotationProcessors, resolve=True) |
1414 for apProject in p.annotationProcessors: | |
1415 apClasses = project(apProject).annotationProcessorClasses | |
1416 if len(apClasses) == 0: | |
1417 abort("Project " + p + " specifies " + apProject + " as an annotation processor but " + apProject + " does not specifiy any annotation processor class") | |
1418 annotationProcessors += apClasses | |
1419 | |
1420 genDir = p.source_gen_dir(); | 1416 genDir = p.source_gen_dir(); |
1421 if exists(genDir): | 1417 if exists(genDir): |
1422 shutil.rmtree(genDir) | 1418 shutil.rmtree(genDir) |
1423 os.mkdir(genDir) | 1419 os.mkdir(genDir) |
1424 javacArgs += ['-processor', ",".join(annotationProcessors), "-s", genDir] | 1420 javacArgs += ['-processorpath', join(processorPath), '-s', genDir] |
1425 else: | 1421 else: |
1426 javacArgs += ['-proc:none'] | 1422 javacArgs += ['-proc:none'] |
1427 | 1423 |
1428 toBeDeleted = [argfileName] | 1424 toBeDeleted = [argfileName] |
1429 try: | 1425 try: |
1465 | 1461 |
1466 if suppliedParser: | 1462 if suppliedParser: |
1467 return args | 1463 return args |
1468 return None | 1464 return None |
1469 | 1465 |
1470 def processorjars(args): | 1466 def processorjars(): |
1471 hasProcessorJars = [] | 1467 projects = set([]) |
1472 | 1468 |
1473 for p in sorted_deps(): | 1469 for p in sorted_deps(): |
1474 if hasattr(p, 'annotationProcessorClasses') and len(p.annotationProcessorClasses) > 0: | 1470 if _needsEclipseJarBuild(p): |
1475 hasProcessorJars.append(p) | 1471 projects.add(p) |
1476 | 1472 |
1477 if len(hasProcessorJars) <= 0: | 1473 if len(projects) <= 0: |
1478 return | 1474 return |
1479 | 1475 |
1480 build(['--projects', ",".join(map(lambda p: p.name, hasProcessorJars))]) | 1476 build(['--projects', ",".join(map(lambda p: p.name, projects))]) |
1481 | 1477 |
1482 for p in hasProcessorJars: | 1478 for p in projects: |
1483 spDir = join(p.output_dir(), 'META-INF', 'services') | 1479 targetJar = join(p.dir, p.name + '.jar') |
1484 if not exists(spDir): | 1480 jar(targetJar, [p.output_dir()]) |
1485 os.makedirs(spDir) | |
1486 spFile = join(spDir, 'javax.annotation.processing.Processor') | |
1487 with open(spFile, 'w') as fp: | |
1488 fp.writelines(p.annotationProcessorClasses) | |
1489 created = False | |
1490 for dep in p.all_deps([], False): | |
1491 if created: | |
1492 cmd = 'uf' | |
1493 else: | |
1494 cmd = 'cf' | |
1495 created = True | |
1496 jarCmd = [java().jar, cmd, join(p.dir, p.name + 'AnnotationProcessor.jar'), '-C', dep.output_dir(), '.'] | |
1497 subprocess.check_call(jarCmd) | |
1498 log('added ' + dep.name + ' to ' + p.name + '.jar'); | |
1499 | 1481 |
1482 | |
1483 def jar(destFileName, dirs): | |
1484 lib = library("ANT_JAR_TOOL", fatalIfMissing=False) | |
1485 | |
1486 if lib is None : | |
1487 log('No library ANT_JAR_TOOL defined. Falling back to JDK Jar tool.'); | |
1488 _java_jar_tool(destFileName, dirs) | |
1489 else: | |
1490 _ant_jar_tool(lib, destFileName, dirs) | |
1491 | |
1492 def _java_jar_tool(destFileName, dirs): | |
1493 created = False | |
1494 for directory in dirs: | |
1495 if created: | |
1496 cmd = 'uf' | |
1497 else: | |
1498 cmd = 'cf' | |
1499 created = True | |
1500 jarCmd = [java().jar, cmd, destFileName, '-C', directory, '.'] | |
1501 subprocess.check_call(jarCmd) | |
1502 | |
1503 def _ant_jar_tool(lib, destFileName, dirs): | |
1504 antJar = lib.get_path(True) | |
1505 | |
1506 jarCmd = [java().java, '-jar', antJar, destFileName] | |
1507 for directory in dirs : | |
1508 jarCmd.append(directory) | |
1509 | |
1510 subprocess.check_call(jarCmd) | |
1511 | |
1500 | 1512 |
1501 def canonicalizeprojects(args): | 1513 def canonicalizeprojects(args): |
1502 """process all project files to canonicalize the dependencies | 1514 """process all project files to canonicalize the dependencies |
1503 | 1515 |
1504 The exit code of this command reflects how many files were updated.""" | 1516 The exit code of this command reflects how many files were updated.""" |
1864 """(re)generate Eclipse project configurations""" | 1876 """(re)generate Eclipse project configurations""" |
1865 | 1877 |
1866 if suite is None: | 1878 if suite is None: |
1867 suite = _mainSuite | 1879 suite = _mainSuite |
1868 | 1880 |
1869 processorjars([]) | 1881 processorjars() |
1870 | 1882 |
1871 for p in projects(): | 1883 for p in projects(): |
1872 if p.native: | 1884 if p.native: |
1873 continue | 1885 continue |
1874 | 1886 |
1881 for src in p.srcDirs: | 1893 for src in p.srcDirs: |
1882 srcDir = join(p.dir, src) | 1894 srcDir = join(p.dir, src) |
1883 if not exists(srcDir): | 1895 if not exists(srcDir): |
1884 os.mkdir(srcDir) | 1896 os.mkdir(srcDir) |
1885 out.element('classpathentry', {'kind' : 'src', 'path' : src}) | 1897 out.element('classpathentry', {'kind' : 'src', 'path' : src}) |
1898 | |
1899 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | |
1900 genDir = p.source_gen_dir(); | |
1901 if exists(genDir): | |
1902 shutil.rmtree(genDir) | |
1903 os.mkdir(genDir) | |
1904 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) | |
1886 | 1905 |
1887 # Every Java program depends on the JRE | 1906 # Every Java program depends on the JRE |
1888 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER'}) | 1907 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER'}) |
1889 | 1908 |
1890 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | 1909 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project |
1973 for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']: | 1992 for buildCommand in ['org.eclipse.pde.ManifestBuilder', 'org.eclipse.pde.SchemaBuilder']: |
1974 out.open('buildCommand') | 1993 out.open('buildCommand') |
1975 out.element('name', data=buildCommand) | 1994 out.element('name', data=buildCommand) |
1976 out.element('arguments', data='') | 1995 out.element('arguments', data='') |
1977 out.close('buildCommand') | 1996 out.close('buildCommand') |
1997 | |
1998 if (_needsEclipseJarBuild(p)): | |
1999 out.open('buildCommand') | |
2000 out.element('name', data='org.eclipse.ui.externaltools.ExternalToolBuilder') | |
2001 out.element('triggers', data='auto,full,incremental,') | |
2002 out.open('arguments') | |
2003 out.open('dictionary') | |
2004 out.element('key', data = 'LaunchConfigHandle') | |
2005 out.element('value', data = _genEclipseJarBuild(p)) | |
2006 out.close('dictionary') | |
2007 out.open('dictionary') | |
2008 out.element('key', data = 'incclean') | |
2009 out.element('value', data = 'true') | |
2010 out.close('dictionary') | |
2011 out.close('arguments') | |
2012 out.close('buildCommand') | |
2013 | |
1978 out.close('buildSpec') | 2014 out.close('buildSpec') |
1979 out.open('natures') | 2015 out.open('natures') |
1980 out.element('nature', data='org.eclipse.jdt.core.javanature') | 2016 out.element('nature', data='org.eclipse.jdt.core.javanature') |
1981 if exists(csConfig): | 2017 if exists(csConfig): |
1982 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature') | 2018 out.element('nature', data='net.sf.eclipsecs.core.CheckstyleNature') |
2008 out = XMLDoc() | 2044 out = XMLDoc() |
2009 out.open('factorypath') | 2045 out.open('factorypath') |
2010 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | 2046 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
2011 for ap in p.annotationProcessors: | 2047 for ap in p.annotationProcessors: |
2012 apProject = project(ap) | 2048 apProject = project(ap) |
2013 out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + apProject.name + '/' + apProject.name + 'AnnotationProcessor.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | 2049 out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + apProject.name + '/' + apProject.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
2014 for dep in apProject.all_deps([], True): | 2050 for dep in apProject.all_deps([], True): |
2015 if dep.isLibrary(): | 2051 if dep.isLibrary(): |
2016 if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'): | 2052 if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'): |
2017 if dep.mustExist: | 2053 if dep.mustExist: |
2018 path = dep.get_path(resolve=True) | 2054 path = dep.get_path(resolve=True) |
2020 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse | 2056 # Relative paths for "lib" class path entries have various semantics depending on the Eclipse |
2021 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's | 2057 # version being used (e.g. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737) so it's |
2022 # safest to simply use absolute paths. | 2058 # safest to simply use absolute paths. |
2023 path = join(suite.dir, path) | 2059 path = join(suite.dir, path) |
2024 out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : path, 'enabled' : 'true', 'runInBatchMode' : 'false'}) | 2060 out.element('factorypathentry', {'kind' : 'EXTJAR', 'id' : path, 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
2061 else: | |
2062 out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + dep.name + '/' + dep.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | |
2025 out.close('factorypath') | 2063 out.close('factorypath') |
2026 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) | 2064 update_file(join(p.dir, '.factorypath'), out.xml(indent='\t', newl='\n')) |
2027 | 2065 |
2028 make_eclipse_attach('localhost', '8000', deps=projects()) | 2066 make_eclipse_attach('localhost', '8000', deps=projects()) |
2067 | |
2068 | |
2069 def _needsEclipseJarBuild(p): | |
2070 processors = set([]) | |
2071 | |
2072 for otherProject in projects(): | |
2073 if hasattr(otherProject, 'annotationProcessors') and len(otherProject.annotationProcessors) > 0: | |
2074 for processorName in otherProject.annotationProcessors: | |
2075 processors.add(project(processorName, fatalIfMissing=True)) | |
2076 | |
2077 if p in processors: | |
2078 return True | |
2079 | |
2080 for otherProject in processors: | |
2081 deps = otherProject.all_deps([], True) | |
2082 if p in deps: | |
2083 return True | |
2084 | |
2085 return False | |
2086 | |
2087 def _genEclipseJarBuild(p): | |
2088 externalToolDir = '.externalToolBuilders' | |
2089 relPath = join(externalToolDir, 'Jar.launch') | |
2090 absPath = join(p.dir, relPath) | |
2091 | |
2092 if not exists(join(p.dir, externalToolDir)): | |
2093 os.makedirs(join(p.dir, externalToolDir)) | |
2094 | |
2095 antOut = XMLDoc() | |
2096 antOut.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'}) | |
2097 antOut.open('target', {'name' : 'default'}) | |
2098 antOut.open('jar', {'destfile' : p.name + '.jar'}) | |
2099 antOut.element('fileset', {'dir' : p.output_dir()}) | |
2100 antOut.close('jar') | |
2101 antOut.close('target') | |
2102 antOut.close('project') | |
2103 | |
2104 update_file(join(p.dir, 'eclipse-build.xml'), antOut.xml(indent='\t', newl='\n')) | |
2105 | |
2106 launchOut = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
2107 <launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> | |
2108 <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> | |
2109 <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> | |
2110 <booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/> | |
2111 <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/""" + p.name + """" type="4"/> </resources>}"/> | |
2112 <booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/> | |
2113 <booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/> | |
2114 <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/> | |
2115 <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> | |
2116 <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> | |
2117 <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | |
2118 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.launching.remote.InternalAntRunner"/> | |
2119 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""" + '"' + p.name + '"' + """/> | |
2120 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/""" + p.name + """/eclipse-build.xml}"/> | |
2121 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="auto,full,incremental"/> | |
2122 <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> | |
2123 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/""" + p.name + """}"/> | |
2124 <stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/> | |
2125 </launchConfiguration> | |
2126 """ | |
2127 update_file(absPath, launchOut) | |
2128 | |
2129 return "<project>/.externalToolBuilders/Jar.launch" | |
2130 | |
2131 | |
2132 | |
2029 | 2133 |
2030 def netbeansinit(args, suite=None): | 2134 def netbeansinit(args, suite=None): |
2031 """(re)generate NetBeans project configurations""" | 2135 """(re)generate NetBeans project configurations""" |
2032 | 2136 |
2033 if suite is None: | 2137 if suite is None: |
2061 out.open('data', {'xmlns' : 'http://www.netbeans.org/ns/j2se-project/3'}) | 2165 out.open('data', {'xmlns' : 'http://www.netbeans.org/ns/j2se-project/3'}) |
2062 out.element('name', data=p.name) | 2166 out.element('name', data=p.name) |
2063 out.element('explicit-platform', {'explicit-source-supported' : 'true'}) | 2167 out.element('explicit-platform', {'explicit-source-supported' : 'true'}) |
2064 out.open('source-roots') | 2168 out.open('source-roots') |
2065 out.element('root', {'id' : 'src.dir'}) | 2169 out.element('root', {'id' : 'src.dir'}) |
2170 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | |
2171 out.element('root', {'id' : 'src.ap-source-output.dir'}) | |
2066 out.close('source-roots') | 2172 out.close('source-roots') |
2067 out.open('test-roots') | 2173 out.open('test-roots') |
2068 out.element('root', {'id' : 'test.src.dir'}) | |
2069 out.close('test-roots') | 2174 out.close('test-roots') |
2070 out.close('data') | 2175 out.close('data') |
2071 | 2176 |
2072 firstDep = True | 2177 firstDep = True |
2073 for dep in p.all_deps([], True): | 2178 for dep in p.all_deps([], True): |
2097 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent=' ', newl='\n')) or updated | 2202 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent=' ', newl='\n')) or updated |
2098 | 2203 |
2099 out = StringIO.StringIO() | 2204 out = StringIO.StringIO() |
2100 jdkPlatform = 'JDK_' + java().version | 2205 jdkPlatform = 'JDK_' + java().version |
2101 | 2206 |
2207 annotationProcessorEnabled = "false" | |
2208 annotationProcessorReferences = "" | |
2209 annotationProcessorSrcFolder = "" | |
2210 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | |
2211 annotationProcessorEnabled = "true" | |
2212 annotationProcessorSrcFolder = "src.ap-source-output.dir=${build.generated.sources.dir}/ap-source-output" | |
2213 | |
2102 content = """ | 2214 content = """ |
2103 annotation.processing.enabled=false | 2215 annotation.processing.enabled=""" + annotationProcessorEnabled + """ |
2104 annotation.processing.enabled.in.editor=false | 2216 annotation.processing.enabled.in.editor=""" + annotationProcessorEnabled + """ |
2105 annotation.processing.processors.list= | 2217 annotation.processing.processors.list= |
2106 annotation.processing.run.all.processors=true | 2218 annotation.processing.run.all.processors=true |
2107 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output | |
2108 application.title=""" + p.name + """ | 2219 application.title=""" + p.name + """ |
2109 application.vendor=mx | 2220 application.vendor=mx |
2110 build.classes.dir=${build.dir} | 2221 build.classes.dir=${build.dir} |
2111 build.classes.excludes=**/*.java,**/*.form | 2222 build.classes.excludes=**/*.java,**/*.form |
2112 # This directory is removed when the project is cleaned: | 2223 # This directory is removed when the project is cleaned: |
2132 includes=** | 2243 includes=** |
2133 jar.compress=false | 2244 jar.compress=false |
2134 # Space-separated list of extra javac options | 2245 # Space-separated list of extra javac options |
2135 javac.compilerargs= | 2246 javac.compilerargs= |
2136 javac.deprecation=false | 2247 javac.deprecation=false |
2137 javac.processorpath=\\ | |
2138 ${javac.classpath} | |
2139 javac.source=1.7 | 2248 javac.source=1.7 |
2140 javac.target=1.7 | 2249 javac.target=1.7 |
2141 javac.test.classpath=\\ | 2250 javac.test.classpath=\\ |
2142 ${javac.classpath}:\\ | 2251 ${javac.classpath}:\\ |
2143 ${build.classes.dir} | 2252 ${build.classes.dir} |
2144 javac.test.processorpath=\\ | |
2145 ${javac.test.classpath} | |
2146 javadoc.additionalparam= | 2253 javadoc.additionalparam= |
2147 javadoc.author=false | 2254 javadoc.author=false |
2148 javadoc.encoding=${source.encoding} | 2255 javadoc.encoding=${source.encoding} |
2149 javadoc.noindex=false | 2256 javadoc.noindex=false |
2150 javadoc.nonavbar=false | 2257 javadoc.nonavbar=false |
2168 # or test-sys-prop.name=value to set system properties for unit tests): | 2275 # or test-sys-prop.name=value to set system properties for unit tests): |
2169 run.jvmargs= | 2276 run.jvmargs= |
2170 run.test.classpath=\\ | 2277 run.test.classpath=\\ |
2171 ${javac.test.classpath}:\\ | 2278 ${javac.test.classpath}:\\ |
2172 ${build.test.classes.dir} | 2279 ${build.test.classes.dir} |
2173 test.src.dir= | 2280 test.src.dir=./test |
2281 """ + annotationProcessorSrcFolder + """ | |
2174 source.encoding=UTF-8""".replace(':', os.pathsep).replace('/', os.sep) | 2282 source.encoding=UTF-8""".replace(':', os.pathsep).replace('/', os.sep) |
2175 print >> out, content | 2283 print >> out, content |
2176 | 2284 |
2177 mainSrc = True | 2285 mainSrc = True |
2178 for src in p.srcDirs: | 2286 for src in p.srcDirs: |
2186 mainSrc = False | 2294 mainSrc = False |
2187 else: | 2295 else: |
2188 print >> out, 'src.' + src + '.dir=${' + ref + '}' | 2296 print >> out, 'src.' + src + '.dir=${' + ref + '}' |
2189 | 2297 |
2190 javacClasspath = [] | 2298 javacClasspath = [] |
2191 for dep in p.all_deps([], True): | 2299 |
2300 deps = p.all_deps([], True) | |
2301 annotationProcessorOnlyDeps = [] | |
2302 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | |
2303 for ap in p.annotationProcessors: | |
2304 apProject = project(ap) | |
2305 if not apProject in deps: | |
2306 deps.append(apProject) | |
2307 annotationProcessorOnlyDeps.append(apProject) | |
2308 | |
2309 annotationProcessorReferences = []; | |
2310 | |
2311 for dep in deps: | |
2192 if dep == p: | 2312 if dep == p: |
2193 continue; | 2313 continue; |
2194 | 2314 |
2195 if dep.isLibrary(): | 2315 if dep.isLibrary(): |
2196 if not dep.mustExist: | 2316 if not dep.mustExist: |
2206 relDepPath = os.path.relpath(dep.dir, p.dir).replace(os.sep, '/') | 2326 relDepPath = os.path.relpath(dep.dir, p.dir).replace(os.sep, '/') |
2207 ref = 'reference.' + n + '.jar' | 2327 ref = 'reference.' + n + '.jar' |
2208 print >> out, 'project.' + n + '=' + relDepPath | 2328 print >> out, 'project.' + n + '=' + relDepPath |
2209 print >> out, ref + '=${project.' + n + '}/dist/' + dep.name + '.jar' | 2329 print >> out, ref + '=${project.' + n + '}/dist/' + dep.name + '.jar' |
2210 | 2330 |
2211 javacClasspath.append('${' + ref + '}') | 2331 if not dep in annotationProcessorOnlyDeps: |
2332 javacClasspath.append('${' + ref + '}') | |
2333 else: | |
2334 annotationProcessorReferences.append('${' + ref + '}') | |
2335 annotationProcessorReferences += ":\\\n ${" + ref + "}" | |
2212 | 2336 |
2213 print >> out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath) | 2337 print >> out, 'javac.classpath=\\\n ' + (os.pathsep + '\\\n ').join(javacClasspath) |
2214 | 2338 print >> out, 'javac.test.processorpath=${javac.test.classpath}\\\n ' + (os.pathsep + '\\\n ').join(annotationProcessorReferences) |
2215 | 2339 print >> out, 'javac.processorpath=${javac.classpath}\\\n ' + (os.pathsep + '\\\n ').join(annotationProcessorReferences) |
2340 | |
2216 updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated | 2341 updated = update_file(join(p.dir, 'nbproject', 'project.properties'), out.getvalue()) or updated |
2217 out.close() | 2342 out.close() |
2218 | 2343 |
2219 if updated: | 2344 if updated: |
2220 log('If using NetBeans:') | 2345 log('If using NetBeans:') |
2221 log(' 1. Ensure that a platform named "JDK ' + java().version + '" is defined (Tools -> Java Platforms)') | 2346 log(' 1. Ensure that a platform named "JDK ' + java().version + '" is defined (Tools -> Java Platforms)') |
2222 log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') | 2347 log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') |
2223 | 2348 |
2224 def ideclean(args, suite=None): | 2349 def ideclean(args, suite=None): |
2225 """remove all Eclipse and NetBeans project configurations""" | 2350 """remove all Eclipse and NetBeans project configurations""" |
2226 | |
2227 def rm(path): | 2351 def rm(path): |
2228 if exists(path): | 2352 if exists(path): |
2229 os.remove(path) | 2353 os.remove(path) |
2230 | 2354 |
2231 for p in projects(): | 2355 for p in projects(): |
2232 if p.native: | 2356 if p.native: |
2233 continue | 2357 continue |
2234 | 2358 |
2235 shutil.rmtree(join(p.dir, '.settings'), ignore_errors=True) | 2359 shutil.rmtree(join(p.dir, '.settings'), ignore_errors=True) |
2360 shutil.rmtree(join(p.dir, '.externalToolBuilders'), ignore_errors=True) | |
2236 shutil.rmtree(join(p.dir, 'nbproject'), ignore_errors=True) | 2361 shutil.rmtree(join(p.dir, 'nbproject'), ignore_errors=True) |
2237 rm(join(p.dir, '.classpath')) | 2362 rm(join(p.dir, '.classpath')) |
2238 rm(join(p.dir, '.project')) | 2363 rm(join(p.dir, '.project')) |
2239 rm(join(p.dir, 'build.xml')) | 2364 rm(join(p.dir, 'build.xml')) |
2365 rm(join(p.dir, 'eclipse-build.xml')) | |
2366 try: | |
2367 rm(join(p.dir, p.name + '.jar')) | |
2368 except: | |
2369 log("Error removing {0}".format(p.name + '.jar')) | |
2370 | |
2240 | 2371 |
2241 def ideinit(args, suite=None): | 2372 def ideinit(args, suite=None): |
2242 """(re)generate Eclipse and NetBeans project configurations""" | 2373 """(re)generate Eclipse and NetBeans project configurations""" |
2243 eclipseinit(args, suite) | 2374 eclipseinit(args, suite) |
2244 netbeansinit(args, suite) | 2375 netbeansinit(args, suite) |