All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11  6:17 Igor Zhbanov
  0 siblings, 0 replies; 7+ messages in thread
From: Igor Zhbanov @ 2012-07-11  6:17 UTC (permalink / raw)
  To: powertop

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

Hello!

I have tried to build PowerTOP for ARM with a cross-compiler. But PowerTOP
uses internal csstoh utility that converts powertop.css to powertoh.h
for inclusion in *.cpp source files.

When you use the cross-compiler (without making complicated rules
in the Makefile) this utility will be compiled for ARM platform too.
And you cannot run it on x86 build host.

To solve this issue (and because of simplicity of the utility)
I have rewritten it in a shell script.

--8<--------------------------------------------------------------------------
diff -purN powertop/Android.mk powertop-cross/Android.mk
--- powertop/Android.mk	2012-07-05 11:54:25.052141513 +0400
+++ powertop-cross/Android.mk	2012-07-05 11:57:09.328145984 +0400
@@ -2,12 +2,11 @@ LOCAL_PATH := $(call my-dir)
  include $(CLEAR_VARS)

  LOCAL_MODULE_TAGS := optional
-CSSTOH_SOURCE := $(LOCAL_PATH)/csstoh.c
  POWERTOP_CSS_SOURCE := $(LOCAL_PATH)/powertop.css
-GEN_CSSTOH := $(LOCAL_PATH)/csstoh
+GEN_CSSTOH := $(LOCAL_PATH)/csstoh.sh
  GEN_CSS_H := $(LOCAL_PATH)/css.h
  $(GEN_CSS_H):
-	$(CC) -o $(GEN_CSSTOH) $(CSSTOH_SOURCE)
+	chmod +x ./$(GEN_CSSTOH)
  	./$(GEN_CSSTOH) $(POWERTOP_CSS_SOURCE) $@

  LOCAL_GENERATED_SOURCES += $(GEN_CSS_H)
diff -purN powertop/.gitignore powertop-cross/.gitignore
--- powertop/.gitignore	2012-07-05 11:54:25.032141514 +0400
+++ powertop-cross/.gitignore	2012-07-05 11:55:49.028143801 +0400
@@ -39,7 +39,6 @@ po/*.gmo
  po/stamp-po
  src/powertop
  src/css.h
-src/csstoh
  src/Makefile.in
  src/.deps/
  src/Makefile
diff -purN powertop/src/csstoh.sh powertop-cross/src/csstoh.sh
--- powertop/src/csstoh.sh	1970-01-01 03:00:00.000000000 +0300
+++ powertop-cross/src/csstoh.sh	2012-07-05 11:50:22.000000000 +0400
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+# or just google for it.
+#
+# Written by Igor Zhbanov<i.zhbanov(a)samsung.com>
+
+
+if [ $# -lt 2 ]; then
+	echo "Usage: csstoh.sh cssfile header.h"
+	exit 1
+fi
+
+if [ ! -r $1 ]; then
+	echo "Can't find file $1"
+	exit 1
+fi
+
+if ! echo -n>$2; then
+	echo "Can't open file $2 for writing."
+	exit 1
+fi
+
+echo "#ifndef __INCLUDE_GUARD_CCS_H">>  $2
+echo "#define __INCLUDE_GUARD_CCS_H">>  $2
+echo>>  $2
+echo "const char css[] = ">>  $2
+
+sed -r 's/^(.*)$/\t\"\1\\n\"/' $1>>  $2
+
+echo ";">>  $2
+echo "#endif">>  $2
diff -purN powertop/src/Makefile.am powertop-cross/src/Makefile.am
--- powertop/src/Makefile.am	2012-07-05 11:54:25.040141514 +0400
+++ powertop-cross/src/Makefile.am	2012-07-05 11:56:42.700145262 +0400
@@ -1,9 +1,6 @@
  AUTOMAKE_OPTIONS = subdir-objects
  ACLOCAL_AMFLAGS = -I ../m4

-noinst_PROGRAMS = csstoh
-csstoh_SOURCES = csstoh.c
-
  sbin_PROGRAMS = powertop
  nodist_powertop_SOURCES = css.h

@@ -44,6 +41,7 @@ AM_LDFLAGS = $(LIBS) $(NCURSES_LIBS) $(P

  BUILT_SOURCES = css.h
  CLEANFILES = css.h
-css.h: csstoh powertop.css
-	./csstoh powertop.css css.h
+css.h: powertop.css
+	chmod +x ./csstoh.sh
+	./csstoh.sh powertop.css css.h

--8<--------------------------------------------------------------------------

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 02-powertop-cross-csstoh.diff --]
[-- Type: text/x-diff, Size: 3059 bytes --]

diff -purN powertop/Android.mk powertop-cross/Android.mk
--- powertop/Android.mk	2012-07-05 11:54:25.052141513 +0400
+++ powertop-cross/Android.mk	2012-07-05 11:57:09.328145984 +0400
@@ -2,12 +2,11 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_MODULE_TAGS := optional
-CSSTOH_SOURCE := $(LOCAL_PATH)/csstoh.c
 POWERTOP_CSS_SOURCE := $(LOCAL_PATH)/powertop.css
-GEN_CSSTOH := $(LOCAL_PATH)/csstoh
+GEN_CSSTOH := $(LOCAL_PATH)/csstoh.sh
 GEN_CSS_H := $(LOCAL_PATH)/css.h
 $(GEN_CSS_H):
-	$(CC) -o $(GEN_CSSTOH) $(CSSTOH_SOURCE)
+	chmod +x ./$(GEN_CSSTOH)
 	./$(GEN_CSSTOH) $(POWERTOP_CSS_SOURCE) $@
 
 LOCAL_GENERATED_SOURCES += $(GEN_CSS_H)
diff -purN powertop/.gitignore powertop-cross/.gitignore
--- powertop/.gitignore	2012-07-05 11:54:25.032141514 +0400
+++ powertop-cross/.gitignore	2012-07-05 11:55:49.028143801 +0400
@@ -39,7 +39,6 @@ po/*.gmo
 po/stamp-po
 src/powertop
 src/css.h
-src/csstoh
 src/Makefile.in
 src/.deps/
 src/Makefile
diff -purN powertop/src/csstoh.sh powertop-cross/src/csstoh.sh
--- powertop/src/csstoh.sh	1970-01-01 03:00:00.000000000 +0300
+++ powertop-cross/src/csstoh.sh	2012-07-05 11:50:22.000000000 +0400
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+# or just google for it.
+#
+# Written by Igor Zhbanov <i.zhbanov@samsung.com>
+
+
+if [ $# -lt 2 ]; then
+	echo "Usage: csstoh.sh cssfile header.h"
+	exit 1
+fi
+
+if [ ! -r $1 ]; then
+	echo "Can't find file $1"
+	exit 1
+fi
+
+if ! echo -n >$2; then
+	echo "Can't open file $2 for writing."
+	exit 1
+fi
+
+echo "#ifndef __INCLUDE_GUARD_CCS_H" >> $2
+echo "#define __INCLUDE_GUARD_CCS_H" >> $2
+echo >> $2
+echo "const char css[] = " >> $2
+
+sed -r 's/^(.*)$/\t\"\1\\n\"/' $1 >> $2
+
+echo ";" >> $2
+echo "#endif" >> $2
diff -purN powertop/src/Makefile.am powertop-cross/src/Makefile.am
--- powertop/src/Makefile.am	2012-07-05 11:54:25.040141514 +0400
+++ powertop-cross/src/Makefile.am	2012-07-05 11:56:42.700145262 +0400
@@ -1,9 +1,6 @@
 AUTOMAKE_OPTIONS = subdir-objects
 ACLOCAL_AMFLAGS = -I ../m4 
 
-noinst_PROGRAMS = csstoh
-csstoh_SOURCES = csstoh.c 
-
 sbin_PROGRAMS = powertop
 nodist_powertop_SOURCES = css.h
 
@@ -44,6 +41,7 @@ AM_LDFLAGS = $(LIBS) $(NCURSES_LIBS) $(P
 
 BUILT_SOURCES = css.h
 CLEANFILES = css.h
-css.h: csstoh powertop.css
-	./csstoh powertop.css css.h
+css.h: powertop.css
+	chmod +x ./csstoh.sh
+	./csstoh.sh powertop.css css.h
 

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

* Re: [Powertop] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11 11:46 Paul Menzel
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Menzel @ 2012-07-11 11:46 UTC (permalink / raw)
  To: powertop

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

Am Mittwoch, den 11.07.2012, 12:47 +0400 schrieb Igor Zhbanov:
> Here is the formatted version of the patch:

Thanks, unfortunately something is incomplete.

>  From 06ee265b637bd75e2147631f49454c2c82be827e Mon Sep 17 00:00:00 2001
> From: Igor Zhbanov<i.zhbanov(a)samsung.com>
> Date: Wed, 11 Jul 2012 12:44:39 +0400
> Subject: [PATCH] csstoh shell-script for cross-compiling PowerTOP
> 
> I have tried to build PowerTOP for ARM with a cross-compiler. But PowerTOP
> uses internal csstoh utility that converts powertop.css to powertoh.h
> for inclusion in *.cpp source files.
> 
> When you use the cross-compiler (without making complicated rules
> in the Makefile) this utility will be compiled for ARM platform too.
> And you cannot run it on x86 build host.
> 
> To solve this issue (and because of simplicity of the utility)
> I have rewritten it in a shell script.
> ---
>   .gitignore      |    1 -
>   src/Makefile.am |    7 ++-----
>   2 files changed, 2 insertions(+), 6 deletions(-)

Git does not know about your new file `csstoh.sh` yet.

    $ git add src/csstoh.sh # explicitly needed, because the file is not yet tracked
    $ git commit --amend -a
    $ git format-patch -1

> diff --git a/.gitignore b/.gitignore
> index 5534072..35f0df6 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -39,7 +39,6 @@ po/*.gmo
>   po/stamp-po
>   src/powertop
>   src/css.h
> -src/csstoh
>   src/Makefile.in
>   src/.deps/
>   src/Makefile
> diff --git a/src/Makefile.am b/src/Makefile.am
> index c77b2aa..15e5feb 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -1,9 +1,6 @@
>   AUTOMAKE_OPTIONS = subdir-objects
>   ACLOCAL_AMFLAGS = -I ../m4
> 
> -noinst_PROGRAMS = csstoh
> -csstoh_SOURCES = csstoh.c
> -
>   sbin_PROGRAMS = powertop
>   nodist_powertop_SOURCES = css.h
> 
> @@ -44,6 +41,6 @@ AM_LDFLAGS = $(LIBS) $(NCURSES_LIBS) $(PCIUTILS_LIBS) $(LIBNL_LIBS) $(LIBZ_LIBS)
> 
>   BUILT_SOURCES = css.h
>   CLEANFILES = css.h
> -css.h: csstoh powertop.css
> -	./csstoh powertop.css css.h
> +css.h: powertop.css
> +	$(SHELL) ./csstoh.sh powertop.css css.h
> 
> -- 
> 1.7.5.4


Thanks,

Paul


PS: In the license header the copyright year is missing if I am not
mistaken.
PPS: Is that also the right license header? Probably you just copied it
from some existing file. So it should be fine.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [Powertop] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11  8:47 Igor Zhbanov
  0 siblings, 0 replies; 7+ messages in thread
From: Igor Zhbanov @ 2012-07-11  8:47 UTC (permalink / raw)
  To: powertop

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

Here is the formatted version of the patch:

 From 06ee265b637bd75e2147631f49454c2c82be827e Mon Sep 17 00:00:00 2001
From: Igor Zhbanov<i.zhbanov(a)samsung.com>
Date: Wed, 11 Jul 2012 12:44:39 +0400
Subject: [PATCH] csstoh shell-script for cross-compiling PowerTOP

I have tried to build PowerTOP for ARM with a cross-compiler. But PowerTOP
uses internal csstoh utility that converts powertop.css to powertoh.h
for inclusion in *.cpp source files.

When you use the cross-compiler (without making complicated rules
in the Makefile) this utility will be compiled for ARM platform too.
And you cannot run it on x86 build host.

To solve this issue (and because of simplicity of the utility)
I have rewritten it in a shell script.
---
  .gitignore      |    1 -
  src/Makefile.am |    7 ++-----
  2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5534072..35f0df6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,7 +39,6 @@ po/*.gmo
  po/stamp-po
  src/powertop
  src/css.h
-src/csstoh
  src/Makefile.in
  src/.deps/
  src/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index c77b2aa..15e5feb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,6 @@
  AUTOMAKE_OPTIONS = subdir-objects
  ACLOCAL_AMFLAGS = -I ../m4

-noinst_PROGRAMS = csstoh
-csstoh_SOURCES = csstoh.c
-
  sbin_PROGRAMS = powertop
  nodist_powertop_SOURCES = css.h

@@ -44,6 +41,6 @@ AM_LDFLAGS = $(LIBS) $(NCURSES_LIBS) $(PCIUTILS_LIBS) $(LIBNL_LIBS) $(LIBZ_LIBS)

  BUILT_SOURCES = css.h
  CLEANFILES = css.h
-css.h: csstoh powertop.css
-	./csstoh powertop.css css.h
+css.h: powertop.css
+	$(SHELL) ./csstoh.sh powertop.css css.h

-- 
1.7.5.4

Paul Menzel wrote:

> Dear Igor, dear Sergey,
>
>
> Am Mittwoch, den 11.07.2012, 10:36 +0300 schrieb Sergey Senozhatsky:
>> On (07/11/12 11:15), Igor Zhbanov wrote:
>>> Here is the new version:
>>>
>>> --8<--Cut-here----------------------------------------------------------------
>> Igor, could you please inline patch as "git diff -u -p" output, not as attachment.
>          $ git commit -a
>          $ git format-patch -1
>
> is the preferred way as far as I know. Please see my other message, I
> sent in reply to »[Powertop] Device list sort function bug«.
>
>
> Thanks,
>
> Paul


-- 
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 related	[flat|nested] 7+ messages in thread

* Re: [Powertop] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11  7:54 Paul Menzel
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Menzel @ 2012-07-11  7:54 UTC (permalink / raw)
  To: powertop

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

Dear Igor, dear Sergey,


Am Mittwoch, den 11.07.2012, 10:36 +0300 schrieb Sergey Senozhatsky:
> On (07/11/12 11:15), Igor Zhbanov wrote:
> > Here is the new version:
> > 
> > --8<--Cut-here----------------------------------------------------------------

> Igor, could you please inline patch as "git diff -u -p" output, not as attachment.

        $ git commit -a
        $ git format-patch -1

is the preferred way as far as I know. Please see my other message, I
sent in reply to »[Powertop] Device list sort function bug«.


Thanks,

Paul

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [Powertop] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11  7:36 Sergey Senozhatsky
  0 siblings, 0 replies; 7+ messages in thread
From: Sergey Senozhatsky @ 2012-07-11  7:36 UTC (permalink / raw)
  To: powertop

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

On (07/11/12 11:15), Igor Zhbanov wrote:
> Here is the new version:
> 
> --8<--Cut-here----------------------------------------------------------------
>

Hello,

Igor, could you please inline patch as "git diff -u -p" output, not as attachment.

Thanks,
	-ss

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

* Re: [Powertop] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11  7:15 Igor Zhbanov
  0 siblings, 0 replies; 7+ messages in thread
From: Igor Zhbanov @ 2012-07-11  7:15 UTC (permalink / raw)
  To: powertop

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

Here is the new version:

--8<--Cut-here----------------------------------------------------------------
diff -purN powertop/Android.mk powertop-csstoh/Android.mk
--- powertop/Android.mk	2012-07-11 11:09:18.388958856 +0400
+++ powertop-csstoh/Android.mk	2012-07-11 11:09:56.884957818 +0400
@@ -2,13 +2,11 @@ LOCAL_PATH := $(call my-dir)
  include $(CLEAR_VARS)

  LOCAL_MODULE_TAGS := optional
-CSSTOH_SOURCE := $(LOCAL_PATH)/csstoh.c
  POWERTOP_CSS_SOURCE := $(LOCAL_PATH)/powertop.css
-GEN_CSSTOH := $(LOCAL_PATH)/csstoh
+GEN_CSSTOH := $(LOCAL_PATH)/csstoh.sh
  GEN_CSS_H := $(LOCAL_PATH)/css.h
  $(GEN_CSS_H):
-	$(CC) -o $(GEN_CSSTOH) $(CSSTOH_SOURCE)
-	./$(GEN_CSSTOH) $(POWERTOP_CSS_SOURCE) $@
+	$(SHELL) ./$(GEN_CSSTOH) $(POWERTOP_CSS_SOURCE) $@

  LOCAL_GENERATED_SOURCES += $(GEN_CSS_H)

diff -purN powertop/.gitignore powertop-csstoh/.gitignore
--- powertop/.gitignore	2012-07-11 11:09:18.372958855 +0400
+++ powertop-csstoh/.gitignore	2012-07-11 11:09:34.180958433 +0400
@@ -39,7 +39,6 @@ po/*.gmo
  po/stamp-po
  src/powertop
  src/css.h
-src/csstoh
  src/Makefile.in
  src/.deps/
  src/Makefile
diff -purN powertop/src/csstoh.sh powertop-csstoh/src/csstoh.sh
--- powertop/src/csstoh.sh	1970-01-01 03:00:00.000000000 +0300
+++ powertop-csstoh/src/csstoh.sh	2012-07-11 11:10:54.716956259 +0400
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+# or just google for it.
+#
+# Written by Igor Zhbanov<i.zhbanov(a)samsung.com>
+
+if [ $# -lt 2 ]; then
+	echo "Usage: csstoh.sh cssfile header.h"
+	exit 1
+fi
+
+if [ ! -r $1 ]; then
+	echo "Can't find file $1"
+	exit 1
+fi
+
+if ! echo -n>$2; then
+	echo "Can't open file $2 for writing."
+	exit 1
+fi
+
+echo "#ifndef __INCLUDE_GUARD_CCS_H">>  $2
+echo "#define __INCLUDE_GUARD_CCS_H">>  $2
+echo>>  $2
+echo "const char css[] = ">>  $2
+
+sed -r 's/^(.*)$/\t\"\1\\n\"/' $1>>  $2
+
+echo ";">>  $2
+echo "#endif">>  $2
diff -purN powertop/src/Makefile.am powertop-csstoh/src/Makefile.am
--- powertop/src/Makefile.am	2012-07-11 11:09:18.376958857 +0400
+++ powertop-csstoh/src/Makefile.am	2012-07-11 11:10:13.888957361 +0400
@@ -1,9 +1,6 @@
  AUTOMAKE_OPTIONS = subdir-objects
  ACLOCAL_AMFLAGS = -I ../m4

-noinst_PROGRAMS = csstoh
-csstoh_SOURCES = csstoh.c
-
  sbin_PROGRAMS = powertop
  nodist_powertop_SOURCES = css.h

@@ -44,6 +41,6 @@ AM_LDFLAGS = $(LIBS) $(NCURSES_LIBS) $(P

  BUILT_SOURCES = css.h
  CLEANFILES = css.h
-css.h: csstoh powertop.css
-	./csstoh powertop.css css.h
+css.h: powertop.css
+	$(SHELL) ./csstoh.sh powertop.css css.h


--8<--------------------------------------------------------------------------


Magnus Fromreide wrote:
> On Wed, 2012-07-11 at 10:17 +0400, Igor Zhbanov wrote:
>> Hello!
>>
>> I have tried to build PowerTOP for ARM with a cross-compiler. But PowerTOP
>> uses internal csstoh utility that converts powertop.css to powertoh.h
>> for inclusion in *.cpp source files.
>>
>> When you use the cross-compiler (without making complicated rules
>> in the Makefile) this utility will be compiled for ARM platform too.
>> And you cannot run it on x86 build host.
>>
>> To solve this issue (and because of simplicity of the utility)
>> I have rewritten it in a shell script.
> Why /bin/bash?
>
> The script doesn't depend on any bashisms so /bin/sh should be enough,
> right?
>
> Why all the games with chmod?
> $(SHELL) csstoh.sh powertop.css css.h
> should also run the script correctly, shouldn't it?
>
> /MF
>
>
-- 
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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 02-powertop-cross-csstoh.diff --]
[-- Type: text/x-diff, Size: 3077 bytes --]

diff -purN powertop/Android.mk powertop-csstoh/Android.mk
--- powertop/Android.mk	2012-07-11 11:09:18.388958856 +0400
+++ powertop-csstoh/Android.mk	2012-07-11 11:09:56.884957818 +0400
@@ -2,13 +2,11 @@ LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_MODULE_TAGS := optional
-CSSTOH_SOURCE := $(LOCAL_PATH)/csstoh.c
 POWERTOP_CSS_SOURCE := $(LOCAL_PATH)/powertop.css
-GEN_CSSTOH := $(LOCAL_PATH)/csstoh
+GEN_CSSTOH := $(LOCAL_PATH)/csstoh.sh
 GEN_CSS_H := $(LOCAL_PATH)/css.h
 $(GEN_CSS_H):
-	$(CC) -o $(GEN_CSSTOH) $(CSSTOH_SOURCE)
-	./$(GEN_CSSTOH) $(POWERTOP_CSS_SOURCE) $@
+	$(SHELL) ./$(GEN_CSSTOH) $(POWERTOP_CSS_SOURCE) $@
 
 LOCAL_GENERATED_SOURCES += $(GEN_CSS_H)
 
diff -purN powertop/.gitignore powertop-csstoh/.gitignore
--- powertop/.gitignore	2012-07-11 11:09:18.372958855 +0400
+++ powertop-csstoh/.gitignore	2012-07-11 11:09:34.180958433 +0400
@@ -39,7 +39,6 @@ po/*.gmo
 po/stamp-po
 src/powertop
 src/css.h
-src/csstoh
 src/Makefile.in
 src/.deps/
 src/Makefile
diff -purN powertop/src/csstoh.sh powertop-csstoh/src/csstoh.sh
--- powertop/src/csstoh.sh	1970-01-01 03:00:00.000000000 +0300
+++ powertop-csstoh/src/csstoh.sh	2012-07-11 11:10:54.716956259 +0400
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# This program file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program in a file named COPYING; if not, write to the
+# Free Software Foundation, Inc,
+# 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301 USA
+# or just google for it.
+#
+# Written by Igor Zhbanov <i.zhbanov@samsung.com>
+
+if [ $# -lt 2 ]; then
+	echo "Usage: csstoh.sh cssfile header.h"
+	exit 1
+fi
+
+if [ ! -r $1 ]; then
+	echo "Can't find file $1"
+	exit 1
+fi
+
+if ! echo -n >$2; then
+	echo "Can't open file $2 for writing."
+	exit 1
+fi
+
+echo "#ifndef __INCLUDE_GUARD_CCS_H" >> $2
+echo "#define __INCLUDE_GUARD_CCS_H" >> $2
+echo >> $2
+echo "const char css[] = " >> $2
+
+sed -r 's/^(.*)$/\t\"\1\\n\"/' $1 >> $2
+
+echo ";" >> $2
+echo "#endif" >> $2
diff -purN powertop/src/Makefile.am powertop-csstoh/src/Makefile.am
--- powertop/src/Makefile.am	2012-07-11 11:09:18.376958857 +0400
+++ powertop-csstoh/src/Makefile.am	2012-07-11 11:10:13.888957361 +0400
@@ -1,9 +1,6 @@
 AUTOMAKE_OPTIONS = subdir-objects
 ACLOCAL_AMFLAGS = -I ../m4 
 
-noinst_PROGRAMS = csstoh
-csstoh_SOURCES = csstoh.c 
-
 sbin_PROGRAMS = powertop
 nodist_powertop_SOURCES = css.h
 
@@ -44,6 +41,6 @@ AM_LDFLAGS = $(LIBS) $(NCURSES_LIBS) $(P
 
 BUILT_SOURCES = css.h
 CLEANFILES = css.h
-css.h: csstoh powertop.css
-	./csstoh powertop.css css.h
+css.h: powertop.css
+	$(SHELL) ./csstoh.sh powertop.css css.h
 

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

* Re: [Powertop] csstoh shell-script for cross-compiling PowerTOP
@ 2012-07-11  6:56 Magnus Fromreide
  0 siblings, 0 replies; 7+ messages in thread
From: Magnus Fromreide @ 2012-07-11  6:56 UTC (permalink / raw)
  To: powertop

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

On Wed, 2012-07-11 at 10:17 +0400, Igor Zhbanov wrote:
> Hello!
> 
> I have tried to build PowerTOP for ARM with a cross-compiler. But PowerTOP
> uses internal csstoh utility that converts powertop.css to powertoh.h
> for inclusion in *.cpp source files.
> 
> When you use the cross-compiler (without making complicated rules
> in the Makefile) this utility will be compiled for ARM platform too.
> And you cannot run it on x86 build host.
> 
> To solve this issue (and because of simplicity of the utility)
> I have rewritten it in a shell script.

Why /bin/bash?

The script doesn't depend on any bashisms so /bin/sh should be enough,
right?

Why all the games with chmod?
$(SHELL) csstoh.sh powertop.css css.h
should also run the script correctly, shouldn't it?

/MF


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

end of thread, other threads:[~2012-07-11 11:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11  6:17 [Powertop] csstoh shell-script for cross-compiling PowerTOP Igor Zhbanov
2012-07-11  6:56 Magnus Fromreide
2012-07-11  7:15 Igor Zhbanov
2012-07-11  7:36 Sergey Senozhatsky
2012-07-11  7:54 Paul Menzel
2012-07-11  8:47 Igor Zhbanov
2012-07-11 11:46 Paul Menzel

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.