changeset 8889:c669e8e621a1

Update the -client line in jvm.cfg when it already exists (ie IGNORE)
author Gilles Duboscq <duboscq@ssw.jku.at>
date Sun, 07 Apr 2013 22:27:16 +0200
parents 89ea104f29ac
children a33b6378cb76
files mx/commands.py
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mx/commands.py	Sun Apr 07 19:37:38 2013 +0200
+++ b/mx/commands.py	Sun Apr 07 22:27:16 2013 +0200
@@ -651,23 +651,31 @@
             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)