SDL2: custom activity that overrides SDLActivity
This commit is contained in:
@@ -48,10 +48,6 @@ fi
|
||||
|
||||
var=""
|
||||
|
||||
if [ "$LibSdlVersion" = "2.0" ]; then
|
||||
JAVA_SRC_PATH=project/javaSDL2
|
||||
fi
|
||||
|
||||
if [ "$CompatibilityHacks" = y ]; then
|
||||
SwVideoMode=y
|
||||
fi
|
||||
@@ -196,7 +192,7 @@ echo "# Here you may type readme text, which will be shown during startup. Forma
|
||||
echo "# Text in English, use \\\\\\\\\\\\\\\\n to separate lines (that's four backslashes)^de:Text in Deutsch^ru:Text in Russian^button:Button that will open some URL:http://url-to-open/" >> AndroidAppSettings.cfg
|
||||
echo ReadmeText=\'$ReadmeText\' | sed 's/\\\\n/\\\\\\\\n/g' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# libSDL version to use (1.2/2.0)" >> AndroidAppSettings.cfg
|
||||
echo "# libSDL version to use (1.2/2)" >> AndroidAppSettings.cfg
|
||||
echo LibSdlVersion=$LibSdlVersion >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape" >> AndroidAppSettings.cfg
|
||||
@@ -415,7 +411,7 @@ echo >> AndroidAppSettings.cfg
|
||||
echo "# How long to show startup menu button, in msec, 0 to disable startup menu" >> AndroidAppSettings.cfg
|
||||
echo StartupMenuButtonTimeout=$StartupMenuButtonTimeout >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Menu items to hide from startup menu, available menu items:" >> AndroidAppSettings.cfg
|
||||
echo "# Menu items to hide from startup menu, available menu items (SDL 1.2 only):" >> AndroidAppSettings.cfg
|
||||
echo "# $MenuOptionsAvailable" >> AndroidAppSettings.cfg
|
||||
echo HiddenMenuOptions=\'$HiddenMenuOptions\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
@@ -498,14 +494,12 @@ AppSharedLibrariesPath=/data/data/$AppFullName/lib
|
||||
ScreenOrientation1=sensorPortrait
|
||||
HorizontalOrientation=false
|
||||
|
||||
UsingSdl13=false
|
||||
if [ "$LibSdlVersion" = "1.3" ] ; then
|
||||
UsingSdl13=true
|
||||
fi
|
||||
|
||||
UsingSdl20=false
|
||||
UsingSdl2=false
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
UsingSdl20=true
|
||||
"$LibSdlVersion" = "2"
|
||||
fi
|
||||
if [ "$LibSdlVersion" = "2" ] ; then
|
||||
UsingSdl2=true
|
||||
fi
|
||||
|
||||
if [ "$ScreenOrientation" = "h" -o "$ScreenOrientation" = "l" ] ; then
|
||||
@@ -790,7 +784,8 @@ else
|
||||
MultiABI="$MultiABI"
|
||||
fi
|
||||
|
||||
LibrariesToLoad="\\\"sdl_native_helpers\\\", \\\"sdl-$LibSdlVersion\\\""
|
||||
LibrariesToLoad="\\\"sdl_native_helpers\\\", \\\"`$UsingSdl2 && echo SDL2 || echo sdl-1.2`\\\""
|
||||
|
||||
StaticLibraries="`echo '
|
||||
include project/jni/SettingsTemplate.mk
|
||||
all:
|
||||
@@ -811,8 +806,11 @@ for lib in $CompatibilityHacksAdditionalPreloadedSharedLibraries; do
|
||||
MainLibrariesToLoad="$MainLibrariesToLoad \\\"$lib\\\","
|
||||
done
|
||||
|
||||
MainLibrariesToLoad="$MainLibrariesToLoad \\\"application\\\", \\\"sdl_main\\\""
|
||||
|
||||
if $UsingSdl2; then
|
||||
MainLibrariesToLoad="$MainLibrariesToLoad \\\"application\\\""
|
||||
else
|
||||
MainLibrariesToLoad="$MainLibrariesToLoad \\\"application\\\", \\\"sdl_main\\\""
|
||||
fi
|
||||
|
||||
if [ "$CustomBuildScript" = "n" ] ; then
|
||||
CustomBuildScript=
|
||||
@@ -840,37 +838,51 @@ if uname -s | grep -i "darwin" > /dev/null ; then
|
||||
SEDI="sed -i.killme.tmp" # MacOsX version of sed is buggy, and requires a mandatory parameter
|
||||
fi
|
||||
|
||||
|
||||
rm -rf project/src
|
||||
mkdir -p project/src
|
||||
|
||||
if $UsingSdl2; then
|
||||
JAVA_SRC_PATH=project/javaSDL2
|
||||
fi
|
||||
|
||||
cd $JAVA_SRC_PATH
|
||||
for F in *.java; do
|
||||
echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN, edit the file under $JAVA_SRC_PATH dir' | cat - $F > ../src/$F
|
||||
echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN, edit the file under '$JAVA_SRC_PATH' dir' | cat - $F > ../src/$F
|
||||
done
|
||||
|
||||
if [ -e ../jni/application/src/java.diff ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.diff || exit 1 ; fi
|
||||
if [ -e ../jni/application/src/java.patch ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.patch || exit 1 ; fi
|
||||
if ls ../jni/application/src/*.java > /dev/null 2>&1; then cp -f ../jni/application/src/*.java ../src ; fi
|
||||
|
||||
for F in ../src/*.java; do
|
||||
echo Patching $F
|
||||
$SEDI "s/^package .*;/package $AppFullName;/" $F
|
||||
done
|
||||
|
||||
cd ../..
|
||||
|
||||
# In case we use SDL2 let simlink the SDLActivity source file
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
ln -s ../jni/sdl-2.0/android-project/src/org/libsdl/app/SDLActivity.java project/src/SDLActivity.java
|
||||
if $UsingSdl2; then
|
||||
# Keep package name org.libsdl.app, it's hardcoded inside libSDL2.so
|
||||
for F in `ls ../jni/sdl2/android-project/app/src/main/java/org/libsdl/app/`; do
|
||||
echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN,' \
|
||||
'edit the file under project/jni/sdl2/android-project/app/src/main/java/org/libsdl/app dir' | \
|
||||
cat - ../jni/sdl2/android-project/app/src/main/java/org/libsdl/app/$F > ../src/$F
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -e ../jni/application/src/java.diff ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.diff || exit 1 ; fi
|
||||
if [ -e ../jni/application/src/java.patch ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.patch || exit 1 ; fi
|
||||
if ls ../jni/application/src/*.java > /dev/null 2>&1; then cp -f ../jni/application/src/*.java ../src ; fi
|
||||
|
||||
cd ../..
|
||||
|
||||
if $UsingSdl2; then
|
||||
ANDROID_MANIFEST_TEMPLATE=project/jni/sdl2/android-project/app/src/main/AndroidManifest.xml
|
||||
else
|
||||
ANDROID_MANIFEST_TEMPLATE=project/AndroidManifestTemplate.xml
|
||||
fi
|
||||
|
||||
echo Patching project/AndroidManifest.xml
|
||||
cat project/AndroidManifestTemplate.xml | \
|
||||
cat $ANDROID_MANIFEST_TEMPLATE | \
|
||||
sed "s/package=.*/package=\"$AppFullName\"/" | \
|
||||
sed "s/android:screenOrientation=.*/android:screenOrientation=\"$ScreenOrientation1\"/" | \
|
||||
sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
|
||||
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
|
||||
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" | \
|
||||
sed "s^activity android:name=.*^activity android:name=\"MainActivity\"^" > \
|
||||
project/AndroidManifest.xml
|
||||
if [ "$AdmobPublisherId" = "n" -o -z "$AdmobPublisherId" ] ; then
|
||||
$SEDI "/==ADMOB==/ d" project/AndroidManifest.xml
|
||||
@@ -980,9 +992,8 @@ fi
|
||||
|
||||
echo Patching project/src/Globals.java
|
||||
$SEDI "s/public static String ApplicationName = .*;/public static String ApplicationName = \"$AppShortName\";/" project/src/Globals.java
|
||||
$SEDI "s/public static final boolean Using_SDL_1_3 = .*;/public static final boolean Using_SDL_1_3 = $UsingSdl13;/" project/src/Globals.java
|
||||
|
||||
$SEDI "s/public static final boolean Using_SDL_2_0 = .*;/public static final boolean Using_SDL_2_0 = $UsingSdl20;/" project/src/Globals.java
|
||||
$SEDI "s/public static final boolean UsingSDL2 = .*;/public static final boolean UsingSDL2 = $UsingSdl2;/" project/src/Globals.java
|
||||
|
||||
# Work around "Argument list too long" problem when compiling VICE
|
||||
#$SEDI "s@public static String DataDownloadUrl = .*@public static String DataDownloadUrl = \"$AppDataDownloadUrl1\";@" project/src/Globals.java
|
||||
@@ -1045,11 +1056,10 @@ $SEDI "s%public static String GooglePlayGameServicesId = .*%public static String
|
||||
$SEDI "s/public static String AppLibraries.*/public static String AppLibraries[] = { $LibrariesToLoad };/" project/src/Globals.java
|
||||
$SEDI "s/public static String AppMainLibraries.*/public static String AppMainLibraries[] = { $MainLibrariesToLoad };/" project/src/Globals.java
|
||||
|
||||
|
||||
echo Patching project/jni/Settings.mk
|
||||
echo '# DO NOT EDIT THIS FILE - it is automatically generated, edit file SettingsTemplate.mk' > project/jni/Settings.mk
|
||||
cat project/jni/SettingsTemplate.mk | \
|
||||
sed "s/APP_MODULES := .*/APP_MODULES := sdl-$LibSdlVersion sdl_native_helpers jpeg png ogg flac vorbis freetype $CompiledLibraries/" | \
|
||||
sed "s/APP_MODULES := .*/APP_MODULES := `$UsingSdl2 && echo SDL2 || echo sdl-1.2` sdl_native_helpers jpeg png ogg flac vorbis freetype $CompiledLibraries/" | \
|
||||
sed "s/APP_ABI := .*/APP_ABI := $MultiABI/" | \
|
||||
sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \
|
||||
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
|
||||
|
||||
Reference in New Issue
Block a user