changeset 7918:0dea5ef60303

Merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Mon, 04 Mar 2013 10:00:49 +0100
parents 1a83cef20ee5 (current diff) 9bff64f43299 (diff)
children 0ae70d44ec9a
files mxtool/mx.py
diffstat 3 files changed, 32 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Mar 04 09:59:47 2013 +0100
+++ b/.hgignore	Mon Mar 04 10:00:49 2013 +0100
@@ -7,7 +7,7 @@
 ^dist/
 ^java/
 ^lib/
-^jdk1.7.0
+^jdk1.(7|8).0
 ^java64/
 ^work/
 \.checkstyle$
--- a/mx/commands.py	Mon Mar 04 09:59:47 2013 +0100
+++ b/mx/commands.py	Mon Mar 04 10:00:49 2013 +0100
@@ -77,6 +77,8 @@
 
 """
 
+_minVersion = mx.JavaVersion('1.7.0_04')
+
 def _chmodDir(chmodFlags, dirname, fnames):
     os.chmod(dirname, chmodFlags)
     for name in fnames:
@@ -91,7 +93,7 @@
     if opts.native:
         os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16')
         mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make'))
-        jdks = join(_graal_home, 'jdk' + mx.java().version)
+        jdks = join(_graal_home, 'jdk' + str(mx.java().version))
         if exists(jdks):
             shutil.rmtree(jdks)
 
@@ -318,7 +320,7 @@
     """
     Get the JDK into which Graal is installed, creating it first if necessary.
     """
-    jdk = join(_graal_home, 'jdk' + mx.java().version, build)
+    jdk = join(_graal_home, 'jdk' + str(mx.java().version), build)
     jdkContents = ['bin', 'include', 'jre', 'lib']
     if (exists(join(jdk, 'db'))):
         jdkContents.append('db')
@@ -435,7 +437,7 @@
     """print the JDK directory selected for the 'vm' command"""
 
     build = _vmbuild if _vmSourcesAvailable else 'product'
-    print join(_graal_home, 'jdk' + mx.java().version, build)
+    print join(_graal_home, 'jdk' + str(mx.java().version), build)
 
 def build(args, vm=None):
     """build the VM binary
@@ -1168,23 +1170,10 @@
 
     mx.commands.update(commands)
 
-def mx_post_parse_cmd_line(opts):
-    version = mx.java().version.split('-')[0]
-    parts = version.split('.')
-    assert len(parts) >= 2
-    assert parts[0] == '1'
-    major = int(parts[1])
-    minor = 0
-    update = 0
-    if len(parts) >= 3:
-        minorParts = parts[2].split('_')
-        if len(minorParts) >= 1:
-            minor = int(minorParts[0])
-        if len(minorParts) >= 2:
-            update = int(minorParts[1])
-    
-    if (not major >= 7) or (major == 7 and minor == 0 and not update >= 4) :
-        mx.abort('Requires Java version 1.7.0_04 or greater, got version ' + version)
+def mx_post_parse_cmd_line(opts):#
+    # TODO _minVersion check could probably be part of a Suite in mx?
+    if (mx.java().version < _minVersion) :
+        mx.abort('Requires Java version ' + str(_minVersion) + ' or greater, got version ' + str(mx.java().version))
 
     if (_vmSourcesAvailable):
         if hasattr(opts, 'vm') and opts.vm is not None:
--- a/mxtool/mx.py	Mon Mar 04 09:59:47 2013 +0100
+++ b/mxtool/mx.py	Mon Mar 04 10:00:49 2013 +0100
@@ -1001,6 +1001,24 @@
             other = JavaCompliance(other)
 
         return cmp(self.value, other.value)
+    
+"""
+A Java version as defined in JSR-56
+"""
+class JavaVersion:
+    def __init__(self, versionString):
+        validChar = '[\x21-\x25\x27-\x29\x2c\x2f-\x5e\x60-\x7f]'
+        separator = '[.-_]'
+        m = re.match(validChar + '+(' + separator + validChar + '+)*', versionString)
+        assert m is not None, 'not a recognized version string: ' + versionString
+        self.versionString = versionString;
+        self.parts = versionString.split(separator)
+        
+    def __str__(self):
+        return self.versionString
+    
+    def __cmp__(self, other):
+        return cmp(self.parts, other.parts)
 
 """
 A JavaConfig object encapsulates info on how Java commands are run.
@@ -1039,8 +1057,8 @@
 
         output = output.split()
         assert output[1] == 'version'
-        self.version = output[2].strip('"')
-        self.javaCompliance = JavaCompliance(self.version)
+        self.version = JavaVersion(output[2].strip('"'))
+        self.javaCompliance = JavaCompliance(self.version.versionString)
 
         if self.debug_port is not None:
             self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(self.debug_port)]
@@ -2303,7 +2321,7 @@
         updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent='    ', newl='\n')) or updated
 
         out = StringIO.StringIO()
-        jdkPlatform = 'JDK_' + java().version
+        jdkPlatform = 'JDK_' + str(java().version)
 
         annotationProcessorEnabled = "false"
         annotationProcessorReferences = ""
@@ -2444,7 +2462,7 @@
 
     if updated:
         log('If using NetBeans:')
-        log('  1. Ensure that a platform named "JDK ' + java().version + '" is defined (Tools -> Java Platforms)')
+        log('  1. Ensure that a platform named "JDK_' + str(java().version) + '" is defined (Tools -> Java Platforms)')
         log('  2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)')
 
 def ideclean(args, suite=None):