Mercurial > hg > graal-jvmci-8
diff mx/mx_graal.py @ 21937:3a292e8b9e51
replaced Service marker interface with non-standard META-INF directory names to differentiate JVMCI providers from standard service providers
META-INF/services/ files for Options provider are now generated directly from files in META-INF/jvmci.options/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 12 Jun 2015 01:19:57 +0200 |
parents | 11f241f26c61 |
children | 95956bc1b1a3 |
line wrap: on
line diff
--- a/mx/mx_graal.py Fri Jun 12 01:06:36 2015 +0200 +++ b/mx/mx_graal.py Fri Jun 12 01:19:57 2015 +0200 @@ -550,71 +550,50 @@ shutil.move(tmp, dstLib) os.chmod(dstLib, permissions) -def _filterJVMCIServices(servicesMap, classpath): - """ - Filters and returns the names in 'serviceImplNames' that denote - types available in 'classpath' implementing or extending - com.oracle.jvmci.service.Service. - """ - _, binDir = mx._compile_mx_class('FilterTypes', os.pathsep.join(classpath), myDir=dirname(__file__)) - serialized = [k + '=' + ','.join(v) for k, v in servicesMap.iteritems()] - cmd = [mx.java().java, '-cp', mx._cygpathU2W(os.pathsep.join([binDir] + classpath)), 'FilterTypes', 'com.oracle.jvmci.service.Service'] + serialized - serialized = subprocess.check_output(cmd) - if len(serialized) == 0: - return {} - servicesMap = {} - for e in serialized.split(' '): - k, v = e.split('=') - impls = v.split(',') - servicesMap[k] = impls - return servicesMap - -def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir, cleanDestination=True): - if cleanDestination: - if exists(servicesDir): - shutil.rmtree(servicesDir) - if exists(optionsDir): - shutil.rmtree(optionsDir) +def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir): + if exists(servicesDir): + shutil.rmtree(servicesDir) + if exists(optionsDir): + shutil.rmtree(optionsDir) if not exists(servicesDir): os.makedirs(servicesDir) if not exists(optionsDir): os.makedirs(optionsDir) - servicesMap = {} + jvmciServices = {} optionsFiles = [] for jar in jvmciJars: if os.path.isfile(jar): with zipfile.ZipFile(jar) as zf: for member in zf.namelist(): - if member.startswith('META-INF/services') and member: - serviceName = basename(member) - if serviceName == "": + if member.startswith('META-INF/jvmci.services') and member: + service = basename(member) + if service == "": continue # Zip files may contain empty entries for directories (jar -cf ... creates such) # we don't handle directories - assert serviceName and member == 'META-INF/services/' + serviceName + assert service and member == 'META-INF/jvmci.services/' + service with zf.open(member) as serviceFile: - serviceImpls = servicesMap.setdefault(serviceName, []) + providers = jvmciServices.setdefault(service, []) for line in serviceFile.readlines(): line = line.strip() if line: - serviceImpls.append(line) - elif member.startswith('META-INF/options'): + providers.append(line) + elif member.startswith('META-INF/jvmci.options'): filename = basename(member) if filename == "": continue # Zip files may contain empty entries for directories (jar -cf ... creates such) # we don't handle directories - assert filename and member == 'META-INF/options/' + filename + assert filename and member == 'META-INF/jvmci.options/' + filename targetpath = join(optionsDir, filename) optionsFiles.append(filename) with zf.open(member) as optionsFile, \ file(targetpath, "wb") as target: shutil.copyfileobj(optionsFile, target) - servicesMap = _filterJVMCIServices(servicesMap, jdkJars) - for serviceName, serviceImpls in servicesMap.iteritems(): - fd, tmp = tempfile.mkstemp(prefix=serviceName) + for service, providers in jvmciServices.iteritems(): + fd, tmp = tempfile.mkstemp(prefix=service) f = os.fdopen(fd, 'w+') - for serviceImpl in serviceImpls: - f.write(serviceImpl + os.linesep) - target = join(servicesDir, serviceName) + for provider in providers: + f.write(provider + os.linesep) + target = join(servicesDir, service) f.close() shutil.move(tmp, target) if mx.get_os() != 'windows':