128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#!/bin/bash
25f93d0a140515e3b8cdd1b9a4c6f5871144e5deejlmiller@webrtc.org#
328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# libjingle
45f93d0a140515e3b8cdd1b9a4c6f5871144e5deejlmiller@webrtc.org# Copyright 2013 Google Inc.
528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#
628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# Redistribution and use in source and binary forms, with or without
728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# modification, are permitted provided that the following conditions are met:
828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#
928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#  1. Redistributions of source code must retain the above copyright notice,
1028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#     this list of conditions and the following disclaimer.
1128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#  2. Redistributions in binary form must reproduce the above copyright notice,
1228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#     this list of conditions and the following disclaimer in the documentation
1328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#     and/or other materials provided with the distribution.
1428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#  3. The name of the author may not be used to endorse or promote products
1528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#     derived from this software without specific prior written permission.
1628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org#
1728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
1828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
2028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
2828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# javac & jar wrapper helping to simplify gyp action specification.
2928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgset -e  # Exit on any error.
3128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# Allow build-error parsers (such as emacs' compilation-mode) to find failing
3328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org# files easily.
3428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgecho "$0: Entering directory \``pwd`'"
3528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
3628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgJAVA_HOME="$1"; shift
3728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgJAR_NAME="$1"; shift
3828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgTMP_DIR="$1"; shift
3928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgCLASSPATH="$1"; shift
4028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
4128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgif [ -z "$1" ]; then
4228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  echo "Usage: $0 jar-name temp-work-dir source-path-dir .so-to-bundle " \
4328e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org    "classpath path/to/Source1.java path/to/Source2.java ..." >&2
4428e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  exit 1
4528e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgfi
4628e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
4728e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgrm -rf "$TMP_DIR"
4828e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.orgmkdir -p "$TMP_DIR"
4928e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org
5028e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org$JAVA_HOME/bin/javac -Xlint:deprecation -Xlint:unchecked -d "$TMP_DIR" \
5128e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org  -classpath "$CLASSPATH" "$@"
5228e20752806a492f5a6a5d343c02f9556f39b1cdhenrike@webrtc.org$JAVA_HOME/bin/jar cf "$JAR_NAME" -C "$TMP_DIR" .
53