diff --git a/mx.truffle/mx_truffle.py b/mx.truffle/mx_truffle.py index 89c9b3edffa4..f9efe8ac3404 100644 --- a/mx.truffle/mx_truffle.py +++ b/mx.truffle/mx_truffle.py @@ -27,6 +27,7 @@ # ---------------------------------------------------------------------------------------------------- import os +import re import subprocess import mx @@ -93,3 +94,58 @@ def _truffle_gate_runner(args, tasks): 'sldebug' : [sldebug, '[SL args|@VM options]'], 'testdownstream' : [testdownstream, ''], }) + +""" +Merges META-INF/truffle/language and META-INF/truffle/instrumentation files. +This code is tightly coupled with the file format generated by +LanguageRegistrationProcessor and InstrumentRegistrationProcessor. +""" +class TruffleArchiveParticipant: + PROPERTY_RE = re.compile(r'(language\d+|instrumentation\d+)(\..+)') + + def _truffle_metainf_file(self, arcname): + if arcname == 'META-INF/truffle/language': + return 'language' + if arcname == 'META-INF/truffle/instrumentation': + return 'instrumentation' + return None + + def __opened__(self, arc, srcArc, services): + self.settings = {} + self.arc = arc + + def __add__(self, arcname, contents): + metainfFile = self._truffle_metainf_file(arcname) + if metainfFile: + properties = self.settings.setdefault(metainfFile, {}) + for line in contents.strip().split(os.linesep): + if not line.startswith('#'): + m = TruffleArchiveParticipant.PROPERTY_RE.match(line) + assert m, line + enum = m.group(1) + prop = m.group(2) + properties.setdefault(enum, []).append(prop) + return True + return False + + def __addsrc__(self, arcname, contents): + return False + + def __closing__(self): + for metainfFile, properties in self.settings.iteritems(): + arcname = 'META-INF/truffle/' + metainfFile + lines = [] + counter = 1 + for enum in sorted(properties.viewkeys()): + assert enum.startswith(metainfFile) + newEnum = metainfFile + str(counter) + counter += 1 + for prop in properties[enum]: + lines.append(newEnum + prop) + + content = os.linesep.join(lines) + self.arc.zf.writestr(arcname, content + '\n') + +def mx_post_parse_cmd_line(opts): + dist = mx.distribution('TRUFFLE_TEST') + dist.set_archiveparticipant(TruffleArchiveParticipant()) diff --git a/mx.truffle/suite.py b/mx.truffle/suite.py index 38befb04da34..e7aa287a1a41 100644 --- a/mx.truffle/suite.py +++ b/mx.truffle/suite.py @@ -454,6 +454,26 @@ ], "description" : "Experimental REPL server to build your debugger console for your language.", "allowsJavadocWarnings": True, - } + }, + + "TRUFFLE_TEST" : { + "subDir" : "truffle", + "javaCompliance" : "1.7", + "dependencies" : [ + "com.oracle.truffle.api.test", + "com.oracle.truffle.api.dsl.test", + "com.oracle.truffle.api.instrumentation.test", + "com.oracle.truffle.api.debug.test", + "com.oracle.truffle.api.interop.java.test", + "com.oracle.truffle.api.object.dsl.test", + "com.oracle.truffle.tools.test", + ], + "exclude" : ["mx:HAMCREST", "mx:JUNIT"], + "distDependencies" : [ + "TRUFFLE_API", + "TRUFFLE_DSL_PROCESSOR", + "TRUFFLE_DEBUG", + ], + }, }, }