diff options
author | Angus Lees | 2010-07-05 01:00:59 +0000 |
---|---|---|
committer | Angus Lees | 2010-07-05 01:00:59 +0000 |
commit | b8778fc7c382ec401409bbaafcb67355f0c566e3 (patch) | |
tree | b451a4f2700dcb83eb729d8096f893d0c064f3ab | |
parent | bb300ec671cfcd6fe7461dfd90615acfede2f1b9 (diff) | |
download | scummvm-rg350-b8778fc7c382ec401409bbaafcb67355f0c566e3.tar.gz scummvm-rg350-b8778fc7c382ec401409bbaafcb67355f0c566e3.tar.bz2 scummvm-rg350-b8778fc7c382ec401409bbaafcb67355f0c566e3.zip |
Switch Android toolchain prefix from arm-android-eabi to
arm-*-linux-androideabi, since this is what the upcoming gcc-4.6
change uses.
Work around Android 2.0 and newer dynamic linker bug by explicitly
linking plugins against the core libscummvm.so.
Mark Android packages as preferring to be on external storage.
Move -lm from LDFLAGS to LIBS.
svn-id: r50665
-rw-r--r-- | backends/platform/android/README.build | 41 | ||||
-rw-r--r-- | backends/platform/android/android.mk | 9 | ||||
-rw-r--r-- | backends/platform/android/module.mk | 22 | ||||
-rw-r--r-- | backends/platform/android/video.cpp | 2 | ||||
-rwxr-xr-x | configure | 31 | ||||
-rw-r--r-- | dists/android/AndroidManifest.xml | 10 | ||||
-rw-r--r-- | dists/android/AndroidManifest.xml.in | 12 | ||||
-rwxr-xr-x | dists/android/mkmanifest.pl | 1 |
8 files changed, 84 insertions, 44 deletions
diff --git a/backends/platform/android/README.build b/backends/platform/android/README.build index a834f8431b..0aa5c6eefd 100644 --- a/backends/platform/android/README.build +++ b/backends/platform/android/README.build @@ -4,12 +4,18 @@ Building the ScummVM Android port You will need these things to build: 1. Android EGL headers and library 2. Android SDK -3. An arm-android-eabi GCC toolchain +3. An arm-oe-linux-androideabi GCC toolchain(*) In the example commands, we are going to build against the Android 1.5 native ABI (but using the Android 1.6 SDK tools). Other version combinations might/should be possible with a bit of tweaking. +(*) Any other sane Android toolchain should be easy to use, but this +is the toolchain prefix that is used by default. You can trivially +find and modify the single location where it appears in ./configure if +you have some other prefix variation. + + In detail: 1. Android EGL headers and library @@ -26,17 +32,17 @@ to just download the 3 Android EGL headers from here: Download and install somewhere. -3. arm-android-eabi GCC toolchain +3. arm-*-linux-androideabi GCC toolchain You have several choices for toolchains: -- Use Google arm-eabi prebuilt toolchain. + - Use Google arm-eabi prebuilt toolchain. This is shipped with both the Android source release and Android NDK. The problem is that "arm-eabi-gcc" can't actually link anything successfully without extra command line flags. To use this with the ScummVM configure/build environment you will need to create a family -of shell wrapper scripts that convert "arm-android-eabi-foo" to +of shell wrapper scripts that convert "arm-oe-linux-androideabi-foo" to "arm-eabi-foo -mandroid". For example, I use this script: @@ -44,17 +50,24 @@ For example, I use this script: exec arm-eabi-${0##*-} -mandroid -DANDROID "$@" ... and create a family of symlinks/hardlinks pointing to it called -arm-android-eabi-gcc, arm-android-eabi-g++, etc. For tools that don't -take a "-mandroid" argument - like arm-eabi-strip - I bypass the shell -wrapper and just create an arm-android-eabi-strip symlink to the tool -directly. +arm-oe-android-linuxeabi-gcc, arm-oe-android-linuxeabi-g++, etc. For +tools that don't take a "-mandroid" argument - like arm-eabi-strip - I +bypass the shell wrapper and just create an arm-oe-android-linuxeabi-strip +symlink to the tool directly. + +In practice you will probably need significant linker command line +massaging in order to get the crtbegin/end and libraries all linked in +the right way. It's not hard to do manually, but it is annoying to +script in a general purpose way. -- Build your own arm-android-eabi toolchain from GCC source. + - Build your own arm-*-linux-androideabi toolchain from GCC source. -This is lots of fun. I suggest my Android openembedded patches, see: - http://wiki.github.com/anguslees/openembedded-android/ -(You just need to have lots of disk space and type a few commands) -If you get stuck, ask +This is lots of fun, but will become significantly easier once gcc-4.6 +is released. In the interim, I suggest using my precompiled Android +openembedded-based toolchain: + wget http://commondatastorage.googleapis.com/anr/sdk/android-2.2-i686-linux-armv5te-linux-androideabi-toolchain-android.tar.bz2 + sudo tar jxf android-2.2-i686-linux-armv5te-linux-androideabi-toolchain-android.tar.bz2 -C / + . /usr/local/android/arm/environment-setup Alternatively, do a websearch - there are several other cross-compile toolchains around. @@ -78,7 +91,7 @@ Then build ScummVM: export ANDROID_SDK=<root of Android SDK> PATH=$ANDROID_SDK/platforms/android-1.6/tools:$ANDROID_SDK/tools:$PATH - # You also want to ensure your arm-android-eabi toolchain is in your $PATH + # You also want to ensure your arm-oe-linux-androideabi toolchain is in $PATH export ANDROID_TOP=<root of built Android source> diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk index 0bc8fa265e..95e848e0d9 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -4,7 +4,6 @@ AAPT = aapt DX = dx APKBUILDER = apkbuilder ADB = adb -e -ANDROID_JAR = $(ANDROID_SDK)/platforms/android-1.6/android.jar JAVAC ?= javac JAVACFLAGS = -source 1.5 -target 1.5 @@ -12,6 +11,14 @@ JAVACFLAGS = -source 1.5 -target 1.5 #LDFLAGS += -Wl,--gc-sections #CXXFLAGS += -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden +resources.ap_: $(srcdir)/dists/android/AndroidManifest.xml $(RESOURCES) $(ASSETS) $(ANDROID_JAR8) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) + $(INSTALL) -d build.tmp/assets/ + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) build.tmp/assets/ + $(AAPT) package -f -M $< -S $(srcdir)/dists/android/res -A build.tmp/assets -I $(ANDROID_JAR8) -F $@ + +build.tmp/%/resources.ap_: build.tmp/%/AndroidManifest.xml build.stage/%/res/values/strings.xml build.stage/%/res/drawable/scummvm.png $(ANDROID_JAR8) + $(AAPT) package -f -M $< -S build.stage/$*/res -I $(ANDROID_JAR8) -F $@ + scummvm.apk: build.tmp/libscummvm.so resources.ap_ classes.dex # Package installer won't delete old libscummvm.so on upgrade so # replace it with a zero size file diff --git a/backends/platform/android/module.mk b/backends/platform/android/module.mk index fdb0ed2ac4..c7b98b996d 100644 --- a/backends/platform/android/module.mk +++ b/backends/platform/android/module.mk @@ -39,14 +39,22 @@ PLUGIN_RESOURCES = \ #ANDROID_VERSIONCODE = 6 Specified in dists/android/AndroidManifest.xml.in ANDROID_PLUGIN_VERSIONCODE = 6 +# This is a bit silly. I want to compile against the 1.6 android.jar, +# to make the compiler check that I don't use something that requires +# a newer Android. However, in order to use android:installLocation, +# we need to give aapt a version >=8 android.jar - even though the +# result will work ok on 1.5+. +ANDROID_JAR = $(ANDROID_SDK)/platforms/android-1.5/android.jar +ANDROID_JAR8 = $(ANDROID_SDK)/platforms/android-8/android.jar + # This library contains scummvm proper build.tmp/libscummvm.so: $(OBJS) @$(MKDIR) -p $(@D) - $(CXX) $(PLUGIN_LDFLAGS) -shared $(LDFLAGS) -Wl,-soname,$(@F) -Wl,--no-undefined -o $@ $(PRE_OBJS_FLAGS) $(OBJS) $(POST_OBJS_FLAGS) $(LIBS) + $(QUIET_LINK)$(CXX) -shared $(LDFLAGS) -Wl,-Bsymbolic -Wl,-soname,$(@F) -Wl,--no-undefined -o $@ $(PRE_OBJS_FLAGS) $(OBJS) $(POST_OBJS_FLAGS) $(LIBS) -backends/platform/android/org/inodes/gus/scummvm/R.java backends/platform/android/org/inodes/gus/scummvm/Manifest.java: $(srcdir)/dists/android/AndroidManifest.xml $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR) - $(AAPT) package -m -J backends/platform/android -M $< -S $(srcdir)/dists/android/res -I $(ANDROID_JAR) +backends/platform/android/org/inodes/gus/scummvm/R.java backends/platform/android/org/inodes/gus/scummvm/Manifest.java: $(srcdir)/dists/android/AndroidManifest.xml $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR8) + $(AAPT) package -m -J backends/platform/android -M $< -S $(srcdir)/dists/android/res -I $(ANDROID_JAR8) build.tmp/classes/%.class: $(srcdir)/backends/platform/android/%.java $(srcdir)/backends/platform/android/org/inodes/gus/scummvm/R.java @$(MKDIR) -p $(@D) @@ -63,14 +71,6 @@ build.tmp/plugins/classes.dex: $(JAVA_PLUGIN_SRC:backends/platform/android/%.jav @$(MKDIR) -p $(@D) $(DX) --dex --output=$@ build.tmp/classes.plugin -resources.ap_: $(srcdir)/dists/android/AndroidManifest.xml $(RESOURCES) $(ASSETS) $(ANDROID_JAR) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) - $(INSTALL) -d build.tmp/assets/ - $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) build.tmp/assets/ - $(AAPT) package -f -M $< -S $(srcdir)/dists/android/res -A build.tmp/assets -I $(ANDROID_JAR) -F $@ - -build.tmp/%/resources.ap_: build.tmp/%/AndroidManifest.xml build.stage/%/res/values/strings.xml build.stage/%/res/drawable/scummvm.png $(ANDROID_JAR) - $(AAPT) package -f -M $< -S build.stage/$*/res -I $(ANDROID_JAR) -F $@ - build.tmp/%/AndroidManifest.xml build.stage/%/res/values/strings.xml: dists/android/mkmanifest.pl configure dists/android/AndroidManifest.xml dists/android/mkmanifest.pl --id=$* --configure=configure \ --version-name=$(VERSION) \ diff --git a/backends/platform/android/video.cpp b/backends/platform/android/video.cpp index 5d16410cea..d4c002fbd0 100644 --- a/backends/platform/android/video.cpp +++ b/backends/platform/android/video.cpp @@ -47,7 +47,7 @@ #define ENTER(args...) /**/ #endif -#if 1 +#if 0 #define CHECK_GL_ERROR() checkGlError(__FILE__, __LINE__) static const char* getGlErrStr(GLenum error) { switch (error) { @@ -1007,7 +1007,7 @@ wince) android) _host_os=android _host_cpu=arm - _host_alias=arm-android-eabi + _host_alias=arm-oe-linux-androideabi ;; *) if test -n "$_host"; then @@ -1687,7 +1687,6 @@ if test -n "$_host"; then add_line_to_config_mk 'USE_ARM_COSTUME_ASM = 1' _backend="android" _port_mk="backends/platform/android/android.mk" - _build_hq_scalers="no" ;; *) echo "WARNING: Unknown target, continuing with auto-detected values" @@ -1990,7 +1989,7 @@ add_to_config_mk_if_yes "$_indeo3" 'USE_INDEO3 = 1' cat > $TMPC << EOF int main(void) { return 0; } EOF -cc_check -lm && LDFLAGS="$LDFLAGS -lm" +cc_check -lm && LIBS="$LIBS -lm" # # Check for Ogg Vorbis @@ -2494,12 +2493,36 @@ case $_backend in LIBS="$LIBS -static -lSDL" ;; android) + static_libs='' + system_libs='' + for lib in $LIBS; do + case $lib in + -lz|-lm) + system_libs="$system_libs $lib" + ;; + *) + static_libs="$static_libs $lib" + ;; + esac + done + # -lgcc is carefully placed here - we want to catch # all toolchain symbols in *our* libraries rather # than pick up anything unhygenic from the Android libs. - LIBS="$LIBS -lgcc -lstdc++ -llog -lGLESv1_CM -lEGL" + LIBS="-Wl,-Bstatic $static_libs -Wl,-Bdynamic -lgcc $system_libs -lstdc++ -llog -lGLESv1_CM -lEGL" DEFINES="$DEFINES -D__ANDROID__ -DANDROID_BACKEND -DREDUCE_MEMORY_USAGE" add_line_to_config_mk 'PLUGIN_LDFLAGS += $(LDFLAGS) -Wl,-shared,-Bsymbolic' + + # Work around an Android 2.0+ run-time linker bug: + # The linker doesn't actually look in previously + # loaded libraries when trying to resolve symbols - + # effectively turning all dlopen(RTLD_GLOBAL) calls + # into dlopen(RTLD_LOCAL). It *does* look in + # DT_NEEDED libraries, so the workaround is to add an + # (otherwise unnecessary) dependency from plugins back + # to the main libscummvm.so. + add_line_to_config_mk 'PLUGIN_LDFLAGS += -Lbuild.tmp -lscummvm' + add_line_to_config_mk 'PLUGIN_EXTRA_DEPS += build.tmp/libscummvm.so' ;; *) echo "support for $_backend backend not implemented in configure script yet" diff --git a/dists/android/AndroidManifest.xml b/dists/android/AndroidManifest.xml index 438703a3cc..55e3bf2f38 100644 --- a/dists/android/AndroidManifest.xml +++ b/dists/android/AndroidManifest.xml @@ -2,16 +2,14 @@ <!-- NB: android:versionCode needs to be bumped for formal releases --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.inodes.gus.scummvm" - android:versionCode="6" android:versionName="1.2.0svn"> + android:versionCode="6" android:versionName="1.2.0svn" + android:installLocation="preferExternal"> <!-- This version is built against a cupcake (and newer?) ABI. - It works on Android 1.5 (SDK 3) and Android 1.6 (SDK 4). - Native libraries changed around in Android 2.0 (SDK 5) so we - don't work on that yet. + It works on Android 1.5 (SDK 3) and newer. --> <uses-sdk android:minSdkVersion="3" - android:maxSdkVersion="4" - android:targetSdkVersion="4" /> + android:targetSdkVersion="8" /> <application android:name=".ScummVMApplication" android:label="@string/app_name" diff --git a/dists/android/AndroidManifest.xml.in b/dists/android/AndroidManifest.xml.in index ce0bef6f94..26a94f957b 100644 --- a/dists/android/AndroidManifest.xml.in +++ b/dists/android/AndroidManifest.xml.in @@ -2,16 +2,14 @@ <!-- NB: android:versionCode needs to be bumped for formal releases --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.inodes.gus.scummvm" - android:versionCode="6" android:versionName="@VERSION@"> + android:versionCode="6" android:versionName="@VERSION@" + android:installLocation="preferExternal"> - <!-- This version is built against a cupcake (and newer?) ABI. - It works on Android 1.5 (SDK 3) and Android 1.6 (SDK 4). - Native libraries changed around in Android 2.0 (SDK 5) so we - don't work on that yet. + <!-- This version works on Android 1.5 (SDK 3) and newer, but we + want Android 2.2 (SDK 8) defaults and features. --> <uses-sdk android:minSdkVersion="3" - android:maxSdkVersion="4" - android:targetSdkVersion="4" /> + android:targetSdkVersion="8" /> <application android:name=".ScummVMApplication" android:label="@string/app_name" diff --git a/dists/android/mkmanifest.pl b/dists/android/mkmanifest.pl index 00d15f561e..62caa64a55 100755 --- a/dists/android/mkmanifest.pl +++ b/dists/android/mkmanifest.pl @@ -105,6 +105,7 @@ sub print_manifest { 'package' => "org.inodes.gus.scummvm.plugin.$info->{name}", [ANDROID, 'versionCode'] => $package_versionCode, [ANDROID, 'versionName'] => $package_versionName, + [ANDROID, 'installLocation'] => 'preferExternal', ); $writer->startTag( |