All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Powertop] [PATCH] Make ncurses dependency optional
@ 2012-07-19  6:26 Igor Zhbanov
  0 siblings, 0 replies; 5+ messages in thread
From: Igor Zhbanov @ 2012-07-19  6:26 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 996 bytes --]

Arjan van de Ven wrote:
> On 7/18/2012 7:54 AM, Igor Zhbanov wrote:
>> Make ncurses dependency optional. Provide --without-ncurses option
>> to configure.
> I'm sorry but this patch is disgusting;
> PowerTOP uses ncurses. Really.
>
> crapping ifdefs all over the codebase to pretend it does not, we're just
> really not going to do that this way.
I agree that lots of #ifdefs are ugly. But some mobile platforms doesn't
have ncurses. And is is not convenient to run PowerTOP via terminal on it.
Sometimes HTML-report is all that we need. So I try to make possible to build
PowerTOP without ncurses. Linaro's version does the same except that they
just provide -DDISABLE_NCURSES to make without any configure options.

Thank you.

-- 
Best regards,
Igor Zhbanov,
Expert Software Engineer,
phone: +7 (495) 797 25 00 ext 3806
e-mail: i.zhbanov(a)samsung.com

ASWG, Moscow R&D center, Samsung Electronics
12 Dvintsev street, building 1
127018, Moscow, Russian Federation


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Powertop] [PATCH] Make ncurses dependency optional
@ 2012-07-19 16:02 Kok, Auke-jan H
  0 siblings, 0 replies; 5+ messages in thread
From: Kok, Auke-jan H @ 2012-07-19 16:02 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

On Thu, Jul 19, 2012 at 3:15 PM, Arjan van de Ven <arjan(a)linux.intel.com> wrote:
> On 7/18/2012 11:26 PM, Igor Zhbanov wrote:
>> Arjan van de Ven wrote:
>>> On 7/18/2012 7:54 AM, Igor Zhbanov wrote:
>>>> Make ncurses dependency optional. Provide --without-ncurses option
>>>> to configure.
>>> I'm sorry but this patch is disgusting;
>>> PowerTOP uses ncurses. Really.
>>>
>>> crapping ifdefs all over the codebase to pretend it does not, we're just
>>> really not going to do that this way.
>> I agree that lots of #ifdefs are ugly. But some mobile platforms doesn't
>> have ncurses.
>
> then maybe those mobile platforms should add ncurses?
>
> I did not realize Tizen lacked ncurses for example, sounds daft to be
> honest.

it doesn't:

https://review.tizen.org/git/?p=pkgs/n/ncurses.git

Auke

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Powertop] [PATCH] Make ncurses dependency optional
@ 2012-07-19 15:15 Arjan van de Ven
  0 siblings, 0 replies; 5+ messages in thread
From: Arjan van de Ven @ 2012-07-19 15:15 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 647 bytes --]

On 7/18/2012 11:26 PM, Igor Zhbanov wrote:
> Arjan van de Ven wrote:
>> On 7/18/2012 7:54 AM, Igor Zhbanov wrote:
>>> Make ncurses dependency optional. Provide --without-ncurses option
>>> to configure.
>> I'm sorry but this patch is disgusting;
>> PowerTOP uses ncurses. Really.
>>
>> crapping ifdefs all over the codebase to pretend it does not, we're just
>> really not going to do that this way.
> I agree that lots of #ifdefs are ugly. But some mobile platforms doesn't
> have ncurses. 

then maybe those mobile platforms should add ncurses?

I did not realize Tizen lacked ncurses for example, sounds daft to be
honest.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Powertop] [PATCH] Make ncurses dependency optional
@ 2012-07-18 15:32 Arjan van de Ven
  0 siblings, 0 replies; 5+ messages in thread
From: Arjan van de Ven @ 2012-07-18 15:32 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

On 7/18/2012 7:54 AM, Igor Zhbanov wrote:
> Make ncurses dependency optional. Provide --without-ncurses option
> to configure.

I'm sorry but this patch is disgusting;
PowerTOP uses ncurses. Really.

crapping ifdefs all over the codebase to pretend it does not, we're just
really not going to do that this way.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Powertop] [PATCH] Make ncurses dependency optional
@ 2012-07-18 14:54 Igor Zhbanov
  0 siblings, 0 replies; 5+ messages in thread
From: Igor Zhbanov @ 2012-07-18 14:54 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 6617 bytes --]

Make ncurses dependency optional. Provide --without-ncurses option
to configure.
---
 configure.ac               |    6 +++++-
 src/cpu/cpu.cpp            |    3 +++
 src/display.cpp            |    7 +++++++
 src/display.h              |    3 +++
 src/lib.cpp                |    7 +++++++
 src/main.cpp               |    2 ++
 src/process/do_process.cpp |    7 +++++++
 src/tuning/tuning.cpp      |    5 +++++
 8 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index ff4cdea..084056f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,7 +45,11 @@ AC_FUNC_REALLOC
 AC_FUNC_STRTOD
 AC_CHECK_FUNCS([fdatasync getpagesize gettimeofday memmove memset mkdir munmap pow realpath regcomp select setlocale socket sqrt strcasecmp strchr strdup strerror strncasecmp strstr strtoul strtoull])
 
-AC_SEARCH_LIBS([delwin], [ncursesw ncurses], [], AC_MSG_ERROR([ncurses is required but was not found]), [])
+AC_ARG_WITH([ncurses], AS_HELP_STRING([--without-ncurses], [Disable ncurses support]))
+AS_IF([test "x$with_ncurses" = "xno"], [
+	AC_DEFINE([DISABLE_NCURSES], [1], [Disable ncurses support])], [
+	AC_SEARCH_LIBS([delwin], [ncursesw ncurses], [],
+		AC_MSG_ERROR([ncurses is required but was not found]), [])])
 
 PKG_CHECK_MODULES([PCIUTILS], [libpci],[],[
 	AC_SEARCH_LIBS([pci_get_dev], [pci], [], AC_MSG_ERROR([libpci is required but was not found]), [])
diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp
index 941bcff..1c66740 100644
--- a/src/cpu/cpu.cpp
+++ b/src/cpu/cpu.cpp
@@ -22,12 +22,15 @@
  * Authors:
  *	Arjan van de Ven <arjan(a)linux.intel.com>
  */
+#include "../../config.h"
 #include <iostream>
 #include <fstream>
 #include <vector>
 #include <string.h>
 #include <stdlib.h>
+#ifndef DISABLE_NCURSES
 #include <ncurses.h>
+#endif /* !DISABLE_NCURSES */
 
 #include "cpu.h"
 #include "cpudevice.h"
diff --git a/src/display.cpp b/src/display.cpp
index caa66d0..75d347f 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -22,10 +22,13 @@
  * Authors:
  *	Arjan van de Ven <arjan(a)linux.intel.com>
  */
+#include "../config.h"
 #include "display.h"
 #include "lib.h"
 
+#ifndef DISABLE_NCURSES
 #include <ncurses.h>
+#endif /* !DISABLE_NCURSES */
 
 
 #include <vector>
@@ -85,7 +88,11 @@ void reset_display(void)
 	echo();
 	nocbreak();
 
+#ifndef NCURSES_NOMACROS
 	resetterm();
+#else /* NCURSES_NOMACROS */
+	reset_shell_mode();
+#endif /* NCURSES_NOMACROS */
 }
 
 
diff --git a/src/display.h b/src/display.h
index e0f66a3..67c191a 100644
--- a/src/display.h
+++ b/src/display.h
@@ -26,9 +26,12 @@
 #define __INCLUDE_GUARD_DISPLAY_H_
 
 
+#include "../config.h"
 #include <map>
 #include <string>
+#ifndef DISABLE_NCURSES
 #include <ncurses.h>
+#endif /* !DISABLE_NCURSES */
 
 using namespace std;
 
diff --git a/src/lib.cpp b/src/lib.cpp
index 0f87e48..26b8c0e 100644
--- a/src/lib.cpp
+++ b/src/lib.cpp
@@ -23,6 +23,7 @@
  *	Arjan van de Ven <arjan(a)linux.intel.com>
  *	Peter Anvin
  */
+#include "../config.h"
 #include <map>
 #include <string.h>
 #include <iostream>
@@ -55,7 +56,9 @@ extern "C" {
 #endif
 #include <limits>
 #include <math.h>
+#ifndef DISABLE_NCURSES
 #include <ncurses.h>
+#endif /* !DISABLE_NCURSES */
 
 static int kallsyms_read = 0;
 
@@ -260,8 +263,10 @@ void format_watts(double W, char *buffer, unsigned int len)
 		sprintf(buffer, _("    0 mW"));
 
 #ifndef DISABLE_NCURSES
+#ifndef DISABLE_WSTRING
 	while (mbstowcs(NULL,buffer,0) < len)
 		strcat(buffer, " ");
+#endif /* DISABLE_WSTRING */
 #endif
 }
 
@@ -418,6 +423,7 @@ void process_directory(const char *d_name, callback fn)
 	closedir(dir);
 }
 
+#ifndef DISABLE_NCURSES
 int get_user_input(char *buf, unsigned sz)
 {
 	fflush(stdout);
@@ -429,3 +435,4 @@ int get_user_input(char *buf, unsigned sz)
 	/* to distinguish between getnstr error and empty line */
 	return ret || strlen(buf);
 }
+#endif /* DISABLE_NCURSES */
diff --git a/src/main.cpp b/src/main.cpp
index 7a1b976..8f096c9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -86,6 +86,7 @@ static void print_version()
 	printf(_("PowerTOP version" POWERTOP_VERSION ", compiled on " __DATE__ "\n"));
 }
 
+#ifndef DISABLE_NCURSES
 static bool set_refresh_timeout()
 {
 	static char buf[4];
@@ -99,6 +100,7 @@ static bool set_refresh_timeout()
 	time_out = time;
 	return 1;
 }
+#endif /* !DISABLE_NCURSES */
 
 static void print_usage()
 {
diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp
index 731fe3e..6c7950b 100644
--- a/src/process/do_process.cpp
+++ b/src/process/do_process.cpp
@@ -22,6 +22,7 @@
  * Authors:
  *	Arjan van de Ven <arjan(a)linux.intel.com>
  */
+#include "../../config.h"
 #include "process.h"
 #include "interrupt.h"
 #include "timer.h"
@@ -37,7 +38,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#ifndef DISABLE_NCURSES
 #include <ncurses.h>
+#endif /* !DISABLE_NCURSES */
 
 #include "../perf/perf_bundle.h"
 #include "../perf/perf_event.h"
@@ -858,7 +861,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 /* !DISABLE_WSTRING */
 
 
 		if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0)
@@ -871,7 +876,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 /* !DISABLE_WSTRING */
 		sprintf(events, "%5.1f", all_power[i]->events());
 		if (!all_power[i]->show_events())
 			events[0] = 0;
diff --git a/src/tuning/tuning.cpp b/src/tuning/tuning.cpp
index 1a90417..2e1981b 100644
--- a/src/tuning/tuning.cpp
+++ b/src/tuning/tuning.cpp
@@ -23,11 +23,14 @@
  *	Arjan van de Ven <arjan(a)linux.intel.com>
  */
 
+#include "../../config.h"
 #include <algorithm>
 
 #include <stdio.h>
 #include <string.h>
+#ifndef DISABLE_NCURSES
 #include <ncurses.h>
+#endif /* !DISABLE_NCURSES */
 
 
 #include "tuning.h"
@@ -182,12 +185,14 @@ static bool tunables_sort(class tunable * i, class tunable * j)
 	return false;
 }
 
+#ifndef DISABLE_NCURSES
 void tuning_window::window_refresh()
 {
 	clear_tuning();
 	should_clear = TRUE;
 	init_tuning();
 }
+#endif /* !DISABLE_NCURSES */
 
 static void sort_tunables(void)
 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-07-19 16:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-19  6:26 [Powertop] [PATCH] Make ncurses dependency optional Igor Zhbanov
  -- strict thread matches above, loose matches on Subject: below --
2012-07-19 16:02 Kok, Auke-jan H
2012-07-19 15:15 Arjan van de Ven
2012-07-18 15:32 Arjan van de Ven
2012-07-18 14:54 Igor Zhbanov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.