comparison mx/mx_graal.py @ 21887:543f150e7fa0

com.oracle.jvmci.service.Service is now a marker for service implementations available via JVMCI; removed Truffle -> JVMCI dependency
author Doug Simon <doug.simon@oracle.com>
date Tue, 09 Jun 2015 22:44:34 +0200
parents b1234c06ea49
children 9fe51d8fae0f
comparison
equal deleted inserted replaced
21886:b1234c06ea49 21887:543f150e7fa0
548 shutil.copyfile(src, tmp) 548 shutil.copyfile(src, tmp)
549 os.close(fd) 549 os.close(fd)
550 shutil.move(tmp, dstLib) 550 shutil.move(tmp, dstLib)
551 os.chmod(dstLib, permissions) 551 os.chmod(dstLib, permissions)
552 552
553 def _filterJVMCIServices(serviceImplNames, classpath): 553 def _filterJVMCIServices(servicesMap, classpath):
554 """ 554 """
555 Filters and returns the names in 'serviceImplNames' that denote 555 Filters and returns the names in 'serviceImplNames' that denote
556 types available in 'classpath' implementing or extending 556 types available in 'classpath' implementing or extending
557 com.oracle.jvmci.service.Service. 557 com.oracle.jvmci.service.Service.
558 """ 558 """
559 _, binDir = mx._compile_mx_class('FilterTypes', os.pathsep.join(classpath), myDir=dirname(__file__)) 559 _, binDir = mx._compile_mx_class('FilterTypes', os.pathsep.join(classpath), myDir=dirname(__file__))
560 cmd = [mx.java().java, '-cp', mx._cygpathU2W(os.pathsep.join([binDir] + classpath)), 'FilterTypes', 'com.oracle.jvmci.service.Service'] + serviceImplNames 560 serialized = [k + '=' + ','.join(v) for k, v in servicesMap.iteritems()]
561 services = subprocess.check_output(cmd) 561 cmd = [mx.java().java, '-cp', mx._cygpathU2W(os.pathsep.join([binDir] + classpath)), 'FilterTypes', 'com.oracle.jvmci.service.Service'] + serialized
562 if len(services) == 0: 562 serialized = subprocess.check_output(cmd)
563 return [] 563 if len(serialized) == 0:
564 return services.split('|') 564 return {}
565 servicesMap = {}
566 for e in serialized.split(' '):
567 k, v = e.split('=')
568 impls = v.split(',')
569 servicesMap[k] = impls
570 return servicesMap
565 571
566 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir, cleanDestination=True): 572 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir, cleanDestination=True):
567 if cleanDestination: 573 if cleanDestination:
568 if exists(servicesDir): 574 if exists(servicesDir):
569 shutil.rmtree(servicesDir) 575 shutil.rmtree(servicesDir)
600 targetpath = join(optionsDir, filename) 606 targetpath = join(optionsDir, filename)
601 optionsFiles.append(filename) 607 optionsFiles.append(filename)
602 with zf.open(member) as optionsFile, \ 608 with zf.open(member) as optionsFile, \
603 file(targetpath, "wb") as target: 609 file(targetpath, "wb") as target:
604 shutil.copyfileobj(optionsFile, target) 610 shutil.copyfileobj(optionsFile, target)
605 jvmciServices = _filterJVMCIServices(servicesMap.keys(), jdkJars) 611 servicesMap = _filterJVMCIServices(servicesMap, jdkJars)
606 for serviceName in jvmciServices: 612 for serviceName, serviceImpls in servicesMap.iteritems():
607 serviceImpls = servicesMap[serviceName]
608 fd, tmp = tempfile.mkstemp(prefix=serviceName) 613 fd, tmp = tempfile.mkstemp(prefix=serviceName)
609 f = os.fdopen(fd, 'w+') 614 f = os.fdopen(fd, 'w+')
610 for serviceImpl in serviceImpls: 615 for serviceImpl in serviceImpls:
611 f.write(serviceImpl + os.linesep) 616 f.write(serviceImpl + os.linesep)
612 target = join(servicesDir, serviceName) 617 target = join(servicesDir, serviceName)
613 f.close() 618 f.close()
614 shutil.move(tmp, target) 619 shutil.move(tmp, target)
615 if mx.get_os() != 'windows': 620 if mx.get_os() != 'windows':
616 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE) 621 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE)
617 return (jvmciServices, optionsFiles)
618 622
619 def _updateJVMCIFiles(jdkDir): 623 def _updateJVMCIFiles(jdkDir):
620 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci') 624 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci')
621 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.endswith('.jar')] 625 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.endswith('.jar')]
622 jreJVMCIServicesDir = join(jreJVMCIDir, 'services') 626 jreJVMCIServicesDir = join(jreJVMCIDir, 'services')