Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 21974:7a0c8adc0a30
mx: Fix typos and error if mx/env does not exist
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Thu, 11 Jun 2015 15:38:42 +0200 |
parents | 3adf20a59771 |
children | 290a87b718e1 |
comparison
equal
deleted
inserted
replaced
21973:e23e6dc49a11 | 21974:7a0c8adc0a30 |
---|---|
1274 logv('[omitting optional library {0} as {1} does not exist]'.format(d, d.path)) | 1274 logv('[omitting optional library {0} as {1} does not exist]'.format(d, d.path)) |
1275 ommittedDeps.add(d.name) | 1275 ommittedDeps.add(d.name) |
1276 del _libs[d.name] | 1276 del _libs[d.name] |
1277 self.libs.remove(d) | 1277 self.libs.remove(d) |
1278 elif d.isProject(): | 1278 elif d.isProject(): |
1279 if java(d.javaCompliance, cancel='some projects will be omitted which may result in errrors') is None: | 1279 if java(d.javaCompliance, cancel='some projects will be omitted which may result in errors') is None: |
1280 logv('[omitting project {0} as Java compliance {1} cannot be satisfied by configured JDKs]'.format(d, d.javaCompliance)) | 1280 logv('[omitting project {0} as Java compliance {1} cannot be satisfied by configured JDKs]'.format(d, d.javaCompliance)) |
1281 ommittedDeps.add(d.name) | 1281 ommittedDeps.add(d.name) |
1282 del _projects[d.name] | 1282 del _projects[d.name] |
1283 self.projects.remove(d) | 1283 self.projects.remove(d) |
1284 else: | 1284 else: |
1838 assert jdk not in _extra_java_homes | 1838 assert jdk not in _extra_java_homes |
1839 _extra_java_homes.append(jdk) | 1839 _extra_java_homes.append(jdk) |
1840 return jdk | 1840 return jdk |
1841 | 1841 |
1842 def _find_jdk(versionCheck=None, versionDescription=None, purpose=None, cancel=None): | 1842 def _find_jdk(versionCheck=None, versionDescription=None, purpose=None, cancel=None): |
1843 if not versionCheck: | |
1844 versionCheck = lambda v: True | |
1845 assert not versionDescription or versionCheck | 1843 assert not versionDescription or versionCheck |
1846 if not versionCheck and not purpose: | 1844 if not versionCheck and not purpose: |
1847 isDefaultJdk = True | 1845 isDefaultJdk = True |
1848 else: | 1846 else: |
1849 isDefaultJdk = False | 1847 isDefaultJdk = False |
1848 if not versionCheck: | |
1849 versionCheck = lambda v: True | |
1850 | 1850 |
1851 candidateJdks = [] | 1851 candidateJdks = [] |
1852 source = '' | 1852 source = '' |
1853 if _opts.java_home: | 1853 if _opts.java_home: |
1854 candidateJdks.append(_opts.java_home) | 1854 candidateJdks.append(_opts.java_home) |
1933 return None | 1933 return None |
1934 elif len(configs) == 1: | 1934 elif len(configs) == 1: |
1935 selected = configs[0] | 1935 selected = configs[0] |
1936 msg = 'Selected ' + str(selected) + ' as ' | 1936 msg = 'Selected ' + str(selected) + ' as ' |
1937 if isDefaultJdk: | 1937 if isDefaultJdk: |
1938 msg += 'default' | 1938 msg += 'default ' |
1939 msg += 'JDK' | 1939 msg += 'JDK' |
1940 if versionDescription: | 1940 if versionDescription: |
1941 msg = msg + ' ' + versionDescription | 1941 msg = msg + ' ' + versionDescription |
1942 if purpose: | 1942 if purpose: |
1943 msg += ' for' + purpose | 1943 msg += ' for' + purpose |
1959 varName = 'JAVA_HOME' if isDefaultJdk else 'EXTRA_JAVA_HOMES' | 1959 varName = 'JAVA_HOME' if isDefaultJdk else 'EXTRA_JAVA_HOMES' |
1960 allowMultiple = not isDefaultJdk | 1960 allowMultiple = not isDefaultJdk |
1961 envPath = join(_primary_suite.mxDir, 'env') | 1961 envPath = join(_primary_suite.mxDir, 'env') |
1962 if is_interactive() and ask_yes_no('Persist this setting by adding "{0}={1}" to {2}'.format(varName, selected.jdk, envPath), 'y'): | 1962 if is_interactive() and ask_yes_no('Persist this setting by adding "{0}={1}" to {2}'.format(varName, selected.jdk, envPath), 'y'): |
1963 envLines = [] | 1963 envLines = [] |
1964 with open(envPath) as fp: | 1964 if exists(envPath): |
1965 with open(envPath) as fp: | |
1966 append = True | |
1967 for line in fp: | |
1968 if line.rstrip().startswith(varName): | |
1969 _, currentValue = line.split('=', 1) | |
1970 currentValue = currentValue.strip() | |
1971 if not allowMultiple and currentValue: | |
1972 if not ask_yes_no('{0} is already set to {1}, overwrite with {2}?'.format(varName, currentValue, selected.jdk), 'n'): | |
1973 return selected | |
1974 else: | |
1975 line = varName + '=' + selected.jdk + os.linesep | |
1976 else: | |
1977 line = line.rstrip() | |
1978 if currentValue: | |
1979 line += os.pathsep | |
1980 line += selected.jdk + os.linesep | |
1981 append = False | |
1982 envLines.append(line) | |
1983 else: | |
1965 append = True | 1984 append = True |
1966 for line in fp: | 1985 |
1967 if line.rstrip().startswith(varName): | |
1968 _, currentValue = line.split('=', 1) | |
1969 currentValue = currentValue.strip() | |
1970 if not allowMultiple and currentValue: | |
1971 if not ask_yes_no('{0} is already set to {1}, overwrite with {2}?'.format(varName, currentValue, selected.jdk), 'n'): | |
1972 return selected | |
1973 else: | |
1974 line = varName + '=' + selected.jdk + os.linesep | |
1975 else: | |
1976 line = line.rstrip() | |
1977 if currentValue: | |
1978 line += os.pathsep | |
1979 line += selected.jdk + os.linesep | |
1980 append = False | |
1981 envLines.append(line) | |
1982 if append: | 1986 if append: |
1983 envLines.append(varName + '=' + selected.jdk) | 1987 envLines.append(varName + '=' + selected.jdk + os.linesep) |
1984 | 1988 |
1985 with open(envPath, 'w') as fp: | 1989 with open(envPath, 'w') as fp: |
1986 for line in envLines: | 1990 for line in envLines: |
1987 fp.write(line) | 1991 fp.write(line) |
1988 | 1992 |