comparison mxtool/mx.py @ 12661:0497d6702cff

mxtool: fixed eclipse builder glitches and rebuild loops.
author Christian Humer <christian.humer@gmail.com>
date Mon, 04 Nov 2013 12:18:58 +0100
parents 6860d5528902
children c6cc96cc6a1f
comparison
equal deleted inserted replaced
12640:6860d5528902 12661:0497d6702cff
23 # or visit www.oracle.com if you need additional information or have any 23 # or visit www.oracle.com if you need additional information or have any
24 # questions. 24 # questions.
25 # 25 #
26 # ---------------------------------------------------------------------------------------------------- 26 # ----------------------------------------------------------------------------------------------------
27 # 27 #
28
29 r""" 28 r"""
30 mx is a command line tool for managing the development of Java code organized as suites of projects. 29 mx is a command line tool for managing the development of Java code organized as suites of projects.
31 30
32 Full documentation can be found at https://wiki.openjdk.java.net/display/Graal/The+mx+Tool 31 Full documentation can be found at https://wiki.openjdk.java.net/display/Graal/The+mx+Tool
33 """ 32 """
2978 out.open('buildCommand') 2977 out.open('buildCommand')
2979 out.element('name', data=buildCommand) 2978 out.element('name', data=buildCommand)
2980 out.element('arguments', data='') 2979 out.element('arguments', data='')
2981 out.close('buildCommand') 2980 out.close('buildCommand')
2982 2981
2982 # The path should always be p.name/dir. independent of where the workspace actually is.
2983 # So we use the parent folder of the project, whatever that is, to generate such a relative path.
2984 logicalWorkspaceRoot = os.path.dirname(p.dir)
2985 binFolder = os.path.relpath(p.output_dir(), logicalWorkspaceRoot)
2986
2983 if _isAnnotationProcessorDependency(p): 2987 if _isAnnotationProcessorDependency(p):
2984 _genEclipseBuilder(out, p, 'Jar', 'archive ' + p.name, refresh=False, async=False, xmlIndent='', xmlStandalone='no') 2988 refreshFile = os.path.relpath(join(p.dir, p.name + '.jar'), logicalWorkspaceRoot)
2985 _genEclipseBuilder(out, p, 'Refresh', '', refresh=True, async=True) 2989 _genEclipseBuilder(out, p, 'Jar', 'archive ' + p.name, refresh=True, refreshFile=refreshFile, relevantResources=[binFolder], async=True, xmlIndent='', xmlStandalone='no')
2986 2990
2987 if projToDist.has_key(p.name): 2991 if projToDist.has_key(p.name):
2988 dist, distDeps = projToDist[p.name] 2992 dist, distDeps = projToDist[p.name]
2989 _genEclipseBuilder(out, p, 'Create' + dist.name + 'Dist', 'archive @' + dist.name, logToFile=True, refresh=False, async=True) 2993 _genEclipseBuilder(out, p, 'Create' + dist.name + 'Dist', 'archive @' + dist.name, relevantResources=[binFolder], logToFile=True, refresh=False, async=True)
2990 2994
2991 out.close('buildSpec') 2995 out.close('buildSpec')
2992 out.open('natures') 2996 out.open('natures')
2993 out.element('nature', data='org.eclipse.jdt.core.javanature') 2997 out.element('nature', data='org.eclipse.jdt.core.javanature')
2994 if exists(csConfig): 2998 if exists(csConfig):
3046 """ 3050 """
3047 Determines if a given project is part of an annotation processor. 3051 Determines if a given project is part of an annotation processor.
3048 """ 3052 """
3049 return p in sorted_deps(annotation_processors()) 3053 return p in sorted_deps(annotation_processors())
3050 3054
3051 def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, async=False, logToConsole=False, logToFile=False, appendToLogFile=True, xmlIndent='\t', xmlStandalone=None): 3055 def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, refreshFile=None, relevantResources=None, async=False, logToConsole=False, logToFile=False, appendToLogFile=True, xmlIndent='\t', xmlStandalone=None):
3052 externalToolDir = join(p.dir, '.externalToolBuilders') 3056 externalToolDir = join(p.dir, '.externalToolBuilders')
3053 launchOut = XMLDoc() 3057 launchOut = XMLDoc()
3054 consoleOn = 'true' if logToConsole else 'false' 3058 consoleOn = 'true' if logToConsole else 'false'
3055 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) 3059 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'})
3056 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn}) 3060 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn})
3057 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'}) 3061 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'})
3058 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java().jdk}) 3062 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java().jdk})
3059 launchOut.close('mapAttribute') 3063 launchOut.close('mapAttribute')
3060 3064
3061 if refresh: 3065 if refresh:
3062 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE', 'value': '${project}'}) 3066 if refreshFile is None:
3067 refreshScope = '${project}'
3068 else:
3069 refreshScope = '${working_set:<?xml version="1.0" encoding="UTF-8"?><resources><item path="' + refreshFile + '" type="1"/></resources>}'
3070
3071 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_RECURSIVE', 'value': 'false'})
3072 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.core.ATTR_REFRESH_SCOPE', 'value': refreshScope})
3073
3074 if relevantResources is not None:
3075 resources = '${working_set:<?xml version="1.0" encoding="UTF-8"?><resources>'
3076 for relevantResource in relevantResources:
3077 resources += '<item path="' + relevantResource +'" type="2" />'
3078 resources += '</resources>}'
3079 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE', 'value': resources})
3080
3081
3063 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON', 'value': consoleOn}) 3082 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON', 'value': consoleOn})
3064 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND', 'value': 'true' if async else 'false'}) 3083 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND', 'value': 'true' if async else 'false'})
3065 if logToFile: 3084 if logToFile:
3066 logFile = join(externalToolDir, name + '.log') 3085 logFile = join(externalToolDir, name + '.log')
3067 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE', 'value': logFile}) 3086 launchOut.element('stringAttribute', {'key' : 'org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE', 'value': logFile})
3079 cmdPath = join(dirname(baseDir), cmd) 3098 cmdPath = join(dirname(baseDir), cmd)
3080 if not os.path.exists(cmdPath): 3099 if not os.path.exists(cmdPath):
3081 abort('cannot locate ' + cmd) 3100 abort('cannot locate ' + cmd)
3082 3101
3083 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION', 'value': cmdPath}) 3102 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_LOCATION', 'value': cmdPath})
3084 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'auto,full,incremental'}) 3103 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS', 'value': 'full,incremental,auto,'})
3085 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': mxCommand}) 3104 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS', 'value': mxCommand})
3086 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED', 'value': 'true'}) 3105 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED', 'value': 'true'})
3087 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': p.suite.dir}) 3106 launchOut.element('stringAttribute', {'key' : 'org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY', 'value': p.suite.dir})
3088 3107
3089 3108