Skip to contentSkip to conversation

build: Add skeleton for BlueZ Android

PATCH Superseded Frederic Danis 4 participants 10 messages Sep 24, 2013 – Sep 30, 2013

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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..e810654
@@ -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 | tr -d ' ' | sed -e 's/.*(.*,\(.*\))/\1/')
+
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 v2 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 e810654..06a93b3 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 | tr -d ' ' | sed -e 's/.*(.*,\(.*\))/\1/')
 
+# 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
maintainer
#2 lore raw

Re: [PATCH v2 2/3] android: Add skeleton of BlueZ Android daemon

Hi Fred,

Quoted 7 lines

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 +++

I rather keep the changes to a global Makefile separate from the android/ stuff.

Quoted 4 lines

android/Android.mk | 24 ++++++++++++
android/main.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++

4 files changed, 141 insertions(+)

create mode 100644 android/main.c

It is perfectly fine to split this into two patches. Add the *.c file(s) first and in a second patch add the build changes.

Quoted 22 lines
.gitignore +0 -0
index 8a25a3e..3707209 100644
@@ -98,3 +98,5 @@ unit/test-gobex-packet

unit/test-gobex-transfer
unit/test-*.log
unit/test-*.trs

.gitignore +2 -0
+
+android/bluetoothd
Makefile.android +0 -0
index 5e43730..e056dce 100644
@@ -1,4 +1,9 @@
 

if ANDROID

Makefile.android +5 -0
+noinst_PROGRAMS += android/bluetoothd
+
+android_bluetoothd_SOURCES = android/main.c
+android_bluetoothd_LDADD = @GLIB_LIBS@
+
Quoted 2 lines

EXTRA_DIST += android/Android.mk
endif

You can not put the EXTRA_DIST under an if ANDROID. Make that part global.

I expect that make distcheck works no matter what is configured. Check the final tarballs if all files are actually included.

Regards

Marcel

#3 lore raw

Re: [PATCH v2 2/3] android: Add skeleton of BlueZ Android daemon

Hello Marcel,

Quoted 7 lines · Marcel Holtmann
Quoted 7 lines

Define local mapping to glib path, otherwise this has to be inside central

Quoted 6 lines

place in the build repository.

Retrieve Bluetooth version from configure.ac.
---

.gitignore         |    2 +
Makefile.android   |    5 +++
Quoted 8 lines

I rather keep the changes to a global Makefile separate from the android/ stuff.

Quoted 4 lines
Quoted 4 lines

android/Android.mk | 24 ++++++++++++
android/main.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++

4 files changed, 141 insertions(+)

create mode 100644 android/main.c

It is perfectly fine to split this into two patches. Add the *.c file(s) first and in a second patch add the build changes.

Ok, so I will send .gitignore, Makefile.android and Android.mk in a second patch.

Regards

Fred

Signature · 2 lines
Frederic Danis                            Open Source Technology Center
[email protected]                              Intel Corporation
#4 lore raw

PATCH v2 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 06a93b3..04413de 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
maintainer
#5 lore raw

Re: [PATCH v2 3/3] android: Android version of log.c

Hi Fred,

Quoted 3 lines

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

lets just use stdout for now. Changing this later is pretty trivial and introducing large build alternates is a bit too complicated at this point.

Regards

Marcel

#6 lore raw

Re: [PATCH v2 3/3] android: Android version of log.c

Hello Marcel,

Quoted 4 lines · Marcel Holtmann
Quoted 3 lines

Add logging system to BlueZ Android daemon.

Quoted 2 lines

Android build will use android/log.c file while autotools build will use src/log.c instead.

lets just use stdout for now. Changing this later is pretty trivial and introducing large build alternates is a bit too complicated at this point.

I do not understand how writing code to log to stdout can be more simple than building and linking existing code.

Regards

Fred

Signature · 2 lines
Frederic Danis                            Open Source Technology Center
[email protected]                              Intel Corporation
#7 lore raw

Re: [PATCH v2 3/3] android: Android version of log.c

Hi,

"Frederic Danis" <[email protected]>

Quoted 8 lines

Hello Marcel,

Quoted 3 lines · Marcel Holtmann
Quoted 3 lines

Add logging system to BlueZ Android daemon.

Quoted 1 line

Android build will use android/log.c file while autotools build will

use

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

src/log.c instead.

lets just use stdout for now. Changing this later is pretty trivial and

introducing large build alternates is a bit too complicated at this point.

Quoted 3 lines

I do not understand how writing code to log to stdout can be more simple

than building and linking existing code.

I agree with Frederic here. Why do we use error, warn, DBG, etc if we print to stdout?

This actually will significantly slow log parsing since first you pay attention to error messages. If all messages are printed with the same priorities then we loose this ability.

Regards,
Andrei

#8 lore raw
In reply to Frederic Danis

Hi Frederic,

android/Android.mk line 4

Quoted 7 lines · Frederic Danis
android/Android.mk new file +4 -0
@@ -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 | tr -d ' ' | sed -e 's/.*(.*,\(.*\))/\1/')

It also works if you use the C preprocessor to get the version:

BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/../configure.ac | cpp -P -D'AC_INIT(_,v)=v')

Best Regards,

Signature · 3 lines
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
maintainer
#9 lore raw
In reply to Frederic Danis

Hi Fred,

Quoted 37 lines
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 +0 -0
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

Makefile.am +0 -0
@@ -293,7 +294,8 @@ pkgconfig_DATA = lib/bluez.pc

endif

DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles --enable-library \

Makefile.am +2 -1
-					--disable-systemd --disable-udev
+					--disable-systemd --disable-udev \
+					--enable-android

DISTCLEANFILES = $(pkgconfig_DATA)

Makefile.android new file +0 -0
new file mode 100644
index 0000000..5e43730

Makefile.android line 4

Quoted 4 lines
Makefile.android new file +4 -0
@@ -0,0 +1,4 @@
+
+if ANDROID
+EXTRA_DIST += android/Android.mk
+endif

as I mentioned in another patch. No need for if around EXTRA_DIST.

Quoted 16 lines
android/Android.mk new file +5 -0
new file mode 100644
index 0000000..e810654
@@ -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 | tr -d ' ' | sed -e 's/.*(.*,\(.*\))/\1/')
+
bootstrap-configure +0 -0
index 7a6e7d1..8bde920 100755

bootstrap-configure fi · line 16

Quoted 6 lines
bootstrap-configure +2 -1
@@ -12,4 +12,5 @@ fi
 		--sysconfdir=/etc \
 		--localstatedir=/var \
 		--enable-experimental \
-		--disable-datafiles $*
+		--disable-datafiles \
+		--enable-android $*

Historically --disable-datafiles is always last. And I like to keep it that way. Please add it after --enable-experimental.

configure.ac AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}", · line 246

Quoted 10 lines
configure.ac +2 -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}])

I would call it BlueZ for Android, but that is minor details.

configure.ac AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}", · line 247

Quoted 1 line
configure.ac +1 -0
+AM_CONDITIONAL(ANDROID, test "${android}" = "yes")

However this should be ${enable_android} like with every other configure option we have.

configure.ac AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}", · line 249

Quoted 2 lines
configure.ac +1 -0
+
 AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)

Regards

Marcel