# HG changeset patch # User Christian Humer # Date 1357149153 -3600 # Node ID 57edf6b07d3630a42ab17f500d0612f18db45f66 # Parent 4d6d84714c17d1956835efa9015e12c87eaf2881 Removed ANT_JAR_TOOL dependency. Eclipse jar builds are now calling the command 'mx jar ${projectName}'. diff -r 4d6d84714c17 -r 57edf6b07d36 graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/ProcessorContext.java --- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/ProcessorContext.java Wed Dec 26 13:55:43 2012 -0800 +++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/ProcessorContext.java Wed Jan 02 18:52:33 2013 +0100 @@ -45,16 +45,18 @@ private final ProcessCallback callback; private final Log log; - private final TruffleTypes truffleTypes; + private TruffleTypes truffleTypes; public ProcessorContext(ProcessingEnvironment env, ProcessCallback callback) { this.environment = env; this.callback = callback; this.log = new Log(environment); - this.truffleTypes = new TruffleTypes(this); } public TruffleTypes getTruffleTypes() { + if (truffleTypes == null) { + truffleTypes = new TruffleTypes(this); + } return truffleTypes; } diff -r 4d6d84714c17 -r 57edf6b07d36 mx/commands.py --- a/mx/commands.py Wed Dec 26 13:55:43 2012 -0800 +++ b/mx/commands.py Wed Jan 02 18:52:33 2013 +0100 @@ -1075,6 +1075,20 @@ mx.abort('jacocoreport takes only one argument : an output directory') mx.run_java(['-jar', jacocoreport.get_path(True), '-in', 'jacoco.exec', '-g', join(_graal_home, 'graal'), out]) +def jar(args): + parser = ArgumentParser(prog='mx jar'); + parser.add_argument('projects', nargs=REMAINDER, metavar='projects...') + args = parser.parse_args(args) + + if not args.projects: + mx.abort('Please specify at least one project to jar.') + + for pname in args.projects: + p = mx.project(pname, fatalIfMissing=True) + outputDir = p.output_dir() + targetJar = join(p.dir, p.name + '.jar') + mx.jar(targetJar, [outputDir]) + def site(args): """create a website containing javadoc and the project dependency graph""" @@ -1101,6 +1115,7 @@ 'dacapo': [dacapo, '[[n] benchmark] [VM options|@DaCapo options]'], 'scaladacapo': [scaladacapo, '[[n] benchmark] [VM options|@Scala DaCapo options]'], 'specjvm2008': [specjvm2008, '[VM options|@specjvm2008 options]'], + 'jar': [jar, '[-options]'], #'example': [example, '[-v] example names...'], 'gate' : [gate, '[-options]'], 'gv' : [gv, ''], diff -r 4d6d84714c17 -r 57edf6b07d36 mx/projects --- a/mx/projects Wed Dec 26 13:55:43 2012 -0800 +++ b/mx/projects Wed Jan 02 18:52:33 2013 +0100 @@ -10,9 +10,6 @@ library@CHECKSTYLE@path=lib/checkstyle-5.5-all.jar library@CHECKSTYLE@urls=jar:http://sourceforge.net/projects/checkstyle/files/checkstyle/5.5/checkstyle-5.5-bin.zip/download!/checkstyle-5.5/checkstyle-5.5-all.jar -library@ANT_JAR_TOOL@path=lib/ant-jar-tool.jar -library@ANT_JAR_TOOL@urls=http://lafo.ssw.uni-linz.ac.at/ant-jar-tool/ant-jar-tool.jar - library@DACAPO@path=lib/dacapo-9.12-bach.jar library@DACAPO@urls=http://softlayer.dl.sourceforge.net/project/dacapobench/9.12-bach/dacapo-9.12-bach.jar diff -r 4d6d84714c17 -r 57edf6b07d36 mxtool/mx.py --- a/mxtool/mx.py Wed Dec 26 13:55:43 2012 -0800 +++ b/mxtool/mx.py Wed Jan 02 18:52:33 2013 +0100 @@ -1382,7 +1382,7 @@ dst = join(outputDir, src[len(sourceDir) + 1:]) if not exists(dirname(dst)): os.makedirs(dirname(dst)) - if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) != os.path.getmtime(src)): + if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) < os.path.getmtime(src)): shutil.copyfile(src, dst) if not mustBuild: @@ -1481,34 +1481,42 @@ def jar(destFileName, dirs): - lib = library("ANT_JAR_TOOL", fatalIfMissing=False) + latestMod = _latestModification(dirs) - if lib is None : - log('No library ANT_JAR_TOOL defined. Falling back to JDK Jar tool.'); - _java_jar_tool(destFileName, dirs) - else: - _ant_jar_tool(lib, destFileName, dirs) - -def _java_jar_tool(destFileName, dirs): - created = False + if exists(destFileName): + mod = os.path.getmtime(destFileName) + if int(round(latestMod*1000)) == int(round(mod*1000)): + # nothing todo + return + + if latestMod is None and exists(destFileName): + return + + jarCmd = [java().jar, 'cf', destFileName] + for directory in dirs: - if created: - cmd = 'uf' - else: - cmd = 'cf' - created = True - jarCmd = [java().jar, cmd, destFileName, '-C', directory, '.'] - subprocess.check_call(jarCmd) + jarCmd += ['-C', directory, '.'] + + subprocess.check_call(jarCmd) + log('Written jar file {0}'.format(destFileName)) -def _ant_jar_tool(lib, destFileName, dirs): - antJar = lib.get_path(True) - - jarCmd = [java().java, '-jar', antJar, destFileName] - for directory in dirs : - jarCmd.append(directory) - - subprocess.check_call(jarCmd) - + atime = os.path.getatime(destFileName) + os.utime(destFileName, (atime, latestMod)) + +def _latestModification(directories): + latestMod = None + for directory in directories: + if not os.path.exists (directory): + continue + for root, _, files in os.walk(directory): + for names in files: + filepath = os.path.join(root, names) + mod = os.path.getmtime(filepath) + if latestMod is None: + latestMod = mod + elif mod > latestMod: + latestMod = mod + return latestMod def canonicalizeprojects(args): """process all project files to canonicalize the dependencies @@ -1899,9 +1907,8 @@ if hasattr(p, 'annotationProcessors') and len(p.annotationProcessors) > 0: genDir = p.source_gen_dir(); - if exists(genDir): - shutil.rmtree(genDir) - os.mkdir(genDir) + if not exists(genDir): + os.mkdir(genDir) out.element('classpathentry', {'kind' : 'src', 'path' : 'src_gen'}) # Every Java program depends on the JRE @@ -2047,7 +2054,6 @@ out.element('factorypathentry', {'kind' : 'PLUGIN', 'id' : 'org.eclipse.jst.ws.annotations.core', 'enabled' : 'true', 'runInBatchMode' : 'false'}) for ap in p.annotationProcessors: apProject = project(ap) - out.element('factorypathentry', {'kind' : 'WKSPJAR', 'id' : '/' + apProject.name + '/' + apProject.name + '.jar', 'enabled' : 'true', 'runInBatchMode' : 'false'}) for dep in apProject.all_deps([], True): if dep.isLibrary(): if not hasattr(dep, 'eclipse.container') and not hasattr(dep, 'eclipse.project'): @@ -2086,46 +2092,32 @@ return False def _genEclipseJarBuild(p): - externalToolDir = '.externalToolBuilders' - relPath = join(externalToolDir, 'Jar.launch') - absPath = join(p.dir, relPath) - - if not exists(join(p.dir, externalToolDir)): - os.makedirs(join(p.dir, externalToolDir)) + launchOut = XMLDoc(); + launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) + launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE', 'value': '${project}'}) + launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': 'false'}) + launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON', 'value': 'false'}) + launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND', 'value': 'true'}) - antOut = XMLDoc() - antOut.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'}) - antOut.open('target', {'name' : 'default'}) - antOut.open('jar', {'destfile' : p.name + '.jar'}) - antOut.element('fileset', {'dir' : p.output_dir()}) - antOut.close('jar') - antOut.close('target') - antOut.close('project') - - update_file(join(p.dir, 'eclipse-build.xml'), antOut.xml(indent='\t', newl='\n')) + baseDir = dirname(dirname(os.path.abspath(__file__))) - launchOut = """ - - - - - - - - - - - - - - - - - - - -""" - update_file(absPath, launchOut) + cmd = 'mx.sh' + if get_os() == 'windows': + cmd = 'mx.cmd' + launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION', 'value': join(baseDir, cmd) }) + launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'auto,full,incremental'}) + launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': ''.join(['jar', ' ', p.name])}) + launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED','value': 'true'}) + launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': baseDir}) + + + launchOut.close('launchConfiguration') + + externalToolDir = join(p.dir, '.externalToolBuilders') + + if not exists(externalToolDir): + os.makedirs(externalToolDir) + update_file(join(externalToolDir, 'Jar.launch'), launchOut.xml(indent='\t', newl='\n')) return "/.externalToolBuilders/Jar.launch"