From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Linus Walleij <linus.walleij@linaro.org>,
Kent Gibson <warthog618@gmail.com>,
Erik Schilling <erik.schilling@linaro.org>,
Phil Howard <phil@gadgetoid.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Dan Carpenter <dan.carpenter@linaro.org>
Cc: "As advised by Dan Carpenter - I'm CC'ing
dbus"@lists.freedesktop.orgto, linux-gpio@vger.kernel.org,
dbus@lists.freedesktop.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH RESEND libgpiod v2 03/18] bindings: glib: add build files
Date: Fri, 28 Jun 2024 20:58:22 +0200 [thread overview]
Message-ID: <20240628-dbus-v2-3-c1331ac17cb8@linaro.org> (raw)
In-Reply-To: <20240628-dbus-v2-0-c1331ac17cb8@linaro.org>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Add the directory structure and build files as well as changes to
.gitignore and Doxygen.in for GLib bindings.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
.gitignore | 2 +
Doxyfile.in | 4 +-
bindings/Makefile.am | 7 ++++
bindings/glib/Makefile.am | 78 ++++++++++++++++++++++++++++++++++++
bindings/glib/examples/.gitignore | 14 +++++++
bindings/glib/examples/Makefile.am | 22 ++++++++++
bindings/glib/gpiod-glib.pc.in | 14 +++++++
bindings/glib/gpiod-glib/Makefile.am | 18 +++++++++
bindings/glib/tests/.gitignore | 4 ++
bindings/glib/tests/Makefile.am | 29 ++++++++++++++
configure.ac | 24 +++++++++++
11 files changed, 215 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index cf66e97..c3a29d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,8 @@
*.o
*.lo
*.la
+generated-*.c
+generated-*.h
doc
*.pc
*.tar.gz
diff --git a/Doxyfile.in b/Doxyfile.in
index 9c85e21..548a0da 100644
--- a/Doxyfile.in
+++ b/Doxyfile.in
@@ -46,7 +46,9 @@ WARN_FORMAT =
WARN_LOGFILE =
INPUT = @top_srcdir@/include/gpiod.h \
@top_srcdir@/bindings/cxx/gpiod.hpp \
- @top_srcdir@/bindings/cxx/gpiodcxx/
+ @top_srcdir@/bindings/cxx/gpiodcxx/ \
+ @top_srcdir@/bindings/glib/gpiod-glib.h \
+ @top_srcdir@/bindings/glib/gpiod-glib/
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
REFERENCED_BY_RELATION = YES
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
index 004ae23..a177187 100644
--- a/bindings/Makefile.am
+++ b/bindings/Makefile.am
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
+# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
SUBDIRS = .
@@ -20,3 +21,9 @@ if WITH_BINDINGS_RUST
SUBDIRS += rust
endif
+
+if WITH_BINDINGS_GLIB
+
+SUBDIRS += glib
+
+endif
diff --git a/bindings/glib/Makefile.am b/bindings/glib/Makefile.am
new file mode 100644
index 0000000..750a913
--- /dev/null
+++ b/bindings/glib/Makefile.am
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+SUBDIRS = . gpiod-glib
+
+if WITH_TESTS
+
+SUBDIRS += tests
+
+endif
+
+if WITH_EXAMPLES
+
+SUBDIRS += examples
+
+endif
+
+lib_LTLIBRARIES = libgpiod-glib.la
+
+libgpiod_glib_la_SOURCES = \
+ chip.c \
+ chip-info.c \
+ edge-event.c \
+ error.c \
+ info-event.c \
+ internal.c \
+ internal.h \
+ line-config.c \
+ line-info.c \
+ line-request.c \
+ line-settings.c \
+ misc.c \
+ request-config.c
+
+EXTRA_DIST = \
+ generated-enums.c.template \
+ generated-enums.h.template
+
+project_headers = \
+ $(srcdir)/gpiod-glib/line.h \
+ $(srcdir)/gpiod-glib/edge-event.h \
+ $(srcdir)/gpiod-glib/info-event.h
+
+generated-enums.c: $(project_headers) generated-enums.c.template
+ $(AM_V_GEN)$(GLIB_MKENUMS) \
+ --symbol-prefix=G \
+ --template=$(srcdir)/generated-enums.c.template \
+ --output=$(builddir)/$@ \
+ $(project_headers)
+
+gpiod-glib/generated-enums.h: $(project_headers) generated-enums.h.template
+ $(AM_V_GEN)$(GLIB_MKENUMS) \
+ --symbol-prefix=G \
+ --template=$(srcdir)/generated-enums.h.template \
+ --output=$(srcdir)/$@ \
+ $(project_headers)
+
+nodist_libgpiod_glib_la_SOURCES = \
+ generated-enums.c \
+ gpiod-glib/generated-enums.h
+
+BUILT_SOURCES = $(nodist_libgpiod_glib_la_SOURCES)
+CLEANFILES = $(nodist_libgpiod_glib_la_SOURCES)
+
+libgpiod_glib_la_CFLAGS = -Wall -Wextra -g
+libgpiod_glib_la_CFLAGS += -I$(top_srcdir)/include/ -include $(top_builddir)/config.h
+libgpiod_glib_la_CFLAGS += $(GLIB_CFLAGS) $(GIO_CFLAGS) $(GIO_UNIX_CFLAGS)
+libgpiod_glib_la_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-glib\"
+libgpiod_glib_la_CFLAGS += $(PROFILING_CFLAGS)
+libgpiod_glib_la_LDFLAGS = -version-info $(subst .,:,$(ABI_GLIB_VERSION))
+libgpiod_glib_la_LDFLAGS += -lgpiod -L$(top_builddir)/lib
+libgpiod_glib_la_LDFLAGS += $(GLIB_LIBS) $(GIO_LIBS) $(GIO_UNIX_LIBS)
+libgpiod_glib_la_LDFLAGS += $(PROFILING_LDFLAGS)
+
+include_HEADERS = gpiod-glib.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gpiod-glib.pc
diff --git a/bindings/glib/examples/.gitignore b/bindings/glib/examples/.gitignore
new file mode 100644
index 0000000..c2415ae
--- /dev/null
+++ b/bindings/glib/examples/.gitignore
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: CC0-1.0
+# SPDX-FileCopyrightText: 2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+find_line_by_name_glib
+get_chip_info_glib
+get_line_info_glib
+get_line_value_glib
+get_multiple_line_values_glib
+reconfigure_input_to_output_glib
+toggle_line_value_glib
+toggle_multiple_line_values_glib
+watch_line_info_glib
+watch_line_value_glib
+watch_multiple_edge_rising_glib
diff --git a/bindings/glib/examples/Makefile.am b/bindings/glib/examples/Makefile.am
new file mode 100644
index 0000000..fb4e5b1
--- /dev/null
+++ b/bindings/glib/examples/Makefile.am
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+bin_PROGRAMS = \
+ find_line_by_name_glib \
+ get_chip_info_glib \
+ get_line_info_glib \
+ get_line_value_glib \
+ get_multiple_line_values_glib \
+ reconfigure_input_to_output_glib \
+ toggle_line_value_glib \
+ toggle_multiple_line_values_glib \
+ watch_line_info_glib \
+ watch_line_value_glib \
+ watch_multiple_edge_rising_glib
+
+AM_CFLAGS = -I$(top_srcdir)/bindings/glib/
+AM_CFLAGS += -include $(top_builddir)/config.h
+AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS) $(GOBJECT_CFLAGS)
+AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiotools-glib\"
+LDADD = $(top_builddir)/bindings/glib/libgpiod-glib.la
+LDADD += $(GLIB_LIBS) $(GOBJECT_LIBS)
diff --git a/bindings/glib/gpiod-glib.pc.in b/bindings/glib/gpiod-glib.pc.in
new file mode 100644
index 0000000..5da56da
--- /dev/null
+++ b/bindings/glib/gpiod-glib.pc.in
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: gpiod-glib
+Description: GObject bindings for libgpiod
+URL: @PACKAGE_URL@
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lgpiod-glib
+Cflags: -I${includedir}
diff --git a/bindings/glib/gpiod-glib/Makefile.am b/bindings/glib/gpiod-glib/Makefile.am
new file mode 100644
index 0000000..3d47772
--- /dev/null
+++ b/bindings/glib/gpiod-glib/Makefile.am
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+otherincludedir = $(includedir)/gpiod-glib
+otherinclude_HEADERS = \
+ chip.h \
+ chip-info.h \
+ edge-event.h \
+ error.h \
+ generated-enums.h \
+ info-event.h \
+ line.h \
+ line-config.h \
+ line-info.h \
+ line-request.h \
+ line-settings.h \
+ misc.h \
+ request-config.h
diff --git a/bindings/glib/tests/.gitignore b/bindings/glib/tests/.gitignore
new file mode 100644
index 0000000..8eb499f
--- /dev/null
+++ b/bindings/glib/tests/.gitignore
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: CC0-1.0
+# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+gpiod-glib-test
diff --git a/bindings/glib/tests/Makefile.am b/bindings/glib/tests/Makefile.am
new file mode 100644
index 0000000..a90587a
--- /dev/null
+++ b/bindings/glib/tests/Makefile.am
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
+
+noinst_PROGRAMS = gpiod-glib-test
+gpiod_glib_test_SOURCES = \
+ helpers.c \
+ helpers.h \
+ tests-chip.c \
+ tests-chip-info.c \
+ tests-edge-event.c \
+ tests-info-event.c \
+ tests-line-config.c \
+ tests-line-info.c \
+ tests-line-request.c \
+ tests-line-settings.c \
+ tests-misc.c \
+ tests-request-config.c
+
+AM_CFLAGS = -I$(top_srcdir)/bindings/glib/
+AM_CFLAGS += -I$(top_srcdir)/tests/gpiosim-glib/
+AM_CFLAGS += -I$(top_srcdir)/tests/harness/
+AM_CFLAGS += -include $(top_builddir)/config.h
+AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS) $(GIO_CFLAGS)
+AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-glib-test\"
+LDADD = $(top_builddir)/bindings/glib/libgpiod-glib.la
+LDADD += $(top_builddir)/tests/gpiosim/libgpiosim.la
+LDADD += $(top_builddir)/tests/gpiosim-glib/libgpiosim-glib.la
+LDADD += $(top_builddir)/tests/harness/libgpiod-test-harness.la
+LDADD += $(GLIB_LIBS) $(GIO_LIBS)
diff --git a/configure.ac b/configure.ac
index 93d9d75..74ba004 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,6 +31,8 @@ AC_SUBST(ABI_CXX_VERSION, [3.0.1])
# ABI version for libgpiosim (we need this since it can be installed if we
# enable tests).
AC_SUBST(ABI_GPIOSIM_VERSION, [1.1.0])
+# ... and another one for GLib bindings:
+AC_SUBST(ABI_GLIB_VERSION, [1.0.0])
AC_CONFIG_AUX_DIR([autostuff])
AC_CONFIG_MACRO_DIRS([m4])
@@ -248,6 +250,23 @@ then
fi
fi
+AC_ARG_ENABLE([bindings-glib],
+ [AS_HELP_STRING([--enable-bindings-glib],[enable GLib 2.0 bindings [default=no]])],
+ [if test "x$enableval" = xyes; then with_bindings_glib=true; fi],
+ [with_bindings_glib=false])
+AM_CONDITIONAL([WITH_BINDINGS_GLIB], [test "x$with_bindings_glib" = xtrue])
+
+if test "x$with_bindings_glib" = xtrue
+then
+ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.54])
+ PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.54])
+ PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.54])
+ PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.54])
+ PKG_PROG_PKG_CONFIG([0.28])
+ PKG_CHECK_VAR([GLIB_MKENUMS], [glib-2.0], [glib_mkenums], [],
+ AC_MSG_ERROR([glib-mkenums not found - needed to build GLib bindings]))
+fi
+
AC_CHECK_PROG([has_doxygen], [doxygen], [true], [false])
AM_CONDITIONAL([HAS_DOXYGEN], [test "x$has_doxygen" = xtrue])
if test "x$has_doxygen" = xfalse
@@ -284,6 +303,11 @@ AC_CONFIG_FILES([Makefile
bindings/cxx/gpiodcxx/Makefile
bindings/cxx/examples/Makefile
bindings/cxx/tests/Makefile
+ bindings/glib/gpiod-glib.pc
+ bindings/glib/Makefile
+ bindings/glib/examples/Makefile
+ bindings/glib/gpiod-glib/Makefile
+ bindings/glib/tests/Makefile
bindings/python/Makefile
bindings/python/gpiod/Makefile
bindings/python/gpiod/ext/Makefile
--
2.43.0
next prev parent reply other threads:[~2024-06-28 18:59 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 18:58 [PATCH RESEND libgpiod v2 00/18] dbus: add GLib-based DBus daemon and command-line client Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 01/18] tests: split out reusable test code into a local static library Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 02/18] tests: split out the common test code for bash scripts Bartosz Golaszewski
2024-06-28 18:58 ` Bartosz Golaszewski [this message]
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 04/18] bindings: glib: add public headers Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 05/18] bindings: glib: add core code Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 06/18] bindings: glib: add examples Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 07/18] bindings: glib: add tests Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 08/18] README: document GLib bindings Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 09/18] dbus: add build files Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 10/18] dbus: add the API definitions Bartosz Golaszewski
2024-06-30 16:49 ` Thiago Macieira
2024-07-01 8:40 ` Bartosz Golaszewski
2024-07-02 6:48 ` Sverdlin, Alexander
2024-07-02 9:06 ` Thiago Macieira
2024-07-02 9:15 ` Bartosz Golaszewski
2024-07-02 10:35 ` Sverdlin, Alexander
2024-07-03 10:53 ` Thiago Macieira
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 11/18] dbus: add a wrapper around the gdbus-codegen generated header Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 12/18] dbus: add data files Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 13/18] dbus: add gpio-manager code Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 14/18] dbus: add tests Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 15/18] dbus: add a command-line client Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 16/18] dbus: client: add tests Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 17/18] README: document the DBus API Bartosz Golaszewski
2024-06-28 18:58 ` [PATCH RESEND libgpiod v2 18/18] TODO: drop the DBus daemon from the list Bartosz Golaszewski
2024-07-02 6:59 ` [PATCH RESEND libgpiod v2 00/18] dbus: add GLib-based DBus daemon and command-line client Sverdlin, Alexander
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240628-dbus-v2-3-c1331ac17cb8@linaro.org \
--to=brgl@bgdev.pl \
--cc="As advised by Dan Carpenter - I'm CC'ing dbus"@lists.freedesktop.orgto \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=dan.carpenter@linaro.org \
--cc=dbus@lists.freedesktop.org \
--cc=erik.schilling@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=phil@gadgetoid.com \
--cc=viresh.kumar@linaro.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).