On 2023/04/03 22:38, Volker Schlecht wrote:
> Updates libhidapi to the most recent release.
> https://github.com/libusb/hidapi/releases/tag/hidapi-0.13.1
> 
> * Switch to new github organization (signal11 -> libusb)
> * Switch from deprecated autotools build to devel/cmake
> * Adapt patches
> * Couldn't figure out how to run cmake twice to build
> both static and shared libs, so just built the shared ones
> 
> I rebuilt libsigrok, dolphin and openocd on amd64, which
> built fine.
> 
> I also locally built https://github.com/solokeys/solo2-cli
> 
> That one built without a hitch, and does talk to the Solo2, though
> admittedly not better than what we already had in ports.
> 
> I'm not super interested in this, and don't know if the missing
> static libs are a showstopper, but I thought I'd put it out there
> anyway.

I have no way to test runtime for the existing ports (and given
that USB can be a bit awkward on OpenBSD it maybe worth checking that
if there's someone that cares about them), but a few comments on the
update

- I don't think it's a problem to lose static libraries.
The way to change this would be in the cmakefiles (create a separate
target with a different name, but use set_target_properties to reset
the name e.g. 'set_target_properties somelib-static PROPERTIES
OUTPUT_NAME somelib') but I don't think it's usually worth it
unless there's a special case.

>  post-install:
> +     mkdir -p ${DOCDIR} && \
> +     cp ${WRKSRC}/LICENSE* ${DOCDIR} && \
> +     cp ${WRKSRC}/README.md ${DOCDIR} && \
> +     cp ${WRKSRC}/AUTHORS.txt ${DOCDIR}

- please use ${INSTALL_xx} vars instead of cp/mkdir

- could do something like this to save a few forks

        ${INSTALL_DATA_DIR} ${DOCDIR}
        cd ${WRKSRC}; ${INSTALL_DATA} LICENSE* README.md AUTHORS.txt ${DOCDIR}/

(or && but ; is ok too as this is run in a '-e' shell anyway)

>       cd ${PREFIX}/lib && \
> -             ln -sf libhidapi-libusb.so.${LIBhidapi-libusb_VERSION} \
> -                     libhidapi.so.${LIBhidapi-libusb_VERSION}
> +     ln -sf libhidapi-libusb.so.${LIBhidapi-libusb_VERSION} \
> +     libhidapi.so.${LIBhidapi-libusb_VERSION}

- doesn't matter but since you're touching it anyway we might as
well lose the unnecessary "cd ... &&",

        ln -sf libhidapi-libusb.so.${LIBhidapi-libusb_VERSION} \
                ${PREFIX}/lib/libhidapi.so.${LIBhidapi-libusb_VERSION}

and some of the patches lost their comments, so I'd go with this:

Index: Makefile
===================================================================
RCS file: /cvs/ports/comms/libhidapi/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- Makefile    30 Mar 2023 03:04:05 -0000      1.8
+++ Makefile    4 Apr 2023 10:56:56 -0000
@@ -3,17 +3,16 @@ COMMENT =     library for communicating with
 # XXX Any consumer should be patched to use hidapi_hid_init() instead of
 # hid_init(3) to avoid conflict with base usbhid(3).

-V =            0.8.0pre20160128
+V =            0.13.1
 DISTNAME =     libhidapi-${V}
-REVISION =     1

-GH_ACCOUNT =   signal11
+GH_ACCOUNT =   libusb
 GH_PROJECT =   hidapi
-GH_COMMIT =    a6a622ffb680c55da0de787ff93b80280498330f
+GH_TAGNAME =   hidapi-${V}

 #libhidapi is symlink to hidapi-libusb. Same version numbers should be kept.
-SHARED_LIBS +=  hidapi-libusb          0.0 # 0.0
-SHARED_LIBS +=  hidapi                 0.0 # 0.0
+SHARED_LIBS += hidapi-libusb           1.0 # 0.0
+SHARED_LIBS += hidapi                  1.0 # 0.0

 CATEGORIES =   comms

@@ -26,20 +25,16 @@ WANTLIB += iconv pthread usb-1.0
 LIB_DEPENDS =  converters/libiconv \
                devel/libusb1

-SEPARATE_BUILD =       Yes
-CONFIGURE_STYLE =      autoreconf
-CONFIGURE_ENV =                CPPFLAGS="-I${LOCALBASE}/include/libusb-1.0 \
-                               -I${LOCALBASE}/include" \
-                       LDFLAGS="-L${LOCALBASE}/lib -lusb-1.0 -liconv"
+MODULES =      devel/cmake

-AUTOCONF_VERSION =     2.69
-AUTOMAKE_VERSION =     1.15
+DOCDIR =       ${PREFIX}/share/doc/hidapi

-NO_TEST =              Yes
+NO_TEST =      Yes

 post-install:
-       cd ${PREFIX}/lib && \
-               ln -sf libhidapi-libusb.so.${LIBhidapi-libusb_VERSION} \
-                       libhidapi.so.${LIBhidapi-libusb_VERSION}
+       ${INSTALL_DATA_DIR} ${DOCDIR}
+       cd ${WRKSRC}; ${INSTALL_DATA} LICENSE* README.md AUTHORS.txt ${DOCDIR}/
+       ln -sf libhidapi-libusb.so.${LIBhidapi-libusb_VERSION} \
+               ${PREFIX}/lib/libhidapi.so.${LIBhidapi-libusb_VERSION}

 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/comms/libhidapi/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo    18 Jun 2018 23:37:01 -0000      1.1.1.1
+++ distinfo    4 Apr 2023 10:56:56 -0000
@@ -1,2 +1,2 @@
-SHA256 (libhidapi-0.8.0pre20160128-a6a622ff.tar.gz) = 
ZvagI/auGUBb5QEGFmRuEiRsA7IAqucuLAU6IkUD5IE=
-SIZE (libhidapi-0.8.0pre20160128-a6a622ff.tar.gz) = 103980
+SHA256 (libhidapi-0.13.1.tar.gz) = R2osmk3H0fyX3SI7hDONvqOAmoTK6i3NiH2XeHJUkOM=
+SIZE (libhidapi-0.13.1.tar.gz) = 244666
Index: patches/patch-README_md
===================================================================
RCS file: patches/patch-README_md
diff -N patches/patch-README_md
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-README_md     4 Apr 2023 10:56:56 -0000
@@ -0,0 +1,14 @@
+rename hid_init() to hidapi_hid_init() to avoid collision with usbhid
+
+Index: README.md
+--- README.md.orig
++++ README.md
+@@ -112,7 +112,7 @@ int main(int argc, char* argv[])
+       int i;
+
+       // Initialize the hidapi library
+-      res = hid_init();
++      res = hidapi_hid_init();
+
+       // Open the device using the VID, PID,
+       // and optionally the Serial number.
Index: patches/patch-README_txt
===================================================================
RCS file: patches/patch-README_txt
diff -N patches/patch-README_txt
--- patches/patch-README_txt    11 Mar 2022 18:26:28 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-rename hid_init() to hidapi_hid_init() to avoid collision with usbhid
-
-Index: README.txt
---- README.txt.orig
-+++ README.txt
-@@ -64,7 +64,7 @@ int main(int argc, char* argv[])
-       int i;
-
-       // Initialize the hidapi library
--      res = hid_init();
-+      res = hidapi_hid_init();
-
-       // Open the device using the VID, PID,
-       // and optionally the Serial number.
Index: patches/patch-configure_ac
===================================================================
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- patches/patch-configure_ac  11 Mar 2022 18:26:28 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,31 +0,0 @@
-add openbsd as recognized platform
-use linux backend
-disable hidraw component which checks for udev
-remove librt check
-
-Index: configure.ac
---- configure.ac.orig
-+++ configure.ac
-@@ -53,7 +53,7 @@ hidapi_prog_error() {
- AC_MSG_CHECKING([operating system])
- AC_MSG_RESULT($host)
- case $host in
--*-linux*)
-+*-linux* | *-openbsd*)
-       AC_MSG_RESULT([ (Linux back-end)])
-       AC_DEFINE(OS_LINUX, 1, [Linux implementations])
-       AC_SUBST(OS_LINUX)
-@@ -61,13 +61,7 @@ case $host in
-       os="linux"
-       threads="pthreads"
-
--      # HIDAPI/hidraw libs
--      PKG_CHECK_MODULES([libudev], [libudev], true, [hidapi_lib_error 
libudev])
--      LIBS_HIDRAW_PR+=" $libudev_LIBS"
--      CFLAGS_HIDRAW+=" $libudev_CFLAGS"
--
-       # HIDAPI/libusb libs
--      AC_CHECK_LIB([rt], [clock_gettime], [LIBS_LIBUSB_PRIVATE+=" -lrt"], 
[hidapi_lib_error librt])
-       PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9], true, 
[hidapi_lib_error libusb-1.0])
-       LIBS_LIBUSB_PRIVATE+=" $libusb_LIBS"
-       CFLAGS_LIBUSB+=" $libusb_CFLAGS"
Index: patches/patch-hidapi_hidapi_h
===================================================================
RCS file: /cvs/ports/comms/libhidapi/patches/patch-hidapi_hidapi_h,v
retrieving revision 1.2
diff -u -p -r1.2 patch-hidapi_hidapi_h
--- patches/patch-hidapi_hidapi_h       11 Mar 2022 18:26:28 -0000      1.2
+++ patches/patch-hidapi_hidapi_h       4 Apr 2023 10:56:56 -0000
@@ -3,9 +3,9 @@ rename hid_init() to hidapi_hid_init() t
 Index: hidapi/hidapi.h
 --- hidapi/hidapi.h.orig
 +++ hidapi/hidapi.h
-@@ -93,7 +93,7 @@ extern "C" {
-                       @returns
+@@ -197,7 +197,7 @@ extern "C" {
                                This function returns 0 on success and -1 on 
error.
+                               Call hid_error(NULL) to get the failure reason.
                */
 -              int HID_API_EXPORT HID_API_CALL hid_init(void);
 +              int HID_API_EXPORT HID_API_CALL hidapi_hid_init(void);
Index: patches/patch-hidtest_Makefile_am
===================================================================
RCS file: patches/patch-hidtest_Makefile_am
diff -N patches/patch-hidtest_Makefile_am
--- patches/patch-hidtest_Makefile_am   11 Mar 2022 18:26:28 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,17 +0,0 @@
-pry hidraw out of hidapi's cold, dead hands
-
-Index: hidtest/Makefile.am
---- hidtest/Makefile.am.orig
-+++ hidtest/Makefile.am
-@@ -2,10 +2,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/hidapi/
-
- ## Linux
- if OS_LINUX
--noinst_PROGRAMS = hidtest-libusb hidtest-hidraw
--
--hidtest_hidraw_SOURCES = hidtest.cpp
--hidtest_hidraw_LDADD = $(top_builddir)/linux/libhidapi-hidraw.la
-+noinst_PROGRAMS = hidtest-libusb
-
- hidtest_libusb_SOURCES = hidtest.cpp
- hidtest_libusb_LDADD = $(top_builddir)/libusb/libhidapi-libusb.la
Index: patches/patch-hidtest_hidtest_cpp
===================================================================
RCS file: patches/patch-hidtest_hidtest_cpp
diff -N patches/patch-hidtest_hidtest_cpp
--- patches/patch-hidtest_hidtest_cpp   11 Mar 2022 18:26:28 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-rename hid_init() to hidapi_hid_init() to avoid collision with usbhid
-
-Index: hidtest/hidtest.cpp
---- hidtest/hidtest.cpp.orig
-+++ hidtest/hidtest.cpp
-@@ -43,7 +43,7 @@ int main(int argc, char* argv[])
-
-       struct hid_device_info *devs, *cur_dev;
-
--      if (hid_init())
-+      if (hidapi_hid_init())
-               return -1;
-
-       devs = hid_enumerate(0x0, 0x0);
Index: patches/patch-hidtest_test_c
===================================================================
RCS file: patches/patch-hidtest_test_c
diff -N patches/patch-hidtest_test_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-hidtest_test_c        4 Apr 2023 10:56:56 -0000
@@ -0,0 +1,21 @@
+rename hid_init() to hidapi_hid_init() to avoid collision with usbhid
+
+Index: hidtest/test.c
+--- hidtest/test.c.orig
++++ hidtest/test.c
+@@ -93,12 +93,12 @@ int main(int argc, char* argv[])
+               printf("Compile-time version is different than runtime version 
of hidapi.\n]n");
+       }
+
+-      if (hid_init())
++      if (hidapi_hid_init())
+               return -1;
+
+ #if defined(__APPLE__) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
+-      // To work properly needs to be called before hid_open/hid_open_path 
after hid_init.
+-      // Best/recommended option - call it right after hid_init.
++      // To work properly needs to be called before hid_open/hid_open_path 
after hidapi_hid_init.
++      // Best/recommended option - call it right after hidapi_hid_init.
+       hid_darwin_set_open_exclusive(0);
+ #endif
+
Index: patches/patch-libusb_hid_c
===================================================================
RCS file: /cvs/ports/comms/libhidapi/patches/patch-libusb_hid_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-libusb_hid_c
--- patches/patch-libusb_hid_c  11 Mar 2022 18:26:28 -0000      1.2
+++ patches/patch-libusb_hid_c  4 Apr 2023 10:56:56 -0000
@@ -3,16 +3,16 @@ rename hid_init() to hidapi_hid_init() t
 Index: libusb/hid.c
 --- libusb/hid.c.orig
 +++ libusb/hid.c
-@@ -490,7 +490,7 @@ static char *make_path(libusb_device *dev, int interfa
+@@ -536,7 +536,7 @@ HID_API_EXPORT const char* HID_API_CALL hid_version_st
+       return HID_API_VERSION_STR;
  }

-
 -int HID_API_EXPORT hid_init(void)
 +int HID_API_EXPORT hidapi_hid_init(void)
  {
        if (!usb_context) {
                const char *locale;
-@@ -529,7 +529,7 @@ struct hid_device_info  HID_API_EXPORT *hid_enumerate(
+@@ -750,7 +750,7 @@ struct hid_device_info  HID_API_EXPORT *hid_enumerate(
        struct hid_device_info *root = NULL; /* return object */
        struct hid_device_info *cur_dev = NULL;

@@ -21,9 +21,18 @@ Index: libusb/hid.c
                return NULL;

        num_devs = libusb_get_device_list(usb_context, &devs);
-@@ -877,7 +877,7 @@ hid_device * HID_API_EXPORT hid_open_path(const char *
+@@ -1144,7 +1144,7 @@ hid_device * HID_API_EXPORT hid_open_path(const char *
        int d = 0;
        int good_open = 0;
+
+-      if(hid_init() < 0)
++      if(hidapi_hid_init() < 0)
+               return NULL;
+
+       dev = new_hid_device();
+@@ -1206,7 +1206,7 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_libusb_wr
+       int res = 0;
+       int j = 0, k = 0;

 -      if(hid_init() < 0)
 +      if(hidapi_hid_init() < 0)
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/comms/libhidapi/pkg/PLIST,v
retrieving revision 1.3
diff -u -p -r1.3 PLIST
--- pkg/PLIST   11 Mar 2022 18:26:28 -0000      1.3
+++ pkg/PLIST   4 Apr 2023 10:56:56 -0000
@@ -1,7 +1,12 @@
 include/hidapi/
 include/hidapi/hidapi.h
-lib/libhidapi-libusb.a
-lib/libhidapi-libusb.la
+include/hidapi/hidapi_libusb.h
+lib/cmake/
+lib/cmake/hidapi/
+lib/cmake/hidapi/hidapi-config-version.cmake
+lib/cmake/hidapi/hidapi-config.cmake
+lib/cmake/hidapi/libhidapi${MODCMAKE_BUILD_SUFFIX}
+lib/cmake/hidapi/libhidapi.cmake
 @lib lib/libhidapi-libusb.so.${LIBhidapi-libusb_VERSION}
 @lib lib/libhidapi.so.${LIBhidapi_VERSION}
 lib/pkgconfig/hidapi-libusb.pc
@@ -11,5 +16,5 @@ share/doc/hidapi/LICENSE-bsd.txt
 share/doc/hidapi/LICENSE-gpl3.txt
 share/doc/hidapi/LICENSE-orig.txt
 share/doc/hidapi/LICENSE.txt
-share/doc/hidapi/README.txt
+share/doc/hidapi/README.md
 share/doc/pkg-readmes/${PKGSTEM}

Reply via email to