changeset 3720:bb1924f0625b

Removed pytools - replaced by mxtool.
author Doug Simon <doug.simon@oracle.com>
date Fri, 16 Dec 2011 14:24:37 +0100
parents 5140bf905747
children 71b1204a74b4
files pytools/.project pytools/.pydevproject pytools/commands.py pytools/gl pytools/gl.py
diffstat 5 files changed, 0 insertions(+), 509 deletions(-) [+]
line wrap: on
line diff
--- a/pytools/.project	Fri Dec 16 13:37:14 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>pytools</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.python.pydev.PyDevBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.python.pydev.pythonNature</nature>
-	</natures>
-</projectDescription>
--- a/pytools/.pydevproject	Fri Dec 16 13:37:14 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?eclipse-pydev version="1.0"?>
-
-<pydev_project>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
-<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
-<path>/pytools</path>
-</pydev_pathproperty>
-
-</pydev_project>
--- a/pytools/commands.py	Fri Dec 16 13:37:14 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-#
-# commands.py - the default commands available to gl.py
-#
-# ----------------------------------------------------------------------------------------------------
-#
-# Copyright (c) 2007, 2011, 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 os
-from os.path import join, exists
-from collections import Callable
-
-def clean(env, args):
-    """cleans the GraalVM source tree"""
-    os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16')
-    env.run([env.gmake_cmd(), 'clean'], cwd=join(env.graal_home, 'make'))
-
-def bootstrap(env, args):
-    return env.run_vm(args + ['-version'])
-
-def example(env, args):
-    """run some or all Graal examples"""
-    examples = {
-        'safeadd': ['com.oracle.max.graal.examples.safeadd', 'com.oracle.max.graal.examples.safeadd.Main'],
-        'vectorlib': ['com.oracle.max.graal.examples.vectorlib', 'com.oracle.max.graal.examples.vectorlib.Main'],
-    }
-
-    def run_example(env, verbose, project, mainClass):
-        cp = env.mx().pdb().classpath(project)
-        sharedArgs = ['-Xcomp', '-XX:CompileOnly=Main', mainClass]
-        
-        res = []
-        env.log("=== Server VM ===")
-        printArg = '-XX:+PrintCompilation' if verbose else '-XX:-PrintCompilation'
-        res.append(env.run_vm(['-cp', cp, printArg] + sharedArgs, vm="-server"))
-        env.log("=== Graal VM ===")
-        printArg = '-G:+PrintCompilation' if verbose else '-G:-PrintCompilation'
-        res.append(env.run_vm(['-cp', cp, printArg, '-G:-Extend', '-G:-Inline'] + sharedArgs))
-        env.log("=== Graal VM with extensions ===")
-        res.append(env.run_vm(['-cp', cp, printArg, '-G:+Extend', '-G:-Inline'] + sharedArgs))
-        
-        if len([x for x in res if x != 0]) != 0:
-            return 1
-        return 0
-
-    verbose = False
-    if '-v' in args:
-        verbose = True
-        args = [a for a in args if a != '-v']
-
-    if len(args) == 0:
-        args = examples.keys()
-    for a in args:
-        config = examples.get(a)
-        if config is None:
-            env.log('unknown example: ' + a + '  {available examples = ' + str(examples.keys()) + '}')
-        else:
-            env.log('--------- ' + a + ' ------------')
-            project, mainClass = config
-            run_example(env, verbose, project, mainClass)
-
-def dacapo(env, args):
-    """run a DaCapo benchmark"""
-    
-    benchmarks = {
-        'avrora': ['-n', '5'],
-        'batik': ['-n', '5'],
-        'eclipse': ['-n', '5'],
-        'fop': ['-n', '5'],
-        'h2': ['-n', '5'],
-        'jython': ['-n', '5'],
-        'luindex': ['-n', '5'],
-        'lusearch': ['-n', '5'],
-        'pmd': ['-n', '5'],
-        'sunflow': ['-n', '5'],
-        'tomcat': ['-n', '5'],
-        'tradebeans': ['-n', '5'],
-        'tradesoap': ['-n', '5'],
-        'xalan': ['-n', '5'],
-    }
-    
-    if len(args) == 0:
-        args = args[0:]
-        for bm in benchmarks:
-            env.run_dacapo(args + ['Harness', '-n', '2'] + [bm])
-        return 
-    else:
-        bm = args[0]
-        config = benchmarks.get(bm)
-        if (config is None):
-            env.abort('unknown benchmark: ' + bm + '\nselect one of: ' + str(benchmarks.keys()))
-        args = args[1:]
-        return env.run_dacapo(args + ['Harness'] + config + [bm])
-    
-def tests(env, args):
-    """run a selection of the Maxine JTT tests in Graal"""
-    
-    def jtt(name):
-        return join(env.maxine, 'com.oracle.max.vm', 'test', 'jtt', name)
-    
-    return env.run_vm(args + ['-ea', '-esa', '-Xcomp', '-XX:+PrintCompilation', '-XX:CompileOnly=jtt'] + args +
-                       ['-Xbootclasspath/p:' + join(env.maxine, 'com.oracle.max.vm', 'bin'), 
-                        '-Xbootclasspath/p:' + join(env.maxine, 'com.oracle.max.base', 'bin'),
-                        'test.com.sun.max.vm.compiler.JavaTester',
-                        '-verbose=1', '-gen-run-scheme=false', '-run-scheme-package=all',
-                        jtt('bytecode'),
-                        jtt('except'), 
-                        jtt('jdk'), 
-                        jtt('hotpath'), 
-                        jtt('jdk'), 
-                        jtt('lang'), 
-                        jtt('loop'), 
-                        jtt('micro'), 
-                        jtt('optimize'), 
-                        jtt('reflect'), 
-                        jtt('threads'), 
-                        jtt('hotspot')])
-
-def help_(env, args):
-    """show help for a given command
-
-With no arguments, print a list of commands and short help for each command.
-
-Given a command name, print help for that command."""
-    if len(args) == 0:
-        env.print_help()
-        return
-    
-    name = args[0]
-    if not table.has_key(name):
-        env.error('unknown command: ' + name)
-    
-    value = table[name]
-    (func, usage) = value[:2]
-    doc = func.__doc__
-    if len(value) > 2:
-        docArgs = value[2:]
-        fmtArgs = []
-        for d in docArgs:
-            if isinstance(d, Callable):
-                fmtArgs += [d(env)]
-            else:
-                fmtArgs += [str(d)]
-        doc = doc.format(*fmtArgs)
-    print 'gl {0} {1}\n\n{2}\n'.format(name, usage, doc)
-
-def make(env, args):
-    """builds the GraalVM binary"""
-
-    def fix_jvm_cfg(env, jdk):
-        jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg')
-        found = False
-        if not exists(jvmCfg):
-            env.abort(jvmCfg + ' does not exist')
-            
-        with open(jvmCfg) as f:
-            for line in f:
-                if '-graal KNOWN' in line:
-                    found = True
-                    break
-        if not found:
-            env.log('Appending "-graal KNOWN" to ' + jvmCfg)
-            with open(jvmCfg, 'a') as f:
-                f.write('-graal KNOWN\n')
-
-    fix_jvm_cfg(env, env.jdk7)
-
-    if env.get_os() != 'windows':
-        javaLink = join(env.graal_home, 'hotspot', 'java')
-        if not exists(javaLink):
-            javaExe = join(env.jdk7, 'jre', 'bin', 'java')
-            env.log('Creating link: ' + javaLink + ' -> ' + javaExe)
-            os.symlink(javaExe, javaLink)
-
-    graalVmDir = join(env.jdk7, 'jre', 'lib', 'amd64', 'graal')
-    if not exists(graalVmDir):
-        env.log('Creating Graal directory in JDK7: ' + graalVmDir)
-        os.makedirs(graalVmDir)
-
-    os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='4', ALT_BOOTDIR=env.jdk7, INSTALL='y')
-    env.run([env.gmake_cmd(), 'productgraal'], cwd=join(env.graal_home, 'make'))
-    
-def vm(env, args):
-    return env.run_vm(args)
-
-# Table of commands in alphabetical order.
-# Keys are command names, value are lists: [<function>, <usage msg>, <format args to doc string of function>...]
-# If any of the format args are instances of Callable, then they are called with an 'env' are before being
-# used in the call to str.format().  
-# Extensions should update this table directly
-table = {
-    'dacapo': [dacapo, 'benchmark [VM options]'],
-    'example': [example, '[-v] example names...'],
-    'bootstrap': [bootstrap, ''],
-    'clean': [clean, ''],
-    'help': [help_, '[command]'],
-    'make': [make, ''],
-    'tests': [tests, ''],
-    'vm': [vm, ''],
-}
--- a/pytools/gl	Fri Dec 16 13:37:14 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-dir=`/bin/pwd`
-while [ ! \( -f "$dir/pytools/gl.py" -a -f "$dir/GRAAL_README" \) ]; do
-    dir="$(dirname $dir)"
-    if [ "$dir" = "/" ]; then 
-        echo "Cannot find 'pytools/gl.py' in `/bin/pwd` or any of it's parents"
-        exit 1
-    fi
-done
-
-python <<END
-import sys
-major, minor, micro, _, _ = sys.version_info
-if major != 2 or minor != 7:
-    raise SystemExit('The gl.py script requires Python 2.7, not {0}.{1}.{2}'.format(major, minor, micro))
-END
-if [ $? -eq 0 ]; then
-    exec python "$dir/pytools/gl.py" "$@"
-fi
-
--- a/pytools/gl.py	Fri Dec 16 13:37:14 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,240 +0,0 @@
-#!/usr/bin/python
-#
-# gl.py - shell interface for Graal source code
-#
-# ----------------------------------------------------------------------------------------------------
-#
-# Copyright (c) 2007, 2011, 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.
-#
-# ----------------------------------------------------------------------------------------------------
-#
-# A launcher for Graal executables and tools.
-#
-
-import subprocess
-from threading import Thread
-from argparse import ArgumentParser, REMAINDER
-from os.path import join, dirname, abspath, exists, isfile, isdir
-import commands
-import types
-import sys
-import os
-
-class Env(ArgumentParser):
-
-    # Override parent to append the list of available commands
-    def format_help(self):
-        msg = ArgumentParser.format_help(self) + '\navailable commands:\n\n'
-        for cmd in sorted(commands.table.iterkeys()):
-            c, _ = commands.table[cmd][:2]
-            doc = c.__doc__
-            if doc is None:
-                doc = ''
-            msg += ' {0:<20} {1}\n'.format(cmd, doc.split('\n', 1)[0])
-        return msg + '\n'
-    
-    def __init__(self):
-        self.dacapo = os.getenv('DACAPO')
-        self.jdk7 = os.getenv('JDK7')
-        self.maxine = os.getenv('MAXINE')
-        self._mx = None
-        
-        ArgumentParser.__init__(self, prog='gl')
-    
-        self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output')
-        self.add_argument('-d', action='store_true', dest='java_dbg', help='make Java processes wait on port 8000 for a debugger')
-        self.add_argument('--dacapo', help='path to DaCapo 9.12 jar file', metavar='<path>')
-        self.add_argument('--jdk7', help='JDK7 in which the GraalVM will be installed', metavar='<path>')
-        self.add_argument('-M', dest='maxine', help='path to Maxine code base', metavar='<path>')
-        
-    def parse_cmd_line(self, configFile):
-        
-        self.add_argument('commandAndArgs', nargs=REMAINDER, metavar='command args...')
-        
-        self.parse_args(namespace=self)
-
-        if self.jdk7 is None:
-            self.abort('JDK7 is required. Use --jdk7 option or set JDK7 environment variable (in ' + configFile + ')')
-            
-        if not isdir(self.jdk7):
-            self.abort('Specified JDK7 path is not a directory: ' + self.jdk7)
-
-        self.graal_home = dirname(abspath(dirname(sys.argv[0])))
-    
-    def load_config_file(self, configFile):
-        """ adds attributes to this object from a file containing key=value lines """
-        if exists(configFile):
-            with open(configFile) as f:
-                #self.log('[loading vars from ' + configFile + ']')
-                for line in f:
-                    if not line.startswith('#'):
-                        kv = line.split('=', 1)
-                        if len(kv) == 2:
-                            k = kv[0].strip().lower()
-                            setattr(self, k, os.path.expandvars(kv[1].strip()))
-
-    def get_os(self):
-        if sys.platform.startswith('darwin'):
-            return 'darwin'
-        elif sys.platform.startswith('linux'):
-            return 'linux'
-        elif sys.platform.startswith('sunos'):
-            return 'solaris'
-        elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
-            return 'windows'
-        else:
-            self.abort('Supported operating system could not be derived from ' + sys.platform)
-
-        
-    def exe(self, name):
-        if self.get_os() == 'windows':
-            return name + '.exe'
-        return name
-
-    def run_dacapo(self, args):
-        if self.dacapo is None:
-            self.abort('Need to specify DaCapo jar with --dacapo option or DACAPO environment variable')
-        if not isfile(self.dacapo) or not self.dacapo.endswith('.jar'):
-            self.abort('Specified DaCapo jar file does not exist or is not a jar file: ' + self.dacapo)
-        return self.run_vm(['-Xms1g', '-Xmx2g', '-esa', '-cp', self.dacapo] + args)
-
-    def run_vm(self, args, vm='-graal'):
-        if self.maxine is None:
-            configFile = join(dirname(sys.argv[0]), 'glrc')
-            self.abort('Path to Maxine code base must be specified with -M option or MAXINE environment variable (in ' + configFile + ')')
-        if not exists(join(self.maxine, 'com.oracle.max.graal.hotspot', 'bin', 'com', 'oracle', 'max', 'graal', 'hotspot', 'VMEntriesNative.class')):
-            self.abort('Maxine code base path specified -M option or MAXINE environment variable does not contain com.oracle.max.graal.hotspot/bin/com/oracle/max/graal/hotspot/VMEntriesNative.class: ' + self.maxine)
-            
-        if self.java_dbg:
-            args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args
-
-        os.environ['MAXINE'] = self.maxine
-        exe = join(self.jdk7, 'bin', self.exe('java'))
-        return self.run([exe, vm] + args)
-
-    def run(self, args, nonZeroIsFatal=True, out=None, err=None, cwd=None):
-        """
-        
-        Run a command in a subprocess, wait for it to complete and return the exit status of the process.
-        If the exit status is non-zero and `nonZeroIsFatal` is true, then the program is exited with
-        the same exit status.
-        Each line of the standard output and error streams of the subprocess are redirected to the
-        provided out and err functions if they are not None.
-        
-        """
-        
-        assert isinstance(args, types.ListType), "'args' must be a list: " + str(args)
-        for arg in args:
-            if not isinstance(arg, types.StringTypes):
-                self.abort('argument is not a string: ' + str(arg))
-        
-        if self.verbose:
-            self.log(' '.join(args))
-            
-        try:
-            if out is None and err is None:
-                retcode = subprocess.call(args, cwd=cwd)
-            else:
-                def redirect(stream, f):
-                    for line in iter(stream.readline, ''):
-                        f(line)
-                    stream.close()
-                p = subprocess.Popen(args, stdout=None if out is None else subprocess.PIPE, stderr=None if err is None else subprocess.PIPE)
-                if out is not None:
-                    t = Thread(target=redirect, args=(p.stdout, out))
-                    t.daemon = True # thread dies with the program
-                    t.start()
-                if err is not None:
-                    t = Thread(target=redirect, args=(p.stderr, err))
-                    t.daemon = True # thread dies with the program
-                    t.start()
-                retcode = p.wait()
-        except OSError as e:
-            self.log('Error executing \'' + ' '.join(args) + '\': ' + str(e))
-            if self.verbose:
-                raise e
-            self.abort(e.errno)
-        
-
-        if retcode and nonZeroIsFatal:
-            if self.verbose:
-                raise subprocess.CalledProcessError(retcode, ' '.join(args))
-            self.abort(retcode)
-            
-        return retcode
-
-    def gmake_cmd(self):
-        for a in ['make', 'gmake', 'gnumake']:
-            try:
-                output = subprocess.check_output([a, '--version'])
-                if 'GNU' in output:
-                    return a;
-            except:
-                pass
-        self.abort('Could not find a GNU make executable on the current path.')
-    
-    def log(self, msg=None):
-        if msg is None:
-            print
-        else:
-            print msg
-           
-    def abort(self, code):
-        """ raises a SystemExit exception with the provided exit code """
-        raise SystemExit(code)
-
-    def mx(self):
-        if (self._mx is None):
-            p = join(self.maxine, 'com.oracle.max.shell')
-            sys.path.insert(0, p)
-            import mx
-            self._mx = mx.Env()
-            self._mx.maxine_home = self.maxine
-            self._mx.parse_cmd_line([])
-        return self._mx
-
-def main(env):
-    configFile = join(dirname(sys.argv[0]), 'glrc')
-    env.load_config_file(configFile)
-    env.parse_cmd_line(configFile)
-    
-    if len(env.commandAndArgs) == 0:
-        env.print_help()
-        return
-    
-    env.command = env.commandAndArgs[0]
-    env.command_args = env.commandAndArgs[1:]
-    
-    if not commands.table.has_key(env.command):
-        env.error('unknown command "' + env.command + '"')
-        
-    c, _ = commands.table[env.command][:2]
-    try:
-        retcode = c(env, env.command_args)
-        if retcode is not None and retcode != 0:
-            env.abort(retcode)
-    except KeyboardInterrupt:
-        env.abort(1)
-        
-#This idiom means the below code only runs when executed from command line
-if __name__ == '__main__':
-    main(Env())