Skip to contentSkip to conversation

Add Android build support

PATCH In review Gary Bisson 2 participants 13 messages Jun 8, 2020 – Aug 18, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Add Android build support

Hi,

This series adds support to build libgpiod library and tools as part of an Android build.

Some comments are included into the individual patches, to explain the choices made.

This was tested inside an Android 10 AOSP tree.

Let me know if you have any questions.

Regards,
Gary

Gary Bisson (3):
core: add missing header inclusion
tools-common: fix build for Android
Android.bp: initial addition

 Android.bp           | 95 ++++++++++++++++++++++++++++++++++++++++++++
 lib/core.c           |  1 +
 tools/tools-common.c | 10 +++--
 3 files changed, 103 insertions(+), 3 deletions(-)
 create mode 100644 Android.bp
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/3 core: add missing header inclusion

Otherwise throwing the following error:
lib/core.c:102:9: error: implicit declaration of function 'basename' is invalid in C99

---
 lib/core.c | 1 +
 1 file changed, 1 insertion(+)
lib/core.c +1 -0
index f704b44..b71a284 100644
@@ -10,6 +10,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <gpiod.h>
+#include <libgen.h>
 #include <limits.h>
 #include <linux/gpio.h>
 #include <poll.h>
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/3 tools-common: fix build for Android

In reply to Gary Bisson

program_invocation_name doesn't exist in Android, getprogname() should be used instead.

---
Hi,

I couldn't an equivalent to program_invocation_short_name, so the program is now using program_invocation_name all the time, hope it's ok.

Regards,
Gary

---
 tools/tools-common.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tools/tools-common.c +7 -3
index 12bde20..1d7fc2c 100644
@@ -21,7 +21,11 @@
 
 const char *get_progname(void)
 {
+#if defined __ANDROID__
+	return getprogname();
+#else
 	return program_invocation_name;
+#endif
 }
 
 void die(const char *fmt, ...)
@@ -29,7 +33,7 @@ void die(const char *fmt, ...)
 	va_list va;
 
 	va_start(va, fmt);
-	fprintf(stderr, "%s: ", program_invocation_name);
+	fprintf(stderr, "%s: ", get_progname());
 	vfprintf(stderr, fmt, va);
 	fprintf(stderr, "\n");
 	va_end(va);
@@ -42,7 +46,7 @@ void die_perror(const char *fmt, ...)
 	va_list va;
 
 	va_start(va, fmt);
-	fprintf(stderr, "%s: ", program_invocation_name);
+	fprintf(stderr, "%s: ", get_progname());
 	vfprintf(stderr, fmt, va);
 	fprintf(stderr, ": %s\n", strerror(errno));
 	va_end(va);
@@ -53,7 +57,7 @@ void die_perror(const char *fmt, ...)
 void print_version(void)
 {
 	printf("%s (libgpiod) v%s\n",
-	       program_invocation_short_name, gpiod_version_string());
+	       get_progname(), gpiod_version_string());
 	printf("Copyright (C) 2017-2018 Bartosz Golaszewski\n");
 	printf("License: LGPLv2.1\n");
 	printf("This is free software: you are free to change and redistribute it.\n");
Signature · 1 line
2.26.2
#3 lore raw

Re: [libgpiod][PATCH 2/3] tools-common: fix build for Android

Quoted 22 lines · Gary Bisson

program_invocation_name doesn't exist in Android, getprogname() should be used instead.

---
Hi,

I couldn't an equivalent to program_invocation_short_name, so the program is now using program_invocation_name all the time, hope it's ok.

Regards,
Gary

---
 tools/tools-common.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tools/tools-common.c +0 -0
index 12bde20..1d7fc2c 100644

tools/tools-common.c line 24

Quoted 4 lines
tools/tools-common.c +1 -0
@@ -21,7 +21,11 @@
 
 const char *get_progname(void)
 {
+#if defined __ANDROID__

I'd prefer to keep libgpiod Android-agnostic. Does prctl() exist in Android? It too can be used for that.

Bartosz

Quoted 37 lines
tools/tools-common.c +6 -4
+       return getprogname();
+#else
        return program_invocation_name;
+#endif
 }
 
 void die(const char *fmt, ...)
@@ -29,7 +33,7 @@ void die(const char *fmt, ...)
        va_list va;
 
        va_start(va, fmt);
-       fprintf(stderr, "%s: ", program_invocation_name);
+       fprintf(stderr, "%s: ", get_progname());
        vfprintf(stderr, fmt, va);
        fprintf(stderr, "\n");
        va_end(va);
@@ -42,7 +46,7 @@ void die_perror(const char *fmt, ...)
        va_list va;
 
        va_start(va, fmt);
-       fprintf(stderr, "%s: ", program_invocation_name);
+       fprintf(stderr, "%s: ", get_progname());
        vfprintf(stderr, fmt, va);
        fprintf(stderr, ": %s\n", strerror(errno));
        va_end(va);
@@ -53,7 +57,7 @@ void die_perror(const char *fmt, ...)
 void print_version(void)
 {
        printf("%s (libgpiod) v%s\n",
-              program_invocation_short_name, gpiod_version_string());
+              get_progname(), gpiod_version_string());
        printf("Copyright (C) 2017-2018 Bartosz Golaszewski\n");
        printf("License: LGPLv2.1\n");
        printf("This is free software: you are free to change and redistribute it.\n");
--

2.26.2

#4 lore raw

Re: [libgpiod][PATCH 2/3] tools-common: fix build for Android

Hi,

Sorry for the delay.

Quoted 25 lines · Bartosz Golaszewski
Quoted 23 lines · Gary Bisson

program_invocation_name doesn't exist in Android, getprogname() should be used instead.

---
Hi,

I couldn't an equivalent to program_invocation_short_name, so the program is now using program_invocation_name all the time, hope it's ok.

Regards,
Gary

---
 tools/tools-common.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tools/tools-common.c +0 -0
index 12bde20..1d7fc2c 100644
@@ -21,7 +21,11 @@
 
Quoted 6 lines

tools/tools-common.c line 24

Quoted 3 lines
tools/tools-common.c +1 -0
 const char *get_progname(void)
 {
+#if defined __ANDROID__

I'd prefer to keep libgpiod Android-agnostic. Does prctl() exist in Android? It too can be used for that.

Yes I understand. prctl() can be used in Android so it would definitely be a better option.

Regards,
Gary

#5 lore raw

Re: [libgpiod][PATCH 2/3] tools-common: fix build for Android

Quoted 38 lines · Gary Bisson

Hi,

Sorry for the delay.

Quoted 25 lines · Bartosz Golaszewski
Quoted 23 lines · Gary Bisson

program_invocation_name doesn't exist in Android, getprogname() should be used instead.

---
Hi,

I couldn't an equivalent to program_invocation_short_name, so the program is now using program_invocation_name all the time, hope it's ok.

Regards,
Gary

---
 tools/tools-common.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tools/tools-common.c +0 -0
index 12bde20..1d7fc2c 100644
@@ -21,7 +21,11 @@
 
Quoted 6 lines

tools/tools-common.c line 24

Quoted 3 lines
tools/tools-common.c +1 -0
 const char *get_progname(void)
 {
+#if defined __ANDROID__

I'd prefer to keep libgpiod Android-agnostic. Does prctl() exist in Android? It too can be used for that.

Quoted 5 lines

Yes I understand. prctl() can be used in Android so it would definitely be a better option.

Regards,
Gary

The name returned by prctl(PR_GET_NAME, ...) is equivalent to program_invocation_short_name. That would mean ditching the full executable path everywhere in messages. Alternatively we can just set the full program name at the start of every tool. I'm fine with the latter too as long as we don't stick these __ANDROID__ ifdefs in the tree.

Bart

#6 lore raw

Re: [libgpiod][PATCH 2/3] tools-common: fix build for Android

Hi,

Quoted 46 lines · Bartosz Golaszewski
Quoted 38 lines · Gary Bisson

Hi,

Sorry for the delay.

Quoted 25 lines · Bartosz Golaszewski
Quoted 23 lines · Gary Bisson

program_invocation_name doesn't exist in Android, getprogname() should be used instead.

---
Hi,

I couldn't an equivalent to program_invocation_short_name, so the program is now using program_invocation_name all the time, hope it's ok.

Regards,
Gary

---
 tools/tools-common.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tools/tools-common.c +0 -0
index 12bde20..1d7fc2c 100644
@@ -21,7 +21,11 @@
 
Quoted 6 lines

tools/tools-common.c line 24

Quoted 3 lines
tools/tools-common.c +1 -0
 const char *get_progname(void)
 {
+#if defined __ANDROID__

I'd prefer to keep libgpiod Android-agnostic. Does prctl() exist in Android? It too can be used for that.

Quoted 5 lines

Yes I understand. prctl() can be used in Android so it would definitely be a better option.

Regards,
Gary

Quoted 6 lines

The name returned by prctl(PR_GET_NAME, ...) is equivalent to program_invocation_short_name. That would mean ditching the full executable path everywhere in messages. Alternatively we can just set the full program name at the start of every tool. I'm fine with the latter too as long as we don't stick these __ANDROID__ ifdefs in the tree.

Ok, I'll test this and send a v2. Might not be before next week though.

Regards,
Gary

#7 lore raw

PATCH 3/3 Android.bp: initial addition

In reply to Gary Bisson

- Defines both shared and static versions of libgpiod
- Defines all the libs/tools as vendor (installed in /vendor)

---
Hi,

One thing that isn't ideal here is to set GPIOD_VERSION_STR manually, that will require to keep track of it for all versions.

Not sure if there's a better way to provide that value to Android.bp.

Regards,
Gary

---
 Android.bp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 Android.bp
Android.bp new file +95 -0
new file mode 100644
index 0000000..6c437df
@@ -0,0 +1,95 @@
+cc_library_shared {
+    name: "libgpiod",
+    vendor: true,
+    srcs: [
+        "lib/core.c",
+        "lib/ctxless.c",
+        "lib/helpers.c",
+        "lib/iter.c",
+        "lib/misc.c",
+    ],
+    cflags: ["-Werror", "-Wno-macro-redefined", "-DGPIOD_VERSION_STR=\"1.6-devel\""],
+    export_include_dirs: ["include"],
+    local_include_dirs: ["include"],
+}
+
+cc_library_static {
+    name: "libgpiod_static",
+    vendor: true,
+    srcs: [
+        "lib/core.c",
+        "lib/ctxless.c",
+        "lib/helpers.c",
+        "lib/iter.c",
+        "lib/misc.c",
+    ],
+    cflags: ["-Werror", "-Wno-macro-redefined", "-DGPIOD_VERSION_STR=\"1.6-devel\""],
+    export_include_dirs: ["include"],
+    local_include_dirs: ["include"],
+}
+
+cc_binary {
+    name: "gpiodetect",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiodetect.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpiofind",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiofind.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioget",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioget.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioinfo",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioinfo.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpiomon",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiomon.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioset",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioset.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
Signature · 1 line
2.26.2
#8 lore raw

Re: [libgpiod][PATCH 3/3] Android.bp: initial addition

Quoted 4 lines · Gary Bisson

- Defines both shared and static versions of libgpiod
- Defines all the libs/tools as vendor (installed in /vendor)

Quoted 9 lines

---
Hi,

One thing that isn't ideal here is to set GPIOD_VERSION_STR manually, that will require to keep track of it for all versions.

Not sure if there's a better way to provide that value to Android.bp.

I don't know Android very well but if its build system can launch autotools, then maybe you could autotoolify this file by providing Android.bp.in and letting autotools expand this macro?

Quoted 109 lines

Regards,
Gary

---
 Android.bp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 Android.bp
Android.bp new file +95 -1
new file mode 100644
index 0000000..6c437df
@@ -0,0 +1,95 @@
+cc_library_shared {
+    name: "libgpiod",
+    vendor: true,
+    srcs: [
+        "lib/core.c",
+        "lib/ctxless.c",
+        "lib/helpers.c",
+        "lib/iter.c",
+        "lib/misc.c",
+    ],
+    cflags: ["-Werror", "-Wno-macro-redefined", "-DGPIOD_VERSION_STR=\"1.6-devel\""],
+    export_include_dirs: ["include"],
+    local_include_dirs: ["include"],
+}
+
+cc_library_static {
+    name: "libgpiod_static",
+    vendor: true,
+    srcs: [
+        "lib/core.c",
+        "lib/ctxless.c",
+        "lib/helpers.c",
+        "lib/iter.c",
+        "lib/misc.c",
+    ],
+    cflags: ["-Werror", "-Wno-macro-redefined", "-DGPIOD_VERSION_STR=\"1.6-devel\""],
+    export_include_dirs: ["include"],
+    local_include_dirs: ["include"],
+}
+
+cc_binary {
+    name: "gpiodetect",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiodetect.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpiofind",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiofind.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioget",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioget.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioinfo",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioinfo.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpiomon",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiomon.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioset",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioset.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
--
Quoted 2 lines

2.26.2

Can I somehow test this build file on linux? We'll surely be expanding libgpiod in the future so I need to be able to update this file.

Bartosz

#9 lore raw

Re: [libgpiod][PATCH 3/3] Android.bp: initial addition

Hi,

Quoted 13 lines · Bartosz Golaszewski
Quoted 11 lines · Gary Bisson

- Defines both shared and static versions of libgpiod
- Defines all the libs/tools as vendor (installed in /vendor)

---
Hi,

One thing that isn't ideal here is to set GPIOD_VERSION_STR manually, that will require to keep track of it for all versions.

Quoted 6 lines
Quoted 2 lines

Not sure if there's a better way to provide that value to Android.bp.

I don't know Android very well but if its build system can launch autotools, then maybe you could autotoolify this file by providing Android.bp.in and letting autotools expand this macro?

No unfortunately that is not how the AOSP build system works (or at least I'm not aware of it).
AFAIK all the open-source projects used in AOSP (see external/ folder) have a separate Android.bp alongside the autotools files.

Here are a few examples of Android.bp files added by Google to well-known projects:
- curl [1]
- iputils [2]
- strace [3]

In the case above it is up to Google to maintain that file as only hosted on their servers (not merged upstream).
But some other projects are ok merging it which makes it easier (at least for me) like can-utils [4].

Quoted 106 lines
Quoted 106 lines

Regards,
Gary

---
 Android.bp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 Android.bp
Android.bp new file +93 -0
new file mode 100644
index 0000000..6c437df
@@ -0,0 +1,95 @@
+cc_library_shared {
+    name: "libgpiod",
+    vendor: true,
+    srcs: [
+        "lib/core.c",
+        "lib/ctxless.c",
+        "lib/helpers.c",
+        "lib/iter.c",
+        "lib/misc.c",
+    ],
+    cflags: ["-Werror", "-Wno-macro-redefined", "-DGPIOD_VERSION_STR=\"1.6-devel\""],
+    export_include_dirs: ["include"],
+    local_include_dirs: ["include"],
+}
+
+cc_library_static {
+    name: "libgpiod_static",
+    vendor: true,
+    srcs: [
+        "lib/core.c",
+        "lib/ctxless.c",
+        "lib/helpers.c",
+        "lib/iter.c",
+        "lib/misc.c",
+    ],
+    cflags: ["-Werror", "-Wno-macro-redefined", "-DGPIOD_VERSION_STR=\"1.6-devel\""],
+    export_include_dirs: ["include"],
+    local_include_dirs: ["include"],
+}
+
+cc_binary {
+    name: "gpiodetect",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiodetect.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpiofind",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiofind.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioget",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioget.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioinfo",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioinfo.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpiomon",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiomon.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioset",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioset.c",
+    ],
+    shared_libs: ["libgpiod"],
Quoted 8 lines
Quoted 5 lines
Android.bp new file +2 -1
+    cflags: ["-Werror"],
+}
--

2.26.2

Can I somehow test this build file on linux? We'll surely be expanding libgpiod in the future so I need to be able to update this file.

I'm not sure what's the easiest way to get you a build env. In my case I use the full AOSP tree [5][6] which might not be ideal for you as it involves pulling 40G+ of data.
For me the commands were:

$ source build/envsetup.sh
$ lunch aosp_arm-eng
$ mmm external/libgpiod

Maybe someone else has a way to setup a Soong build without pulling everything.

Let me know if you have any questions.

Regards,
Gary

[1] https://android.googlesource.com/platform/external/curl/+/refs/heads/master/Android.bp
[2] https://android.googlesource.com/platform/external/iputils/+/refs/heads/master/Android.bp
[3] https://android.googlesource.com/platform/external/strace/+/refs/heads/master/Android.bp
[4] https://github.com/linux-can/can-utils/blob/master/Android.mk
[5] https://source.android.com/setup/build/downloading
[6] https://source.android.com/setup/build/building

#10 lore raw

Re: [libgpiod][PATCH 3/3] Android.bp: initial addition

Quoted 35 lines · Gary Bisson

Hi,

Quoted 13 lines · Bartosz Golaszewski
Quoted 11 lines · Gary Bisson

- Defines both shared and static versions of libgpiod
- Defines all the libs/tools as vendor (installed in /vendor)

---
Hi,

One thing that isn't ideal here is to set GPIOD_VERSION_STR manually, that will require to keep track of it for all versions.

Quoted 6 lines
Quoted 2 lines

Not sure if there's a better way to provide that value to Android.bp.

I don't know Android very well but if its build system can launch autotools, then maybe you could autotoolify this file by providing Android.bp.in and letting autotools expand this macro?

No unfortunately that is not how the AOSP build system works (or at least I'm not aware of it).
AFAIK all the open-source projects used in AOSP (see external/ folder) have a separate Android.bp alongside the autotools files.

Here are a few examples of Android.bp files added by Google to well-known projects:
- curl [1]
- iputils [2]
- strace [3]

Quoted 5 lines

In the case above it is up to Google to maintain that file as only hosted on their servers (not merged upstream).
But some other projects are ok merging it which makes it easier (at least for me) like can-utils [4].

I'm perfectly fine with merging this file but I don't like having another place to look at when bumping the version number. I bunched up all API and ABI versions together in configure.ac in order to not forget anything when making new releases.

I'm sure Android's build system is not as limited as not to allow to run some external scripts that would at least fetch the current version from configure.ac, is it?

Quoted 131 lines
Quoted 106 lines
Quoted 106 lines

Regards,
Gary

---
 Android.bp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 Android.bp
Android.bp new file +93 -0
new file mode 100644
index 0000000..6c437df
@@ -0,0 +1,95 @@
+cc_library_shared {
+    name: "libgpiod",
+    vendor: true,
+    srcs: [
+        "lib/core.c",
+        "lib/ctxless.c",
+        "lib/helpers.c",
+        "lib/iter.c",
+        "lib/misc.c",
+    ],
+    cflags: ["-Werror", "-Wno-macro-redefined", "-DGPIOD_VERSION_STR=\"1.6-devel\""],
+    export_include_dirs: ["include"],
+    local_include_dirs: ["include"],
+}
+
+cc_library_static {
+    name: "libgpiod_static",
+    vendor: true,
+    srcs: [
+        "lib/core.c",
+        "lib/ctxless.c",
+        "lib/helpers.c",
+        "lib/iter.c",
+        "lib/misc.c",
+    ],
+    cflags: ["-Werror", "-Wno-macro-redefined", "-DGPIOD_VERSION_STR=\"1.6-devel\""],
+    export_include_dirs: ["include"],
+    local_include_dirs: ["include"],
+}
+
+cc_binary {
+    name: "gpiodetect",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiodetect.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpiofind",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiofind.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioget",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioget.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioinfo",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioinfo.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpiomon",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpiomon.c",
+    ],
+    shared_libs: ["libgpiod"],
+    cflags: ["-Werror"],
+}
+
+cc_binary {
+    name: "gpioset",
+    vendor: true,
+    srcs: [
+        "tools/tools-common.c",
+        "tools/gpioset.c",
+    ],
+    shared_libs: ["libgpiod"],
Quoted 8 lines
Quoted 5 lines
Android.bp new file +2 -1
+    cflags: ["-Werror"],
+}
--

2.26.2

Can I somehow test this build file on linux? We'll surely be expanding libgpiod in the future so I need to be able to update this file.

I'm not sure what's the easiest way to get you a build env. In my case I use the full AOSP tree [5][6] which might not be ideal for you as it involves pulling 40G+ of data.
For me the commands were:

$ source build/envsetup.sh
$ lunch aosp_arm-eng
$ mmm external/libgpiod

Maybe someone else has a way to setup a Soong build without pulling everything.

Let me know if you have any questions.

Regards,
Gary

Quoted 6 lines

[1] https://android.googlesource.com/platform/external/curl/+/refs/heads/master/Android.bp
[2] https://android.googlesource.com/platform/external/iputils/+/refs/heads/master/Android.bp
[3] https://android.googlesource.com/platform/external/strace/+/refs/heads/master/Android.bp
[4] https://github.com/linux-can/can-utils/blob/master/Android.mk
[5] https://source.android.com/setup/build/downloading
[6] https://source.android.com/setup/build/building

Thanks for the links. I have access to a build server so at least for now I can fetch the whole tree alright.

Bartosz

#11 lore raw

Re: [libgpiod][PATCH 3/3] Android.bp: initial addition

Quoted 1 line · Bartosz Golaszewski

[snip]

Quoted 22 lines
Quoted 16 lines
Quoted 4 lines

I don't know Android very well but if its build system can launch autotools, then maybe you could autotoolify this file by providing Android.bp.in and letting autotools expand this macro?

No unfortunately that is not how the AOSP build system works (or at least I'm not aware of it).
AFAIK all the open-source projects used in AOSP (see external/ folder) have a separate Android.bp alongside the autotools files.

Here are a few examples of Android.bp files added by Google to well-known projects:
- curl [1]
- iputils [2]
- strace [3]

Quoted 5 lines

In the case above it is up to Google to maintain that file as only hosted on their servers (not merged upstream).
But some other projects are ok merging it which makes it easier (at least for me) like can-utils [4].

Quoted 9 lines

I'm perfectly fine with merging this file but I don't like having another place to look at when bumping the version number. I bunched up all API and ABI versions together in configure.ac in order to not forget anything when making new releases.

I'm sure Android's build system is not as limited as not to allow to run some external scripts that would at least fetch the current version from configure.ac, is it?

Can you do something like this[1] but make the command fetch the version string from configure.ac?

Bartosz

[1] http://androidxref.com/9.0.0_r3/xref/external/libmojo/Android.bp#67

[snip]

#12 lore raw

Re: [libgpiod][PATCH 3/3] Android.bp: initial addition

Hi,

Quoted 37 lines · Bartosz Golaszewski
Quoted 1 line · Bartosz Golaszewski

[snip]

Quoted 22 lines
Quoted 16 lines
Quoted 4 lines

I don't know Android very well but if its build system can launch autotools, then maybe you could autotoolify this file by providing Android.bp.in and letting autotools expand this macro?

No unfortunately that is not how the AOSP build system works (or at least I'm not aware of it).
AFAIK all the open-source projects used in AOSP (see external/ folder) have a separate Android.bp alongside the autotools files.

Here are a few examples of Android.bp files added by Google to well-known projects:
- curl [1]
- iputils [2]
- strace [3]

Quoted 5 lines

In the case above it is up to Google to maintain that file as only hosted on their servers (not merged upstream).
But some other projects are ok merging it which makes it easier (at least for me) like can-utils [4].

Quoted 9 lines

I'm perfectly fine with merging this file but I don't like having another place to look at when bumping the version number. I bunched up all API and ABI versions together in configure.ac in order to not forget anything when making new releases.

I'm sure Android's build system is not as limited as not to allow to run some external scripts that would at least fetch the current version from configure.ac, is it?

Quoted 6 lines

Can you do something like this[1] but make the command fetch the version string from configure.ac?

Bartosz

[1] http://androidxref.com/9.0.0_r3/xref/external/libmojo/Android.bp#67

Yes I'll try to come up with something that get the version from configure.ac. Same as the other patch, might be only next week.

Thanks,
Gary