diff mx/commands.py @ 9212:216dce75d5ac

Merge.
author Christian Humer <christian.humer@gmail.com>
date Mon, 08 Apr 2013 17:02:55 +0200
parents ca82d06ec93a
children 822163edb8bf
line wrap: on
line diff
--- a/mx/commands.py	Mon Apr 08 17:00:31 2013 +0200
+++ b/mx/commands.py	Mon Apr 08 17:02:55 2013 +0200
@@ -296,14 +296,14 @@
     Get the JDK into which Graal is installed, creating it first if necessary.
     """
     jdk = join(_graal_home, 'jdk' + str(mx.java().version), build)
+    srcJdk = mx.java().jdk
     jdkContents = ['bin', 'include', 'jre', 'lib']
-    if exists(join(jdk, 'db')):
+    if exists(join(srcJdk, 'db')):
         jdkContents.append('db')
-    if mx.get_os() != 'windows' and exists(join(jdk, 'man')):
+    if mx.get_os() != 'windows' and exists(join(srcJdk, 'man')):
         jdkContents.append('man')
     if create:
         if not exists(jdk):
-            srcJdk = mx.java().jdk
             mx.log('Creating ' + jdk + ' from ' + srcJdk)
             os.makedirs(jdk)
             for d in jdkContents:
@@ -485,7 +485,7 @@
     
     out.element('target', {'name' : 'main', 'depends' : 'jar'})
 
-    out.open('target', {'name' : 'compile'})
+    out.open('target', {'name' : 'compile', 'depends' : 'cleanclasses'})
     out.element('mkdir', {'dir' : '${classes.dir}'})
     out.open('javac', {'destdir' : '${classes.dir}', 'debug' : 'on', 'includeantruntime' : 'false', })
     for p in mx.sorted_deps(mx.distribution('GRAAL').deps):
@@ -506,9 +506,12 @@
     out.element('jar', {'destfile' : '${jar.file}', 'basedir' : '${classes.dir}'})
     out.close('target')
     
-    out.open('target', {'name' : 'clean'})
+    out.open('target', {'name' : 'cleanclasses'})
     out.element('delete', {'dir' : '${classes.dir}'})
-    out.element('delete', {'file' : '${jar.filr}'})
+    out.close('target')
+
+    out.open('target', {'name' : 'clean', 'depends' : 'cleanclasses'})
+    out.element('delete', {'file' : '${jar.file}'})
     out.close('target')
 
     out.close('project')
@@ -540,7 +543,6 @@
         buildSuffix = ''
     elif vm == 'client':
         buildSuffix = '1'
-        return
     else:
         assert vm == 'graal', vm
         buildSuffix = 'graal'
@@ -618,11 +620,12 @@
             if build == 'debug':
                 build = 'jvmg'
             runCmd.append(build + buildSuffix) 
-            env = os.environ
+            env = os.environ.copy()
             env.setdefault('ARCH_DATA_MODEL', '64')
             env.setdefault('LANG', 'C')
             env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus))
-            env['ALT_BOOTDIR'] = jdk
+            env['ALT_BOOTDIR'] = mx.java().jdk
+            env['JAVA_HOME'] = jdk
             if not env.has_key('OMIT_GRAAL'):
                 env['GRAAL'] = join(_graal_home, 'graal') # needed for TEST_IN_BUILD
             env.setdefault('INSTALL', 'y')
@@ -648,26 +651,34 @@
             env.pop('LD_LIBRARY_PATH', None)
             env.pop('CLASSPATH', None)
 
-            mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage)
+            mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage, env=env)
 
         jvmCfg = _vmCfgInJdk(jdk)
-        found = False
         if not exists(jvmCfg):
             mx.abort(jvmCfg + ' does not exist')
 
         prefix = '-' + vm
-        vmKnown = prefix + ' KNOWN'
+        vmKnown = prefix + ' KNOWN\n'
+        lines = []
+        found = False
         with open(jvmCfg) as f:
             for line in f:
-                if vmKnown == line.strip():
+                if line.strip() == vmKnown.strip():
                     found = True
-                    break
+                lines.append(line)
+                
         if not found:
             mx.log('Appending "' + prefix + ' KNOWN" to ' + jvmCfg)
             if mx.get_os() != 'windows':
                 os.chmod(jvmCfg, 0755)
-            with open(jvmCfg, 'a') as f:
-                print >> f, vmKnown
+            with open(jvmCfg, 'w') as f:
+                for line in lines:
+                    if line.startswith(prefix):
+                        line = vmKnown
+                        found = True
+                    f.write(line)
+                if not found:
+                    f.write(vmKnown)
 
         if exists(timestampFile):
             os.utime(timestampFile, None)
@@ -1054,7 +1065,9 @@
         for dacapo in dacapos:
             if dacapo not in sanitycheck.dacapoSanityWarmup.keys():
                 mx.abort('Unknown DaCapo : ' + dacapo)
-            benchmarks += [sanitycheck.getDacapo(dacapo, sanitycheck.dacapoSanityWarmup[dacapo][sanitycheck.SanityCheckLevel.Benchmark])]
+            iterations = sanitycheck.dacapoSanityWarmup[dacapo][sanitycheck.SanityCheckLevel.Benchmark]
+            if (iterations > 0):
+                benchmarks += [sanitycheck.getDacapo(dacapo, iterations)]
 
     if ('scaladacapo' in args or 'all' in args):
         benchmarks += sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Benchmark)
@@ -1063,7 +1076,9 @@
         for scaladacapo in scaladacapos:
             if scaladacapo not in sanitycheck.dacapoScalaSanityWarmup.keys():
                 mx.abort('Unknown Scala DaCapo : ' + scaladacapo)
-            benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, sanitycheck.dacapoScalaSanityWarmup[scaladacapo][sanitycheck.SanityCheckLevel.Benchmark])]
+            iterations = sanitycheck.dacapoScalaSanityWarmup[scaladacapo][sanitycheck.SanityCheckLevel.Benchmark]
+            if (iterations > 0):
+                benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, iterations)]
 
     #Bootstrap
     if ('bootstrap' in args or 'all' in args):