Author: boisvert
Date: Wed Dec 9 01:31:11 2009
New Revision: 888671
URL: http://svn.apache.org/viewvc?rev=888671&view=rev
Log:
Add all-in-one JRuby distro script
Added:
buildr/trunk/all-in-one/
buildr/trunk/all-in-one/_buildr
buildr/trunk/all-in-one/buildr (with props)
buildr/trunk/all-in-one/buildr.cmd (with props)
buildr/trunk/rakelib/all-in-one.rake (with props)
Added: buildr/trunk/all-in-one/_buildr
URL:
http://svn.apache.org/viewvc/buildr/trunk/all-in-one/_buildr?rev=888671&view=auto
==============================================================================
--- buildr/trunk/all-in-one/_buildr (added)
+++ buildr/trunk/all-in-one/_buildr Wed Dec 9 01:31:11 2009
@@ -0,0 +1,19 @@
+#!/usr/bin/env jruby
+#
+# This file was generated by RubyGems.
+#
+# The application 'buildr' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'rubygems'
+
+version = ">= 0"
+
+if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
+ version = $1
+ ARGV.shift
+end
+
+gem 'buildr', version
+load Gem.bin_path('buildr', 'buildr', version)
Added: buildr/trunk/all-in-one/buildr
URL:
http://svn.apache.org/viewvc/buildr/trunk/all-in-one/buildr?rev=888671&view=auto
==============================================================================
--- buildr/trunk/all-in-one/buildr (added)
+++ buildr/trunk/all-in-one/buildr Wed Dec 9 01:31:11 2009
@@ -0,0 +1,369 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# jruby.sh - Start Script for the JRuby interpreter
+#
+# Environment Variable Prequisites
+#
+# JRUBY_OPTS (Optional) Default JRuby command line args
+# JRUBY_SHELL Where/What is system shell
+#
+# JAVA_HOME Must point at your Java Development Kit installation.
+#
+# -----------------------------------------------------------------------------
+
+cygwin=false
+
+# ----- Identify OS we are running under --------------------------------------
+case "`uname`" in
+ CYGWIN*) cygwin=true;;
+ Darwin) darwin=true;;
+esac
+
+#
+# Figure out the OS and cpu the same as JNA would, so the library path can be
set
+#
+case "`uname -m`" in
+ i[34567]86) JNA_CPU=i386; JNA_ALT_CPU=amd64;;
+ i86pc) JNA_CPU="x86"; JNA_ALT_CPU=amd64;;
+ amd64|x86_64) JNA_CPU=amd64; JNA_ALT_CPU=i386;;
+ sparc*) JNA_CPU=sparc; JNA_ALT_CPU=sparcv9;;
+esac
+
+# ----- Verify and Set Required Environment Variables -------------------------
+
+## resolve links - $0 may be a link to home
+PRG=$0
+progname=`basename "$0"`
+
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '.*/.*' > /dev/null; then
+ if expr "$link" : '^/' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname ${PRG}`/${link}"
+ fi
+ else
+ PRG="`dirname $PRG`/$link"
+ fi
+done
+
+JRUBY_HOME_1=`dirname "$PRG"` # the ./bin dir
+if [ "$JRUBY_HOME_1" = '.' ] ; then
+ cwd=`pwd`
+ JRUBY_HOME=`dirname $cwd` # JRUBY-2699
+else
+ JRUBY_HOME=`dirname "$JRUBY_HOME_1"` # the . dir
+fi
+
+if [ -z "$JRUBY_OPTS" ] ; then
+ JRUBY_OPTS=""
+fi
+
+JRUBY_OPTS_SPECIAL="--ng" # space-separated list of special flags
+unset JRUBY_OPTS_TEMP
+function process_special_opts {
+ case $1 in
+ --ng) nailgun_client=true;;
+ *) break;;
+ esac
+}
+for opt in ${jruby_op...@]}; do
+ for special in ${jruby_opts_speci...@]}; do
+ if [ $opt != $special ]; then
+ JRUBY_OPTS_TEMP="${JRUBY_OPTS_TEMP} $opt"
+ else
+ # make sure flags listed in JRUBY_OPTS_SPECIAL are processed
+ case "$opt" in
+ --ng)
+ process_special_opts $opt;;
+ esac
+ fi
+ done
+done
+JRUBY_OPTS=${JRUBY_OPTS_TEMP}
+
+if [ -z "$JAVA_HOME" ] ; then
+ JAVA_CMD='java'
+else
+ if $cygwin; then
+ JAVA_HOME=`cygpath -u "$JAVA_HOME"`
+ fi
+ JAVA_CMD="$JAVA_HOME/bin/java"
+fi
+
+# If you're seeing odd exceptions, you may have a bad JVM install.
+# Uncomment this and report the version to the JRuby team along with error.
+#$JAVA_CMD -version
+
+JRUBY_SHELL=/bin/sh
+
+# ----- Set Up The Boot Classpath -------------------------------------------
+
+CP_DELIMITER=":"
+
+# add jruby jars for command-line execution
+for j in "$JRUBY_HOME"/lib/{jruby*,bsf}.jar; do
+ if [ "$JRUBY_CP" ]; then
+ JRUBY_CP="$JRUBY_CP$CP_DELIMITER$j"
+ else
+ JRUBY_CP="$j"
+ fi
+done
+
+if $cygwin; then
+ JRUBY_CP=`cygpath -p -w "$JRUBY_CP"`
+fi
+
+# ----- Set Up The System Classpath -------------------------------------------
+
+if [ "$JRUBY_PARENT_CLASSPATH" != "" ]; then
+ # Use same classpath propagated from parent jruby
+ CP=$JRUBY_PARENT_CLASSPATH
+else
+ # add other jars in lib to CP for command-line execution
+ for j in "$JRUBY_HOME"/lib/*.jar; do
+ if [ "$CP" ]; then
+ CP="$CP$CP_DELIMITER$j"
+ else
+ CP="$j"
+ fi
+ done
+
+ if $cygwin; then
+ CP=`cygpath -p -w "$CP"`
+ fi
+fi
+
+if $cygwin; then
+ # switch delimiter only after building Unix style classpaths
+ CP_DELIMITER=";"
+fi
+
+# ----- Execute The Requested Command -----------------------------------------
+
+if [ -z "$JAVA_MEM" ] ; then
+ JAVA_MEM=-Xmx500m
+fi
+
+if [ -z "$JAVA_STACK" ] ; then
+ JAVA_STACK=-Xss1024k
+fi
+
+JAVA_VM=-client
+JAVA_ENCODING=""
+
+declare -a java_args
+declare -a ruby_args
+
+java_class=org.jruby.Main
+
+# Split out any -J argument for passing to the JVM.
+# Scanning for args is aborted by '--'.
+while [ $# -gt 0 ]
+do
+ case "$1" in
+ # Stuff after '-J' in this argument goes to JVM
+ -J*)
+ val=${1:2}
+ if [ "${val:0:4}" = "-Xmx" ]; then
+ JAVA_MEM=$val
+ elif [ "${val:0:4}" = "-Xss" ]; then
+ JAVA_STACK=$val
+ elif [ "${val}" = "" ]; then
+ $JAVA_CMD -help
+ echo "(Prepend -J in front of these options when using 'jruby'
command)"
+ exit
+ elif [ "${val}" = "-X" ]; then
+ $JAVA_CMD -X
+ echo "(Prepend -J in front of these options when using 'jruby'
command)"
+ exit
+ elif [ "${val}" = "-classpath" ]; then
+ CP="$CP$CP_DELIMITER$2"
+ shift
+ elif [ "${val}" = "-cp" ]; then
+ CP="$CP$CP_DELIMITER$2"
+ shift
+ else
+ if [ "${val:0:3}" = "-ea" ]; then
+ VERIFY_JRUBY="yes"
+ elif [ "${val:0:16}" = "-Dfile.encoding=" ]; then
+ JAVA_ENCODING=$val
+ fi
+ java_args=("${java_ar...@]}" "${1:2}")
+ fi
+ if [ "$CP" != "" ]; then
+ CLASSPATH=""
+ fi
+ ;;
+ # Match switches that take an argument
+ -C|-e|-I|-S) ruby_args=("${ruby_ar...@]}" "$1" "$2"); shift ;;
+ # Match same switches with argument stuck together
+ -e*|-I*|-S*) ruby_args=("${ruby_ar...@]}" "$1" ) ;;
+ # Run with the instrumented profiler: http://jiprof.sourceforge.net/
+ --profile)
+ PROFILE_ARGS="-javaagent:$JRUBY_HOME/lib/profile.jar
-Dprofile.properties=$JRUBY_HOME/lib/profile-ruby.properties"
+ JRUBY_OPTS=("${jruby_op...@]}" "-X+C")
+ VERIFY_JRUBY="yes"
+ ;;
+ # Run with the instrumented profiler: http://jiprof.sourceforge.net/
+ --profile-all)
+ PROFILE_ARGS="-javaagent:$JRUBY_HOME/lib/profile.jar
-Dprofile.properties=$JRUBY_HOME/lib/profile-all.properties"
+ JRUBY_OPTS=("${jruby_op...@]}" "-X+C")
+ VERIFY_JRUBY="yes"
+ ;;
+ # Run with JMX management enabled
+ --manage)
+ java_args=("${java_ar...@]}" "-Dcom.sun.management.jmxremote") ;;
+ # Don't launch a GUI window, no matter what
+ --headless)
+ java_args=("${java_ar...@]}" "-Djava.awt.headless=true") ;;
+ # Run under JDB
+ --jdb)
+ if [ -z "$JAVA_HOME" ] ; then
+ JAVA_CMD='jdb'
+ else
+ if $cygwin; then
+ JAVA_HOME=`cygpath -u "$JAVA_HOME"`
+ fi
+ JAVA_CMD="$JAVA_HOME/bin/jdb"
+ fi
+ java_args=("${java_ar...@]}" "-sourcepath"
"$JRUBY_HOME/lib/ruby/1.8:.")
+ JRUBY_OPTS=("${jruby_op...@]}" "-X+C") ;;
+ --client)
+ JAVA_VM=-client ;;
+ --server)
+ JAVA_VM=-server ;;
+ --sample)
+ java_args=("${java_ar...@]}" "-Xprof") ;;
+ --ng-server)
+ # Start up as Nailgun server
+ java_class=com.martiansoftware.nailgun.NGServer
+ JAVA_VM=-server
+ VERIFY_JRUBY=true ;;
+ --ng)
+ # Use native Nailgun client to toss commands to server
+ process_special_opts "--ng" ;;
+ # Abort processing on the double dash
+ --) break ;;
+ # Other opts go to ruby
+ -*) ruby_args=("${ruby_ar...@]}" "$1") ;;
+ # Abort processing on first non-opt arg
+ *) break ;;
+ esac
+ shift
+done
+
+# Force file.encoding to UTF-8 when on Mac, since Apple JDK defaults to
MacRoman (JRUBY-3576)
+if [[ $darwin && -z "$JAVA_ENCODING" ]]; then
+ java_args=("${java_ar...@]}" "-Dfile.encoding=UTF-8")
+fi
+
+# Add a property to report memory max
+JAVA_OPTS="$JAVA_OPTS $JAVA_VM -Djruby.memory.max=${JAVA_MEM:4}
-Djruby.stack.max=${JAVA_STACK:4}"
+
+# Append the rest of the arguments
+ruby_args=("${ruby_ar...@]}" "$@")
+
+# Put the ruby_args back into the position arguments $1, $2 etc
+set -- "${ruby_ar...@]}"
+
+JAVA_OPTS="$JAVA_OPTS $JAVA_MEM $JAVA_STACK"
+JNA_OS="`uname -s | tr '[:upper:]' '[:lower:]'`"
+case "$JNA_OS" in
+darwin) JNA_PATH="$JRUBY_HOME/lib/native/darwin";;
+ *)
JNA_PATH="$JRUBY_HOME/lib/native/${JNA_OS}-${JNA_CPU}:$JRUBY_HOME/lib/native/${JNA_OS}-${JNA_ALT_CPU}";;
+esac
+#JAVA_OPTS="$JAVA_OPTS -Djna.boot.library.path=$JNA_PATH"
+JAVA_JNA="-Djna.boot.library.path=$JNA_PATH"
+
+JFFI_BOOT=""
+for d in $JRUBY_HOME/lib/native/*`uname -s`; do
+ if [ -z "$JFFI_BOOT" ]; then
+ JFFI_BOOT="$d"
+ else
+ JFFI_BOOT="$JFFI_BOOT:$d"
+ fi
+done
+JFFI_OPTS="-Djffi.boot.library.path=$JFFI_BOOT"
+
+if $cygwin; then
+ JRUBY_HOME=`cygpath --mixed "$JRUBY_HOME"`
+ JRUBY_SHELL=`cygpath --mixed "$JRUBY_SHELL"`
+
+ if [[ ( "${1:0:1}" = "/" ) && ( ( -f "$1" ) || ( -d "$1" )) ]]; then
+ win_arg=`cygpath -w "$1"`
+ shift
+ win_args=("$win_arg" "$@")
+ set -- "${win_ar...@]}"
+ fi
+
+ # fix JLine to use UnixTerminal
+ stty -icanon min 1 -echo > /dev/null 2>&1
+ if [ $? = 0 ]; then
+ JAVA_OPTS="$JAVA_OPTS -Djline.terminal=jline.UnixTerminal"
+ fi
+
+fi
+
+if [ "$nailgun_client" != "" ]; then
+ if [ -f $JRUBY_HOME/tool/nailgun/ng ]; then
+ exec $JRUBY_HOME/tool/nailgun/ng org.jruby.util.NailMain $JRUBY_OPTS "$@"
+ else
+ echo "error: ng executable not found; run 'make' in
${JRUBY_HOME}/tool/nailgun"
+ exit 1
+ fi
+else
+if [ "$VERIFY_JRUBY" != "" ]; then
+ if [ "$PROFILE_ARGS" != "" ]; then
+ echo "Running with instrumented profiler"
+ fi
+
+ "$JAVA_CMD" $PROFILE_ARGS $JAVA_OPTS "$JAVA_JNA" "$JFFI_OPTS"
"${java_ar...@]}" -classpath "$JRUBY_CP$CP_DELIMITER$CP$CP_DELIMITER$CLASSPATH"
\
+ "-Djruby.home=$JRUBY_HOME" \
+ "-Djruby.lib=$JRUBY_HOME/lib" -Djruby.script=jruby \
+ "-Djruby.shell=$JRUBY_SHELL" \
+ $java_class $JRUBY_OPTS -S _buildr "$@"
+
+ # Record the exit status immediately, or it will be overridden.
+ JRUBY_STATUS=$?
+
+ if [ "$PROFILE_ARGS" != "" ]; then
+ echo "Profiling results:"
+ cat profile.txt
+ rm profile.txt
+ fi
+
+ if $cygwin; then
+ stty icanon echo > /dev/null 2>&1
+ fi
+
+ exit $JRUBY_STATUS
+else
+ if $cygwin; then
+ # exec doed not work correctly with cygwin bash
+ "$JAVA_CMD" $JAVA_OPTS "$JAVA_JNA" "$JFFI_OPTS" "${java_ar...@]}"
-Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMITER$CLASSPATH" \
+ "-Djruby.home=$JRUBY_HOME" \
+ "-Djruby.lib=$JRUBY_HOME/lib" -Djruby.script=jruby \
+ "-Djruby.shell=$JRUBY_SHELL" \
+ $java_class $JRUBY_OPTS -S _buildr "$@"
+
+ # Record the exit status immediately, or it will be overridden.
+ JRUBY_STATUS=$?
+
+ stty icanon echo > /dev/null 2>&1
+
+ exit $JRUBY_STATUS
+ else
+ exec "$JAVA_CMD" $JAVA_OPTS "$JAVA_JNA" "$JFFI_OPTS" "${java_ar...@]}"
-Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMITER$CLASSPATH" \
+ "-Djruby.home=$JRUBY_HOME" \
+ "-Djruby.lib=$JRUBY_HOME/lib" -Djruby.script=jruby \
+ "-Djruby.shell=$JRUBY_SHELL" \
+ $java_class $JRUBY_OPTS -S _buildr "$@"
+ fi
+fi
+fi
+
+# Be careful adding code down here, you might override the exit
+# status of the jruby invocation.
Propchange: buildr/trunk/all-in-one/buildr
------------------------------------------------------------------------------
svn:executable = *
Added: buildr/trunk/all-in-one/buildr.cmd
URL:
http://svn.apache.org/viewvc/buildr/trunk/all-in-one/buildr.cmd?rev=888671&view=auto
==============================================================================
--- buildr/trunk/all-in-one/buildr.cmd (added)
+++ buildr/trunk/all-in-one/buildr.cmd Wed Dec 9 01:31:11 2009
@@ -0,0 +1 @@
+...@%~dp0\_buildr.exe %*
\ No newline at end of file
Propchange: buildr/trunk/all-in-one/buildr.cmd
------------------------------------------------------------------------------
svn:executable = *
Added: buildr/trunk/rakelib/all-in-one.rake
URL:
http://svn.apache.org/viewvc/buildr/trunk/rakelib/all-in-one.rake?rev=888671&view=auto
==============================================================================
--- buildr/trunk/rakelib/all-in-one.rake (added)
+++ buildr/trunk/rakelib/all-in-one.rake Wed Dec 9 01:31:11 2009
@@ -0,0 +1,83 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership. The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+task "all-in-one" => :gem do
+ version = "1.4.0"
+ jruby_distro = "jruby-bin-#{version}.tar.gz"
+ url = "http://jruby.kenai.com/downloads/#{version}/#{jruby_distro}"
+ dir = "jruby-#{version}"
+
+ mkpath '_all-in-one'
+ cd '_all-in-one'
+
+ # Download and extract JRuby
+ lambda do
+ unless File.exist? jruby_distro
+ puts "Downloading JRuby from #{url} ..."
+ sh 'wget', url
+ puts "[X] Downloaded JRuby"
+ end
+
+ rm_rf dir if File.exist? dir
+
+ puts "Extracting JRuby to #{dir} ..."
+ sh 'tar', 'xzf', jruby_distro
+ puts "[X] Extracted JRuby"
+ cd dir
+ end.call
+
+ # Cleanup JRuby distribution
+ lambda do
+ rm_rf 'docs'
+ mkpath 'jruby-docs'
+ mv Dir["COPYING*"], 'jruby-docs'
+ mv Dir["LICENSE*"], 'jruby-docs'
+ mv 'README', 'jruby-docs'
+ rm_rf 'lib/ruby/1.9'
+ rm_rf 'samples'
+ rm_rf 'share'
+ end.call
+
+ # Install Buildr gem and dependencies
+ lambda do
+ puts "Install Buildr gem ..."
+ sh "bin/jruby", '-S', 'gem', 'install',
FileList['../../pkg/*-java.gem'].first,
+ '--no-rdoc', '--no-ri'
+ puts "[X] Install Buildr gem"
+ end.call
+
+ # Add Buildr executables/scripts
+ lambda do
+ cp 'bin/jruby.exe', 'bin/_buildr.exe'
+ cp Dir["../../all-in-one/*"], 'bin'
+ end.call
+
+ # Package distribution
+ lambda do
+ puts "Zipping distribution ..."
+ cd '..'
+ new_dir = "buildr-#{dir}"
+ mv dir, new_dir
+ zip = "#{new_dir}.zip"
+ rm zip if File.exist? zip
+ sh 'zip', '-q', '-r', zip, new_dir
+ puts "[X] Zipped distribution"
+ rm_rf new_dir
+ end.call
+
+end
+
+task(:clobber) { rm_rf '_all-in-one' }
Propchange: buildr/trunk/rakelib/all-in-one.rake
------------------------------------------------------------------------------
svn:executable = *