OSDN Git Service

Add support for Linux build
authorOctavian Purdila <octavian.purdila@intel.com>
Tue, 22 Jul 2014 10:48:10 +0000 (13:48 +0300)
committerAdriana Reus <adriana.reus@intel.com>
Fri, 25 Jul 2014 13:50:43 +0000 (16:50 +0300)
This patch adds support for building the sensor HAL and the test
program wihtin a Linux environment. It is usefull for faster sensor
HAL and driver development.

Change-Id: I13b6240899a4ed5351c5ae6660bb317cbcb3f793
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Makefile [new file with mode: 0644]
linux/cutils/native_handle.h [new file with mode: 0644]
linux/cutils/properties.h [new file with mode: 0644]
linux/log.c [new file with mode: 0644]
linux/system/graphics.h [new file with mode: 0644]
linux/utils/Log.h [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..dbe8702
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,18 @@
+LIBHARDWARE?=../../../../hardware/libhardware/
+CFLAGS=-DLOG_TAG=\"sens\" -I$(LIBHARDWARE)include/ -I./linux -fPIC
+LDFLAGS=-ldl -lpthread -lm -lrt
+
+all: sensors-hal.so sens
+
+linux_src = linux/log.o
+
+sens: sens.o $(linux_src)
+       cc -o $@ $^ $(LDFLAGS)
+
+hal_src = entry.c enumeration.c control.c description.c utils.c transform.c compass-calibration.c matrix-ops.c \
+
+sensors-hal.so: $(patsubst %.c,%.o,$(hal_src) $(linux_src))
+       cc -o $@ $^ $(LDFLAGS) -shared
+
+clean:
+       -rm $(patsubst %.c,%.o,$(hal_src) $(linux_src) sens.c) sens sensors-hal.so 2>/dev/null
diff --git a/linux/cutils/native_handle.h b/linux/cutils/native_handle.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/linux/cutils/properties.h b/linux/cutils/properties.h
new file mode 100644 (file)
index 0000000..fbb1f9b
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2014 Intel Corporation.
+ */
+
+#ifndef _LINUX_APROP_H
+#define _LINUX_APROP_H
+
+#define PROP_VALUE_MAX 16
+#define PROP_NAME_MAX 16
+
+static inline int property_get(const char *name, const char *val, const char *x)
+{
+       return 0;
+}
+
+#endif
diff --git a/linux/log.c b/linux/log.c
new file mode 100644 (file)
index 0000000..3d1dd25
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2014 Intel Corporation.
+ */
+
+#include <stdarg.h>
+#include <syslog.h>
+
+static int log;
+
+int __android_log_print(int prio, const char *tag, const char *fmt, ...)
+{
+       va_list args;
+       int loglevel;
+
+       if (!log) {
+               openlog("android", LOG_CONS, LOG_DAEMON);
+               log = 1;
+       }
+
+       switch (prio) {
+       default:
+       case 0:
+       case 1:
+               loglevel = LOG_INFO;
+               break;
+       case 2:
+       case 3:
+               loglevel = LOG_DEBUG;
+               break;
+       case 4:
+               loglevel = LOG_NOTICE;
+               break;
+       case 5:
+               loglevel = LOG_WARNING;
+               break;
+       case 6:
+               loglevel = LOG_ERR;
+               break;
+       case 7:
+               loglevel = LOG_EMERG;
+               break;
+       }
+
+       va_start(args, fmt);
+       vsyslog(loglevel, fmt, args);
+       va_end(args);
+
+       return 0;
+}
diff --git a/linux/system/graphics.h b/linux/system/graphics.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/linux/utils/Log.h b/linux/utils/Log.h
new file mode 100644 (file)
index 0000000..46cc485
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2014 Intel Corporation.
+ */
+
+#ifndef _LINUX_ALOG_H
+#define _LINUX_ALOG_H
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <linux/limits.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+
+#ifndef ALOGE
+#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#endif
+
+#ifndef ALOGI
+#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
+#endif
+
+#ifndef ALOGD
+#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#endif
+
+#ifndef ALOGW
+#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
+#endif
+
+#ifndef ALOGV
+#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#endif
+
+#ifndef ALOG
+#define ALOG(priority, tag, ...) \
+    LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
+#endif
+
+#ifndef LOG_PRI
+#define LOG_PRI(priority, tag, ...) \
+    android_printLog(priority, tag, __VA_ARGS__)
+#endif
+
+#define android_printLog(prio, tag, fmt...) \
+    __android_log_print(prio, tag, fmt)
+
+typedef enum android_LogPriority {
+       ANDROID_LOG_UNKNOWN = 0,
+       ANDROID_LOG_DEFAULT,    /* only for SetMinPriority() */
+       ANDROID_LOG_VERBOSE,
+       ANDROID_LOG_DEBUG,
+       ANDROID_LOG_INFO,
+       ANDROID_LOG_WARN,
+       ANDROID_LOG_ERROR,
+       ANDROID_LOG_FATAL,
+       ANDROID_LOG_SILENT,     /* only for SetMinPriority(); must be last */
+} android_LogPriority;
+
+extern int __android_log_print(int prio, const char *tag, const char *fmt, ...);
+
+#endif
+