Skip to contentSkip to conversation

build: Add skeleton for BlueZ Android

PATCH Superseded Frederic Danis 1 participant 3 messages Sep 24, 2013

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 build: Add skeleton for BlueZ Android

---
 Makefile.am         |    4 +++-
 Makefile.android    |    4 ++++
 android/Android.mk  |    5 +++++
 bootstrap-configure |    3 ++-
 configure.ac        |    4 ++++
 5 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 Makefile.android
 create mode 100644 android/Android.mk
Makefile.am +3 -1
index 4e4b1c5..51204f4 100644
@@ -179,6 +179,7 @@ test_scripts =
 
 include Makefile.tools
 include Makefile.obexd
+include Makefile.android
 
 if HID2HCI
 rulesdir = @UDEV_DIR@/rules.d
@@ -293,7 +294,8 @@ pkgconfig_DATA = lib/bluez.pc
 endif
 
 DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles --enable-library \
-					--disable-systemd --disable-udev
+					--disable-systemd --disable-udev \
+					--enable-android
 
 DISTCLEANFILES = $(pkgconfig_DATA)
 
Makefile.android new file +4 -0
new file mode 100644
index 0000000..5e43730
@@ -0,0 +1,4 @@
+
+if ANDROID
+EXTRA_DIST += android/Android.mk
+endif
android/Android.mk new file +5 -0
new file mode 100644
index 0000000..31e2c1e
@@ -0,0 +1,5 @@
+LOCAL_PATH := $(call my-dir)
+
+# Retrieve BlueZ version from configure.ac file
+BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/../configure.ac | cpp -P -D'AC_INIT(_,v)=v')
+
bootstrap-configure +2 -1
index 7a6e7d1..8bde920 100755
@@ -12,4 +12,5 @@ fi
 		--sysconfdir=/etc \
 		--localstatedir=/var \
 		--enable-experimental \
-		--disable-datafiles $*
+		--disable-datafiles \
+		--enable-android $*
configure.ac +4 -0
index 41c2935..22ab240 100644
@@ -242,4 +242,8 @@ AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
 			[Directory for the configuration files])
 AC_SUBST(CONFIGDIR, "${configdir}")
 
+AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android],
+			[enable BlueZ Android]), [android=${enableval}])
+AM_CONDITIONAL(ANDROID, test "${android}" = "yes")
+
 AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 2/3 android: Add skeleton of BlueZ Android daemon

Define local mapping to glib path, otherwise this has to be inside central place in the build repository.

Retrieve Bluetooth version from configure.ac.

---
 .gitignore         |    2 +
 Makefile.android   |    5 +++
 android/Android.mk |   24 ++++++++++++
 android/main.c     |  110 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+)
 create mode 100644 android/main.c
.gitignore +2 -0
index 8a25a3e..3707209 100644
@@ -98,3 +98,5 @@ unit/test-gobex-packet
 unit/test-gobex-transfer
 unit/test-*.log
 unit/test-*.trs
+
+android/bluetoothd
Makefile.android +5 -0
index 5e43730..e056dce 100644
@@ -1,4 +1,9 @@
 
 if ANDROID
+noinst_PROGRAMS += android/bluetoothd
+
+android_bluetoothd_SOURCES = android/main.c
+android_bluetoothd_LDADD = @GLIB_LIBS@
+
 EXTRA_DIST += android/Android.mk
 endif
android/Android.mk +24 -0
index 31e2c1e..fc3d6c2 100644
@@ -3,3 +3,27 @@ LOCAL_PATH := $(call my-dir)
 # Retrieve BlueZ version from configure.ac file
 BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/../configure.ac | cpp -P -D'AC_INIT(_,v)=v')
 
+# Specify pathmap for glib
+pathmap_INCL += glib:external/bluetooth/glib
+
+#
+# Android BlueZ daemon (bluetoothd)
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	main.c \
+
+LOCAL_C_INCLUDES := \
+	$(call include-path-for, glib) \
+	$(call include-path-for, glib)/glib \
+
+LOCAL_CFLAGS := -DVERSION=\"$(BLUEZ_VERSION)\"
+
+LOCAL_SHARED_LIBRARIES := \
+	libglib \
+
+LOCAL_MODULE := bluetoothd
+
+include $(BUILD_EXECUTABLE)
android/main.c new file +110 -0

110 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 3/3 android: Android version of log.c

In reply to Frederic Danis

Add logging system to BlueZ Android daemon.
Android build will use android/log.c file while autotools build will use src/log.c instead.

---
 Makefile.android   |    4 +-
 android/Android.mk |    1 +
 android/log.c      |  172 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 android/main.c     |   34 +++++++++++
 4 files changed, 209 insertions(+), 2 deletions(-)
 create mode 100644 android/log.c
Makefile.android +2 -2
index e056dce..1184e5f 100644
@@ -2,8 +2,8 @@
 if ANDROID
 noinst_PROGRAMS += android/bluetoothd
 
-android_bluetoothd_SOURCES = android/main.c
+android_bluetoothd_SOURCES = android/main.c src/log.c
 android_bluetoothd_LDADD = @GLIB_LIBS@
 
-EXTRA_DIST += android/Android.mk
+EXTRA_DIST += android/Android.mk android/log.c
 endif
android/Android.mk +1 -0
index fc3d6c2..e3f0fd7 100644
@@ -14,6 +14,7 @@ include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
 	main.c \
+	log.c \
 
 LOCAL_C_INCLUDES := \
 	$(call include-path-for, glib) \
android/log.c new file +172 -0

172 lines not on this page · raw message

android/main.c +34 -0
index 1dba2d4..c0a56b1 100644
@@ -34,6 +34,8 @@
 
 #include <glib.h>
 
+#include "log.h"
+
 #define SHUTDOWN_GRACE_SECONDS 10
 
 static GMainLoop *event_loop;
@@ -57,10 +59,31 @@ static void sig_term(int sig)
 	__terminated = true;
 }
 
+static char *option_debug = NULL;
 static gboolean option_detach = TRUE;
 static gboolean option_version = FALSE;
 
+static void free_options(void)
+{
+	g_free(option_debug);
+	option_debug = NULL;
+}
+
+static gboolean parse_debug(const char *key, const char *value,
+				gpointer user_data, GError **error)
+{
+	if (value)
+		option_debug = g_strdup(value);
+	else
+		option_debug = g_strdup("*");
+
+	return TRUE;
+}
+
 static GOptionEntry options[] = {
+	{ "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
+				G_OPTION_ARG_CALLBACK, parse_debug,
+				"Specify debug options to enable", "DEBUG" },
 	{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
 				G_OPTION_ARG_NONE, &option_detach,
 				"Run with logging in foreground", NULL },
@@ -102,9 +125,20 @@ int main(int argc, char *argv[])
 	sigaction(SIGINT, &sa, NULL);
 	sigaction(SIGTERM, &sa, NULL);
 
+	__btd_log_init(option_debug, option_detach);
+
+	/* no need to keep parsed option in memory */
+	free_options();
+
+	DBG("Entering main loop");
+
 	g_main_loop_run(event_loop);
 
 	g_main_loop_unref(event_loop);
 
+	info("Exit");
+
+	__btd_log_cleanup();
+
 	return EXIT_SUCCESS;
 }
Signature · 1 line
1.7.9.5