From patchwork Fri Jul 15 06:35:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Daniel Kachhap X-Patchwork-Id: 2708 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0EB2B23F55 for ; Fri, 15 Jul 2011 06:36:28 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id CA1DEA18315 for ; Fri, 15 Jul 2011 06:36:27 +0000 (UTC) Received: by mail-qy0-f173.google.com with SMTP id 10so295967qyk.11 for ; Thu, 14 Jul 2011 23:36:27 -0700 (PDT) Received: by 10.229.217.3 with SMTP id hk3mr2668219qcb.38.1310711787590; Thu, 14 Jul 2011 23:36:27 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs38391qcb; Thu, 14 Jul 2011 23:36:27 -0700 (PDT) Received: by 10.223.75.25 with SMTP id w25mr1184850faj.140.1310711786695; Thu, 14 Jul 2011 23:36:26 -0700 (PDT) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by mx.google.com with ESMTPS id a10si1270915fak.66.2011.07.14.23.36.26 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Jul 2011 23:36:26 -0700 (PDT) Received-SPF: pass (google.com: domain of amitdanielk@gmail.com designates 209.85.161.44 as permitted sender) client-ip=209.85.161.44; Authentication-Results: mx.google.com; spf=pass (google.com: domain of amitdanielk@gmail.com designates 209.85.161.44 as permitted sender) smtp.mail=amitdanielk@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by mail-fx0-f44.google.com with SMTP id 6so1724844fxe.17 for ; Thu, 14 Jul 2011 23:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=IxssfjFDbDpgGXwJvuMyKJMDaiBJEvRzXRU9+x6yoOA=; b=pkDoaH1LTHIUHR/+yBCpe26lbDzseqxG4sXAVmMuYg74TgTSalI20jEVYyBhad0pjH 6R0z1Gj6Qw27qWbm32OkCyGInV2Rscvp4SQ8cH9tqJkid0xD1LRcx4gsKrsNSccJq9Kk 0D0/0Ztt1VGPizt5xfHibv0s+u6fGexV3r+9Q= Received: by 10.223.7.10 with SMTP id b10mr4831362fab.76.1310711785987; Thu, 14 Jul 2011 23:36:25 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id e10sm582327fak.18.2011.07.14.23.36.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Jul 2011 23:36:25 -0700 (PDT) Sender: amit kachhap From: Amit Daniel Kachhap To: arjan@linux.intel.com, kristen@linux.intel.com, power@bughost.org Cc: linaro-dev@lists.linaro.org, amit.kachhap@linaro.org, patches@linaro.org Subject: [PATCH 3/3] powertop: ncurses: Enable ncurses for android and miscellaneous changes Date: Fri, 15 Jul 2011 12:05:48 +0530 Message-Id: <1310711748-23531-4-git-send-email-amit.kachhap@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1310711748-23531-1-git-send-email-amit.kachhap@linaro.org> References: <1310711748-23531-1-git-send-email-amit.kachhap@linaro.org> 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 --- 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;