# HG changeset patch # User Doug Simon # Date 1435223034 -7200 # Node ID 1ecffe20e46076d8f86c5112e65f6f654d26c77e # Parent 907d35ccde5dcd51ece65de37d49e5ac4d4587a5 removed outputparser.py and FINDBUGS library diff -r 907d35ccde5d -r 1ecffe20e460 mx.truffle/mx_truffle.py --- a/mx.truffle/mx_truffle.py Thu Jun 25 10:44:51 2015 +0200 +++ b/mx.truffle/mx_truffle.py Thu Jun 25 11:03:54 2015 +0200 @@ -26,10 +26,9 @@ # # ---------------------------------------------------------------------------------------------------- -import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, StringIO, socket +import os, stat, errno, sys, shutil, zipfile, tarfile, tempfile, re, time, datetime, platform, subprocess, socket from os.path import join, exists, dirname, basename from argparse import ArgumentParser, RawDescriptionHelpFormatter, REMAINDER -from outputparser import OutputParser, ValuesMatcher import mx import xml.dom.minidom import itertools @@ -1360,120 +1359,6 @@ '--title', 'Graal OpenJDK Project Documentation', '--dot-output-base', 'projects'] + args) -def generateZshCompletion(args): - """generate zsh completion for mx""" - try: - from genzshcomp import CompletionGenerator - except ImportError: - mx.abort("install genzshcomp (pip install genzshcomp)") - - # need to fake module for the custom mx arg parser, otherwise a check in genzshcomp fails - originalModule = mx._argParser.__module__ - mx._argParser.__module__ = "argparse" - generator = CompletionGenerator("mx", mx._argParser) - mx._argParser.__module__ = originalModule - - # strip last line and define local variable "ret" - complt = "\n".join(generator.get().split('\n')[0:-1]).replace('context state line', 'context state line ret=1') - - # add array of possible subcommands (as they are not part of the argument parser) - complt += '\n ": :->command" \\\n' - complt += ' "*::args:->args" && ret=0\n' - complt += '\n' - complt += 'case $state in\n' - complt += '\t(command)\n' - complt += '\t\tlocal -a main_commands\n' - complt += '\t\tmain_commands=(\n' - for cmd in sorted(mx._commands.iterkeys()): - c, _ = mx._commands[cmd][:2] - doc = c.__doc__ - complt += '\t\t\t"{0}'.format(cmd) - if doc: - complt += ':{0}'.format(_fixQuotes(doc.split('\n', 1)[0])) - complt += '"\n' - complt += '\t\t)\n' - complt += '\t\t_describe -t main_commands command main_commands && ret=0\n' - complt += '\t\t;;\n' - - complt += '\t(args)\n' - # TODO: improve matcher: if mx args are given, this doesn't work - complt += '\t\tcase $line[1] in\n' - complt += '\t\t\t\tnoglob \\\n' - complt += '\t\t\t\t\t_arguments -s -S \\\n' - complt += _appendOptions("jvmci", r"G\:") - # TODO: fix -XX:{-,+}Use* flags - complt += _appendOptions("hotspot", r"XX\:") - complt += '\t\t\t\t\t"-version" && ret=0 \n' - complt += '\t\t\t\t;;\n' - complt += '\t\tesac\n' - complt += '\t\t;;\n' - complt += 'esac\n' - complt += '\n' - complt += 'return $ret' - print complt - -def _fixQuotes(arg): - return arg.replace('\"', '').replace('\'', '').replace('`', '').replace('{', '\\{').replace('}', '\\}').replace('[', '\\[').replace(']', '\\]') - -def _appendOptions(optionType, optionPrefix): - def isBoolean(vmap, field): - return vmap[field] == "Boolean" or vmap[field] == "bool" - - def hasDescription(vmap): - return vmap['optDefault'] or vmap['optDoc'] - - complt = "" - for vmap in _parseVMOptions(optionType): - complt += '\t\t\t\t\t-"' - complt += optionPrefix - if isBoolean(vmap, 'optType'): - complt += '"{-,+}"' - complt += vmap['optName'] - if not isBoolean(vmap, 'optType'): - complt += '=' - if hasDescription(vmap): - complt += "[" - if vmap['optDefault']: - complt += r"(default\: " + vmap['optDefault'] + ")" - if vmap['optDoc']: - complt += _fixQuotes(vmap['optDoc']) - if hasDescription(vmap): - complt += "]" - complt += '" \\\n' - return complt - -def _parseVMOptions(optionType): - parser = OutputParser() - # TODO: the optDoc part can wrapped accross multiple lines, currently only the first line will be captured - # TODO: fix matching for float literals - jvmOptions = re.compile( - r"^[ \t]*" - r"(?P(Boolean|Integer|Float|Double|String|bool|intx|uintx|ccstr|double)) " - r"(?P[a-zA-Z0-9]+)" - r"[ \t]+=[ \t]*" - r"(?P([\-0-9]+(\.[0-9]+(\.[0-9]+\.[0-9]+))?|false|true|null|Name|sun\.boot\.class\.path))?" - r"[ \t]*" - r"(?P.+)?", - re.MULTILINE) - parser.addMatcher(ValuesMatcher(jvmOptions, { - 'optType' : '', - 'optName' : '', - 'optDefault' : '', - 'optDoc' : '', - })) - - # gather JVMCI options - output = StringIO.StringIO() - vm(['-XX:-BootstrapJVMCI', '-XX:+UnlockDiagnosticVMOptions', '-G:+PrintFlags' if optionType == "jvmci" else '-XX:+PrintFlagsWithComments'], - vm="jvmci", - vmbuild="optimized", - nonZeroIsFatal=False, - out=output.write, - err=subprocess.STDOUT) - - valueMap = parser.parse(output.getvalue()) - return valueMap - def findbugs(args): '''run FindBugs against non-test Java projects''' findBugsHome = mx.get_env('FINDBUGS_HOME', None) @@ -1544,7 +1429,6 @@ 'checkheaders': [checkheaders, ''], 'clean': [clean, ''], 'findbugs': [findbugs, ''], - 'generateZshCompletion' : [generateZshCompletion, ''], 'maven-install-truffle' : [maven_install_truffle, ''], 'jdkhome': [print_jdkhome, ''], 'gate' : [gate, '[-options]'], diff -r 907d35ccde5d -r 1ecffe20e460 mx.truffle/outputparser.py --- a/mx.truffle/outputparser.py Thu Jun 25 10:44:51 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -# ---------------------------------------------------------------------------------------------------- -# -# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# ---------------------------------------------------------------------------------------------------- - -import re - -class OutputParser: - - def __init__(self): - self.matchers = [] - - def addMatcher(self, matcher): - self.matchers.append(matcher) - - def parse(self, output): - valueMaps = [] - for matcher in self.matchers: - matcher.parse(output, valueMaps) - return valueMaps - -""" -Produces a value map for each match of a given regular expression -in some text. The value map is specified by a template map -where each key and value in the template map is either a constant -value or a named group in the regular expression. The latter is -given as the group name enclosed in '<' and '>'. -""" -class ValuesMatcher: - - def __init__(self, regex, valuesTemplate): - assert isinstance(valuesTemplate, dict) - self.regex = regex - self.valuesTemplate = valuesTemplate - - def parse(self, text, valueMaps): - for match in self.regex.finditer(text): - valueMap = {} - for keyTemplate, valueTemplate in self.valuesTemplate.items(): - key = self.get_template_value(match, keyTemplate) - value = self.get_template_value(match, valueTemplate) - assert not valueMap.has_key(key), key - valueMap[key] = value - valueMaps.append(valueMap) - - def get_template_value(self, match, template): - def replace_var(m): - groupName = m.group(1) - return match.group(groupName) - - return re.sub(r'<([\w]+)>', replace_var, template) diff -r 907d35ccde5d -r 1ecffe20e460 mx.truffle/suite.py --- a/mx.truffle/suite.py Thu Jun 25 10:44:51 2015 +0200 +++ b/mx.truffle/suite.py Thu Jun 25 11:03:54 2015 +0200 @@ -82,20 +82,6 @@ "sha1" : "508bcd26a4d7c4c44048990c6ea789a3b11a62dc", }, - "FINDBUGS" : { - "path" : "jvmci/findbugs-SuppressFBWarnings.jar", - "sha1" : "fb78822d27c68fabf2cb2e5e573b3cdb5f9cae2d", - }, - - "DACAPO" : { - "path" : "lib/dacapo-9.12-bach.jar", - "urls" : [ - "http://lafo.ssw.uni-linz.ac.at/graal-external-deps/dacapo-9.12-bach.jar", - "http://softlayer.dl.sourceforge.net/project/dacapobench/9.12-bach/dacapo-9.12-bach.jar", - ], - "sha1" : "2626a9546df09009f6da0df854e6dc1113ef7dd4", - }, - "JACOCOAGENT" : { "path" : "lib/jacocoagent.jar", "urls" : ["http://lafo.ssw.uni-linz.ac.at/jacoco/jacocoagent-0.7.1-1.jar"], @@ -308,7 +294,6 @@ "com.oracle.truffle.api.dsl", "com.oracle.truffle.api.object", "com.oracle.truffle.tools", - "FINDBUGS" ], "checkstyle" : "com.oracle.truffle.dsl.processor", "javaCompliance" : "1.7",