Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More options for build.sh

  • Loading branch information...
commit 911783e6d0c123d59af6075e65da7adf589edd24 1 parent 600660c
@pelya authored
View
2  bugs.txt
@@ -20,8 +20,6 @@ Known bugs
Requested features
==================
-- It's impossible to do "./build.sh release"
-
- Perform a check for free space available on SD card before writing there, and write to the internal storage if SD card is unplugged.
- Split Settings.java into several files
View
77 build.sh
@@ -3,6 +3,13 @@
install_apk=false
run_apk=false
+sign_apk=false
+build_release=false
+
+if [ "$#" -gt 0 -a "$1" = "-s" ]; then
+ shift
+ sign_apk=true
+fi
if [ "$#" -gt 0 -a "$1" = "-i" ]; then
shift
@@ -15,6 +22,11 @@ if [ "$#" -gt 0 -a "$1" = "-r" ]; then
run_apk=true
fi
+if [ "$#" -gt 0 -a "$1" = "release" ]; then
+ shift
+ build_release=true
+fi
+
[ -e project/local.properties ] || {
android update project -p project || exit 1
rm -f project/src/Globals.java
@@ -30,6 +42,9 @@ if ( grep "package $AppFullName;" project/src/Globals.java > /dev/null 2>&1 && \
sleep 1
touch project/src/Globals.java
fi
+if $build_release ; then
+ sed -i 's/android:debuggable="true"/android:debuggable="false"/g' project/AndroidManifest.xml
+fi
MYARCH=linux-x86
NCPU=4
@@ -50,31 +65,39 @@ rm -r -f project/bin/* # New Android SDK introduced some lame-ass optimizations
./AndroidPreBuild.sh || { echo "AndroidPreBuild.sh returned with error" ; exit 1 ; }
cd ../../../..
}
+
cd project && env PATH=$NDKBUILDPATH BUILD_NUM_CPUS=$NCPU nice -n19 ndk-build -j$NCPU V=1 && \
- { grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
- echo Stripping libapplication.so by hand && \
- rm obj/local/armeabi/libapplication.so && \
- cp jni/application/src/libapplication.so obj/local/armeabi/ && \
- cp jni/application/src/libapplication.so libs/armeabi/ && \
- `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi/libapplication.so \
- || true ; } && \
- { grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
- grep "MultiABI=y" ../AndroidAppSettings.cfg > /dev/null && \
- echo Stripping libapplication-armeabi-v7a.so by hand && \
- rm obj/local/armeabi-v7a/libapplication.so && \
- cp jni/application/src/libapplication-armeabi-v7a.so obj/local/armeabi-v7a/libapplication.so && \
- cp jni/application/src/libapplication-armeabi-v7a.so libs/armeabi-v7a/libapplication.so && \
- `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi-v7a/libapplication.so \
- || true ; } && \
- cd .. && ./copyAssets.sh && cd project && \
- ant debug && \
- $install_apk && [ -n "`adb devices | tail -n +2`" ] && \
- { cd bin && adb install -r MainActivity-debug.apk | grep 'Failure' && \
- adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && adb install -r MainActivity-debug.apk ; true ; } && \
- $run_apk && {
- ActivityName="`grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity"
- RUN_APK="adb shell am start -n $ActivityName"
- echo "Running $ActivityName on the USB-connected device:"
- echo "$RUN_APK"
- eval $RUN_APK
- }
+ { grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
+ echo Stripping libapplication.so by hand && \
+ rm obj/local/armeabi/libapplication.so && \
+ cp jni/application/src/libapplication.so obj/local/armeabi/ && \
+ cp jni/application/src/libapplication.so libs/armeabi/ && \
+ `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi/libapplication.so \
+ || true ; } && \
+ { grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
+ grep "MultiABI=y" ../AndroidAppSettings.cfg > /dev/null && \
+ echo Stripping libapplication-armeabi-v7a.so by hand && \
+ rm obj/local/armeabi-v7a/libapplication.so && \
+ cp jni/application/src/libapplication-armeabi-v7a.so obj/local/armeabi-v7a/libapplication.so && \
+ cp jni/application/src/libapplication-armeabi-v7a.so libs/armeabi-v7a/libapplication.so && \
+ `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi-v7a/libapplication.so \
+ || true ; } && \
+ cd .. && ./copyAssets.sh && cd project && \
+ { if $build_release ; then \
+ ant release || exit 1 ; \
+ jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -sigalg MD5withRSA -digestalg SHA1 bin/MainActivity-release-unsigned.apk androiddebugkey || exit 1 ; \
+ zipalign 4 bin/MainActivity-release-unsigned.apk bin/MainActivity-debug.apk ; \
+ else \
+ ant debug ; \
+ fi ; } && \
+ { if $sign_apk; then cd .. && ./sign.sh && cd project ; else true ; fi ; } && \
+ $install_apk && [ -n "`adb devices | tail -n +2`" ] && \
+ { cd bin && adb install -r MainActivity-debug.apk | grep 'Failure' && \
+ adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && adb install -r MainActivity-debug.apk ; true ; } && \
+ $run_apk && { \
+ ActivityName="`grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity" ; \
+ RUN_APK="adb shell am start -n $ActivityName" ; \
+ echo "Running $ActivityName on the USB-connected device:" ; \
+ echo "$RUN_APK" ; \
+ eval $RUN_APK ; \
+ }
View
29 project/jni/application/test-advertisements/ballfield.cpp
@@ -579,18 +579,6 @@ int main(int argc, char* argv[])
}
}
- if(adSize.w == 0 || adSize.h == 0)
- SDL_ANDROID_GetAdvertisementParams(NULL, &adSize);
- int adX = abs(x_offs / 100) % (physicalW - adSize.w);
- int adY = abs(y_offs / 80) % (physicalH - adSize.h);
- SDL_ANDROID_SetAdvertisementPosition(adX, adY);
- SDL_Rect adRect;
- adRect.x = adX * SCREEN_W / physicalW;
- adRect.w = adSize.w * SCREEN_W / physicalW;
- adRect.y = adY * SCREEN_H / physicalH;
- adRect.h = adSize.h * SCREEN_H / physicalH;
- SDL_FillRect(screen, &adRect, 0xff0);
-
print_num(screen, font, screen->w-37, screen->h-12, fps);
++fps_count;
@@ -607,6 +595,7 @@ int main(int argc, char* argv[])
SDL_FillRect(screen, &r, 0xaaaaaa);
print_num(screen, font, r.x, r.y, i+1);
}
+ int adX, adY;
int mx, my;
int b = SDL_GetMouseState(&mx, &my);
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Mouse buttons: %d", b);
@@ -624,8 +613,22 @@ int main(int argc, char* argv[])
adX = mx * physicalW / SCREEN_W - adSize.w - 10;
adY = my * physicalH / SCREEN_H - adSize.h - 10;
SDL_ANDROID_SetAdvertisementPosition(adX, adY);
- SDL_ANDROID_SetAdvertisementVisible(1);
}
+ else
+ {
+ if(adSize.w == 0 || adSize.h == 0)
+ SDL_ANDROID_GetAdvertisementParams(NULL, &adSize);
+ adX = abs(x_offs / 100) % (physicalW - adSize.w);
+ adY = abs(y_offs / 80) % (physicalH - adSize.h);
+ SDL_ANDROID_SetAdvertisementPosition(adX, adY);
+ }
+ SDL_Rect adRect;
+ adRect.x = adX * SCREEN_W / physicalW;
+ adRect.w = adSize.w * SCREEN_W / physicalW;
+ adRect.y = adY * SCREEN_H / physicalH;
+ adRect.h = adSize.h * SCREEN_H / physicalH;
+ SDL_FillRect(screen, &adRect, 0xff0);
+
r.x = mx;
r.y = my;
r.w = 30;
View
2  sign.sh
@@ -15,7 +15,7 @@ zip -d Signed.apk "META-INF/*"
# Sign with the new certificate
echo Using keystore $ANDROID_KEYSTORE_FILE and alias $ANDROID_KEYSTORE_ALIAS
stty -echo
-jarsigner -verbose -keystore $ANDROID_KEYSTORE_FILE -sigalg MD5withRSA -digestalg SHA1 Signed.apk $ANDROID_KEYSTORE_ALIAS
+jarsigner -verbose -keystore $ANDROID_KEYSTORE_FILE -sigalg MD5withRSA -digestalg SHA1 Signed.apk $ANDROID_KEYSTORE_ALIAS || exit 1
stty echo
echo
zipalign 4 Signed.apk SignedAligned.apk
Please sign in to comment.
Something went wrong with that request. Please try again.