From b64ae1026600f290b69afe0fbea07fb1bbc4a5b8 Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 14 Jun 2001 01:51:28 +0000 Subject: [PATCH] Skeleton of viztool project for visualizing Java classes. git-svn-id: https://samskivert.googlecode.com/svn/trunk@156 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- projects/viztool/bin/runjava | 93 +++++++++++++++++++ projects/viztool/build.xml | 54 +++++++++++ projects/viztool/lib/README | 16 ++++ .../src/java/com/samskivert/viztool/Log.java | 38 ++++++++ 4 files changed, 201 insertions(+) create mode 100755 projects/viztool/bin/runjava create mode 100644 projects/viztool/build.xml create mode 100644 projects/viztool/lib/README create mode 100644 projects/viztool/src/java/com/samskivert/viztool/Log.java diff --git a/projects/viztool/bin/runjava b/projects/viztool/bin/runjava new file mode 100755 index 00000000..759ee948 --- /dev/null +++ b/projects/viztool/bin/runjava @@ -0,0 +1,93 @@ +#!/usr/bin/perl -w +# +# $Id: runjava,v 1.1 2001/06/14 01:51:28 mdb Exp $ +# +# A script for invoking java. The project root is inferred to be one +# directory above the directory in which this script lives. Based on the +# root, all .jar files in the lib subdirectory are added to the classpath. +# Additionally all shared libraries in lib/$arch, where $arch is generated +# via uname and looks something like i686-Linux, are added to the +# LD_LIBRARY_PATH environment variable. Classes are assumed to live in +# $classdir as defined below. + +use strict; +use Getopt::Std; + +# this is where our classfiles live (relative to the project root) +my $classdir = "dist/classes"; + +# parse the arguments +my %opts; +getopts('p:v', \%opts); +my $pid_file = $opts{"p"}; +my $verbose = $opts{"v"}; + +# make sure they specified a classfile +my $usage = "Usage: $0 [-p pid_file] [-v] [-- args to pass to java] class\n"; +die $usage unless (@ARGV); + +# get the server root by popping the /bin off of our directory +my $location; +chomp($location = `dirname $0`); +my @parts = split(/\//, $location); +pop(@parts); +my $root = join("/", @parts); + +# figure out where our JVM lives +my $jhome = $ENV{"JAVA_HOME"}; + +# make sure JAVA_HOME is set +if (!defined $jhome) { + warn "$0: Error: No JAVA_HOME specified!\n"; + warn "\n"; + warn "You must set your JAVA_HOME environment variable to the\n"; + warn "the absolute path of your JDK installation. For example:\n"; + warn "\n"; + warn " % JAVA_HOME=/usr/local/jdk1.2\n"; + warn " % export JAVA_HOME\n"; + die "\n"; +} + +my $java = "$jhome/bin/java"; +my $jlib = "$jhome/lib/classes.zip"; + +# make sure we can run the jvm +if (! -x $java) { + die "$0: Can't find a java interpreter in '$jhome'.\n"; +} + +# determine our machine architecture +my $ostype = `uname -s`; +my $machtype = `uname -m`; +chomp($ostype); +chomp($machtype); +my $arch = "$machtype-$ostype"; + +# add our native libraries to the runtime library path +my $libs = "$root/lib/$arch"; +my $libpath = $ENV{"LD_LIBRARY_PATH"}; + +if (defined $libpath) { + $ENV{"LD_LIBRARY_PATH"} = "$libs:$libpath"; +} else { + $ENV{"LD_LIBRARY_PATH"} = $libs; +} + +# put everything in our class path +my $classpath = "-classpath $jlib:$root/$classdir"; + +# any zip or jar files in our lib/ directory get added to the class path +if (opendir(DIR, "$root/lib")) { + my $lib; + foreach $lib (grep { /.(zip|jar)/ && -f "$root/lib/$_" } readdir(DIR)) { + $classpath .= ":$root/lib/$lib"; + } + closedir DIR; +} + +# log the pid file if requested to do so +print `echo $$ > $pid_file` if (defined $pid_file); + +my $cmd = "$java -mx256M $classpath " . join(" ", @ARGV); +print "$cmd\n" if ($verbose); +exec($cmd); diff --git a/projects/viztool/build.xml b/projects/viztool/build.xml new file mode 100644 index 00000000..6c3bec00 --- /dev/null +++ b/projects/viztool/build.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/viztool/lib/README b/projects/viztool/lib/README new file mode 100644 index 00000000..e6f6c5ec --- /dev/null +++ b/projects/viztool/lib/README @@ -0,0 +1,16 @@ +Required external libraries +--------------------------- + +The viztool code requires the following external Java libraries (JAR +files) to be placed here in the lib/ directory or in the shared library +directory specified in the build.xml file (${java.libraries}). + +* samskivert library: + http://www.samskivert.com/code/samskivert/ + +Once the jar files are in place (regardless of what they are named), the +build system will automatically include them in the compile-time +classpath. + +-- +$Id: README,v 1.1 2001/06/14 01:51:28 mdb Exp $ diff --git a/projects/viztool/src/java/com/samskivert/viztool/Log.java b/projects/viztool/src/java/com/samskivert/viztool/Log.java new file mode 100644 index 00000000..89c0b839 --- /dev/null +++ b/projects/viztool/src/java/com/samskivert/viztool/Log.java @@ -0,0 +1,38 @@ +// +// $Id: Log.java,v 1.1 2001/06/14 01:51:28 mdb Exp $ + +package com.samskivert.vistool; + +/** + * A placeholder class that contains a reference to the log object used by + * the viztool package. + */ +public class Log +{ + public static com.samskivert.util.Log log = + new com.samskivert.util.Log("viztool"); + + /** Convenience function. */ + public static void debug (String message) + { + log.debug(message); + } + + /** Convenience function. */ + public static void info (String message) + { + log.info(message); + } + + /** Convenience function. */ + public static void warning (String message) + { + log.warning(message); + } + + /** Convenience function. */ + public static void logStackTrace (Throwable t) + { + log.logStackTrace(com.samskivert.util.Log.WARNING, t); + } +}