2019-05-01 18:05:15 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-08-28 00:18:26 +02:00
|
|
|
if echo "$HOME" | grep "com.termux"; then
|
|
|
|
echo "-- Configuring for termux"
|
|
|
|
export JAVAC=ecj
|
|
|
|
export JAVA=true # /bin/true does nothing but returns success
|
|
|
|
export JAR=true
|
|
|
|
export JAVADOC=true
|
|
|
|
TERMUX_ARG="--termux"
|
2019-09-10 07:27:21 +02:00
|
|
|
TOOLCHAIN=host
|
2019-08-28 00:18:26 +02:00
|
|
|
else
|
|
|
|
echo "-- Configuring for Android SDK/NDK"
|
2019-10-11 07:53:03 +02:00
|
|
|
if [ -z "$TOOLCHAIN" ]; then
|
2019-10-09 00:51:14 +02:00
|
|
|
TOOLCHAIN=4.9
|
|
|
|
fi
|
2019-08-28 00:18:26 +02:00
|
|
|
fi
|
2019-10-09 00:49:56 +02:00
|
|
|
|
2019-10-11 07:53:03 +02:00
|
|
|
if [ -z "$ARCHS" ]; then
|
2019-10-09 00:49:56 +02:00
|
|
|
ARCHS="armeabi-v7a armeabi x86"
|
|
|
|
fi
|
2019-10-11 07:53:03 +02:00
|
|
|
|
2019-11-07 05:08:06 +01:00
|
|
|
if [ -z "$API" ]; then
|
|
|
|
API=9
|
|
|
|
fi
|
2019-05-01 18:05:15 +02:00
|
|
|
ROOT="$PWD" # compile.sh must be run from root of android project sources
|
2019-10-11 07:53:03 +02:00
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2019-05-06 18:12:39 +02:00
|
|
|
BUILD_TYPE=debug
|
|
|
|
else
|
|
|
|
BUILD_TYPE=$1
|
2019-10-11 08:11:12 +02:00
|
|
|
if [ "$TOOLCHAIN" = "host" ]; then
|
|
|
|
ENGINE_FLAGS="--enable-poly-opt"
|
|
|
|
SDK_FLAGS="--enable-poly-opt"
|
|
|
|
fi
|
2019-05-06 18:12:39 +02:00
|
|
|
fi
|
2019-05-06 03:24:42 +02:00
|
|
|
|
|
|
|
# Cleanup libraries
|
|
|
|
rm -rf android/lib/
|
2019-05-01 18:05:15 +02:00
|
|
|
|
2019-07-29 07:39:40 +02:00
|
|
|
# Generate extras.pak(TODO: move this to waf somehow)
|
|
|
|
if [ -L "xash3d-fwgs-sl" ]; then
|
|
|
|
python xash3d-fwgs-sl/scripts/makepak.py xash-extras android/assets/extras.pak
|
|
|
|
else
|
|
|
|
python xash3d-fwgs/scripts/makepak.py xash-extras android/assets/extras.pak
|
|
|
|
fi
|
2019-05-06 19:18:38 +02:00
|
|
|
|
2019-05-01 18:05:15 +02:00
|
|
|
# Generate configs
|
|
|
|
android/gen-config.sh android/
|
|
|
|
android/gen-version.sh android/
|
|
|
|
|
2019-05-06 18:12:39 +02:00
|
|
|
# configure android project
|
2019-08-28 00:18:26 +02:00
|
|
|
./waf configure -T $BUILD_TYPE $TERMUX_ARG|| exit 1
|
2019-05-06 18:12:39 +02:00
|
|
|
|
2019-10-09 01:59:16 +02:00
|
|
|
die()
|
|
|
|
{
|
|
|
|
cat $1/config.log
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-05-01 18:05:15 +02:00
|
|
|
build_native_project()
|
|
|
|
{
|
2019-10-11 07:53:03 +02:00
|
|
|
prj=$1
|
|
|
|
shift
|
|
|
|
arch=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
out="$ROOT/build-$prj/$arch"
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
if [ -L "$prj-sl" ]; then
|
|
|
|
cd $prj-sl # need to change directory, as waf doesn't work well with symlinks(used in development purposes)
|
2019-05-06 03:24:42 +02:00
|
|
|
else
|
2019-10-11 07:53:03 +02:00
|
|
|
cd $prj
|
2019-05-06 03:24:42 +02:00
|
|
|
fi
|
2019-10-11 07:53:03 +02:00
|
|
|
./waf -o "$out" configure -T $BUILD_TYPE --android="$arch,$TOOLCHAIN,$API" $* build || die "$out"
|
2019-11-07 06:47:48 +01:00
|
|
|
./waf install --destdir=$ROOT/build/android/ --strip
|
2019-05-06 03:24:42 +02:00
|
|
|
cd $ROOT # obviously, we can't ../ from symlink directory, so change to our root directory
|
2019-05-01 18:05:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Do it inside waf?
|
2019-09-10 07:27:21 +02:00
|
|
|
for i in $ARCHS; do
|
2019-10-11 07:53:03 +02:00
|
|
|
build_native_project "xash3d-fwgs" "$i" $ENGINE_FLAGS
|
|
|
|
build_native_project "hlsdk-xash3d" "$i" $SDK_FLAGS
|
2019-09-10 07:27:21 +02:00
|
|
|
done
|
2019-05-01 18:05:15 +02:00
|
|
|
|
|
|
|
# Run waf
|
2019-08-28 00:18:26 +02:00
|
|
|
./waf build -v|| exit 1
|
2019-05-06 18:12:39 +02:00
|
|
|
|
2019-10-07 04:54:56 +02:00
|
|
|
if [ "$BUILD_TYPE" != "debug" ] && [ "$USER" = "a1ba" ]; then
|
|
|
|
# :)
|
2019-09-27 04:33:12 +02:00
|
|
|
cp build/android/xashdroid.apk xashdroid.apk
|
2019-07-29 07:06:16 +02:00
|
|
|
|
2019-10-07 04:54:56 +02:00
|
|
|
apksigner sign --ks ../myks.keystore xashdroid.apk
|
2019-09-27 04:33:12 +02:00
|
|
|
else
|
|
|
|
cp build/android/xashdroid-signed.apk xashdroid.apk
|
2019-07-29 07:06:16 +02:00
|
|
|
fi
|