Skip to content

Commit

Permalink
Added multi-ABI support to ChangeAppSettings.sh, fixed libMAD compila…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
pelya committed Jul 8, 2010
1 parent 9fdddca commit 650aca4
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 27 deletions.
2 changes: 1 addition & 1 deletion alienblaster/AppSettings.cfg
Expand Up @@ -5,5 +5,5 @@ AppDataDownloadUrl="http://sites.google.com/site/xpelyax/Home/alienblaster110_da
DownloadToSdcard=n
SdlVideoResize=a
NeedDepthBuffer=n
CompiledLibraries="sdl sdl_mixer tremor mad sdl_image png jpeg sdl_ttf freetype"
CompiledLibraries="mad sdl_mixer sdl_image sdl_ttf"
ReadmeText='^Use accelerometer to navigate menus and control ship^Press "Menu" to select menu and for secondary fire^Press "Call" or touch screen for primary fire^Press "Volume Up/Down" to cycle through weapons'
34 changes: 27 additions & 7 deletions alienblaster/ChangeAppSettings.sh
Expand Up @@ -45,10 +45,16 @@ if [ -n "$var" ] ; then
NeedDepthBuffer="$var"
fi

echo -n "\nLibraries to compile (removing some of them will save space, MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed)"
echo -n "\nEnable multi-ABI binary, with hardware FPU support (it will also work on old devices, but .apk size is 2x bigger) (y) or (n) ($MultiABI): "
read var
if [ -n "$var" ] ; then
MultiABI="$var"
fi

echo -n "\nOptional shared libraries to compile - removing some of them will save space\nMP3 support by libMAD is encumbered by patents and libMAD is GPL-ed\n"
grep 'Available libraries:' project/Application.mk
grep 'depends on' project/Application.mk
echo "Current: $CompiledLibraries\n\n: "
grep 'depends on' project/Application.mk
echo -n "Current: $CompiledLibraries\n\n: "
read var
if [ -n "$var" ] ; then
CompiledLibraries="$var"
Expand All @@ -58,6 +64,7 @@ echo -n "\nHere you may type some short readme text that will be shown when app
echo -n "\nCurrent text:\n"
echo -n "`echo $ReadmeText | tr '^' '\\n'`"
echo -n "\n\nNew text (empty line to finish):\n\n"

ReadmeText1=""
while true; do
read var
Expand All @@ -81,6 +88,7 @@ echo AppDataDownloadUrl=\"$AppDataDownloadUrl\" >> AppSettings.cfg
echo DownloadToSdcard=$DownloadToSdcard >> AppSettings.cfg
echo SdlVideoResize=$SdlVideoResize >> AppSettings.cfg
echo NeedDepthBuffer=$NeedDepthBuffer >> AppSettings.cfg
echo MultiABI=$MultiABI >> AppSettings.cfg
echo CompiledLibraries=\"$CompiledLibraries\" >> AppSettings.cfg
echo ReadmeText=\'$ReadmeText\' >> AppSettings.cfg

Expand Down Expand Up @@ -110,13 +118,23 @@ if [ "$NeedDepthBuffer" = "y" ] ; then
else
NeedDepthBuffer=false
fi
if [ "$MultiABI" = "y" ] ; then
MultiABI="armeabi armeabi-v7a"
else
MultiABI="armeabi"
fi
SdlMixerUseLibMad=0
if echo $CompiledLibraries | grep '\bmad\b' > /dev/null ; then
SdlMixerUseLibMad=1
fi
echo ReadmeText1 "$ReadmeText"
LibrariesToLoad="System.loadLibrary(\\\"sdl\\\");"
for lib in $CompiledLibraries; do
LibrariesToLoad="$LibrariesToLoad System.loadLibrary(\\\"$lib\\\");"
done
echo CompiledLibraries $CompiledLibraries
echo LibrariesToLoad $LibrariesToLoad

ReadmeText="`echo $ReadmeText | sed 's/\"/\\\\\\\\\"/g' | sed 's/[&%]//g'`"
echo ReadmeText2 "$ReadmeText"

echo Patching project/AndroidManifest.xml
cat project/AndroidManifest.xml | \
Expand All @@ -139,7 +157,8 @@ cat project/src/Globals.java | \
sed "s^public static String DataDownloadUrl = \".*\";^public static String DataDownloadUrl = \"$AppDataDownloadUrl1\";^" | \
sed "s/public static boolean DownloadToSdcard = .*;/public static boolean DownloadToSdcard = $DownloadToSdcard1;/" | \
sed "s/public static boolean NeedDepthBuffer = .*;/public static boolean NeedDepthBuffer = $NeedDepthBuffer;/" | \
sed "s%public static String ReadmeText = .*%public static String ReadmeText = \"$ReadmeText\".replace(\"^\",\"\\\n\");%" > \
sed "s%public static String ReadmeText = .*%public static String ReadmeText = \"$ReadmeText\".replace(\"^\",\"\\\n\");%" | \
sed "s/public LoadLibrary() .*/public LoadLibrary() { $LibrariesToLoad };/" > \
project/src/Globals.java.1
mv -f project/src/Globals.java.1 project/src/Globals.java

Expand All @@ -156,7 +175,8 @@ cat project/jni/Android.mk | \
mv -f project/jni/Android.mk.1 project/jni/Android.mk

cat project/Application.mk | \
sed "s/APP_MODULES := .*/APP_MODULES := application sdl_main $CompiledLibraries/" > \
sed "s/APP_MODULES := .*/APP_MODULES := application sdl_main stlport tremor png jpeg freetype $CompiledLibraries/" | \
sed "s/APP_ABI := .*/APP_ABI := $MultiABI/" > \
project/Application.mk.1
mv -f project/Application.mk.1 project/Application.mk

Expand Down
6 changes: 4 additions & 2 deletions alienblaster/project/Application.mk
@@ -1,8 +1,10 @@
APP_PROJECT_PATH := $(call my-dir)

# Available libraries: stlport sdl sdl_mixer tremor mad sdl_image png jpeg sdl_ttf freetype
# Available libraries: mad sdl_mixer sdl_image sdl_ttf
# sdl_mixer depends on tremor and optionally mad
# sdl_image depends on png and jpeg
# sdl_ttf depends on freetype

APP_MODULES := application sdl_main sdl sdl_mixer tremor mad sdl_image png jpeg sdl_ttf freetype
APP_MODULES := application sdl_main stlport tremor png jpeg freetype mad sdl_mixer sdl_image sdl_ttf

APP_ABI := armeabi armeabi-v7a
3 changes: 2 additions & 1 deletion alienblaster/project/jni/mad/Android.mk
Expand Up @@ -5,7 +5,8 @@ include $(CLEAR_VARS)
LOCAL_MODULE := mad

LOCAL_CFLAGS := -I$(LOCAL_PATH) \
-DOPT_SPEED -DSTDC_HEADERS -DHAVE_UNISTD_H \
-DFPM_64BIT -DOPT_SPEED \
-DSTDC_HEADERS -DHAVE_UNISTD_H \
-DSIZEOF_INT=4 -DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 \
-DHAVE_ASSERT_H -DHAVE_ERRNO_H -DHAVE_FCNTL_H -DHAVE_INTTYPES_H \
-DHAVE_LIMITS_H -DHAVE_MEMORY_H -DHAVE_STDINT_H -DHAVE_STDLIB_H \
Expand Down
7 changes: 4 additions & 3 deletions alienblaster/project/jni/sdl_mixer/Android.mk
Expand Up @@ -4,17 +4,18 @@ include $(CLEAR_VARS)

LOCAL_MODULE := sdl_mixer

LOCAL_CFLAGS := -I$(LOCAL_PATH) -I$(LOCAL_PATH)/.. -I$(LOCAL_PATH)/../sdl/include \
LOCAL_CFLAGS := -I$(LOCAL_PATH) -I$(LOCAL_PATH)/.. -I$(LOCAL_PATH)/../sdl/include -I$(LOCAL_PATH)/../mad \
-DWAV_MUSIC -DOGG_USE_TREMOR -DOGG_MUSIC

LOCAL_CPP_EXTENSION := .cpp

LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))

LOCAL_SHARED_LIBRARIES := sdl tremor
LOCAL_SHARED_LIBRARIES := sdl
LOCAL_STATIC_LIBRARIES := tremor

ifneq ($(SDL_MIXER_USE_LIBMAD),)
LOCAL_CFLAGS := -DMP3_MAD_MUSIC
LOCAL_CFLAGS += -DMP3_MAD_MUSIC
LOCAL_SHARED_LIBRARIES += mad
endif

Expand Down
2 changes: 1 addition & 1 deletion alienblaster/project/jni/tremor/Android.mk
Expand Up @@ -10,5 +10,5 @@ LOCAL_CPP_EXTENSION := .cpp

LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))

include $(BUILD_SHARED_LIBRARY)
include $(BUILD_STATIC_LIBRARY)

14 changes: 2 additions & 12 deletions alienblaster/project/src/Globals.java
@@ -1,22 +1,19 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount anywhere
package de.schwardtnet.alienblaster;

import android.app.Activity;
import android.content.Context;

class Globals {
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
public static String ApplicationName = "AlienBlaster";

// Should be zip file
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
public static String DataDownloadUrl = "http://sites.google.com/site/xpelyax/Home/alienblaster110_data.zip?attredirects=0%26d=1"; // This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount

// Set DownloadToSdcard to true if your app data is bigger than 5 megabytes.
// It will download app data to /sdcard/alienblaster then,
// otherwise it will download it to /data/data/de.schwardtnet.alienblaster/files -
// set this dir in jni/Android.mk in SDL_CURDIR_PATH
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
public static boolean DownloadToSdcard = false;

// Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D
Expand All @@ -27,12 +24,5 @@ class Globals {
}

class LoadLibrary {
public LoadLibrary()
{
System.loadLibrary("tremor");
System.loadLibrary("sdl");
System.loadLibrary("sdl_mixer");
System.loadLibrary("sdl_image");
System.loadLibrary("sdl_ttf");
}
public LoadLibrary() { System.loadLibrary("sdl"); System.loadLibrary("mad"); System.loadLibrary("sdl_mixer"); System.loadLibrary("sdl_image"); System.loadLibrary("sdl_ttf"); };
}

0 comments on commit 650aca4

Please sign in to comment.