comparison mx/mx_graal.py @ 21976:36e37644f91e

mx: improve first usage experience: Create mx.ask_persist_env to handle env file modifications, make it deal with files missing final newline Use mx.ask_persist_env to persist the DEFAULT_VM Make mx_graal specify its version restrictions when asking for the default JDK When selecting versions manually or automatically, use JDKs from JAVA_HOME first, then from EXTRA_JAVA_HOMES, then from standard locations, then sort by version. Even if EXTRA_JAVA_HOMES is already defained, let the user decide which JAVA_HOME to use
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Fri, 12 Jun 2015 16:51:32 +0200
parents 290a87b718e1
children 2a98e51646c2
comparison
equal deleted inserted replaced
21975:290a87b718e1 21976:36e37644f91e
135 mx.abort('Need to specify VM with --vm option or DEFAULT_VM environment variable') 135 mx.abort('Need to specify VM with --vm option or DEFAULT_VM environment variable')
136 mx.log('Please select the VM to be executed from the following: ') 136 mx.log('Please select the VM to be executed from the following: ')
137 items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None] 137 items = [k for k in _vmChoices.keys() if _vmChoices[k] is not None]
138 descriptions = [_vmChoices[k] for k in _vmChoices.keys() if _vmChoices[k] is not None] 138 descriptions = [_vmChoices[k] for k in _vmChoices.keys() if _vmChoices[k] is not None]
139 vm = mx.select_items(items, descriptions, allowMultiple=False) 139 vm = mx.select_items(items, descriptions, allowMultiple=False)
140 if mx.ask_yes_no('Persist this choice by adding "DEFAULT_VM=' + vm + '" to ' + envPath, 'y'): 140 mx.ask_persist_env('DEFAULT_VM', vm)
141 with open(envPath, 'a') as fp:
142 print >> fp, 'DEFAULT_VM=' + vm
143 _vm = vm 141 _vm = vm
144 return vm 142 return vm
145 143
146 """ 144 """
147 A context manager that can be used with the 'with' statement to set the VM 145 A context manager that can be used with the 'with' statement to set the VM
1806 v8u20 = mx.VersionSpec("1.8.0_20") 1804 v8u20 = mx.VersionSpec("1.8.0_20")
1807 v8u40 = mx.VersionSpec("1.8.0_40") 1805 v8u40 = mx.VersionSpec("1.8.0_40")
1808 v8 = mx.VersionSpec("1.8") 1806 v8 = mx.VersionSpec("1.8")
1809 def _igvJdkVersionCheck(version): 1807 def _igvJdkVersionCheck(version):
1810 return version >= v8 and (version < v8u20 or version >= v8u40) 1808 return version >= v8 and (version < v8u20 or version >= v8u40)
1811 return mx.java_version(_igvJdkVersionCheck, versionDescription='>= 1.8 and < 1.8.0u20 or >= 1.8.0u40', purpose="building & running IGV").jdk 1809 return mx.java(_igvJdkVersionCheck, versionDescription='>= 1.8 and < 1.8.0u20 or >= 1.8.0u40', purpose="building & running IGV").jdk
1812 1810
1813 def _igvBuildEnv(): 1811 def _igvBuildEnv():
1814 # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs 1812 # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs
1815 env = dict(os.environ) 1813 env = dict(os.environ)
1816 proxy = os.environ.get('http_proxy') 1814 proxy = os.environ.get('http_proxy')
2615 2613
2616 mx.update_commands(suite, commands) 2614 mx.update_commands(suite, commands)
2617 2615
2618 def mx_post_parse_cmd_line(opts): # 2616 def mx_post_parse_cmd_line(opts): #
2619 # TODO _minVersion check could probably be part of a Suite in mx? 2617 # TODO _minVersion check could probably be part of a Suite in mx?
2620 if mx.java().version < _minVersion: 2618 def _versionCheck(version):
2621 mx.abort('Requires Java version ' + str(_minVersion) + ' or greater for JAVA_HOME, got version ' + str(mx.java().version)) 2619 return version >= _minVersion and (not _untilVersion or version >= _untilVersion)
2622 if _untilVersion and mx.java().version >= _untilVersion: 2620 versionDesc = ">=" + str(_minVersion)
2623 mx.abort('Requires Java version strictly before ' + str(_untilVersion) + ' for JAVA_HOME, got version ' + str(mx.java().version)) 2621 if _untilVersion:
2622 versionDesc += " and <=" + str(_untilVersion)
2623 mx.java(_versionCheck, versionDescription=versionDesc, defaultJdk=True)
2624 2624
2625 if _vmSourcesAvailable: 2625 if _vmSourcesAvailable:
2626 if hasattr(opts, 'vm') and opts.vm is not None: 2626 if hasattr(opts, 'vm') and opts.vm is not None:
2627 global _vm 2627 global _vm
2628 _vm = opts.vm 2628 _vm = opts.vm