• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# GNU/Linux build script for ProGuard.
4
5#
6# Configuration.
7#
8
9ANT_HOME=${ANT_HOME:-/usr/local/java/ant}
10WTK_HOME=${WTK_HOME:-/usr/local/java/wtk}
11
12if [ -z $PROGUARD_HOME ]; then
13  PROGUARD_HOME=$(which "$0")
14  PROGUARD_HOME=$(dirname "$0")/..
15fi
16
17cd "$PROGUARD_HOME"
18
19SRC=src
20CLASSES=classes
21LIB=lib
22
23PROGUARD=proguard/ProGuard
24PROGUARD_GUI=proguard/gui/ProGuardGUI
25RETRACE=proguard/retrace/ReTrace
26ANT_TASK=proguard/ant/ProGuardTask
27WTK_PLUGIN=proguard/wtk/ProGuardObfuscator
28
29ANT_JAR=$ANT_HOME/lib/ant.jar
30WTK_JAR=$WTK_HOME/wtklib/kenv.zip
31
32PROGUARD_JAR=$LIB/proguard.jar
33PROGUARD_GUI_JAR=$LIB/proguardgui.jar
34RETRACE_JAR=$LIB/retrace.jar
35
36#
37# Function definitions.
38#
39
40function compile {
41  # Compile java source files.
42  echo "Compiling ${1//\//.} ..."
43  javac -nowarn -Xlint:none -sourcepath "$SRC" -d "$CLASSES" \
44    "$SRC/$1.java" 2>&1 \
45  | sed -e 's|^|  |'
46
47  # Copy resource files.
48  (cd "$SRC"; find $(dirname $1) -maxdepth 1 \
49     \( -name \*.properties -o -name \*.png -o -name \*.gif -o -name \*.pro \) \
50     -exec cp --parents {} "../$CLASSES" \; )
51}
52
53function createjar {
54  echo "Creating $2..."
55  jar -cfm "$2" "$SRC/$(dirname $1)/MANIFEST.MF" -C "$CLASSES" $(dirname $1)
56}
57
58function updatejar {
59  echo "Updating $PROGUARD_JAR..."
60  jar -uf "$PROGUARD_JAR" -C "$CLASSES" $(dirname $1)
61}
62
63#
64# Main script body.
65#
66
67mkdir -p "$CLASSES"
68
69compile   $PROGUARD
70createjar $PROGUARD "$PROGUARD_JAR"
71
72compile   $PROGUARD_GUI
73createjar $PROGUARD_GUI "$PROGUARD_GUI_JAR"
74
75compile   $RETRACE
76createjar $RETRACE "$RETRACE_JAR"
77
78if [ -f "$ANT_JAR" ]; then
79  export CLASSPATH=$ANT_JAR
80  compile   $ANT_TASK
81  updatejar $ANT_TASK
82else
83  echo "Please make sure the environment variable ANT_HOME is set correctly,"
84  echo "if you want to compile the optional ProGuard Ant task."
85fi
86
87if [ -f "$WTK_JAR" ]; then
88  export CLASSPATH=$WTK_JAR
89  compile   $WTK_PLUGIN
90  updatejar $WTK_PLUGIN
91else
92  echo "Please make sure the environment variable WTK_HOME is set correctly,"
93  echo "if you want to compile the optional ProGuard WTK plugin."
94fi
95