comparison mx/commands.py @ 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 34d13df4165b
children a33b6378cb76
comparison
equal deleted inserted replaced
8888:89ea104f29ac 8889:c669e8e621a1
649 env.pop('CLASSPATH', None) 649 env.pop('CLASSPATH', None)
650 650
651 mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage, env=env) 651 mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage, env=env)
652 652
653 jvmCfg = _vmCfgInJdk(jdk) 653 jvmCfg = _vmCfgInJdk(jdk)
654 found = False
655 if not exists(jvmCfg): 654 if not exists(jvmCfg):
656 mx.abort(jvmCfg + ' does not exist') 655 mx.abort(jvmCfg + ' does not exist')
657 656
658 prefix = '-' + vm 657 prefix = '-' + vm
659 vmKnown = prefix + ' KNOWN' 658 vmKnown = prefix + ' KNOWN\n'
659 lines = []
660 found = False
660 with open(jvmCfg) as f: 661 with open(jvmCfg) as f:
661 for line in f: 662 for line in f:
662 if vmKnown == line.strip(): 663 if line.strip() == vmKnown.strip():
663 found = True 664 found = True
664 break 665 lines.append(line)
666
665 if not found: 667 if not found:
666 mx.log('Appending "' + prefix + ' KNOWN" to ' + jvmCfg) 668 mx.log('Appending "' + prefix + ' KNOWN" to ' + jvmCfg)
667 if mx.get_os() != 'windows': 669 if mx.get_os() != 'windows':
668 os.chmod(jvmCfg, 0755) 670 os.chmod(jvmCfg, 0755)
669 with open(jvmCfg, 'a') as f: 671 with open(jvmCfg, 'w') as f:
670 print >> f, vmKnown 672 for line in lines:
673 if line.startswith(prefix):
674 line = vmKnown
675 found = True
676 f.write(line)
677 if not found:
678 f.write(vmKnown)
671 679
672 if exists(timestampFile): 680 if exists(timestampFile):
673 os.utime(timestampFile, None) 681 os.utime(timestampFile, None)
674 else: 682 else:
675 file(timestampFile, 'a') 683 file(timestampFile, 'a')