SDL: Fixed clang C++ exception support in setEnvironment build scripts

This commit is contained in:
Sergii Pylypenko
2018-06-21 20:36:50 +03:00
parent 3988790916
commit 19ad345143
10 changed files with 49 additions and 36 deletions

View File

@@ -68,10 +68,10 @@ SdlVideoResize=y
SdlVideoResizeKeepAspect=n
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
InhibitSuspend=n
InhibitSuspend=y
# Create Android service, so the app is less likely to be killed while in background
CreateService=y
CreateService=n
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
@@ -238,7 +238,7 @@ RedefinedKeysThirdGamepad="F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 PR
RedefinedKeysFourthGamepad="KP0 KP1 KP2 KP3 KP4 KP5 KP6 KP7 KP8 KP9 KP_PERIOD KP_DIVIDE KP_MULTIPLY KP_MINUS KP_PLUS KP_ENTER"
# How long to show startup menu button, in msec, 0 to disable startup menu
StartupMenuButtonTimeout=3000
StartupMenuButtonTimeout=1000
# Menu items to hide from startup menu, available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
@@ -264,7 +264,7 @@ APP_PLATFORM=
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a
MultiABI='armeabi-v7a x86'
MultiABI='arm64-v8a'
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
@@ -275,13 +275,13 @@ CompiledLibraries="sdl_image"
CustomBuildScript=n
# Aditional CFLAGS for application
AppCflags='-O2 -finline-functions'
AppCflags='-O0'
# Aditional C++-specific compiler flags for application, added after AppCflags
AppCppflags=''
AppCppflags='-frtti -fexceptions'
# Additional LDFLAGS for application
AppLdflags=''
AppLdflags='-frtti -fexceptions'
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
AppOverlapsSystemHeaders=

View File

@@ -14,6 +14,7 @@
#include <math.h>
#include <android/log.h>
#include <wchar.h>
#include <stdexcept>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
@@ -129,7 +130,7 @@ SDL_Surface *clean_alpha(SDL_Surface *s)
/*
* Load and convert an antialiazed, zoomed set of sprites.
*/
SDL_Surface *load_zoomed(char *name, int alpha)
SDL_Surface *load_zoomed(const char *name, int alpha)
{
SDL_Surface *sprites;
SDL_Surface *temp = IMG_Load(name);
@@ -295,7 +296,7 @@ static int ballfield_init_frames(ballfield_t *bf)
}
int ballfield_load_gfx(ballfield_t *bf, char *name, unsigned int color)
int ballfield_load_gfx(ballfield_t *bf, const char *name, unsigned int color)
{
if(color >= COLORS)
return -1;
@@ -410,6 +411,16 @@ void tiled_back(SDL_Surface *back, SDL_Surface *screen, int xo, int yo)
SDL_BlitSurface(back, NULL, screen, &r);
}
void throw_something_more()
{
throw std::runtime_error("Exception: whoops");
}
void throw_something()
{
throw_something_more();
}
/*----------------------------------------------------------
main()
----------------------------------------------------------*/
@@ -689,6 +700,11 @@ int main(int argc, char* argv[])
{
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 1);
SDL_ANDROID_SetMouseEmulationMode(0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
try {
throw_something();
} catch (const std::exception & e) {
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Got exception: %s", e.what());
}
}
if(evt.key.keysym.sym == SDLK_1)
{

View File

@@ -7,10 +7,10 @@ AppName="OpenTTD"
AppFullName=org.openttd.sdl
# Application version code (integer)
AppVersionCode=18075
AppVersionCode=18076
# Application user-visible version name (string)
AppVersionName="1.8.0.75"
AppVersionName="1.8.0.76"
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
@@ -243,7 +243,7 @@ AppMinimumRAM=0
NDK_TOOLCHAIN_VERSION=clang
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a x86_64
# Available architectures: armeabi-v7a x86 arm64-v8a x86_64
MultiABI='armeabi-v7a x86 arm64-v8a x86_64'
# Optional shared libraries to compile - removing some of them will save space

View File

@@ -26,12 +26,5 @@ CPU_TYPE=32
NCPU=4
uname -s | grep -i "linux" > /dev/null && NCPU=`cat /proc/cpuinfo | grep -c -i processor`
# clang arm hack
LIBATOMIC=
echo $1 | grep 'armeabi-v7a' && LIBATOMIC="-lunwind"
env CLANG=1 ../setEnvironment-$1.sh sh -c "cd openttd-$VER-$1 && make -j$NCPU VERBOSE=1 STRIP='' "' LIBS="-lsdl-1.2 -llzo2 -lpng -ltimidity -lfontconfig -lfreetype -lexpat-sdl -licui18n -liculx -licu-le-hb -lharfbuzz -licuuc -licudata $LDFLAGS"' && cp -f openttd-$VER-$1/objs/release/openttd libapplication-$1.so || exit 1
LIBANDROIDSUPPORT=
[ "$1" = "armeabi-v7a" ] && LIBANDROIDSUPPORT="-landroid_support"
[ "$1" = "x86" ] && LIBANDROIDSUPPORT="-landroid_support"
env CLANG=1 LIBATOMIC=$LIBATOMIC ../setEnvironment-$1.sh sh -c "cd openttd-$VER-$1 && make -j$NCPU VERBOSE=1 STRIP='' LIBS='-lsdl-1.2 -llzo2 -lpng -ltimidity -lfontconfig -lfreetype -lexpat-sdl -licui18n -liculx -licu-le-hb -lharfbuzz -licuuc -licudata -lgcc -lz -lc -lc++_static -lc++abi $LIBANDROIDSUPPORT $LIBATOMIC'" && cp -f openttd-$VER-$1/objs/release/openttd libapplication-$1.so || exit 1

View File

@@ -132,7 +132,7 @@ $NDK/toolchains/aarch64-linux-android-4.9/prebuilt/$MYARCH
-target
aarch64-none-linux-android
-fpic
--sysroot $NDK/platforms/android-21/arch-arm64
--sysroot $NDK/sysroot
-isystem $NDK/sysroot/usr/include
-isystem $NDK/sysroot/usr/include/aarch64-linux-android
-D__ANDROID_API__=21
@@ -151,12 +151,13 @@ $APP_SHARED_LIBS
-L$NDK/sources/android/support/../../cxx-stl/llvm-libc++/libs/$ARCH
$NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH/libc++_static.a
$NDK/sources/cxx-stl/llvm-libc++abi/../llvm-libc++/libs/$ARCH/libc++abi.a
-lgcc -Wl,--exclude-libs,libgcc.a
-latomic -Wl,--exclude-libs,libatomic.a
-gcc-toolchain
$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/$MYARCH
-target aarch64-none-linux-android -no-canonical-prefixes
-Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-lc -lm -lstdc++ -ldl -llog -lz
-lc -lm -nostdlib++ -ldl -llog -lz
$LDFLAGS"
LDFLAGS="`echo $LDFLAGS | tr '\n' ' '`"

View File

@@ -130,24 +130,24 @@ CFLAGS="
-gcc-toolchain
$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/$MYARCH
-target
armv7-none-linux-androideabi15
armv7-none-linux-androideabi18
-march=armv7-a
-mfloat-abi=softfp
-mfpu=vfpv3-d16
-mthumb
-fpic
-fno-integrated-as
--sysroot $NDK/platforms/android-14/arch-arm
--sysroot $NDK/sysroot
-isystem $NDK/sysroot/usr/include
-isystem $NDK/sysroot/usr/include/arm-linux-androideabi
-D__ANDROID_API__=15
-D__ANDROID_API__=18
$APP_MODULES_INCLUDE
$CFLAGS"
CFLAGS="`echo $CFLAGS | tr '\n' ' '`"
LDFLAGS="
--sysroot $NDK/platforms/android-14/arch-arm
--sysroot $NDK/platforms/android-18/arch-arm
$SHARED $UNRESOLVED
-L$LOCAL_PATH/../../obj/local/$ARCH
$APP_SHARED_LIBS
@@ -158,12 +158,13 @@ $NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH/libc++_static.a
$NDK/sources/cxx-stl/llvm-libc++abi/../llvm-libc++/libs/$ARCH/libc++abi.a
$NDK/sources/android/support/../../cxx-stl/llvm-libc++/libs/$ARCH/libandroid_support.a
$NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH/libunwind.a
-lgcc -Wl,--exclude-libs,libgcc.a
-latomic -Wl,--exclude-libs,libatomic.a
-gcc-toolchain
$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/$MYARCH
-no-canonical-prefixes -target armv7-none-linux-androideabi14
-no-canonical-prefixes -target armv7-none-linux-androideabi18
-Wl,--fix-cortex-a8 -Wl,--exclude-libs,libunwind.a -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-lc -lm -lstdc++ -ldl -llog -lz
-lc -lm -nostdlib++ -ldl -llog -lz
$LDFLAGS"
LDFLAGS="`echo $LDFLAGS | tr '\n' ' '`"

View File

@@ -133,17 +133,17 @@ $NDK/toolchains/x86-4.9/prebuilt/$MYARCH
i686-none-linux-android
-fPIC
-mstackrealign
--sysroot $NDK/platforms/android-14/arch-x86
--sysroot $NDK/sysroot
-isystem $NDK/sysroot/usr/include
-isystem $NDK/sysroot/usr/include/i686-linux-android
-D__ANDROID_API__=15
-D__ANDROID_API__=18
$APP_MODULES_INCLUDE
$CFLAGS"
CFLAGS="`echo $CFLAGS | tr '\n' ' '`"
LDFLAGS="
--sysroot $NDK/platforms/android-14/arch-x86
--sysroot $NDK/platforms/android-18/arch-x86
$SHARED $UNRESOLVED
-L$LOCAL_PATH/../../obj/local/$ARCH
$APP_SHARED_LIBS
@@ -153,12 +153,13 @@ $APP_SHARED_LIBS
$NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH/libc++_static.a
$NDK/sources/cxx-stl/llvm-libc++abi/../llvm-libc++/libs/$ARCH/libc++abi.a
$NDK/sources/android/support/../../cxx-stl/llvm-libc++/libs/$ARCH/libandroid_support.a
-lgcc -Wl,--exclude-libs,libgcc.a
-latomic -Wl,--exclude-libs,libatomic.a
-gcc-toolchain
$NDK/toolchains/x86-4.9/prebuilt/$MYARCH
-target i686-none-linux-android -no-canonical-prefixes
-Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-lc -lm -lstdc++ -ldl -llog -lz
-lc -lm -nostdlib++ -ldl -llog -lz
$LDFLAGS"
LDFLAGS="`echo $LDFLAGS | tr '\n' ' '`"

View File

@@ -132,7 +132,7 @@ $NDK/toolchains/x86_64-4.9/prebuilt/$MYARCH
-target
x86_64-none-linux-android
-fPIC
--sysroot $NDK/platforms/android-21/arch-x86_64
--sysroot $NDK/sysroot
-isystem $NDK/sysroot/usr/include
-isystem $NDK/sysroot/usr/include/x86_64-linux-android
-D__ANDROID_API__=21
@@ -151,12 +151,13 @@ $APP_SHARED_LIBS
-L$NDK/sources/android/support/../../cxx-stl/llvm-libc++/libs/$ARCH
$NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH/libc++_static.a
$NDK/sources/cxx-stl/llvm-libc++abi/../llvm-libc++/libs/$ARCH/libc++abi.a
-lgcc -Wl,--exclude-libs,libgcc.a
-latomic -Wl,--exclude-libs,libatomic.a
-gcc-toolchain
$NDK/toolchains/x86_64-4.9/prebuilt/$MYARCH
-target x86_64-none-linux-android -no-canonical-prefixes
-Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings
-lc -lm -lstdc++ -ldl -llog -lz
-lc -lm -nostdlib++ -ldl -llog -lz
$LDFLAGS"
LDFLAGS="`echo $LDFLAGS | tr '\n' ' '`"