diff mbox series

[libgpiod,v2,2/2] build: add Android.bp to build within Android tree

Message ID 20230225031235.3886280-3-benl@squareup.com
State Superseded
Headers show
Series tools: fix compile issues when GNU extensions are not present | expand

Commit Message

Benjamin Li Feb. 25, 2023, 3:12 a.m. UTC
Add an Android.bp file for Soong, the Android build system, to build
the library including C++ bindings along with all the CLI tools.

Signed-off-by: Benjamin Li <benl@squareup.com>
---
 Android.bp | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 Android.bp

Comments

Bartosz Golaszewski Feb. 25, 2023, 6:38 p.m. UTC | #1
On Sat, Feb 25, 2023 at 4:12 AM Benjamin Li <benl@squareup.com> wrote:
>
> Add an Android.bp file for Soong, the Android build system, to build
> the library including C++ bindings along with all the CLI tools.
>
> Signed-off-by: Benjamin Li <benl@squareup.com>
> ---

If I take it into the main tree, I would like to be at least able to
check that it builds correctly. Could you post some instructions on
how to build the android package in the least number of steps? Will I
need to jump through all the regular hoops involved in building
android images?

Bart
Benjamin Li Feb. 27, 2023, 8:58 p.m. UTC | #2
On 2/25/23 10:38 AM, Bartosz Golaszewski wrote:
> If I take it into the main tree, I would like to be at least able to
> check that it builds correctly. Could you post some instructions on
> how to build the android package in the least number of steps? Will I
> need to jump through all the regular hoops involved in building
> android images?
> 
> Bart

Ah, I mentioned in the cover letter that this was informational and I
didn't expect you to take it. Unfortunately I think you would need to
jump through all the regular hoops.

Roughly, the steps would be:
- Checkout AOSP: https://source.android.com/docs/setup/download/downloading
- Checkout libgpiod under external/
- Build AOSP: https://source.android.com/docs/setup/build/building

Of course I would appreciate if you went out of your way to take this,
but otherwise hopefully this public mailing list patch helps other
Android device manufacturers/tinkerers for now.

Ben
diff mbox series

Patch

diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..55ddcc8
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,129 @@ 
+//
+// libgpiod main library
+//
+
+cc_library {
+    name: "libgpiod",
+    defaults: [
+        "libgpiod_defaults",
+    ],
+    srcs: [
+        "lib/*.c",
+        "bindings/cxx/*.cpp",
+    ],
+    export_include_dirs: [
+        "include",
+        // Not great to mix sources and includes in this dir.
+        "bindings/cxx",
+    ],
+}
+
+cc_defaults {
+    name: "libgpiod_defaults",
+    device_specific: true,
+    cpp_std: "gnu++17",
+    cflags: [
+        "-DGPIOD_VERSION_STR=\"2.0-rc3\"",
+        "-DHAVE_GETPROGNAME=1",
+    ],
+    cppflags: [
+        // Google C++ style is to not use exceptions, but this library does
+        // use them.
+        "-fexceptions",
+    ],
+    // Google C++ style is to not use runtime type information, but this
+    // library does use it.
+    rtti: true,
+}
+
+//
+// libgpiod tools
+//
+
+phony {
+    name: "libgpiod_tools",
+    required: [
+        "gpiodetect",
+        "gpioget",
+        "gpioinfo",
+        "gpiomon",
+        "gpionotify",
+        "gpioset",
+    ],
+}
+
+cc_binary {
+    name: "gpiodetect",
+    defaults: [
+        "libgpiod_defaults",
+        "libgpiod_tools_defaults",
+    ],
+    srcs: [
+        "tools/gpiodetect.c",
+    ],
+}
+
+cc_binary {
+    name: "gpioget",
+    defaults: [
+        "libgpiod_defaults",
+        "libgpiod_tools_defaults",
+    ],
+    srcs: [
+        "tools/gpioget.c",
+    ],
+}
+
+cc_binary {
+    name: "gpioinfo",
+    defaults: [
+        "libgpiod_defaults",
+        "libgpiod_tools_defaults",
+    ],
+    srcs: [
+        "tools/gpioinfo.c",
+    ],
+}
+
+cc_binary {
+    name: "gpiomon",
+    defaults: [
+        "libgpiod_defaults",
+        "libgpiod_tools_defaults",
+    ],
+    srcs: [
+        "tools/gpiomon.c",
+    ],
+}
+
+cc_binary {
+    name: "gpionotify",
+    defaults: [
+        "libgpiod_defaults",
+        "libgpiod_tools_defaults",
+    ],
+    srcs: [
+        "tools/gpionotify.c",
+    ],
+}
+
+cc_binary {
+    name: "gpioset",
+    defaults: [
+        "libgpiod_defaults",
+        "libgpiod_tools_defaults",
+    ],
+    srcs: [
+        "tools/gpioset.c",
+    ],
+}
+
+cc_defaults {
+    name: "libgpiod_tools_defaults",
+    srcs: [
+        "tools/tools-common.c",
+    ],
+    shared_libs: [
+        "libgpiod",
+    ],
+}