From 565f159a20fb09feffda3d2c468173b42552e040 Mon Sep 17 00:00:00 2001 From: pelya Date: Tue, 21 Dec 2010 11:18:33 +0000 Subject: [PATCH] Revert "Revert "Disabled STLPort built into NDK in favor of my own STLPort, disabled cin/cout/cerr in my STLPort"" STLPort inside NDK R5 crashes when accessing stdout the smae way as mine built-in STLPort, but I have the possibility to change my own STLPort sources This reverts commit 4a02eeededd4532d0d15ceb44ed964c505ea542d. --- ChangeAppSettings.sh | 2 +- project/jni/Android.mk | 2 +- project/jni/Application.mk | 2 +- project/jni/application/Android.mk | 10 +- .../fheroes2/fheroes2-no-cout.diff | 664 ++++++++++++++++++ project/jni/stlport/Android.mk | 13 +- project/jni/stlport/src/iostream.cpp | 34 +- project/jni/stlport/src/num_get_float.cpp | 4 +- project/jni/stlport/src/time_facets.cpp | 2 +- project/jni/stlport/stlport/stl/_exception.h | 4 + .../jni/stlport/stlport/stl/config/_android.h | 13 +- .../jni/stlport/stlport/stl/config/_system.h | 8 +- readme.txt | 6 +- 13 files changed, 717 insertions(+), 47 deletions(-) create mode 100644 project/jni/application/fheroes2/fheroes2-no-cout.diff diff --git a/ChangeAppSettings.sh b/ChangeAppSettings.sh index 8c39b5585..3517cf7b7 100755 --- a/ChangeAppSettings.sh +++ b/ChangeAppSettings.sh @@ -523,7 +523,7 @@ cat project/src/Globals.java | \ sed "s/public static int AppTouchscreenKeyboardKeysAmountAutoFire = .*;/public static int AppTouchscreenKeyboardKeysAmountAutoFire = $AppTouchscreenKeyboardKeysAmountAutoFire;/" | \ sed "s%public static String ReadmeText = .*%public static String ReadmeText = \"$ReadmeText\".replace(\"^\",\"\\\n\");%" | \ sed "s%public static String CommandLine = .*%public static String CommandLine = \"$AppCmdline\";%" | \ - sed "s/public LoadLibrary() .*/public LoadLibrary() { System.loadLibrary(\"stlport_shared\"); $LibrariesToLoad };/" > \ + sed "s/public LoadLibrary() .*/public LoadLibrary() { $LibrariesToLoad };/" > \ project/src/Globals.java.1 mv -f project/src/Globals.java.1 project/src/Globals.java diff --git a/project/jni/Android.mk b/project/jni/Android.mk index 3296cb34f..a3ff9b0f8 100644 --- a/project/jni/Android.mk +++ b/project/jni/Android.mk @@ -9,7 +9,7 @@ $(info Building with CrystaX toolchain - RTTI and exceptions enabled, STLPort di CRYSTAX_TOOLCHAIN = 1 endif ifneq ($(findstring android-ndk-r5,$(TARGET_CC)),) -$(info Building with NDK r5 - internal STLPort disabled) +$(info Building with NDK r5) NDK_R5_TOOLCHAIN = 1 endif diff --git a/project/jni/Application.mk b/project/jni/Application.mk index 95fdda33c..d688e82c3 100644 --- a/project/jni/Application.mk +++ b/project/jni/Application.mk @@ -1,6 +1,6 @@ APP_PROJECT_PATH := $(call my-dir)/.. -APP_STL := stlport_shared +APP_STL := system include jni/Settings.mk diff --git a/project/jni/application/Android.mk b/project/jni/application/Android.mk index eae8ac7fb..6fe2adb10 100644 --- a/project/jni/application/Android.mk +++ b/project/jni/application/Android.mk @@ -16,7 +16,7 @@ endif LOCAL_CFLAGS := -ifeq ($(CRYSTAX_TOOLCHAIN)$(NDK_R5_TOOLCHAIN),) +ifeq ($(CRYSTAX_TOOLCHAIN),) LOCAL_CFLAGS += -I$(LOCAL_PATH)/../stlport/stlport endif @@ -40,11 +40,7 @@ LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION) $(filter-out $(APP_AVAILABLE_STATIC LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES)) -ifneq ($(NDK_R5_TOOLCHAIN),) LOCAL_STATIC_LIBRARIES += stlport -else -LOCAL_SHARED_LIBRARIES += stlport_shared -endif LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz ifneq ($(NDK_R5_TOOLCHAIN),) @@ -54,8 +50,6 @@ LOCAL_LDFLAGS := -Lobj/local/armeabi LOCAL_LDFLAGS += $(APPLICATION_ADDITIONAL_LDFLAGS) -ifneq (,) - LIBS_WITH_LONG_SYMBOLS := $(strip $(shell \ for f in $(LOCAL_PATH)/../../obj/local/armeabi/*.so ; do \ if echo $$f | grep "libapplication[.]so" > /dev/null ; then \ @@ -79,8 +73,6 @@ please make this library static to avoid problems. ) ) $(error Detected libraries with too long symbol names. Remove all files under project/obj/local/armeabi, make these libs static, and recompile) endif -endif - APP_LIB_DEPENDS := $(foreach LIB, $(LOCAL_SHARED_LIBRARIES), $(abspath $(LOCAL_PATH)/../../obj/local/armeabi/lib$(LIB).so)) APP_LIB_DEPENDS += $(foreach LIB, $(LOCAL_STATIC_LIBRARIES), $(abspath $(LOCAL_PATH)/../../obj/local/armeabi/lib$(LIB).a)) diff --git a/project/jni/application/fheroes2/fheroes2-no-cout.diff b/project/jni/application/fheroes2/fheroes2-no-cout.diff new file mode 100644 index 000000000..7fadce281 --- /dev/null +++ b/project/jni/application/fheroes2/fheroes2-no-cout.diff @@ -0,0 +1,664 @@ +Index: src/engine/midi_mthd.cpp +=================================================================== +--- src/engine/midi_mthd.cpp (revision 2146) ++++ src/engine/midi_mthd.cpp (working copy) +@@ -27,7 +27,9 @@ + + void MThd::Dump(void) const + { ++#ifndef ANDROID + std::cerr << "[MThd] format: " << Format() << ", tracks: " << Tracks() << ", ppqn: " << PPQN() << std::endl; ++#endif + } + + void MThd::SetFormat(const u16 f) +Index: src/engine/audio.cpp +=================================================================== +--- src/engine/audio.cpp (revision 2146) ++++ src/engine/audio.cpp (working copy) +@@ -68,15 +68,19 @@ + { + if(1 == SDL_BuildAudioCVT(this, src.format, src.channels, src.freq, dst.format, dst.channels, dst.freq)) return true; + ++#ifndef ANDROID + std::cerr << "Audio::CVT::Build: " << SDL_GetError() << std::endl; ++#endif + return false; + } + + bool Audio::CVT::Convert(void) + { + if(0 == SDL_ConvertAudio(this)) return true; +- ++ ++#ifndef ANDROID + std::cerr << "Audio::CVT::Convert: " << SDL_GetError() << std::endl; ++#endif + return false; + } + +Index: src/engine/thread.cpp +=================================================================== +--- src/engine/thread.cpp (revision 2146) ++++ src/engine/thread.cpp (working copy) +@@ -128,5 +128,7 @@ + + void Time::Print(const char* header) const + { ++#ifndef ANDROID + std::cerr << (header ? header : "time: ") << Get() << " ms" << std::endl; ++#endif + } +Index: src/engine/midi_chunk.cpp +=================================================================== +--- src/engine/midi_chunk.cpp (revision 2146) ++++ src/engine/midi_chunk.cpp (working copy) +@@ -183,6 +183,7 @@ + + void Chunk::Dump(void) const + { ++#ifndef ANDROID + std::cerr << "id: "; + std::cerr.write(id, 4); + std::cerr << std::endl << "size: " << std::dec << size << std::endl << "data: " << std::endl; +@@ -200,4 +201,5 @@ + } + } + std::cerr << std::endl; ++#endif + } +Index: src/engine/midi_mid.cpp +=================================================================== +--- src/engine/midi_mid.cpp (revision 2146) ++++ src/engine/midi_mid.cpp (working copy) +@@ -77,8 +77,9 @@ + + if(! mthd.isValid()) + { ++#ifndef ANDROID + std::cerr << "Mid::Read: " << "error format" << std::endl; +- ++#endif + return false; + } + +@@ -89,8 +90,9 @@ + { + if(ptr >= &body[0] + body.size()) + { ++#ifndef ANDROID + std::cerr << "Mid::Read: " << "error read chunk, total: " << count << ", current: " << ii << std::endl; +- ++#endif + return false; + } + +@@ -111,8 +113,9 @@ + + if(!fd.is_open()) + { ++#ifndef ANDROID + std::cerr << "Mid::Read: " << "error read: " << filename << std::endl; +- ++#endif + return false; + } + +@@ -120,8 +123,9 @@ + + if(! mthd.isValid()) + { ++#ifndef ANDROID + std::cerr << "Mid::Read: " << "error format: " << filename << std::endl; +- ++#endif + return false; + } + +@@ -131,8 +135,9 @@ + { + if(fd.fail()) + { ++#ifndef ANDROID + std::cerr << "Mid::Read: " << "error read chunk, total: " << count << ", current: " << ii << std::endl; +- ++#endif + return false; + } + +@@ -187,8 +192,9 @@ + + if(!fd.is_open()) + { ++#ifndef ANDROID + std::cerr << "Mid::Write: " << "error write: " << filename << std::endl; +- ++#endif + return false; + } + +Index: src/engine/midi_mtrk.cpp +=================================================================== +--- src/engine/midi_mtrk.cpp (revision 2146) ++++ src/engine/midi_mtrk.cpp (working copy) +@@ -102,7 +102,9 @@ + default: + end = true; + CloseEvents(); ++#ifndef ANDROID + std::cerr << "unknown st: 0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast(status) << ", ln: " << static_cast(p + s - ptr) << std::endl; ++#endif + break; + } + } +@@ -202,8 +204,8 @@ + + void MTrk::Dump(void) const + { ++#ifndef ANDROID + std::cerr << "[MTrk]\n"; +- + if(events.size()) + { + std::list::const_iterator it1 = events.begin(); +@@ -211,6 +213,7 @@ + for(; it1 != it2; ++it1) if(*it1) (*it1)->Dump(); + } + std::cerr << std::endl; ++#endif + } + + void MTrk::ImportXmiEVNT(const Chunk & evnt) +@@ -345,7 +348,9 @@ + // unused command + default: + CloseEvents(); ++#ifndef ANDROID + std::cerr << "unknown st: 0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast(*ptr) << ", ln: " << static_cast(evnt.data + evnt.size - ptr) << std::endl; ++#endif + break; + } + } +Index: src/engine/midi_event.cpp +=================================================================== +--- src/engine/midi_event.cpp (revision 2146) ++++ src/engine/midi_event.cpp (working copy) +@@ -125,6 +125,7 @@ + + void Event::Dump(void) const + { ++#ifndef ANDROID + std::cerr << std::hex << std::setfill('0') \ + << "[dl:0x" << std::setw(4) << delta \ + << ":st:0x" << std::setw(2) << static_cast(static_cast(status)) << ":dt"; +@@ -143,4 +144,5 @@ + } + + std::cerr << "]" << std::endl; ++#endif + } +Index: src/engine/rand.cpp +=================================================================== +--- src/engine/rand.cpp (revision 2146) ++++ src/engine/rand.cpp (working copy) +@@ -80,6 +80,8 @@ + if(rand <= amount) return (*it).first; + } + ++#ifndef ANDROID + std::cerr << "Rand::Queue::Get:" << " weight not found, return 0" << std::endl; ++#endif + return 0; + } +Index: src/engine/surface.cpp +=================================================================== +--- src/engine/surface.cpp (revision 2146) ++++ src/engine/surface.cpp (working copy) +@@ -135,7 +135,9 @@ + if(bs.surface) + { + surface = SDL_ConvertSurface(bs.surface, bs.surface->format, bs.surface->flags); ++#ifndef ANDROID + if(!surface) std::cerr << "Surface: copy constructor, error: " << SDL_GetError() << std::endl; ++#endif + } + } + +@@ -303,7 +305,9 @@ + + if(!surface) + { ++#ifndef ANDROID + std::cerr << "w: " << sw << ", h: " << sh << std::endl; ++#endif + Error::Except("Surface::CreateSurface: empty surface, error:", SDL_GetError()); + } + } +@@ -797,13 +801,17 @@ + // valid sf_src + if(!sf_src.surface || sf_src.w() != sf_src.h()) + { ++#ifndef ANDROID + std::cerr << "Surface::TILReflect: " << "incorrect size" << std::endl; ++#endif + return; + } + + if(sf_src.depth() != 8) + { ++#ifndef ANDROID + std::cerr << "Surface::TILReflect: " << "incorrect depth, use only 8 bpp" << std::endl; ++#endif + return; + } + +@@ -905,14 +913,26 @@ + /* scale surface */ + void Surface::ScaleMinifyByTwo(Surface & sf_dst, const Surface & sf_src, bool event) + { +- if(!sf_src.isValid()) { std::cerr << "Surface::ScaleMinifyByTwo: " << "invalid surface" << std::endl; return; }; ++ if(!sf_src.isValid()) ++ { ++#ifndef ANDROID ++ std::cerr << "Surface::ScaleMinifyByTwo: " << "invalid surface" << std::endl; ++#endif ++ return; ++ }; + u16 x, y, x2, y2; + + u8 mul = 2; + u16 w = sf_src.w() / mul; + u16 h = sf_src.h() / mul; + +- if(2 > w || 2 > h){ std::cerr << "Surface::ScaleMinifyByTwo: " << "small size" << std::endl; return; }; ++ if(2 > w || 2 > h) ++ { ++#ifndef ANDROID ++ std::cerr << "Surface::ScaleMinifyByTwo: " << "small size" << std::endl; ++#endif ++ return; ++ }; + + sf_dst.Set(w, h, sf_src.depth(), SWSURFACE); + sf_dst.SetColorKey(); +Index: src/engine/midi_xmi.cpp +=================================================================== +--- src/engine/midi_xmi.cpp (revision 2146) ++++ src/engine/midi_xmi.cpp (working copy) +@@ -42,7 +42,9 @@ + { + if(0 == body.size()) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "incorrect size" << std::endl; ++#endif + return false; + } + +@@ -50,7 +52,9 @@ + + if(memcmp(ID_FORM, ptr, 4)) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "incorrect id: " << ID_FORM << std::endl; ++#endif + return false; + } + +@@ -59,7 +63,9 @@ + + if(memcmp(ID_CAT, ptr, 4)) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "incorrect id: " << ID_CAT<< std::endl; ++#endif + return false; + } + +@@ -67,7 +73,9 @@ + + if(memcmp(ID_XMID, ptr, 4)) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "incorrect cat id: " << ID_XMID << std::endl; ++#endif + return false; + } + +@@ -75,7 +83,9 @@ + + if(memcmp(ID_FORM, ptr, 4)) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "incorrect xmid id: " << ID_FORM << std::endl; ++#endif + return false; + } + else +@@ -83,7 +93,9 @@ + + if(memcmp(ID_XMID, ptr, 4)) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "incorrect form id: " << ID_XMID << std::endl; ++#endif + return false; + } + +@@ -91,7 +103,9 @@ + + if(memcmp(ID_TIMB, ptr, 4)) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "incorrect id: " << ID_TIMB << std::endl; ++#endif + return false; + } + +@@ -100,7 +114,9 @@ + + if(memcmp(ID_EVNT, ptr, 4)) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "incorrect id: " << ID_EVNT << std::endl; ++#endif + return false; + } + +@@ -115,7 +131,9 @@ + + if(!fd.is_open()) + { ++#ifndef ANDROID + std::cerr << "Xmi: " << "error read: " << filename.c_str() << std::endl; ++#endif + return false; + } + +Index: src/engine/audio_music.cpp +=================================================================== +--- src/engine/audio_music.cpp (revision 2146) ++++ src/engine/audio_music.cpp (working copy) +@@ -41,12 +41,20 @@ + if(fadein) + { + if(music && Mix_FadeInMusic(music, loop ? -1 : 0, fadein) == -1) ++ { ++#ifndef ANDROID + std::cerr << "Music::Play: " << Mix_GetError() << std::endl; ++#endif ++ } + } + else + { + if(music && Mix_PlayMusic(music, loop ? -1 : 0) == -1) ++ { ++#ifndef ANDROID + std::cerr << "Music::Play: " << Mix_GetError() << std::endl; ++#endif ++ } + } + } + +@@ -73,7 +81,11 @@ + music = Mix_LoadMUS(file); + + if(! music) ++ { ++#ifndef ANDROID + std::cerr << "Music::Play: " << Mix_GetError() << std::endl; ++#endif ++ } + else + Music::Play(loop); + } +Index: src/engine/audio_mixer.cpp +=================================================================== +--- src/engine/audio_mixer.cpp (revision 2146) ++++ src/engine/audio_mixer.cpp (working copy) +@@ -61,7 +61,9 @@ + + if(0 != Mix_OpenAudio(hardware.freq, hardware.format, hardware.channels, hardware.samples)) + { ++#ifndef ANDROID + std::cerr << "Mixer: " << SDL_GetError() << std::endl; ++#endif + valid = false; + } + else +@@ -75,7 +77,9 @@ + } + else + { ++#ifndef ANDROID + std::cerr << "Mixer: audio subsystem not initialize" << std::endl; ++#endif + valid = false; + } + } +@@ -104,21 +108,27 @@ + Mixer::chunk_t* Mixer::LoadWAV(const char* file) + { + Mix_Chunk *sample = Mix_LoadWAV(file); ++#ifndef ANDROID + if(!sample) std::cerr << "Mixer::LoadWAV: " << Mix_GetError() << std::endl; ++#endif + return sample; + } + + Mixer::chunk_t* Mixer::LoadWAV(const u8* ptr, u32 size) + { + Mix_Chunk *sample = Mix_LoadWAV_RW(SDL_RWFromConstMem(ptr, size), 1); ++#ifndef ANDROID + if(!sample) std::cerr << "Mixer::LoadWAV: "<< Mix_GetError() << std::endl; ++#endif + return sample; + } + + int Mixer::Play(chunk_t* sample, int channel, bool loop) + { + int res = Mix_PlayChannel(channel, sample, loop ? -1 : 0); ++#ifndef ANDROID + if(res == -1) std::cerr << "Mixer::Play: " << Mix_GetError() << std::endl;; ++#endif + return res; + } + +@@ -302,7 +312,9 @@ + + if(0 > SDL_OpenAudio(&spec, &Audio::GetHardwareSpec())) + { ++#ifndef ANDROID + std::cerr << "Mixer::Init: " << SDL_GetError() << std::endl; ++#endif + valid = false; + } + else +@@ -314,7 +326,9 @@ + } + else + { ++#ifndef ANDROID + std::cerr << "Mixer::Init: audio subsystem not initialize" << std::endl; ++#endif + valid = false; + } + } +@@ -388,7 +402,9 @@ + it = std::find_if(chunks.begin() + reserved_channels, chunks.end(), PredicateIsFreeSound); + if(it == chunks.end()) + { ++#ifndef ANDROID + std::cerr << "Mixer::PlayRAW: mixer is full" << std::endl; ++#endif + return -1; + } + } +Index: src/engine/display.cpp +=================================================================== +--- src/engine/display.cpp (revision 2146) ++++ src/engine/display.cpp (working copy) +@@ -346,7 +346,9 @@ + + if(modes == (SDL_Rect **) 0) + { ++#ifndef ANDROID + std::cerr << "Display::GetMaxMode: " << "no modes available" << std::endl; ++#endif + return 0; + } + else +Index: src/engine/engine.cpp +=================================================================== +--- src/engine/engine.cpp (revision 2146) ++++ src/engine/engine.cpp (working copy) +@@ -59,7 +59,9 @@ + + if(0 > SDL_Init(system)) + { ++#ifndef ANDROID + std::cerr << "SDL::Init: error: " << SDL_GetError() << std::endl; ++#endif + return false; + } + +Index: src/engine/font.cpp +=================================================================== +--- src/engine/font.cpp (revision 2146) ++++ src/engine/font.cpp (working copy) +@@ -41,7 +41,12 @@ + + void SDL::Font::Init(void) + { +- if(0 != TTF_Init()) std::cerr << "Font::Init: error" << std::endl; ++ if(0 != TTF_Init()) ++ { ++#ifndef ANDROID ++ std::cerr << "Font::Init: error" << std::endl; ++#endif ++ } + else init = true; + } + +@@ -64,7 +69,9 @@ + + fnt = TTF_OpenFont(filename.c_str(), size); + ++#ifndef ANDROID + if(!fnt) std::cerr << "Font::Open: error open: " << filename << std::endl; ++#endif + } + return fnt; + } +Index: src/engine/midi.cpp +=================================================================== +--- src/engine/midi.cpp (revision 2146) ++++ src/engine/midi.cpp (working copy) +@@ -32,7 +32,9 @@ + { + if(4 <= p2 - p) + { ++#ifndef ANDROID + std::cerr << "Event: unpack delta mistake" << std::endl; ++#endif + break; + } + +Index: src/engine/zzlib.cpp +=================================================================== +--- src/engine/zzlib.cpp (revision 2146) ++++ src/engine/zzlib.cpp (working copy) +@@ -40,9 +40,21 @@ + switch(res) + { + case Z_OK: return true; +- case Z_MEM_ERROR: if(debug) std::cerr << "ZLib::UnCompress: " << "Z_MEM_ERROR" << std::endl; return false; +- case Z_BUF_ERROR: if(debug) std::cerr << "ZLib::UnCompress: " << "Z_BUF_ERROR" << std::endl; return false; +- case Z_DATA_ERROR:if(debug) std::cerr << "ZLib::UnCompress: " << "Z_DATA_ERROR"<< std::endl; return false; ++ case Z_MEM_ERROR: ++#ifndef ANDROID ++ if(debug) std::cerr << "ZLib::UnCompress: " << "Z_MEM_ERROR" << std::endl; ++#endif ++ return false; ++ case Z_BUF_ERROR: ++#ifndef ANDROID ++ if(debug) std::cerr << "ZLib::UnCompress: " << "Z_BUF_ERROR" << std::endl; ++#endif ++ return false; ++ case Z_DATA_ERROR: ++#ifndef ANDROID ++ if(debug) std::cerr << "ZLib::UnCompress: " << "Z_DATA_ERROR"<< std::endl; ++#endif ++ return false; + default: break; + } + +Index: src/fheroes2/system/settings.cpp +=================================================================== +--- src/fheroes2/system/settings.cpp (revision 2146) ++++ src/fheroes2/system/settings.cpp (working copy) +@@ -499,6 +499,13 @@ + return true; + } + ++void Settings::Dump() const ++{ ++ std::ostringstream dumped; ++ Dump(dumped); ++ VERBOSE(dumped); ++}; ++ + void Settings::Dump(std::ostream & stream) const + { + std::string str; +Index: src/fheroes2/system/settings.h +=================================================================== +--- src/fheroes2/system/settings.h (revision 2146) ++++ src/fheroes2/system/settings.h (working copy) +@@ -78,7 +78,7 @@ + #define VERBOSE(x) + #define VERBOSN(x) + #define DEBUG(x, y, z) +-#elif defined(ANDROID) ++#elif defined(ANDROID) || defined(__ANDROID__) + #define VERBOSE(x) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); } + #define VERBOSN(x) { std::ostringstream osss; osss << x; __android_log_print(ANDROID_LOG_INFO, "FHeroes", "%s", osss.str().c_str()); } + #define DEBUG(x, y, z) if(IS_DEBUG((x), (y))) VERBOSE(z) +@@ -156,7 +156,8 @@ + bool Read(const std::string & filename); + bool Save(const std::string & filename) const; + +- void Dump(std::ostream & stream = std::cout) const; ++ void Dump(std::ostream & stream) const; ++ void Dump() const; + bool LoadFileMapsMP2(const std::string & file); + Maps::FileInfo & CurrentFileInfo(void); + +Index: src/fheroes2/maps/pairs.h +=================================================================== +--- src/fheroes2/maps/pairs.h (revision 2146) ++++ src/fheroes2/maps/pairs.h (working copy) +@@ -23,8 +23,8 @@ + #ifndef H2PAIRS_H + #define H2PAIRS_H + ++#include // Broken STLPort implementaion on Android requires this file to be included first + #include +-#include + #include "maps_tiles.h" + + class IndexDistance : public std::pair +Index: src/fheroes2/army/army.cpp +=================================================================== +--- src/fheroes2/army/army.cpp (revision 2146) ++++ src/fheroes2/army/army.cpp (working copy) +@@ -967,7 +967,9 @@ + void Army::army_t::Dump(const char* prefix) const + { + if(prefix) ++ { + VERBOSN(prefix); ++ } + else + { + VERBOSN("Army::Dump: " << diff --git a/project/jni/stlport/Android.mk b/project/jni/stlport/Android.mk index e26553ffe..915f1db37 100644 --- a/project/jni/stlport/Android.mk +++ b/project/jni/stlport/Android.mk @@ -4,22 +4,13 @@ include $(CLEAR_VARS) LOCAL_MODULE := stlport -ifneq ($(CRYSTAX_TOOLCHAIN)$(NDK_R5_TOOLCHAIN),) +ifneq ($(CRYSTAX_TOOLCHAIN),) LOCAL_CPP_EXTENSION := .cpp LOCAL_SRC_FILES := dummy.c else -LOCAL_CFLAGS := -O3 -I$(LOCAL_PATH)/stlport -I$(LOCAL_PATH)/src +LOCAL_CFLAGS := -O3 -I$(LOCAL_PATH)/stlport -I$(LOCAL_PATH)/src -DANDROID_NO_COUT=1 LOCAL_CPP_EXTENSION := .cpp LOCAL_SRC_FILES := $(addprefix src/,$(notdir $(wildcard $(LOCAL_PATH)/src/*.cpp $(LOCAL_PATH)/src/*.c))) endif include $(BUILD_STATIC_LIBRARY) - -ifeq ($(NDK_R5_TOOLCHAIN),) -# Dummy stlport_shared to use the same Java code for all NDKs -include $(CLEAR_VARS) -LOCAL_MODULE := stlport_shared -LOCAL_CPP_EXTENSION := .cpp -LOCAL_SRC_FILES := dummy.c -include $(BUILD_SHARED_LIBRARY) -endif diff --git a/project/jni/stlport/src/iostream.cpp b/project/jni/stlport/src/iostream.cpp index a38fa3444..f32b368a5 100644 --- a/project/jni/stlport/src/iostream.cpp +++ b/project/jni/stlport/src/iostream.cpp @@ -16,13 +16,6 @@ * */ -/* Outputting anything to cout/cerr WILL CRASH YOUR PROGRAM on specific devices - - x5a/x6d Android 2.1 tablet, and some other tablets, - however the same code runs on my HTC Evo without problem. - So I've just disabled them altogether. -*/ -#ifndef ANDROID - #include "stlport_prefix.h" #include @@ -63,6 +56,29 @@ using _STLP_VENDOR_CSTD::_streams; // (3) Create streambufs for the global stream objects, and initialize // the stream objects by calling the init() member function. +#if defined (ANDROID_NO_COUT) +/* Outputting anything to cout/cerr WILL CRASH YOUR PROGRAM on specific devices - + x5a/x6d Android 2.1 tablet, and some other tablets, + however the same code runs on my HTC Evo without problem. + So I've just disabled cin/cout/cerr altogether. +*/ + +long ios_base::Init::_S_count = 0; + +ios_base::Init::Init() { + if (_S_count++ == 0) { + _Locale_init(); + _Filebuf_base::_S_initialize(); + } +} + +ios_base::Init::~Init() { + if (--_S_count == 0) { + _Locale_final(); + } +} + +#else #if defined (_STLP_USE_NOT_INIT_SEGMENT) @@ -400,10 +416,10 @@ bool _STLP_CALL ios_base::sync_with_stdio(bool sync) { return was_synced; } -_STLP_END_NAMESPACE - #endif /* ANDROID */ +_STLP_END_NAMESPACE + // Local Variables: // mode:C++ // End: diff --git a/project/jni/stlport/src/num_get_float.cpp b/project/jni/stlport/src/num_get_float.cpp index 3dd85eee3..f3e987263 100644 --- a/project/jni/stlport/src/num_get_float.cpp +++ b/project/jni/stlport/src/num_get_float.cpp @@ -27,7 +27,7 @@ # include #endif -#if defined (__linux__) +#if defined (__linux__) && !defined(__ANDROID__) # include union _ll { @@ -413,7 +413,7 @@ static inline double _Stl_atod(char *buffer, int ndigit, int dexp) { #else /* IEEE representation */ -# if !defined (__linux__) +# if !defined (__linux__) || defined(__ANDROID__) static double _Stl_atod(char *buffer, int ndigit, int dexp) { uint64 value; /* Value develops as follows: * 1) decimal digits as an integer diff --git a/project/jni/stlport/src/time_facets.cpp b/project/jni/stlport/src/time_facets.cpp index 24a573f07..0f04f4bd0 100644 --- a/project/jni/stlport/src/time_facets.cpp +++ b/project/jni/stlport/src/time_facets.cpp @@ -373,7 +373,7 @@ char * _STLP_CALL __write_formatted_time(char* buf, size_t buf_size, char format break; { int diff; -# if defined (__USE_BSD) || defined (__BEOS__) +# if defined (__USE_BSD) || defined (__BEOS__) || defined(__ANDROID__) diff = t->tm_gmtoff; # else diff = t->__tm_gmtoff; diff --git a/project/jni/stlport/stlport/stl/_exception.h b/project/jni/stlport/stlport/stl/_exception.h index f1fdc4c77..f487c4c48 100644 --- a/project/jni/stlport/stlport/stl/_exception.h +++ b/project/jni/stlport/stlport/stl/_exception.h @@ -28,6 +28,10 @@ #ifndef _STLP_INTERNAL_EXCEPTION #define _STLP_INTERNAL_EXCEPTION +#if defined(ANDROID) || defined(__ANDROID__) +# define _STLP_NO_EXCEPTION_HEADER 1 +#endif + #if !defined (_STLP_NO_EXCEPTION_HEADER) # if defined ( _UNCAUGHT_EXCEPTION ) diff --git a/project/jni/stlport/stlport/stl/config/_android.h b/project/jni/stlport/stlport/stl/config/_android.h index 4597c083f..81a4db932 100644 --- a/project/jni/stlport/stlport/stl/config/_android.h +++ b/project/jni/stlport/stlport/stl/config/_android.h @@ -53,6 +53,8 @@ // thrown in any case) #define _STLP_NEW_DONT_THROW_BAD_ALLOC 1 +#define _STLP_NO_LONG_DOUBLE 1 + // Use __new_alloc instead of __node_alloc, so we don't need static functions. //#define _STLP_USE_SIMPLE_NODE_ALLOC 1 @@ -65,17 +67,16 @@ #define _STLP_NO_VENDOR_MATH_L 1 // Define how to include our native headers. -#define _STLP_NATIVE_HEADER(header) <../../usr/include/header> -#define _STLP_NATIVE_C_HEADER(header) <../include/header> -#define _STLP_NATIVE_CPP_C_HEADER(header) <../../usr/include/header> -#define _STLP_NATIVE_OLD_STREAMS_HEADER(header) <../../usr/include/header> -#define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../../usr/include/header> +#if defined(__ANDROID__) /* NDK r5 */ +# define _STLP_NATIVE_CPP_C_INCLUDE_PATH ../../../cxx-stl/system/include +# define _STLP_NATIVE_CPP_RUNTIME_INCLUDE_PATH ../../../cxx-stl/system/include +#endif #ifdef __cplusplus // Hack to prevent including buggy stl_pair.h system header, introduced in Android 1.6 NDK #define _CPP_UTILITY 1 #define __SGI_STL_INTERNAL_PAIR_H 1 -#include +//#include //inline void* operator new(size_t, void* p) { return p; } //inline void* operator new[](size_t, void* p) { return p; } #endif diff --git a/project/jni/stlport/stlport/stl/config/_system.h b/project/jni/stlport/stlport/stl/config/_system.h index 9929aecde..93b8135b8 100644 --- a/project/jni/stlport/stlport/stl/config/_system.h +++ b/project/jni/stlport/stlport/stl/config/_system.h @@ -66,6 +66,10 @@ # elif defined (__HP_aCC) # include # endif +#elif defined (ANDROID) || defined (__ANDROID__) + /* Android mobile phone platform. Somewhat but not entirely GNU/Linux-like */ +# include +# include #elif defined (linux) || defined (__linux__) # include /* Intel's icc define __GNUC__! */ @@ -173,10 +177,6 @@ # endif # include -#elif defined (ANDROID) - /* Android mobile phone platform. Somewhat but not entirely GNU/Linux-like */ -# include -# include #else # error Unknown platform !! #endif diff --git a/readme.txt b/readme.txt index 762ced523..287061a6d 100644 --- a/readme.txt +++ b/readme.txt @@ -119,8 +119,10 @@ http://www.crystax.net/android/ndk-r4.php - note however that you cannot throw e 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 NDK already contains STL library. -One bug is reported with CrystaX NDK - the app crashes when trying to output to std::cout stream on SmartQ V7 device - -probably some exported symbol is duplicated in system libraries and the CrystaX STL lib. +Additionally, the NDK r5 now contains full support for RTTI/exceptions, however I did not check it yet. +There is one bug with STLPort - the app crashes when trying to output to std::cout stream +on SmartQ V7 device, and on x5a/x6d Android 2.1 tablet, so i've disabled cin/cout/cerr totally. +If you really need them you have to define your own versions, which are initialized after main() has been called. Application data may be bundled with app itself, or downloaded from net on first run. Create .ZIP file with your application data, and put it on HTTP server, or to "project/jni/application/src/AndroidData" dir -