Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 7299:57edf6b07d36
Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 02 Jan 2013 18:52:33 +0100 |
parents | 4974776828ec |
children | 442668d41bc2 |
comparison
equal
deleted
inserted
replaced
7298:4d6d84714c17 | 7299:57edf6b07d36 |
---|---|
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)): | 1383 if not exists(dirname(dst)): |
1384 os.makedirs(dirname(dst)) | 1384 os.makedirs(dirname(dst)) |
1385 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)): |
1386 shutil.copyfile(src, dst) | 1386 shutil.copyfile(src, dst) |
1387 | 1387 |
1388 if not mustBuild: | 1388 if not mustBuild: |
1389 for javafile in javafiles: | 1389 for javafile in javafiles: |
1390 classfile = outputDir + javafile[len(sourceDir):-len('java')] + 'class' | 1390 classfile = outputDir + javafile[len(sourceDir):-len('java')] + 'class' |
1479 targetJar = join(p.dir, p.name + '.jar') | 1479 targetJar = join(p.dir, p.name + '.jar') |
1480 jar(targetJar, [p.output_dir()]) | 1480 jar(targetJar, [p.output_dir()]) |
1481 | 1481 |
1482 | 1482 |
1483 def jar(destFileName, dirs): | 1483 def jar(destFileName, dirs): |
1484 lib = library("ANT_JAR_TOOL", fatalIfMissing=False) | 1484 latestMod = _latestModification(dirs) |
1485 | 1485 |
1486 if lib is None : | 1486 if exists(destFileName): |
1487 log('No library ANT_JAR_TOOL defined. Falling back to JDK Jar tool.'); | 1487 mod = os.path.getmtime(destFileName) |
1488 _java_jar_tool(destFileName, dirs) | 1488 if int(round(latestMod*1000)) == int(round(mod*1000)): |
1489 else: | 1489 # nothing todo |
1490 _ant_jar_tool(lib, destFileName, dirs) | 1490 return |
1491 | 1491 |
1492 def _java_jar_tool(destFileName, dirs): | 1492 if latestMod is None and exists(destFileName): |
1493 created = False | 1493 return |
1494 | |
1495 jarCmd = [java().jar, 'cf', destFileName] | |
1496 | |
1494 for directory in dirs: | 1497 for directory in dirs: |
1495 if created: | 1498 jarCmd += ['-C', directory, '.'] |
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 | 1499 |
1503 def _ant_jar_tool(lib, destFileName, dirs): | 1500 subprocess.check_call(jarCmd) |
1504 antJar = lib.get_path(True) | 1501 log('Written jar file {0}'.format(destFileName)) |
1505 | 1502 |
1506 jarCmd = [java().java, '-jar', antJar, destFileName] | 1503 atime = os.path.getatime(destFileName) |
1507 for directory in dirs : | 1504 os.utime(destFileName, (atime, latestMod)) |
1508 jarCmd.append(directory) | 1505 |
1509 | 1506 def _latestModification(directories): |
1510 subprocess.check_call(jarCmd) | 1507 latestMod = None |
1511 | 1508 for directory in directories: |
1509 if not os.path.exists (directory): | |
1510 continue | |
1511 for root, _, files in os.walk(directory): | |
1512 for names in files: | |
1513 filepath = os.path.join(root, names) | |
1514 mod = os.path.getmtime(filepath) | |
1515 if latestMod is None: | |
1516 latestMod = mod | |
1517 elif mod > latestMod: | |
1518 latestMod = mod | |
1519 return latestMod | |
1512 | 1520 |
1513 def canonicalizeprojects(args): | 1521 def canonicalizeprojects(args): |
1514 """process all project files to canonicalize the dependencies | 1522 """process all project files to canonicalize the dependencies |
1515 | 1523 |
1516 The exit code of this command reflects how many files were updated.""" | 1524 The exit code of this command reflects how many files were updated.""" |
1897 os.mkdir(srcDir) | 1905 os.mkdir(srcDir) |
1898 out.element('classpathentry', {'kind' : 'src', 'path' : src}) | 1906 out.element('classpathentry', {'kind' : 'src', 'path' : src}) |
1899 | 1907 |
1900 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: | 1908 if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: |
1901 genDir = p.source_gen_dir(); | 1909 genDir = p.source_gen_dir(); |
1902 if exists(genDir): | 1910 if not exists(genDir): |
1903 shutil.rmtree(genDir) | 1911 os.mkdir(genDir) |
1904 os.mkdir(genDir) | |
1905 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) | 1912 out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) |
1906 | 1913 |
1907 # Every Java program depends on the JRE | 1914 # Every Java program depends on the JRE |
1908 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER'}) | 1915 out.element('classpathentry', {'kind' : 'con', 'path' : 'org.eclipse.jdt.launching.JRE_CONTAINER'}) |
1909 | 1916 |
2045 out = XMLDoc() | 2052 out = XMLDoc() |
2046 out.open('factorypath') | 2053 out.open('factorypath') |
2047 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | 2054 out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) |
2048 for ap in p.annotationProcessors: | 2055 for ap in p.annotationProcessors: |
2049 apProject = project(ap) | 2056 apProject = project(ap) |
2050 out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + apProject.name + '/' + apProject.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) | |
2051 for dep in apProject.all_deps([], True): | 2057 for dep in apProject.all_deps([], True): |
2052 if dep.isLibrary(): | 2058 if dep.isLibrary(): |
2053 if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'): | 2059 if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'): |
2054 if dep.mustExist: | 2060 if dep.mustExist: |
2055 path = dep.get_path(resolve=True) | 2061 path = dep.get_path(resolve=True) |
2084 return True | 2090 return True |
2085 | 2091 |
2086 return False | 2092 return False |
2087 | 2093 |
2088 def _genEclipseJarBuild(p): | 2094 def _genEclipseJarBuild(p): |
2089 externalToolDir = '.externalToolBuilders' | 2095 launchOut = XMLDoc(); |
2090 relPath = join(externalToolDir, 'Jar.launch') | 2096 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) |
2091 absPath = join(p.dir, relPath) | 2097 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE', 'value': '${project}'}) |
2098 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': 'false'}) | |
2099 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON', 'value': 'false'}) | |
2100 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND', 'value': 'true'}) | |
2092 | 2101 |
2093 if not exists(join(p.dir, externalToolDir)): | 2102 baseDir = dirname(dirname(os.path.abspath(__file__))) |
2094 os.makedirs(join(p.dir, externalToolDir)) | |
2095 | 2103 |
2096 antOut = XMLDoc() | 2104 cmd = 'mx.sh' |
2097 antOut.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'}) | 2105 if get_os() == 'windows': |
2098 antOut.open('target', {'name' : 'default'}) | 2106 cmd = 'mx.cmd' |
2099 antOut.open('jar', {'destfile' : p.name + '.jar'}) | 2107 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION', 'value': join(baseDir, cmd) }) |
2100 antOut.element('fileset', {'dir' : p.output_dir()}) | 2108 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'auto,full,incremental'}) |
2101 antOut.close('jar') | 2109 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': ''.join(['jar', ' ', p.name])}) |
2102 antOut.close('target') | 2110 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED','value': 'true'}) |
2103 antOut.close('project') | 2111 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': baseDir}) |
2104 | 2112 |
2105 update_file(join(p.dir, 'eclipse-build.xml'), antOut.xml(indent='\t', newl='\n')) | |
2106 | 2113 |
2107 launchOut = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> | 2114 launchOut.close('launchConfiguration') |
2108 <launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> | 2115 |
2109 <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> | 2116 externalToolDir = join(p.dir, '.externalToolBuilders') |
2110 <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> | 2117 |
2111 <booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/> | 2118 if not exists(externalToolDir): |
2112 <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>}"/> | 2119 os.makedirs(externalToolDir) |
2113 <booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/> | 2120 update_file(join(externalToolDir, 'Jar.launch'), launchOut.xml(indent='\t', newl='\n')) |
2114 <booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/> | |
2115 <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/> | |
2116 <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> | |
2117 <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> | |
2118 <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"/> | |
2119 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.launching.remote.InternalAntRunner"/> | |
2120 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""" + '"' + p.name + '"' + """/> | |
2121 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/""" + p.name + """/eclipse-build.xml}"/> | |
2122 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="auto,full,incremental"/> | |
2123 <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> | |
2124 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/""" + p.name + """}"/> | |
2125 <stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/> | |
2126 </launchConfiguration> | |
2127 """ | |
2128 update_file(absPath, launchOut) | |
2129 | 2121 |
2130 return "<project>/.externalToolBuilders/Jar.launch" | 2122 return "<project>/.externalToolBuilders/Jar.launch" |
2131 | 2123 |
2132 | 2124 |
2133 | 2125 |