Update Android.mk for Lollipop
Daniel Leung
PATCH 1/2 Update Android.mk for Lollipop
() Update Android.mk to include source files,
and paths to external includes/libraries
() Do not include libintl.h if NLS is not enabled
() Workaround missing functions in Android
Based on earlier patches by Ken Lierman <ken.lierman(a)windriver.com>.
Signed-off-by Daniel Leung <daniel.leung(a)linux.intel.com>
--- Android.mk | 41 +++- README.android | 23 +++ .../0001-Android-disable-C-exceptions.patch | 222 +++++++++++++++++++++ src/cpu/intel_cpus.h | 1 + src/lib.cpp | 2 + src/lib.h | 3 + src/main.cpp | 4 + src/report/report.cpp | 5 + src/tuning/tuningusb.cpp | 1 + 9 files changed, 293 insertions(+), 9 deletions(-) create mode 100644 README.android create mode 100644 patches/Android/0001-Android-disable-C-exceptions.patch
Android.mk +32 -9
@@ -1,18 +1,37 @@ +# Please run this before building +# ./src/csstoh.sh src/powertop.css src/css.h + LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := debug LOCAL_SHARED_LIBRARIES := libstlport \ libnl \ - libpci \ - libtraceevnet \ + 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_CFLAGS += -DHAVE_LIBNL20 +LOCAL_CPPFLAGS += -DPACKAGE_VERSION=\"2.7\" -DPACKAGE=powertop -DHAVE_LIBNL20 + LOCAL_C_INCLUDES += external/stlport/stlport/ external/stlport/stlport/stl external/stlport/stlport/using/h/ bionic external/libnl/include/ +# ncurses +LOCAL_C_INCLUDES += external/ncurses/include/ +LOCAL_SHARED_LIBRARIES += libncurses + +# pciutils +LOCAL_C_INCLUDES += external/pciutils/include/ +LOCAL_STATIC_LIBRARIES += libpci_static + +# libtraceevent +LOCAL_C_INCLUDES += $(LOCAL_PATH)/traceevent/ + +# local includes +LOCAL_C_INCLUDES += $(LOCAL_PATH)/src/ + LOCAL_SRC_FILES += \ src/parameters/parameters.cpp \ src/parameters/persistent.cpp \
@@ -21,10 +40,11 @@ LOCAL_SRC_FILES += \ src/process/work.cpp \ src/process/process.cpp \ src/process/timer.cpp \ - src/process/device.cpp \ + src/process/processdevice.cpp \ src/process/interrupt.cpp \ src/process/do_process.cpp \ src/cpu/intel_cpus.cpp \ + src/cpu/intel_gpu.cpp \ src/cpu/cpu.cpp \ src/cpu/cpu_linux.cpp \ src/cpu/cpudevice.cpp \
@@ -39,19 +59,23 @@ LOCAL_SRC_FILES += \ src/measurement/extech.cpp \ src/measurement/sysfs.cpp \ src/display.cpp \ - src/report.cpp \ + src/report/report.cpp \ + src/report/report-maker.cpp \ + src/report/report-formatter-base.cpp \ + src/report/report-formatter-csv.cpp \ + src/report/report-formatter-html.cpp \ + src/report/report-data-html.cpp \ src/main.cpp \ src/tuning/tuning.cpp \ src/tuning/tuningi2c.cpp \ - src/tuning/usb.cpp \ + src/tuning/tuningusb.cpp \ src/tuning/bluetooth.cpp \ src/tuning/ethernet.cpp \ src/tuning/runtime.cpp \ src/tuning/iw.c \ src/tuning/iw.h \ src/tuning/tunable.cpp \ - src/tuning/sysfs.cpp \ - src/tuning/cpufreq.cpp \ + src/tuning/tuningsysfs.cpp \ src/tuning/wifi.cpp \ src/perf/perf_bundle.cpp \ src/perf/perf.cpp \
@@ -67,12 +91,11 @@ LOCAL_SRC_FILES += \ src/devices/network.cpp \ src/devices/device.cpp \ src/devices/gpu_rapl_device.cpp \ + src/devices/devfreq.cpp \ src/devlist.cpp \ src/calibrate/calibrate.cpp \ src/lib.cpp \ traceevent/event-parse.c \ - traceevent/event-parse.h \ - traceevent/event-utils.h \ traceevent/parse-filter.c \ traceevent/parse-utils.c \ traceevent/trace-seq.c
README.android new file +23 -0
@@ -0,0 +1,23 @@ +To build PowerTop for Android: + +1. Obtain pciutils and ncurses libraries. + Skip this step if they are already in the tree. + + pciutils: Clone + https://github.com/trevd/android_external_pciutils + into external/pciutils + + ncurses: Clone + https://github.com/cvpcs/android_external_libncurses + into external/ncurses + +2. Run + ./src/csstoh.sh src/powertop.css src/css.h + to generate the css.h header file. + +3. Apply patches inside patches/Android + +4. PowerTop can be built with top level make, + or by doing "mm". + + The resulting binary is under $ANDROID_PRODUCT_OUT/system/bin/powertop
patches/Android/0001-Android-disable-C-exceptions.patch new file +222 -0
222 lines not on this page · raw message
src/cpu/intel_cpus.h +1 -0
@@ -55,6 +55,7 @@ protected:DIR *dir; public:intel_util (); + virtual ~intel_util() {}; virtual void byt_has_ahci(); virtual int get_byt_ahci_support(); };
src/lib.cpp +2 -0
@@ -52,7 +52,9 @@ extern "C" { #include <sys/stat.h> #include <dirent.h> #include <locale.h> +#ifdef ENABLE_NLS #include <libintl.h> +#endif #include <limits> #include <math.h> #include <ncurses.h>
src/lib.h +3 -0
@@ -25,7 +25,10 @@#ifndef INCLUDE_GUARD_LIB_H #define INCLUDE_GUARD_LIB_H +#ifdef ENABLE_NLS #include <libintl.h> +#endif +#include <stdint.h> /* Include only for Automake builds */
src/main.cpp +4 -0
@@ -44,7 +44,9 @@ #include "perf/perf.h" #include "perf/perf_bundle.h" #include "lib.h" +#ifndef ANDROID #include "../config.h" +#endif #include "devices/device.h"
@@ -392,7 +394,9 @@ int main(int argc, char **argv) char workload[4096] = {0,}; int iterations = 1, auto_tune = 0; +#ifndef ANDROID set_new_handler(out_of_memory); +#endif setlocale (LC_ALL, "");
src/report/report.cpp +5 -0
@@ -37,6 +37,11 @@ #include <unistd.h> #include "report-data-html.h" +// not in Android c-lib +#ifdef ANDROID +#define strchrnul strchr +#endif + using namespace std; struct reportstream reportout;
src/tuning/tuningusb.cpp +1 -0
@@ -32,6 +32,7 @@ #include <utility> #include <iostream> #include <fstream> +#include <ctype.h> #include "../lib.h"
Signature · 1 line
1.8.3.2
Daniel Leung
PATCH 2/2 Fix segfault for Android
The mbsrtowcs() in Android seems to change the content of source pointer to 0x00. So save a copy of the source string so we can manipulate it later, preventing segfaults.
Signed-off-by Daniel Leung <daniel.leung(a)linux.intel.com>
--- src/lib.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
src/lib.cpp +3 -1
@@ -263,6 +263,7 @@ string read_sysfs_string(const char *format, const char *param) void align_string(char *buffer, size_t min_sz, size_t max_sz) { size_t sz; + char *buf = buffer; /** mbsrtowcs() allows NULL dst and zero sz, * comparing to mbstowcs(), which causes undefined
@@ -275,8 +276,9 @@ void align_string(char *buffer, size_t min_sz, size_t max_sz) buffer[min_sz] = 0x00; return; } + while (sz < min_sz) { - strcat(buffer, " "); + strcat(buf, " "); sz++; } }
Signature · 1 line
1.8.3.2