Skip to content

Commit

Permalink
Merge branch 'master' of ssh+git://pacific.mpi-cbg.de/srv/git/fiji
Browse files Browse the repository at this point in the history
  • Loading branch information
acardona committed Apr 27, 2012
2 parents 60c1da9 + 47e3dad commit e21c50f
Show file tree
Hide file tree
Showing 77 changed files with 1,658 additions and 284 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,8 @@ hs_err*.log
/jars/object-inspector.jar
/jars/sezpoz.jar
/jars/velocity.jar
/plugins/CorrectBleach_.jar

# Retrotranslator #
/jars/backport-util-concurrent.jar
/jars/retrotranslator-runtime.jar
161 changes: 69 additions & 92 deletions Build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
#!/bin/sh

# This script is the entry point for the Fiji Build
#
# Call it without parameters to build everything or
# with the filenames of the .jar files to be built

set -a
CWD="$(dirname "$0")" || {
echo "Huh? Cannot cd to $(dirname "$0")" >&2
exit 1
}

dirname () {
case "$1" in
Expand All @@ -21,17 +31,59 @@ look_for_tools_jar () {
test -d "$d" || continue
for j in java default-java
do
test -f "$d/$java/lib/tools.jar" || continue
export TOOLS_JAR="$d/$java/lib/tools.jar"
test -f "$d/$j/lib/tools.jar" || continue
export TOOLS_JAR="$d/$j/lib/tools.jar"
return
done
done
}

CWD="$(dirname "$0")"
get_java_home () {
if test -d "$JAVA_HOME"
then
echo "$JAVA_HOME"
else
if test -n "$java_submodule" && test -d "$CWD/java/$java_submodule"
then
echo "$CWD/java/$java_submodule/$(ls -t "$CWD/java/$java_submodule" | head -n 1)/jre"
fi
fi
}

need_to_build_fake () {
(cd "$CWD" &&
test -f jars/fake.jar || {
echo YesPlease
return
}
for source in $(find src-plugins/fake/ -name \*.java)
do
test "$source" -nt jars/fake.jar && {
echo YesPlease
return
}
done)
return
}

ensure_fake_is_built () {
# test whether we need to build it
test -z "$(need_to_build_fake)" && return

(cd "$CWD" &&
: blow previous builds away
rm -rf build/jars/fake/ &&
mkdir -p build/jars/fake/ &&
: compile classes
javac -classpath precompiled/javac.jar -d build/jars/fake/ $(find src-plugins/fake/ -name \*.java) &&
: compile .jar using Fiji Build
java -classpath build/jars/fake/"$PATHSEP"precompiled/javac.jar fiji.build.Fake jars/fake.jar-rebuild ImageJ)
}

PATHSEP=:
case "$(uname -s)" in
Darwin)
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
java_submodule=macosx-java3d
case "$(uname -r)" in
8.*) platform=tiger;;
Expand All @@ -42,14 +94,16 @@ Linux)
x86_64)
platform=linux64
java_submodule=linux-amd64
look_for_tools_jar /usr/lib/jvm
look_for_tools_jar /usr/lib64/jvm /usr/lib/jvm
;;
*) platform=linux32
java_submodule=linux
look_for_tools_jar /usr/lib64/jvm
look_for_tools_jar /usr/lib/jvm
;;
esac; exe=;;
MINGW*|CYGWIN*)
CWD="$(cd "$CWD" && pwd)"
PATHSEP=\;
case "$PROCESSOR_ARCHITEW6432" in
'') platform=win32; java_submodule=$platform;;
*) platform=win64; java_submodule=$platform;;
Expand All @@ -73,33 +127,25 @@ FreeBSD)
fi;;
*)
platform=
# copy and use bin/ImageJ-other.sh
test -f "$CWD/ImageJ" &&
test "$CWD/bin/ImageJ" -nt "$CWD/bin/ImageJ-other.sh" ||
cp "$CWD/bin/ImageJ-other.sh" "$CWD/ImageJ"
TOOLS_JAR="$(ls -t /usr/jdk*/lib/tools.jar \
/usr/local/jdk*/lib/tools.jar 2> /dev/null |
head -n 1)"
test -z "$TOOLS_JAR" ||
export TOOLS_JAR;;
esac


test -n "$platform" &&
test -z "$JAVA_HOME" &&
JAVA_HOME="$("$CWD"/precompiled/ImageJ-"$platform" --print-java-home 2> /dev/null)"

if test -n "$platform" && test ! -d "$JAVA_HOME"
then
JAVA_HOME="$CWD"/java/$java_submodule
JAVA_HOME="$JAVA_HOME"/"$(ls -t "$JAVA_HOME" | head -n 1)"
fi
JAVA_HOME="$(get_java_home)"

# need to clone java submodule
test -z "$platform" ||
test -f "$JAVA_HOME/lib/tools.jar" || test -f "$JAVA_HOME/../lib/tools.jar" ||
test -f "$CWD"/java/"$java_submodule"/Home/lib/ext/vecmath.jar || {
echo "No JDK found; cloning it"
JAVA_SUBMODULE=java/$java_submodule
: jump through hoops to enable a shallow clone of the JDK
git submodule init "$JAVA_SUBMODULE" && (
URL="$(git config submodule."$JAVA_SUBMODULE".url)" &&
case "$URL" in
Expand Down Expand Up @@ -134,47 +180,11 @@ then
export PATH=$JAVA_HOME/bin:$PATH
fi

handle_variables () {
case "$1" in
--strip) strip_variables=t; shift;;
*) strip_variables=;;
esac
while test $# -ge 1
do
case "$1" in
*=*) test ! -z "$strip_variables" || echo "$1";;
*) test -z "$strip_variables" || echo "$1";;
esac
shift
done
}

targets=$(handle_variables --strip "$@")
variables=$(handle_variables "$@")

jar=jars/fake.jar
source_dir=src-plugins/fake
sources=$source_dir/fiji/build/*.java

jarUpToDate () {
test -f "$CWD/$jar" || return 1
for source in $sources
do
test "$CWD/$source" -nt "$CWD/$jar" && return 1
done
return 0
}

# make sure fake.jar is up-to-date
test "a$targets" != a$jar &&
! jarUpToDate && {
(cd "$CWD" && sh "$(basename "$0")" $variables $jar) || exit
}

# make sure the ImageJ launcher is up-to-date
test "a$targets" != a$jar -a "a$targets" != aImageJ &&
test ! -f "$CWD"/ImageJ -o "$CWD"/ImageJ.c -nt "$CWD"/ImageJ$exe && {
(cd "$CWD" && sh "$(basename "$0")" $variables ImageJ) || exit
: build fake.jar, making sure javac is in the PATH
PATH="$PATH:$(get_java_home)/bin:$(get_java_home)/../bin" \
ensure_fake_is_built || {
echo "Could not build Fiji Build" >&2
exit 1
}

# on Win64, with a 32-bit compiler, do not try to compile
Expand All @@ -185,7 +195,7 @@ win64)

case "$CC,$(gcc --version)" in
,*mingw32*)
# cannot compile!
# cannot compile! Fall back to copying
test "$CWD"/ImageJ.exe -nt "$CWD"/ImageJ.c &&
test "$CWD"/ImageJ.exe -nt "$CWD"/precompiled/ImageJ-win64.exe &&
test "$CWD"/ImageJ.exe -nt "$CWD"/Fakefile &&
Expand All @@ -194,37 +204,4 @@ win64)
esac
esac

# still needed for Windows, which cannot overwrite files that are in use
test -f "$CWD"/ImageJ$exe -a -f "$CWD"/$jar &&
test "a$targets" != a$jar -a "a$targets" != aImageJ &&
"$CWD"/ImageJ$exe --build "$@" &&
exit

export SYSTEM_JAVA=java
export SYSTEM_JAVAC=javac

# If JAVA_HOME leads to an executable java or javac then use them:
if [ x != x$JAVA_HOME ]
then
if [ -e $JAVA_HOME/bin/java ]
then
export SYSTEM_JAVA=$JAVA_HOME/bin/java
fi
if [ -e $JAVA_HOME/bin/javac ]
then
export SYSTEM_JAVAC=$JAVA_HOME/bin/javac
elif [ -e $JAVA_HOME/../bin/javac ]
then
export SYSTEM_JAVAC=$JAVA_HOME/../bin/javac

fi
fi

# fall back to calling Fake with system Java
test -f "$CWD"/$jar &&
$SYSTEM_JAVA -classpath "$CWD"/$jar fiji.build.Fake "$@"

# fall back to compiling and running with system Java
mkdir -p "$CWD"/build &&
$SYSTEM_JAVAC -d "$CWD"/build/ "$CWD"/$sources &&
$SYSTEM_JAVA -classpath "$CWD"/build fiji.build.Fake "$@"
sh "$CWD/bin/ImageJ.sh" --build "$@"
6 changes: 4 additions & 2 deletions Fakefile
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ PLUGIN_TARGETS=plugins/Jython_Interpreter.jar \
plugins/FS_Align_TrakEM2.jar \
jars/fiji-compat.jar \
plugins/Fiji_Package_Maker.jar \
plugins/BalloonSegmentation_.jar
plugins/BalloonSegmentation_.jar \
plugins/CorrectBleach_.jar

LEGACYLAUNCHER=fiji

Expand Down Expand Up @@ -354,7 +355,7 @@ CLASSPATH(plugins/BeanShell_Interpreter.jar)=jars/ij.jar:jars/fiji-scripting.jar
CLASSPATH(plugins/Javascript_.jar)=jars/ij.jar:jars/fiji-scripting.jar:jars/js.jar
CLASSPATH(plugins/CLI_.jar)=jars/ij.jar:jars/fiji-scripting.jar
MAINCLASS(plugins/Script_Editor.jar)=fiji.scripting.Script_Editor
CLASSPATH(plugins/Script_Editor.jar)=jars/ij.jar:jars/rsyntaxtextarea.jar:jars/autocomplete.jar:plugins/Clojure_Interpreter.jar:plugins/JRuby_Interpreter.jar:plugins/Javascript_.jar:plugins/Jython_Interpreter.jar:plugins/Refresh_Javas.jar:plugins/BeanShell_Interpreter.jar:plugins/CLI_.jar:jars/fiji-scripting.jar:jars/fiji-compat.jar:jars/imglib.jar:jars/fiji-lib.jar:jars/fake.jar:$TOOLS_JAR:jars/jfreechart.jar:jars/imglib-ij.jar:jars/commons-math.jar
CLASSPATH(plugins/Script_Editor.jar)=jars/ij.jar:jars/rsyntaxtextarea.jar:jars/autocomplete.jar:plugins/Clojure_Interpreter.jar:plugins/JRuby_Interpreter.jar:plugins/Javascript_.jar:plugins/Jython_Interpreter.jar:plugins/Refresh_Javas.jar:plugins/BeanShell_Interpreter.jar:plugins/CLI_.jar:jars/fiji-scripting.jar:jars/fiji-compat.jar:jars/imglib2.jar:jars/fiji-lib.jar:jars/fake.jar:$TOOLS_JAR:jars/jfreechart.jar:jars/imglib2-ij.jar:jars/commons-math.jar
NO_COMPILE(plugins/Script_Editor.jar)=src-plugins/Script_Editor/templates/**/*
src-plugins/Script_Editor/icon.png[bin/copy-file.bsh $PRE $TARGET] <- images/icon.png
src-plugins/Script_Editor/var.png[bin/copy-file.bsh $PRE $TARGET] <- images/var.png
Expand Down Expand Up @@ -476,6 +477,7 @@ CLASSPATH(plugins/Threshold_Colour.jar)=jars/ij.jar
CLASSPATH(plugins/Helmholtz_Analysis.jar)=jars/ij.jar
CLASSPATH(plugins/Fiji_Package_Maker.jar)=jars/ij.jar:plugins/Fiji_Updater.jar:jars/fiji-lib.jar
CLASSPATH(plugins/BalloonSegmentation_.jar)=jars/ij.jar:jars/Jama.jar
CLASSPATH(plugins/CorrectBleach_.jar)=jars/ij.jar

# pom.xml sub-projects

Expand Down
1 change: 1 addition & 0 deletions LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Name File Author(s) Contact License
* Batik batik.jar http://xmlgraphics.apache.org/batik/contributors.html AL
* Bean Shell language bsh.jar http://www.beanshell.org/ SPL/LGPL
* Bean Shell Interpreter BSH_Interpreter.jar Johannes Schindelin Johannes.Schindelin@gmx.de GPL
* Bleach Corrector CorrectBleach_.jar Kota Miura miura@embl.de GPL
* bUnwarpJ bUnwarpJ_.jar Ignacio Arganda et al. ignacio.arganda@uam.es GPL
* Clojure clojure.jar Rich Hickey http://clojure.sourceforge.net/ EPL
* Clojure Interpreter Clojure_Interpreter.jar Albert Cardona acardona@ini.phys.ethz.ch GPL
Expand Down
29 changes: 28 additions & 1 deletion bin/ImageJ-other.sh → bin/ImageJ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,25 @@ f)
;;
esac

get_first () {
echo "$1"
}

case "$main_class,$(get_first $ij_options)" in
fiji.Main,*.py)
main_class=org.python.util.jython
;;
fiji.Main,*.rb)
main_class=org.jruby.Main
;;
fiji.Main,*.clj)
main_class=clojure.lang.Repl
;;
fiji.Main,*.bsh)
main_class=bsh.Interpreter
;;
esac

case "$main_class" in
fiji.Main|ij.ImageJ)
ij_options="-port7 $ij_options"
Expand Down Expand Up @@ -147,7 +166,15 @@ case "$EXECUTABLE_NAME" in
;;
esac

eval java -Dpython.cachedir.skip=true \
EXT_OPTION=
case "$(uname -s)" in
Darwin)
EXT_OPTION=-Djava.ext.dirs="$FIJI_ROOT_SQ"/java/macosx-java3d/Home/lib/ext:/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Home/lib/ext
;;
esac

eval java $EXT_OPTION \
-Dpython.cachedir.skip=true \
-Xincgc -XX:PermSize=128m \
-Dplugins.dir=$FIJI_ROOT_SQ \
-Djava.class.path="`sq_quote $CLASSPATH`" \
Expand Down
2 changes: 1 addition & 1 deletion bin/analyze-dependencies.bsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
/*/. 2>/dev/null; exec "$(dirname "$0")"/../ImageJ "$0" "$@" # exec with fiji */
/*/. 2>/dev/null; exec "$(dirname "$0")"/ImageJ.sh "$0" "$@" # exec with fiji */

import fiji.build.Fake;

Expand Down
2 changes: 1 addition & 1 deletion bin/calculate-checksums.bsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
/*/. 2>/dev/null; exec "$(dirname "$0")"/../ImageJ "$0" "$@" # exec with fiji */
/*/. 2>/dev/null; exec "$(dirname "$0")"/ImageJ.sh "$0" "$@" # exec with fiji */

import fiji.updater.logic.Checksummer;
import fiji.updater.logic.PluginCollection;
Expand Down
2 changes: 1 addition & 1 deletion bin/checkout-jdk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
''''exec "$(dirname "$0")"/../ImageJ --jython "$0" "$@" # (call again with fiji)'''
''''exec "$(dirname "$0")"/ImageJ.sh --jython "$0" "$@" # (call again with fiji)'''

import os
import sys
Expand Down
2 changes: 1 addition & 1 deletion bin/combined-gource-video.bsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
// 2>&1 | :; exec "$(dirname "$0")"/../ImageJ --bsh "$0" "$@" # exec with fiji */
// 2>&1 | :; exec "$(dirname "$0")"/ImageJ.sh --bsh "$0" "$@" # exec with fiji */

if (bsh.args.length != 1) {
System.err.println("Usage: " + this.interpreter.getSourceFileInfo()
Expand Down
2 changes: 1 addition & 1 deletion bin/commit-plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
''''exec "$(dirname "$0")"/../ImageJ --jython "$0" "$@" # (call again with fiji)'''
''''exec "$(dirname "$0")"/ImageJ.sh --jython "$0" "$@" # (call again with fiji)'''

import os
import sys
Expand Down
2 changes: 1 addition & 1 deletion bin/commit-submodule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
''''exec "$(dirname "$0")"/../ImageJ --jython "$0" "$@" # (call again with fiji)'''
''''exec "$(dirname "$0")"/ImageJ.sh --jython "$0" "$@" # (call again with fiji)'''

import os
import sys
Expand Down
2 changes: 1 addition & 1 deletion bin/configure-submodule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
''''exec "$(dirname "$0")"/../ImageJ --jython "$0" "$@" # (call again with fiji)'''
''''exec "$(dirname "$0")"/ImageJ.sh --jython "$0" "$@" # (call again with fiji)'''

#
# configure-submodule.py
Expand Down
2 changes: 1 addition & 1 deletion bin/copy-file.bsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
/*/. 2>/dev/null; exec "$(dirname "$0")"/../ImageJ "$0" "$@" # exec with fiji */
/*/. 2>/dev/null; exec "$(dirname "$0")"/ImageJ.sh "$0" "$@" # exec with fiji */

if (bsh.args.length < 2) {
System.err.println("Usage: " + this.interpreter.getSourceFileInfo()
Expand Down
2 changes: 1 addition & 1 deletion bin/cross-compiler.bsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
/*/. 2>/dev/null; exec "$(dirname "$0")"/../ImageJ "$0" "$@" # exec with fiji */
/*/. 2>/dev/null; exec "$(dirname "$0")"/ImageJ.sh "$0" "$@" # exec with fiji */

if (bsh.args.length < 1) {
System.err.println("Usage: " + this.interpreter.getSourceFileInfo()
Expand Down
2 changes: 1 addition & 1 deletion bin/eclipse-project-generator.bsh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
exec "$(dirname "$0")"/../ImageJ \
exec "$(dirname "$0")"/ImageJ.sh \
"$(dirname "$0")"/projects-generator.bsh --eclipse "$@"
2 changes: 1 addition & 1 deletion bin/enumerate-java-package.bsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
/*/. 2>/dev/null; exec "$(dirname "$0")"/../ImageJ "$0" "$@" # exec with fiji */
/*/. 2>/dev/null; exec "$(dirname "$0")"/ImageJ.sh "$0" "$@" # exec with fiji */

if (bsh.args.length == 0) {
System.err.println("Usage: " + this.interpreter.getSourceFileInfo()
Expand Down
Loading

0 comments on commit e21c50f

Please sign in to comment.