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 4a02eeeded.
This commit is contained in:
pelya
2010-12-21 11:18:33 +00:00
parent b24ee52c8c
commit 565f159a20
13 changed files with 717 additions and 47 deletions

View File

@@ -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))

View File

@@ -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<int>(status) << ", ln: " << static_cast<int>(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<Event *>::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<int>(*ptr) << ", ln: " << static_cast<int>(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<u16>(static_cast<u8>(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 <list> // Broken STLPort implementaion on Android requires this file to be included first
#include <utility>
-#include <list>
#include "maps_tiles.h"
class IndexDistance : public std::pair<s32, u16>
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: " <<