Mercurial > hg > graal-jvmci-8
comparison mx.jvmci/mx_jvmci.py @ 22140:60d9e50d5481
only perform check for obsolete JVMCI files during full build
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 06 Jul 2015 22:09:10 +0200 |
parents | ed35cb998428 |
children | f85b80b29176 |
comparison
equal
deleted
inserted
replaced
22139:ed35cb998428 | 22140:60d9e50d5481 |
---|---|
500 shutil.copyfile(src, tmp) | 500 shutil.copyfile(src, tmp) |
501 os.close(fd) | 501 os.close(fd) |
502 shutil.move(tmp, dstLib) | 502 shutil.move(tmp, dstLib) |
503 os.chmod(dstLib, permissions) | 503 os.chmod(dstLib, permissions) |
504 | 504 |
505 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir): | 505 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir, obsoleteCheck): |
506 | 506 |
507 oldServices = os.listdir(servicesDir) if exists(servicesDir) else os.makedirs(servicesDir) | 507 oldServices = os.listdir(servicesDir) if exists(servicesDir) else os.makedirs(servicesDir) |
508 oldOptions = os.listdir(optionsDir) if exists(optionsDir) else os.makedirs(optionsDir) | 508 oldOptions = os.listdir(optionsDir) if exists(optionsDir) else os.makedirs(optionsDir) |
509 | 509 |
510 jvmciServices = {} | 510 jvmciServices = {} |
527 assert filename != "", member | 527 assert filename != "", member |
528 targetpath = join(optionsDir, filename) | 528 targetpath = join(optionsDir, filename) |
529 optionsFiles.append(filename) | 529 optionsFiles.append(filename) |
530 with zf.open(member) as optionsFile, \ | 530 with zf.open(member) as optionsFile, \ |
531 file(targetpath, "wb") as target: | 531 file(targetpath, "wb") as target: |
532 shutil.copyfileobj(optionsFile, target) | 532 if not obsoleteCheck: |
533 shutil.copyfileobj(optionsFile, target) | |
533 if oldOptions and filename in oldOptions: | 534 if oldOptions and filename in oldOptions: |
534 oldOptions.remove(filename) | 535 oldOptions.remove(filename) |
535 for service, providers in jvmciServices.iteritems(): | 536 for service, providers in jvmciServices.iteritems(): |
536 fd, tmp = tempfile.mkstemp(prefix=service) | 537 if not obsoleteCheck: |
537 f = os.fdopen(fd, 'w+') | 538 fd, tmp = tempfile.mkstemp(prefix=service) |
538 for provider in providers: | 539 f = os.fdopen(fd, 'w+') |
539 f.write(provider + os.linesep) | 540 for provider in providers: |
540 target = join(servicesDir, service) | 541 f.write(provider + os.linesep) |
541 f.close() | 542 target = join(servicesDir, service) |
542 shutil.move(tmp, target) | 543 f.close() |
544 shutil.move(tmp, target) | |
545 if mx.get_os() != 'windows': | |
546 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE) | |
543 if oldServices and service in oldServices: | 547 if oldServices and service in oldServices: |
544 oldServices.remove(service) | 548 oldServices.remove(service) |
545 if mx.get_os() != 'windows': | 549 |
546 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE) | 550 if obsoleteCheck: |
547 | |
548 if mx.is_interactive(): | |
549 for d, files in [(servicesDir, oldServices), (optionsDir, oldOptions)]: | 551 for d, files in [(servicesDir, oldServices), (optionsDir, oldOptions)]: |
550 if files and mx.ask_yes_no('These files in ' + d + ' look obsolete:\n ' + '\n '.join(files) + '\nDelete them', 'n'): | 552 if files: |
551 for f in files: | 553 print 'These files in ' + d + ' look obsolete:\n ' + '\n '.join(files) |
552 path = join(d, f) | 554 if mx.is_interactive() and mx.ask_yes_no('Delete them', 'n'): |
553 os.remove(path) | 555 for f in files: |
554 mx.log('Deleted ' + path) | 556 path = join(d, f) |
555 | 557 os.remove(path) |
556 def _updateJVMCIFiles(jdkDir): | 558 mx.log('Deleted ' + path) |
559 | |
560 def _updateJVMCIFiles(jdkDir, obsoleteCheck=False): | |
557 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci') | 561 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci') |
558 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.endswith('.jar')] | 562 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.endswith('.jar')] |
559 jreJVMCIServicesDir = join(jreJVMCIDir, 'services') | 563 jreJVMCIServicesDir = join(jreJVMCIDir, 'services') |
560 jreJVMCIOptionsDir = join(jreJVMCIDir, 'options') | 564 jreJVMCIOptionsDir = join(jreJVMCIDir, 'options') |
561 _extractJVMCIFiles(_getJdkDeployedJars(jdkDir), jvmciJars, jreJVMCIServicesDir, jreJVMCIOptionsDir) | 565 _extractJVMCIFiles(_getJdkDeployedJars(jdkDir), jvmciJars, jreJVMCIServicesDir, jreJVMCIOptionsDir, obsoleteCheck) |
562 | 566 |
563 def _installDistInJdks(deployableDist): | 567 def _installDistInJdks(deployableDist): |
564 """ | 568 """ |
565 Installs the jar(s) for a given Distribution into all existing JVMCI JDKs | 569 Installs the jar(s) for a given Distribution into all existing JVMCI JDKs |
566 """ | 570 """ |
585 if deployableDist.usesJVMCIClassLoader: | 589 if deployableDist.usesJVMCIClassLoader: |
586 # deploy service files | 590 # deploy service files |
587 _updateJVMCIFiles(jdkDir) | 591 _updateJVMCIFiles(jdkDir) |
588 if deployableDist.postJdkInstall: | 592 if deployableDist.postJdkInstall: |
589 deployableDist.postJdkInstall(jdkDir, targetDir) | 593 deployableDist.postJdkInstall(jdkDir, targetDir) |
594 | |
595 def _check_for_obsolete_jvmci_files(): | |
596 jdks = _jdksDir() | |
597 if exists(jdks): | |
598 for e in os.listdir(jdks): | |
599 jdkDir = join(jdks, e) | |
600 _updateJVMCIFiles(jdkDir, obsoleteCheck=True) | |
590 | 601 |
591 def _getJdkDeployedJars(jdkDir): | 602 def _getJdkDeployedJars(jdkDir): |
592 """ | 603 """ |
593 Gets jar paths for all deployed distributions in the context of | 604 Gets jar paths for all deployed distributions in the context of |
594 a given JDK directory. | 605 a given JDK directory. |
727 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) | 738 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) |
728 assert len(opts2.remainder) == 0 | 739 assert len(opts2.remainder) == 0 |
729 | 740 |
730 if not opts2.native: | 741 if not opts2.native: |
731 return | 742 return |
743 | |
744 if opts2.java and not opts2.projects and not opts2.only: | |
745 # Only check deployed JVMCI files on a full build | |
746 _check_for_obsolete_jvmci_files() | |
732 | 747 |
733 builds = [_vmbuild] | 748 builds = [_vmbuild] |
734 | 749 |
735 if os.environ.get('BUILDING_FROM_IDE', None) == 'true': | 750 if os.environ.get('BUILDING_FROM_IDE', None) == 'true': |
736 build = os.environ.get('IDE_BUILD_TARGET', None) | 751 build = os.environ.get('IDE_BUILD_TARGET', None) |