| 1 | TERMUX_PKG_HOMEPAGE=https://source.android.com/source/jack.html |
| 2 | TERMUX_PKG_DESCRIPTION="Java Android Compiler Kit" |
| 3 | # Use the date of the below git commit as the version number: |
| 4 | TERMUX_PKG_VERSION=20161006 |
| 5 | TERMUX_PKG_SRCURL=https://android.googlesource.com/toolchain/jack/+archive/c6eba4aeed80acd6b0f41a06463d484c2b06596a.tar.gz |
| 6 | TERMUX_PKG_PLATFORM_INDEPENDENT=true |
| 7 | |
| 8 | termux_step_extract_package() { |
| 9 | mkdir -p $TERMUX_PKG_SRCDIR |
| 10 | cd $TERMUX_PKG_SRCDIR |
| 11 | |
| 12 | filename=`basename $TERMUX_PKG_SRCURL` |
| 13 | file=$TERMUX_PKG_CACHEDIR/$filename |
| 14 | test ! -f $file && termux_download $TERMUX_PKG_SRCURL $file $TERMUX_PKG_SHA256 |
| 15 | tar xf $file |
| 16 | |
| 17 | rm sched/src/com/android/sched/util/log/tracer/probe/GcDurationProbe.java |
| 18 | } |
| 19 | |
| 20 | termux_step_make () { |
| 21 | cd $TERMUX_PKG_SRCDIR |
| 22 | ant jack jill |
| 23 | TERMUX_JACK=$PWD/jack/dist/jack.jar |
| 24 | TERMUX_JILL=$PWD/jill/dist/jill.jar |
| 25 | |
| 26 | # Create $USR/share/dex for dex files, and $USR/share/jack for .jack library files produced by jill: |
| 27 | mkdir -p $TERMUX_PREFIX/share/{dex,jack} |
| 28 | $TERMUX_DX \ |
| 29 | -JXmx4096M --num-threads=4 \ |
| 30 | --dex \ |
| 31 | --output=$TERMUX_PREFIX/share/dex/jack.jar \ |
| 32 | $TERMUX_JACK |
| 33 | |
| 34 | cd $TERMUX_PKG_TMPDIR |
| 35 | rm -rf android-jar |
| 36 | mkdir android-jar |
| 37 | cd android-jar |
| 38 | |
| 39 | # We need the android.jar clases in jill format (.jack extension) for jack to compile against. |
| 40 | cp $ANDROID_HOME/platforms/android-24/android.jar . |
| 41 | # Remove resources not needed for compilation to reduce size: |
| 42 | unzip -q android.jar |
| 43 | rm -Rf android.jar resources.arsc res assets |
| 44 | zip -r -q android.jar . |
| 45 | java -jar $TERMUX_JILL $TERMUX_PKG_TMPDIR/android-jar/android.jar --output $TERMUX_PREFIX/share/jack/android.jack |
| 46 | |
| 47 | # Add support annotations .jack file: |
| 48 | local ANNOTATIONS_VERSION=24.2.0 |
| 49 | local ANNOTATIONS_JAR=$TERMUX_PKG_CACHEDIR/support-annotations-${ANNOTATIONS_VERSION}.jar |
| 50 | if [ ! -f $ANNOTATIONS_JAR ]; then |
| 51 | termux_download http://uiq3.sourceforge.net/Repository/com/android/support/support-annotations/${ANNOTATIONS_VERSION}/support-annotations-${ANNOTATIONS_VERSION}.jar \ |
| 52 | $ANNOTATIONS_JAR \ |
| 53 | af5868da6750bdf42aec5d85fa87ac30de2b72939ca80437a6247e5753a07cad |
| 54 | fi |
| 55 | java -jar $TERMUX_JILL $ANNOTATIONS_JAR --output $TERMUX_PREFIX/share/jack/support-annotations-${ANNOTATIONS_VERSION}.jack |
| 56 | |
| 57 | mkdir -p $TERMUX_PREFIX/bin |
| 58 | install $TERMUX_PKG_BUILDER_DIR/jack.sh $TERMUX_PREFIX/bin/jack |
| 59 | perl -p -i -e "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" $TERMUX_PREFIX/bin/jack |
| 60 | } |