1#!/bin/bash -e
2#
3# Copyright (C) 2011 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Set up prog to be the path of this script, including following
18# symlinks, and set up progdir to be the fully-qualified pathname of
19# its directory.  Switch the current directory to progdir for the
20# remainder of the script.
21prog="$0"
22while [ -h "${prog}" ]; do
23    newProg=`/bin/ls -ld "${prog}"`
24    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
25    if expr "x${newProg}" : 'x/' >/dev/null; then
26        prog="${newProg}"
27    else
28        progdir=`dirname "${prog}"`
29        prog="${progdir}/${newProg}"
30    fi
31done
32oldwd=`pwd`
33progdir=`dirname "${prog}"`
34cd "${progdir}"
35
36resourceDir=../../resources/dalvik/system
37
38rm -rf classes
39rm -rf classes2
40rm -rf classes.dex
41rm -rf loading-test.jar
42
43# This library depends on loading-test2, so compile those classes first,
44# but keep them separate.
45mkdir classes2
46javac -d classes2 ../loading-test2-jar/*.java
47
48mkdir classes
49javac -classpath classes2 -d classes *.java
50dx --dex --output=classes.dex classes
51jar cf loading-test.jar classes.dex -C resources .
52
53rm -rf classes
54rm -rf classes2
55mv classes.dex ${resourceDir}/loading-test.dex
56mv loading-test.jar ${resourceDir}
57