On Thu, Jul 14, 2011 at 11:35 PM, Amit Daniel Kachhap <amit.kach...@linaro.org> wrote: > This patch enables ncurses for android. NCURSES_NOMACRO flag is enabled > as there is some conflict with stl libraries. > > Signed-off-by: Amit Daniel Kachhap <amit.kach...@linaro.org> > --- > Android.mk | 23 +++++++++++++++++++---- > display.cpp | 5 ++++- > display.h | 3 ++- > lib.cpp | 6 ++++-- > main.cpp | 5 +++++ > process/do_process.cpp | 4 ++++ > 6 files changed, 38 insertions(+), 8 deletions(-) > > diff --git a/Android.mk b/Android.mk > index 6948011..e6e73b1 100644 > --- a/Android.mk > +++ b/Android.mk > @@ -1,17 +1,32 @@ > LOCAL_PATH := $(call my-dir) > include $(CLEAR_VARS) > > -LOCAL_MODULE_TAGS := debug > +LOCAL_MODULE_TAGS := optional > LOCAL_SHARED_LIBRARIES := libstlport \ > - libnl \ > + libnl > + > +LOCAL_STATIC_LIBRARIES := libncurses > > LOCAL_MODULE := powertop > > #LOCAL_CFLAGS += -Wall -O2 -g -fno-omit-frame-pointer -fstack-protector > -Wshadow -Wformat -D_FORTIFY_SOURCE=2 > #LOCAL_CPPFLAGS += -Wall -O2 -g -fno-omit-frame-pointer > -LOCAL_CPPFLAGS += -DDISABLE_NCURSES -DDISABLE_I18N -DDISABLE_TRYCATCH > +LOCAL_CPPFLAGS += \ > + -DDISABLE_I18N \ > + -DDISABLE_TRYCATCH \ > + -DNCURSES_NOMACROS \ > + -DDISABLE_WSTRING \ > + -DDEFAULT_TERM=\"xterm\" \ > > -LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl > external/stlport/stlport/using/h/ bionic external/libnl/include/ > +LOCAL_C_INCLUDES += external/stlport/stlport/ \ > + external/stlport/stlport/stl \ > + external/stlport/stlport/using/h/ \ > + bionic \ > + external/libnl/include/ \ > + external/ncurses \ > + external/ncurses/lib \ > + external/ncurses/include \ > + external/ncurses/include/ncurses > > ifneq ($(TARGET_ARCH),arm) > LOCAL_SHARED_LIBRARIES += libpci > diff --git a/display.cpp b/display.cpp > index f486050..283743c 100644 > --- a/display.cpp > +++ b/display.cpp > @@ -84,8 +84,11 @@ void reset_display(void) > keypad(stdscr, FALSE); > echo(); > nocbreak(); > - > +#ifndef NCURSES_NOMACROS > resetterm(); > +#else > + reset_shell_mode(); > +#endif > } > > > diff --git a/display.h b/display.h > index 3b24914..023f68d 100644 > --- a/display.h > +++ b/display.h > @@ -49,7 +49,8 @@ public: > int cursor_pos; > int cursor_max; > WINDOW *win; > - > + > + virtual ~tab_window() {}; > virtual void cursor_down(void) { if (cursor_pos < cursor_max ) > cursor_pos++; repaint(); } ; > virtual void cursor_up(void) { if (cursor_pos > 0) cursor_pos--; > repaint(); }; > > diff --git a/lib.cpp b/lib.cpp > index d058e4f..86fcf96 100644 > --- a/lib.cpp > +++ b/lib.cpp > @@ -238,10 +238,12 @@ void format_watts(double W, char *buffer, unsigned int > len) > if (W < 0.0001) > sprintf(buffer, _(" 0 mW")); > > -#ifndef DISABLE_NCURSES > +#ifndef DISABLE_NCURSES > +#ifndef DISABLE_WSTRING > while (mbstowcs(NULL,buffer,0) < len) > strcat(buffer, " "); > -#endif > +#endif //DISABLE_WSTRING > +#endif //DISABLE_NCURSES > } > > #ifndef DISABLE_PCI > diff --git a/main.cpp b/main.cpp > index 3ee0a7e..fc4b0cf 100644 > --- a/main.cpp > +++ b/main.cpp > @@ -280,6 +280,11 @@ int main(int argc, char **argv) > bindtextdomain ("powertop", "/usr/share/locale"); > textdomain ("powertop"); > #endif > + > +#ifdef DEFAULT_TERM > + if (!getenv("TERM")) > + setenv("TERM", DEFAULT_TERM, 1); > +#endif > uid = getuid(); > > if (uid != 0) { > diff --git a/process/do_process.cpp b/process/do_process.cpp > index 5c382f1..7e39321 100644 > --- a/process/do_process.cpp > +++ b/process/do_process.cpp > @@ -720,7 +720,9 @@ void process_update_display(void) > if (!show_power) > strcpy(power, " "); > sprintf(name, "%s", all_power[i]->type()); > +#ifndef DISABLE_WSTRING > while (mbstowcs(NULL,name,0) < 14) strcat(name, " "); > +#endif > > > if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 > && all_power[i]->Witts() == 0) > @@ -733,7 +735,9 @@ void process_update_display(void) > else > sprintf(usage, "%5i%s", > (int)all_power[i]->usage(), all_power[i]->usage_units()); > } > +#ifndef DISABLE_WSTRING > while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " "); > +#endif > sprintf(events, "%5.1f", all_power[i]->events()); > if (!all_power[i]->show_events()) > events[0] = 0;
most of the code in this patch read "autotoolize this" to me... You can redefine stuff that needs stubbing out easily, get rid of most of the #ifdefs as well. Auke _______________________________________________ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev