Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merged Paul's Google Summer of Code work from SDL-gsoc2010_android

  • Loading branch information
slouken committed Aug 22, 2010
2 parents 18a406d + 7f93737 commit 9d8976e9b4d0338f3abf65a11cd0199c59eaba12
Showing with 2,743 additions and 7 deletions.
  1. +52 −0 Makefile.android
  2. +45 −0 README.android
  3. +1 −0 android/config.cfg
  4. +15 −0 android/project/AndroidManifest.xml
  5. +17 −0 android/project/build.properties
  6. +67 −0 android/project/build.xml
  7. +11 −0 android/project/default.properties
  8. +18 −0 android/project/jni/Android.mk
  9. +242 −0 android/project/jni/android-support.cpp
  10. +574 −0 android/project/jni/lesson05.c
  11. +10 −0 android/project/local.properties
  12. BIN android/project/res/drawable-hdpi/icon.png
  13. BIN android/project/res/drawable-ldpi/icon.png
  14. BIN android/project/res/drawable-mdpi/icon.png
  15. +13 −0 android/project/res/layout/main.xml
  16. +4 −0 android/project/res/values/strings.xml
  17. +388 −0 android/project/src/org/libsdl/app/SDLActivity.java
  18. +15 −0 android/scripts/acc.sh
  19. +20 −0 android/scripts/ald.sh
  20. +145 −0 include/SDL_config_android.h
  21. +5 −0 include/SDL_platform.h
  22. +6 −4 include/SDL_stdinc.h
  23. +11 −0 src/SDL_compat.c
  24. +6 −0 src/audio/SDL_audio.c
  25. +140 −0 src/audio/android/SDL_androidaudio.c
  26. +42 −0 src/audio/android/SDL_androidaudio.h
  27. +2 −0 src/events/SDL_events.c
  28. +3 −3 src/events/SDL_keyboard.c
  29. +106 −0 src/joystick/android/SDL_sysjoystick.c
  30. +3 −0 src/video/SDL_sysvideo.h
  31. +3 −0 src/video/SDL_video.c
  32. +85 −0 src/video/android/SDL_androidevents.c
  33. +29 −0 src/video/android/SDL_androidevents.h
  34. +96 −0 src/video/android/SDL_androidgl.c
  35. +344 −0 src/video/android/SDL_androidrender.c
  36. +28 −0 src/video/android/SDL_androidrender.h
  37. +166 −0 src/video/android/SDL_androidvideo.c
  38. +31 −0 src/video/android/SDL_androidvideo.h
@@ -0,0 +1,52 @@
# Makefile to build the SDL library

include ./android/config.cfg #get ANDROID_NDK

TOOLS_PATH=$(ANDROID_NDK)/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin
ANDROID_INCLUDES = -I$(ANDROID_NDK)/build/platforms/android-4/common/include \
-I$(ANDROID_NDK)/build/platforms/android-4/arch-arm/usr/include
INCLUDE = -I./include
CFLAGS = -g -O2 $(INCLUDE) $(ANDROID_INCLUDES) -DANDROID -DANDROID_NDK -static

AR = $(TOOLS_PATH)/arm-eabi-ar
RANLIB = $(TOOLS_PATH)/arm-eabi-ranlib
CC = $(TOOLS_PATH)/arm-eabi-gcc


CONFIG_H = include/SDL_config.h
TARGET = libSDL.a
SOURCES = \
src/*.c \
src/audio/*.c \
src/cpuinfo/*.c \
src/events/*.c \
src/file/*.c \
src/joystick/*.c \
src/haptic/*.c \
src/stdlib/*.c \
src/thread/*.c \
src/timer/*.c \
src/video/*.c \
src/power/*.c \
src/audio/android/*.c \
src/video/android/*.c \
src/joystick/android/*.c \
src/haptic/dummy/*.c \
src/atomic/dummy/*.c \
src/thread/pthread/*.c \
src/timer/unix/*.c \
src/loadso/dummy/*.c \

OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')

all: $(TARGET)

$(TARGET): $(CONFIG_H) $(OBJECTS)
$(AR) crv $@ $^
$(RANLIB) $@

$(CONFIG_H):
cp $(CONFIG_H).default $(CONFIG_H)

clean:
rm -f $(TARGET) $(OBJECTS)
@@ -0,0 +1,45 @@
================================================================================
Simple DirectMedia Layer for Android
================================================================================

Requirements: Android NDK r4 or later

================================================================================
How the port works
================================================================================

- Android applications are Java-based, optionally with parts written in C
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
the SDL library
- This means that your application C code must be placed inside an android
Java project, along with some C support code that communicates with Java
- This eventually produces a standard Android .apk package






================================================================================
Building an app
================================================================================

Instructions:
1. Edit android/config.cfg to point to the location of the NDK
2. Run 'make -f Makefile.android'. If all goes well, libsdl.a should be created
3. Place your application source files in android/project/jni
4. Edit the Android.mk to include your source files
5. Run 'ndk-build' (a script provided by the NDK). This compiles the C source
6. Run 'ant' in android/testproject. This compiles the .java and eventually
creates a .apk with the C source embedded
7. 'ant install' will push the apk to the device or emulator (if connected)




================================================================================
Known issues
================================================================================

- SDL audio (although it's mostly written, just not working properly yet)
- TODO. I'm sure there's a bunch more stuff I haven't thought of
@@ -0,0 +1 @@
ANDROID_NDK=/home/paul/Projects/gsoc/sdk/android-ndk-r4
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.libsdl.app"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name="SDLActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
@@ -0,0 +1,17 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.

# This file is only used by the Ant script.

# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.

# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="SDLApp" default="help">

<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked in in Version
Control Systems. -->
<property file="local.properties" />

<!-- The build.properties file can be created by you and is never touched
by the 'android' tool. This is the place to change some of the default property values
used by the Ant rules.
Here are some properties you may want to change/update:
application.package
the name of your application package as defined in the manifest. Used by the
'uninstall' rule.
source.dir
the name of the source directory. Default is 'src'.
out.dir
the name of the output directory. Default is 'bin'.
Properties related to the SDK location or the project target should be updated
using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems.
-->
<property file="build.properties" />

<!-- The default.properties file is created and updated by the 'android' tool, as well
as ADT.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems. -->
<property file="default.properties" />

<!-- Custom Android task to deal with the project target, and import the proper rules.
This requires ant 1.6.0 or above. -->
<path id="android.antlibs">
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
<pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
<pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
</path>

<taskdef name="setup"
classname="com.android.ant.SetupTask"
classpathref="android.antlibs" />

<!-- Execute the Android Setup task that will setup some properties specific to the target,
and import the build rules files.
The rules file is imported from
<SDK>/platforms/<target_platform>/templates/android_rules.xml
To customize some build steps for your project:
- copy the content of the main node <project> from android_rules.xml
- paste it in this build.xml below the <setup /> task.
- disable the import by changing the setup task below to <setup import="false" />
This will ensure that the properties are setup correctly but that your customized
build steps are used.
-->
<setup />

</project>
@@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-7
@@ -0,0 +1,18 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := sdlapp
SDL := ../../../

LOCAL_CFLAGS := -DANDROID_NDK \
-DDISABLE_IMPORTGL \
-I$(SDL)/include

LOCAL_SRC_FILES := \
android-support.cpp \
lesson05.c \

LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lSDL -lgcc -L$(SDL)

include $(BUILD_SHARED_LIBRARY)

0 comments on commit 9d8976e

Please sign in to comment.