Skip to content

Commit

Permalink
Merge branch 'master' into 0001-hidapi-libusb-maintain-in-memory-cach…
Browse files Browse the repository at this point in the history
…e-of-vendor-pro.patch
  • Loading branch information
mcuee authored Mar 6, 2024
2 parents e2f8caa + d0732cd commit 9dd96df
Show file tree
Hide file tree
Showing 32 changed files with 2,125 additions and 394 deletions.
98 changes: 69 additions & 29 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: GitHub Builds
on: [push, pull_request]

env:
NIX_COMPILE_FLAGS: -Wall -Wextra -pedantic -Werror
NIX_COMPILE_FLAGS: -Wall -Wextra -pedantic -Werror
GNU_COMPILE_FLAGS: -Wall -Wextra -pedantic -Werror -Wformat-signedness
MSVC_COMPILE_FLAGS: /W4 /WX

jobs:
Expand Down Expand Up @@ -112,8 +113,8 @@ jobs:
- name: Configure CMake
run: |
rm -rf build install
cmake -B build/shared -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install/shared -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
cmake -B build/static -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install/static -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
cmake -B build/shared -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install/shared -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
cmake -B build/static -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install/static -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
- name: Build CMake Shared
working-directory: build/shared
run: make install
Expand All @@ -139,7 +140,7 @@ jobs:
-S hidapisrc/hidtest \
-Dhidapi_ROOT=install/shared \
-DCMAKE_INSTALL_PREFIX=install/shared_test \
"-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
"-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
cd build/shared_test
make install
- name: Check CMake Export Package Static
Expand All @@ -149,7 +150,7 @@ jobs:
-S hidapisrc/hidtest \
-Dhidapi_ROOT=install/static \
-DCMAKE_INSTALL_PREFIX=install/static_test \
"-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
"-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
cd build/static_test
make install
Expand All @@ -169,6 +170,7 @@ jobs:
with:
path: hidapisrc
- name: Install dependencies
shell: cmd
run: |
choco install ninja
pip3 install meson
Expand All @@ -180,15 +182,15 @@ jobs:
- name: Build CMake MSVC
working-directory: build/msvc
run: cmake --build . --config RelWithDebInfo --target install
- name: Check artifacts MSVC
- name: Check artifacts CMake MSVC
uses: andstor/file-existence-action@v2
with:
files: "install/msvc/lib/hidapi.lib, \
install/msvc/bin/hidapi.dll, \
install/msvc/include/hidapi/hidapi.h, \
install/msvc/include/hidapi/hidapi_winapi.h"
fail: true
- name: Check CMake Export Package
- name: Check CMake MSVC Export Package
shell: cmd
run: |
cmake ^
Expand All @@ -202,28 +204,28 @@ jobs:
- name: Run CTest MSVC
shell: cmd
working-directory: build/msvc
run: ctest -C RelWithDebInfo --rerun-failed --output-on-failure
run: ctest -C RelWithDebInfo --no-compress-output --output-on-failure

- name: Configure CMake NMake
- name: Configure CMake NMake MSVC
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake -G"NMake Makefiles" -B build\nmake -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DHIDAPI_ENABLE_ASAN=ON -DCMAKE_INSTALL_PREFIX=install\nmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%"
- name: Build CMake NMake
- name: Build CMake NMake MSVC
working-directory: build\nmake
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
nmake install
- name: Check artifacts NMake
- name: Check artifacts CMake NMake MSVC
uses: andstor/file-existence-action@v2
with:
files: "install/nmake/lib/hidapi.lib, \
install/nmake/bin/hidapi.dll, \
install/nmake/include/hidapi/hidapi.h, \
install/nmake/include/hidapi/hidapi_winapi.h"
fail: true
- name: Check CMake Export Package NMake
- name: Check CMake NMake MSVC Export Package
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
Expand All @@ -236,14 +238,52 @@ jobs:
"-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%"
cd build\nmake_test
nmake install
- name: Run CTest NMake
- name: Run CTest NMake MSVC
working-directory: build\nmake
run: ctest --rerun-failed --output-on-failure
run: ctest --no-compress-output --output-on-failure

- name: Configure CMake NMake ClangCL
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake -G"NMake Makefiles" -B build\clang_cl -S hidapisrc -D CMAKE_C_COMPILER=clang-cl -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DHIDAPI_ENABLE_ASAN=OFF -DCMAKE_INSTALL_PREFIX=install\clang_cl -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%"
- name: Build CMake NMake ClangCL
working-directory: build\clang_cl
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
nmake install
- name: Check artifacts CMake NMake ClangCL
uses: andstor/file-existence-action@v2
with:
files: "install/clang_cl/lib/hidapi.lib, \
install/clang_cl/bin/hidapi.dll, \
install/clang_cl/include/hidapi/hidapi.h, \
install/clang_cl/include/hidapi/hidapi_winapi.h"
fail: true
- name: Check CMake NMake ClangCL Export Package
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake ^
-G"NMake Makefiles" ^
-B build\clang_cl_test ^
-S hidapisrc\hidtest ^
-D CMAKE_C_COMPILER=clang-cl ^
-Dhidapi_ROOT=install\clang_cl ^
-DCMAKE_INSTALL_PREFIX=install\clang_cl_test ^
"-DCMAKE_C_FLAGS=%MSVC_COMPILE_FLAGS%"
cd build\clang_cl_test
cmake --build . --target install
- name: Run CTest NMake ClangCL
shell: cmd
working-directory: build/clang_cl
run: ctest -C RelWithDebInfo --no-compress-output --output-on-failure

- name: Configure CMake MinGW
shell: cmd
run: |
cmake -G"MinGW Makefiles" -B build\mingw -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DCMAKE_INSTALL_PREFIX=install\mingw -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%NIX_COMPILE_FLAGS%"
cmake -G"MinGW Makefiles" -B build\mingw -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_PP_DATA_DUMP=ON -DCMAKE_INSTALL_PREFIX=install\mingw -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=%GNU_COMPILE_FLAGS%"
- name: Build CMake MinGW
working-directory: build\mingw
run: cmake --build . --target install
Expand All @@ -264,12 +304,12 @@ jobs:
-S hidapisrc\hidtest ^
-Dhidapi_ROOT=install\mingw ^
-DCMAKE_INSTALL_PREFIX=install\mingw_test ^
"-DCMAKE_C_FLAGS=%NIX_COMPILE_FLAGS%"
"-DCMAKE_C_FLAGS=%GNU_COMPILE_FLAGS%"
cd build\mingw_test
cmake --build . --target install
- name: Run CTest MinGW
working-directory: build\mingw
run: ctest --rerun-failed --output-on-failure
run: ctest --no-compress-output --output-on-failure

- name: Check Meson build
shell: cmd
Expand All @@ -287,14 +327,14 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: microsoft/[email protected]
- name: MSBuild x86
- name: MSBuild x86 MSVC
run: msbuild windows\hidapi.sln /p:Configuration=Release /p:Platform=Win32
- name: Check artifacts x86
uses: andstor/file-existence-action@v2
with:
files: "windows/Release/hidapi.dll, windows/Release/hidapi.lib, windows/Release/hidapi.pdb"
fail: true
- name: MSBuild x64
- name: MSBuild x64 MSVC
run: msbuild windows\hidapi.sln /p:Configuration=Release /p:Platform=x64
- name: Check artifacts x64
uses: andstor/file-existence-action@v2
Expand Down Expand Up @@ -331,8 +371,8 @@ jobs:
- name: Configure CMake
run: |
rm -rf build install
mingw64-cmake -B build/shared-cmake -S hidapisrc -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared-cmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
mingw64-cmake -B build/static-cmake -S hidapisrc -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static-cmake -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
mingw64-cmake -B build/shared-cmake -S hidapisrc -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared-cmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
mingw64-cmake -B build/static-cmake -S hidapisrc -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static-cmake -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
- name: Configure Automake
working-directory: hidapisrc
run: |
Expand Down Expand Up @@ -372,7 +412,7 @@ jobs:
-S hidapisrc/hidtest \
-Dhidapi_DIR=$PWD/install/shared-cmake/lib/cmake/hidapi \
-DCMAKE_INSTALL_PREFIX=install/shared_test \
"-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
"-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
cd build/shared_test
ninja install
- name: Check CMake Export Package Static
Expand All @@ -383,7 +423,7 @@ jobs:
-S hidapisrc/hidtest \
-Dhidapi_DIR=$PWD/install/static-cmake/lib/cmake/hidapi \
-DCMAKE_INSTALL_PREFIX=install/static_test \
"-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
"-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
cd build/static_test
ninja install
Expand All @@ -399,12 +439,12 @@ jobs:
- name: Install dependencies
run: |
pacman -Sy
pacman -S --noconfirm gcc pkg-config autoconf automake libtool libusb libudev0 cmake make
pacman -S --noconfirm glibc lib32-glibc gcc pkg-config autoconf automake libtool libusb libudev0 cmake make
- name: Configure CMake
run: |
rm -rf build install
cmake -B build/shared-cmake -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared-cmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
cmake -B build/static-cmake -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static-cmake -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
cmake -B build/shared-cmake -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/shared-cmake -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
cmake -B build/static-cmake -S hidapisrc -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=install/static-cmake -DBUILD_SHARED_LIBS=FALSE -DHIDAPI_BUILD_HIDTEST=ON "-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
- name: Configure Automake
working-directory: hidapisrc
run: |
Expand Down Expand Up @@ -447,7 +487,7 @@ jobs:
-S hidapisrc/hidtest \
-Dhidapi_ROOT=install/shared-cmake \
-DCMAKE_INSTALL_PREFIX=install/shared_test \
"-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
"-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
cd build/shared_test
make install
- name: Check CMake Export Package Static
Expand All @@ -457,7 +497,7 @@ jobs:
-S hidapisrc/hidtest \
-Dhidapi_ROOT=install/static-cmake \
-DCMAKE_INSTALL_PREFIX=install/static_test \
"-DCMAKE_C_FLAGS=${NIX_COMPILE_FLAGS}"
"-DCMAKE_C_FLAGS=${GNU_COMPILE_FLAGS}"
cd build/static_test
make install
Expand All @@ -468,7 +508,7 @@ jobs:
container: alpine:edge
env:
# A bug in musl: https://www.openwall.com/lists/musl/2020/01/20/2
ALPINE_COMPILE_FLAGS: ${NIX_COMPILE_FLAGS} -Wno-overflow
ALPINE_COMPILE_FLAGS: ${GNU_COMPILE_FLAGS} -Wno-overflow
steps:
- uses: actions/checkout@v3
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ jobs:
with:
path: src
- name: Install dependencies
run: sudo apt install libudev-dev libusb-1.0-0-dev ninja-build
run: |
sudo apt update
sudo apt install libudev-dev libusb-1.0-0-dev ninja-build
- name: Configure
run: |
cmake -B build -S src -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHIDAPI_WITH_TESTS=ON -DHIDAPI_BUILD_HIDTEST=ON -DCMAKE_C_COMPILER=gcc
Expand Down
2 changes: 1 addition & 1 deletion AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Ludovic Rousseau <[email protected]>:
Correctness fixes

libusb/hidapi Team:
Development/maintainance since June 4th 2019
Development/maintenance since June 4th 2019

For a comprehensive list of contributions, see the commit list at github:
https://github.com/libusb/hidapi/graphs/contributors
Expand Down
4 changes: 3 additions & 1 deletion BUILD.autotools.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ A simple command list, to build HIDAPI with Autotools as a _shared library_ and

```sh
./bootstrap # this prepares the configure script
./configure
mkdir build
cd build # in-source builds are not recommended and known to be broken in some cases (https://github.com/libusb/hidapi/issues/621)
../configure
make # build the library
make install # as root, or using sudo, this will install hidapi into your system
```
Expand Down
6 changes: 3 additions & 3 deletions BUILD.cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ most of this document may not be of interest for you; just check variables names
CMake can be installed either using your system's package manager,
or by downloading an installer/prebuilt version from the [official website](https://cmake.org/download/).

On most \*nix systems, the prefered way to install CMake is via package manager,
On most \*nix systems, the preferred way to install CMake is via package manager,
e.g. `sudo apt install cmake`.

On Windows CMake could be provided by your development environment (e.g. by Visual Studio Installer or MinGW installer),
Expand Down Expand Up @@ -159,7 +159,7 @@ endif()
HIDAPI can be easily used as a subdirectory of a larger CMake project:
```cmake
# root CMakeLists.txt
cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR)
cmake_minimum_required(VERSION 3.4.3...3.25 FATAL_ERROR)
add_subdirectory(hidapi)
add_subdirectory(my_application)
Expand Down Expand Up @@ -214,7 +214,7 @@ This is done to let the host project's developer decide what is important (what
In a _subdirectory build_, even if not set, those variables remain unchanged, so a host project's developer has a full control over the HIDAPI build configuration.

Available CMake targets after `add_subdirectory(hidapi)` _are the same as in case of [standalone build](#standalone-package-build)_, and a few additional ones:
- `hidapi_include` - the interface library; `hidapi::hidapi` is an alias of it;
- `hidapi_include` - the interface library; `hidapi::include` is an alias of it;
- `hidapi_winapi` - library target on Windows; `hidapi::winapi` is an alias of it;
- `hidapi_darwin` - library target on macOS; `hidapi::darwin` is an alias of it;
- `hidapi_libusb` - library target for libusb backend; `hidapi::libusb` is an alias of it;
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1.3 FATAL_ERROR)
cmake_minimum_required(VERSION 3.1.3...3.25 FATAL_ERROR)

if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_subdirectory(src)
Expand Down Expand Up @@ -42,6 +42,9 @@ elseif(NOT WIN32)
option(HIDAPI_WITH_HIDRAW "Build HIDRAW-based implementation of HIDAPI" ON)
option(HIDAPI_WITH_LIBUSB "Build LIBUSB-based implementation of HIDAPI" ON)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
option(HIDAPI_WITH_NETBSD "Build NetBSD/UHID implementation of HIDAPI" ON)
endif()
endif()

option(BUILD_SHARED_LIBS "Build shared version of the libraries, otherwise build statically" ON)
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ case $host in
backend="mac"
os="darwin"
threads="pthreads"
LIBS="${LIBS} -framework IOKit -framework CoreFoundation -framework AppKit"
LIBS="${LIBS} -framework IOKit -framework CoreFoundation"
;;
*-freebsd*)
AC_MSG_RESULT([ (FreeBSD back-end)])
Expand Down
2 changes: 1 addition & 1 deletion dist/hidapi.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Pod::Spec.new do |spec|

spec.public_header_files = "hidapi/hidapi.h", "mac/hidapi_darwin.h"

spec.frameworks = "IOKit", "CoreFoundation", "AppKit"
spec.frameworks = "IOKit", "CoreFoundation"

end
2 changes: 1 addition & 1 deletion hidtest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1.3 FATAL_ERROR)
cmake_minimum_required(VERSION 3.1.3...3.25 FATAL_ERROR)
project(hidtest C)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
Expand Down
2 changes: 1 addition & 1 deletion hidtest/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void print_device(struct hid_device_info *cur_dev) {
printf(" Release: %hx\n", cur_dev->release_number);
printf(" Interface: %d\n", cur_dev->interface_number);
printf(" Usage (page): 0x%hx (0x%hx)\n", cur_dev->usage, cur_dev->usage_page);
printf(" Bus type: %d (%s)\n", cur_dev->bus_type, hid_bus_name(cur_dev->bus_type));
printf(" Bus type: %u (%s)\n", (unsigned)cur_dev->bus_type, hid_bus_name(cur_dev->bus_type));
printf("\n");
}

Expand Down
4 changes: 2 additions & 2 deletions libusb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.6.3 FATAL_ERROR)
cmake_minimum_required(VERSION 3.6.3...3.25 FATAL_ERROR)

list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_libusb.h")

Expand Down Expand Up @@ -66,7 +66,7 @@ else()
else()
# otherwise there is 2 options:
# 1) iconv is provided by Standard C library and the build will be just fine
# 2) The _user_ has to provide additiona compilation options for this project/target
# 2) The _user_ has to provide additional compilation options for this project/target
endif()

# check for error: "conflicting types for 'iconv'"
Expand Down
Loading

0 comments on commit 9dd96df

Please sign in to comment.