Skip to content

Commit

Permalink
added TRUFFLE_TEST distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Mar 9, 2016
1 parent c9dc9cb commit d4d4ff2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
56 changes: 56 additions & 0 deletions mx.truffle/mx_truffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# ----------------------------------------------------------------------------------------------------

import os
import re
import subprocess

import mx
Expand Down Expand Up @@ -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())
22 changes: 21 additions & 1 deletion mx.truffle/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
},
},
}

0 comments on commit d4d4ff2

Please sign in to comment.