# HG changeset patch # User Gilles Duboscq # Date 1365366436 -7200 # Node ID c669e8e621a11f9ea4ceeddc72998d2e9f89491b # Parent 89ea104f29accb2bfcdddbdb77370eb4e5e8dc53 Update the -client line in jvm.cfg when it already exists (ie IGNORE) diff -r 89ea104f29ac -r c669e8e621a1 mx/commands.py --- 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)