From c28c1bf8d03a452791c0c777afe7066eb5c0da02 Mon Sep 17 00:00:00 2001 From: pelya Date: Tue, 14 Sep 2010 18:22:50 +0300 Subject: [PATCH] Added CrystaX toolchain support --- ChangeAppSettings.sh | 18 ++++++++++-------- build.sh | 2 +- project/jni/Android.mk | 7 ++++++- project/jni/application/Android.mk | 16 +++++++++++++--- project/jni/stlport/Android.mk | 10 ++++++---- project/jni/stlport/dummy.c | 1 + project/src/Globals.java | 2 +- readme.txt | 7 +++++++ 8 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 project/jni/stlport/dummy.c diff --git a/ChangeAppSettings.sh b/ChangeAppSettings.sh index 6a9ef5a02..563ca494c 100755 --- a/ChangeAppSettings.sh +++ b/ChangeAppSettings.sh @@ -358,17 +358,19 @@ mv -f project/res/values/strings.xml.1 project/res/values/strings.xml echo Forcing rebuild of specific files rm -rf project/libs/* -rm -rf project/bin/ndk/local/*/objs/sdl_main/* project/bin/ndk/local/*/libsdl_main.so -rm -rf project/bin/ndk/local/*/libsdl.so -rm -rf project/bin/ndk/local/*/objs/sdl/src/*/android -rm -rf project/bin/ndk/local/*/objs/sdl/src/video/SDL_video.o -rm -rf project/bin/ndk/local/*/objs/sdl/SDL_renderer_gles.o +for OUT in bin/ndk obj; do +rm -rf project/$OUT/local/*/objs/sdl_main/* project/$OUT/local/*/libsdl_main.so +rm -rf project/$OUT/local/*/libsdl.so +rm -rf project/$OUT/local/*/objs/sdl/src/*/android +rm -rf project/$OUT/local/*/objs/sdl/src/video/SDL_video.o +rm -rf project/$OUT/local/*/objs/sdl/SDL_renderer_gles.o if [ "$LibSdlVersionOld" '!=' "$LibSdlVersion" ]; then # Internal types are different in SDL 1.2 and 1.3, namely SDL_Rect, so all libs using it have to be recompiled - rm -rf project/bin/ndk/local/*/objs/sdl* project/bin/ndk/local/*/libsdl* - rm -rf project/bin/ndk/local/*/objs/application project/bin/ndk/local/*/libapplication.so + rm -rf project/$OUT/local/*/objs/sdl* project/$OUT/local/*/libsdl* + rm -rf project/$OUT/local/*/objs/application project/$OUT/local/*/libapplication.so fi # Do not rebuild libraries that do not need that -find project/bin/ndk/local -name "*.[oa]" -exec touch '{}' \; +find project/$OUT/local -name "*.[oa]" -exec touch '{}' \; +done echo Done diff --git a/build.sh b/build.sh index dc2d66ca7..0f67e4c6a 100755 --- a/build.sh +++ b/build.sh @@ -3,5 +3,5 @@ # Set here your own NDK path if needed # export PATH=$PATH:~/src/endless_space/android-ndk-r4 -cd project && nice -n5 ndk-build -j2 V=1 && ant debug && cd bin && adb install -r DemoActivity-debug.apk +cd project && nice -n5 ~/src/endless_space/android-ndk-r4-crystax/ndk-build -j2 V=1 && ant debug && cd bin && adb install -r DemoActivity-debug.apk diff --git a/project/jni/Android.mk b/project/jni/Android.mk index 6bd5b8fd6..90c62c592 100644 --- a/project/jni/Android.mk +++ b/project/jni/Android.mk @@ -27,7 +27,7 @@ COMPILED_LIBRARIES := APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2 -DTREMOR=1 -DBUILD_TYPE=LINUX32 -DTARGET_LNX=1 -APPLICATION_ADDITIONAL_LDFLAGS := -Lbin/ndk/local/armeabi -ltremor +APPLICATION_ADDITIONAL_LDFLAGS := -ltremor APPLICATION_SUBDIRS_BUILD := src @@ -39,4 +39,9 @@ ifneq ($(strip $(filter mad, $(COMPILED_LIBRARIES))),) SDL_MIXER_USE_LIBMAD := 1 endif +ifneq ($(findstring -crystax,$(TARGET_CC)),) +$(info Building with CrystaX toolchain - RTTI and exceptions enabled, STLPort disabled) +CRYSTAX_TOOLCHAIN=1 +endif + include $(call all-subdir-makefiles) diff --git a/project/jni/application/Android.mk b/project/jni/application/Android.mk index a2b9872c6..46ccf32b8 100644 --- a/project/jni/application/Android.mk +++ b/project/jni/application/Android.mk @@ -9,7 +9,13 @@ ifneq ($(APP_SUBDIRS_BUILD),) APP_SUBDIRS := $(APP_SUBDIRS_BUILD) endif -LOCAL_CFLAGS := $(foreach D, $(APP_SUBDIRS), -I$(LOCAL_PATH)/$(D)) \ +LOCAL_CFLAGS := + +ifeq ($(CRYSTAX_TOOLCHAIN),) +LOCAL_CFLAGS += -I$(LOCAL_PATH)/../stlport/stlport +endif + +LOCAL_CFLAGS += $(foreach D, $(APP_SUBDIRS), -I$(LOCAL_PATH)/$(D)) \ -I$(LOCAL_PATH)/../sdl/include \ -I$(LOCAL_PATH)/../sdl_mixer \ -I$(LOCAL_PATH)/../sdl_image \ @@ -17,14 +23,12 @@ LOCAL_CFLAGS := $(foreach D, $(APP_SUBDIRS), -I$(LOCAL_PATH)/$(D)) \ -I$(LOCAL_PATH)/../sdl_net \ -I$(LOCAL_PATH)/../sdl_blitpool \ -I$(LOCAL_PATH)/../sdl_gfx \ - -I$(LOCAL_PATH)/../stlport/stlport \ -I$(LOCAL_PATH)/../png \ -I$(LOCAL_PATH)/../jpeg \ -I$(LOCAL_PATH)/../intl \ -I$(LOCAL_PATH)/../freetype/include \ -I$(LOCAL_PATH)/.. - LOCAL_CFLAGS += $(APPLICATION_ADDITIONAL_CFLAGS) #Change C++ file extension as appropriate @@ -40,6 +44,12 @@ LOCAL_STATIC_LIBRARIES := stlport LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz +ifeq ($(CRYSTAX_TOOLCHAIN),) +LOCAL_LDFLAGS := -Lbin/ndk/local/armeabi +else +LOCAL_LDFLAGS := -Lobj/local/armeabi +endif + LOCAL_LDFLAGS += $(APPLICATION_ADDITIONAL_LDFLAGS) LIBS_WITH_LONG_SYMBOLS := $(strip $(shell \ diff --git a/project/jni/stlport/Android.mk b/project/jni/stlport/Android.mk index 00340f9bd..538dc3263 100644 --- a/project/jni/stlport/Android.mk +++ b/project/jni/stlport/Android.mk @@ -4,11 +4,13 @@ include $(CLEAR_VARS) LOCAL_MODULE := stlport -LOCAL_CFLAGS := -I$(LOCAL_PATH)/stlport -I$(LOCAL_PATH)/src - +ifneq ($(CRYSTAX_TOOLCHAIN),) +LOCAL_CPP_EXTENSION := .cpp +LOCAL_SRC_FILES := dummy.c +else +LOCAL_CFLAGS := -I$(LOCAL_PATH)/stlport -I$(LOCAL_PATH)/src LOCAL_CPP_EXTENSION := .cpp - LOCAL_SRC_FILES := $(addprefix src/,$(notdir $(wildcard $(LOCAL_PATH)/src/*.cpp $(LOCAL_PATH)/src/*.c)))) +endif include $(BUILD_STATIC_LIBRARY) - diff --git a/project/jni/stlport/dummy.c b/project/jni/stlport/dummy.c new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/project/jni/stlport/dummy.c @@ -0,0 +1 @@ + diff --git a/project/src/Globals.java b/project/src/Globals.java index e13e82248..f4861b6dd 100644 --- a/project/src/Globals.java +++ b/project/src/Globals.java @@ -8,7 +8,7 @@ class Globals { public static String ApplicationName = "CommanderGenius"; // Should be zip file - public static String DataDownloadUrl = "Data files size is 1 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download"; + public static String DataDownloadUrl = "Data files size is 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download"; // Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D public static boolean NeedDepthBuffer = false; diff --git a/readme.txt b/readme.txt index 08855d4dd..960307cbf 100644 --- a/readme.txt +++ b/readme.txt @@ -85,6 +85,12 @@ The C++ files shall have .cpp extension to be compiled, rename them if necessary Also you can replace icon image at project/res/drawable/icon.png. Then you can launch build.sh. +The NDK has RTTI and exceptions disabled for C++ code, if you need them you may download modified NDK from +http://www.crystax.net/android/ndk-r4.php +Unzip it, and put in your PATH instead of original NDK - do not rename the target dir, my makefiles will +check if there's "crystax" string in path to gcc toolchain, and will disable STLPort because CrystaX's +NDK already contains STL library. + Application data is not bundled with app itself - it should be downloaded from net on first run. Create .ZIP file with your application data, and put it somewhere on HTTP server - ChangeAppSettings.sh will ask you for the URL. @@ -184,6 +190,7 @@ UQM gives 5 FPS without such hacks, if I'll implement that FPS will drop to 1-2 plus VideoView will contain some buffer to ensure the playback is smooth, so the data on your TV will lag halfsecond behind the data on the device screen. +7. Make app data to come inside .apk file in assets instead of downloading it from net. Games to port =============