File: functions.sh

package info (click to toggle)
proguard 6.2.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 8,712 kB
  • sloc: java: 97,785; xml: 1,015; sh: 256; makefile: 91
file content (85 lines) | stat: -rwxr-xr-x 1,978 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
#
# Support functions for building ProGuard.

SRC=src
OUT=out
LIB=../lib

TARGET=1.8

PROGUARD_JAR=$LIB/proguard.jar
RETRACE_JAR=$LIB/retrace.jar
PROGUARD_GUI_JAR=$LIB/proguardgui.jar
ANNOTATIONS_JAR=$LIB/annotations.jar

set -o pipefail

function download {
  if [ ! -f "$2" ]; then
    echo "Downloading $2..."
    mkdir -p $(dirname "$2") && \
    if type wget > /dev/null 2>&1; then
      wget -O "$2" "$1"
    else
      curl -L -o "$2" "$1"
    fi
  fi
}

function compile {
  echo "Compiling $(basename $PWD) ($1)..."
  mkdir -p "$OUT" && \

  # Compile Java source files.
  find $SRC -name '_*.java' -o -path "$SRC/${1//.//}.java" \
  | xargs --no-run-if-empty \
    javac -nowarn -Xlint:none \
    -source $TARGET -target $TARGET \
    -sourcepath "$SRC" -d "$OUT" \
    ${2:+-classpath "$2"} 2>&1 \
  | sed -e 's|^|  |' || return 1

  # Compile Kotlin source files.
  #find $SRC -path "$SRC/${1//.//}.kotlin" \
  #| xargs --no-run-if-empty \
  #  kotlinc -nowarn -jvm-target $TARGET \
  #  -d "$OUT" \
  #  ${2:+-classpath "$2"} 2>&1 \
  #| sed -e 's|^|  |' || return 1

  # Compile Groovy source files.
  find $SRC -path "$SRC/${1//.//}.groovy" \
  | xargs --no-run-if-empty \
    groovyc \
    -sourcepath "$SRC" -d "$OUT" \
    ${2:+-classpath "$2"} 2>&1 \
  | sed -e 's|^|  |' || return 1

  # Copy resource files.
  (cd "$SRC" && \
   find \
     \( -name \*.properties -o -name \*.png -o -name \*.gif -o -name \*.pro \) \
     -exec cp --parents {} "../$OUT" \; )
}

function createjar {
  echo "Creating $1..."
  DIRS=$(ls "$OUT" | sed -e "s|^|-C $OUT |")
  mkdir -p $(dirname "$1") && \
  if [ -f "$SRC/META-INF/MANIFEST.MF" ]; then
    jar -cfm "$1" "$SRC/META-INF/MANIFEST.MF" $DIRS
  else
    jar -cf "$1" $DIRS
  fi
}

function updatejar {
  echo "Updating $1..."
  DIRS=$(ls "$OUT" | sed -e "s|^|-C $OUT |")
  if [ -f "$SRC/META-INF/MANIFEST.MF" ]; then
    jar -ufm "$1" "$SRC/META-INF/MANIFEST.MF" $DIRS
  else
    jar -uf "$1" $DIRS
  fi
}