Skip to content
Merged

Ci #1

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
ae94c81
Add CI
developersu Aug 22, 2026
e17bbe5
inc
developersu Aug 22, 2026
4d60756
inc+1
developersu Aug 22, 2026
e9b548a
inc+2
developersu Aug 22, 2026
bd1d2c4
inc+3
developersu Aug 22, 2026
9e0cf33
temp tests +1
developersu Sep 12, 2026
484526c
temp tests +2
developersu Sep 12, 2026
d29eb28
temp tests +3
developersu Sep 12, 2026
f347f8b
temp tests +4
developersu Sep 12, 2026
30d0cf1
temp tests +5
developersu Sep 12, 2026
3e72ab8
temp tests +6
developersu Sep 12, 2026
2640bba
temp tests +7
developersu Sep 12, 2026
bfd3673
temp tests +8
developersu Sep 12, 2026
745d364
temp tests +9
developersu Sep 12, 2026
82f5025
temp tests +10
developersu Sep 12, 2026
104e122
temp tests +11
developersu Sep 12, 2026
42a48fa
temp tests +12
developersu Sep 12, 2026
85a8dcd
temp tests +13
developersu Sep 12, 2026
ac05d61
temp tests +14
developersu Sep 12, 2026
69c5250
temp tests +15
developersu Sep 12, 2026
15731e7
temp tests +16
developersu Sep 12, 2026
5324ffd
temp tests +17
developersu Sep 12, 2026
bb5f14b
temp tests +18
developersu Sep 12, 2026
e87b99a
temp tests +19
developersu Sep 12, 2026
383591e
temp tests +20
developersu Sep 12, 2026
d6d0619
temp tests +21
developersu Sep 12, 2026
46a9e56
temp tests +22
developersu Sep 13, 2026
5eea462
temp tests +23
developersu Sep 13, 2026
849356a
temp tests +24
developersu Sep 13, 2026
7eea3a2
temp tests +25
developersu Sep 13, 2026
7351720
temp tests +26
developersu Sep 13, 2026
f259093
temp tests +27
developersu Sep 13, 2026
7f2d51e
temp i386 +1
developersu Sep 13, 2026
5f98e11
temp i386 +2
developersu Sep 13, 2026
83b83af
temp i386 +3
developersu Sep 13, 2026
dbfdce3
temp i386 +4
developersu Sep 13, 2026
6f32511
temp i386 +5
developersu Sep 13, 2026
a5b9f3d
temp i386 +6
developersu Sep 13, 2026
2f75448
temp i386 +7
developersu Sep 13, 2026
f793ded
=)
developersu Sep 13, 2026
f8eeedd
=))
developersu Sep 13, 2026
f748c42
=)))
developersu Sep 17, 2026
716567c
=))))
developersu Sep 17, 2026
c3e06f8
=)))))
developersu Sep 17, 2026
4f9a6d0
:)
developersu Sep 17, 2026
5a01b3c
)
developersu Sep 19, 2026
cd97d14
tests
developersu Oct 10, 2026
65b54ad
stub
developersu Oct 10, 2026
fcd481f
stub+1
developersu Oct 10, 2026
53c5c26
tst
developersu Oct 10, 2026
a474398
tst
developersu Oct 10, 2026
eb3762f
tst
developersu Oct 10, 2026
b288366
tst
developersu Oct 10, 2026
3295c54
tst
developersu Oct 10, 2026
ae24e0b
tst
developersu Oct 10, 2026
5461e10
tst--
developersu Oct 10, 2026
c2d8301
tst-+
developersu Oct 10, 2026
12884b7
tst++
developersu Oct 10, 2026
7db7d20
v
developersu Oct 11, 2026
6cdf274
v1
developersu Oct 11, 2026
05a93d9
v2
developersu Oct 11, 2026
6f7cac7
v3
developersu Oct 11, 2026
199af4e
v3
developersu Oct 11, 2026
b679cf0
v4
developersu Oct 11, 2026
2657a89
v5
developersu Oct 11, 2026
0a0b4a0
v6
developersu Oct 11, 2026
b47cf0c
v7
developersu Oct 11, 2026
c307184
v8
developersu Oct 11, 2026
a2fbf55
win
developersu Oct 11, 2026
84bc8a9
win1
developersu Oct 11, 2026
ca34386
all-rewrite
developersu Oct 11, 2026
3a6cf51
slop
developersu Oct 11, 2026
e5d9409
slop 1
developersu Oct 11, 2026
ab3f720
sloop
developersu Oct 11, 2026
8c76ba4
file
developersu Oct 11, 2026
ce3f4fd
rel
developersu Oct 11, 2026
f462cf6
rel+1
developersu Oct 11, 2026
edac3ad
build fat jar
developersu Oct 11, 2026
0fc5b48
refactor
developersu Oct 15, 2026
31ec9bf
readme up
developersu Oct 16, 2026
bfe9723
readme up+1
developersu Oct 16, 2026
c9365e3
Merge branch 'master' into ci
developersu Oct 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions .cmake/Modules/FindLibUsb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
# See COPYING file for copying conditions.
# ============================================================================

if(DEFINED ENV{LIBUSB_ROOT})
set(LibUsb_LIBRARY_HINTS "$ENV{LIBUSB_ROOT}/lib")
set(LibUsb_INCLUDE_HINTS "$ENV{LIBUSB_ROOT}/include")
endif()

# Change the find-library suffix order in case we prefer to use static libs
set(LibUsb_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if (LibUsb_USE_STATIC_LIBS)
Expand All @@ -40,18 +45,29 @@ if (LibUsb_USE_STATIC_LIBS)
endif()
endif()

set(LibUsb_LIBRARY_NAMES "usb-1.0")
# find_library prepends CMAKE_FIND_LIBRARY_PREFIXES to each name. On Unix that
# prefix is "lib", so the unprefixed name "usb-1.0" resolves to libusb-1.0.{a,so,
# dylib}. On Windows the prefix is empty, so the name must already carry the "lib"
# prefix ("libusb-1.0") to resolve to libusb-1.0.lib.
if(WIN32)
set(LibUsb_LIBRARY_NAMES "libusb-1.0")
else()
set(LibUsb_LIBRARY_NAMES "usb-1.0")
endif()

# Search libraries and include directories with pkg-config when possible
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PkgConfigLibUsb libusb-1.0)
if (PkgConfigLibUsb_FOUND)
if(LibUsb_USE_STATIC_LIBS)
set(LibUsb_LIBRARY_NAMES ${PkgConfigLibUsb_STATIC_LIBRARIES})
set(LibUsb_INCLUDE_HINTS ${PkgConfigLibUsb_STATIC_INCLUDE_DIRS})
set(LibUsb_LIBRARY_HINTS ${PkgConfigLibUsb_STATIC_LIBRARY_DIRS})
set(LibUsb_LDFLAGS ${PkgConfigLibUsb_STATIC_LDFLAGS_OTHER})
# Static: leave LibUsb_LIBRARY_NAMES as "libusb-1.0" (set above) so that
# find_library (with the .a/.lib suffix preference set above) plus the
# LIBUSB_ROOT hints locate libusb-1.0.a / libusb-1.0.lib. Do NOT use
# PkgConfigLibUsb_STATIC_LIBRARIES: libusb's .pc has no Static-Libraries
# field and pkg_check_modules was not called with STATIC, so it is empty
# and would break the search. Also do not clobber LibUsb_LDFLAGS or the
# LIBUSB_ROOT hints here.
else()
set(LibUsb_LIBRARY_NAMES ${PkgConfigLibUsb_LIBRARIES})
set(LibUsb_INCLUDE_HINTS ${PkgConfigLibUsb_INCLUDE_DIRS})
Expand Down
104 changes: 74 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,54 @@ name: CI

on:
push:
branches: [ master ]
branches: [ master, ci ]
pull_request:
branches: [ master ]

env:
VERSION: 1.0.30

jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
fail-fast: false
matrix:
include:
# linux-x86-64
- os: ubuntu-latest
targetos: linux
targetarch: amd64
# arm | armhf astr32 armv7l
- os: ubuntu-24.04-arm
targetos: linux
targetarch: armhf
# linux-aarch64
- os: ubuntu-24.04
targetos: linux
targetarch: arm64
# win32-x86-64
- os: windows-latest
targetos: win32
targetarch: x64
# darwin-x86-64
- os: macos-15-intel
targetos: apple
targetarch: amd64
# darwin-arm-64
- os: macos-14
targetos: apple
targetarch: arm64
# # windows arm; should be using `vcpkg install libusb:arm64-windows-static`. Probably requires custom libusbK
# - os: windows-11-arm
# target: win32-aarch64
# ext: dll
# win32-x86-64
- os: windows-latest
target: win32-x86-64
ext: dll
static: true
# linux-x86-64
- os: ubuntu-latest
target: linux-x86-64
ext: so
static: true
# arm | armhf astr32 armv7l
- os: ubuntu-24.04-arm
target: linux-arm
ext: so
static: true
# linux-aarch64
- os: ubuntu-24.04-arm
target: linux-aarch64
ext: so
static: true
# darwin-x86-64
- os: macos-15-intel
target: darwin-x86-64
ext: dylib
static: true
# darwin-arm-64
- os: macos-14
target: darwin-aarch64
ext: dylib
static: true

steps:
- uses: actions/checkout@v7
Expand All @@ -48,12 +60,44 @@ jobs:
java-version: 25

- name: Install dependencies
run: bash ci/deps_${{ matrix.targetos }}.sh
run: bash ci/deps_${{ matrix.ext }}.sh

- name: Build artifacts
run: mkdir build && cd build && cmake .. && cmake --build . --config Release && cd .. && jshell ci/mk-artifact.jsh
run: >-
mkdir build &&
cd build &&
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DLibUsb_USE_STATIC_LIBS=${{ matrix.static }} -DLibUsb_LDFLAGS="${{ env.LIBUSB_LDFLAGS }}" &&
cmake --build . --config Release &&
cd .. &&
mkdir -p publish/org/usb4java/${{ matrix.target }} &&
mv build/out/libusb4java.${{ matrix.ext }} publish/org/usb4java/${{ matrix.target }}/libusb4java.${{ matrix.ext }} &&
cd publish &&
jar cf ./libusb4java-${{ env.VERSION }}-${{ matrix.target }}.jar *

- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.targetos }}-${{ matrix.targetarch }}
path: publish/*
path: publish/libusb4java-${{ env.VERSION }}-${{ matrix.target }}.jar
if-no-files-found: error
archive: false

# bundle:
# needs: build
## if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# runs-on: ubuntu-latest
# steps:
# - uses: actions/download-artifact@v7
# with:
# path: jars
# merge-multiple: true
# - name: Pack bundle jar
# run: |
# mkdir -p bundle
# cp jars/libusb4java-${{ env.VERSION }}-*.jar bundle/
# cp pom.xml "bundle/libusb4java-${{ env.VERSION }}.pom"
# jar cf "dist-bundle/libusb4java-${{ env.VERSION }}-bundle.jar" -C bundle .
# - uses: actions/upload-artifact@v7
# with:
# name: bundle
# path: dist-bundle/libusb4java-${{ env.VERSION }}-bundle.jar
# if-no-files-found: error
# archive: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ target
/build
/.vs
/out/build/x64-Debug
target
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)

project(usb4java C)
set(PROJECT_VERSION 1.3.1)
set(PROJECT_VERSION 1.0.30)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/.cmake/Modules/")

find_package(JNI REQUIRED)
Expand All @@ -10,6 +10,10 @@ find_package(LibUsb REQUIRED)
include_directories(${JNI_INCLUDE_DIRS})
include_directories(${LibUsb_INCLUDE_DIRS})

if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
endif()

if(CMAKE_COMPILER_IS_GNUCC)
add_definitions(-Wall -Werror -std=c99)
endif()
Expand Down
90 changes: 61 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,64 @@
This is the source code of the JNI wrapper for libusb. usb4java
already includes prebuilt libraries for the following platforms:
Fork of the https://github.com/usb4java/libusb4java

* linux-x86
* linux-x86-64
* linux-arm
* linux-armel
* linux-aarch64
* win32-x86
* win32-x86-64
* darwin-x86-64
* darwin-arm-64
Statically-linked JNI wrapper for libusb used by usb4java

If you need the library on an other platform then you can easily compile it
yourself. On a Unix-compatible operating system you only need the Java JDK,
an up-to-date libusb library version, the GNU C compiler and cmake. When
everything is correctly installed then you should be able to build the
library with the following commands:
### Usage
```java
<dependencies>
<dependency>
<groupId>org.usb4java</groupId>
<artifactId>usb4java</artifactId>
<version>1.3.0</version>
<exclusions>
<exclusion>
<groupId>org.usb4java</groupId>
<artifactId>libusb4java</artifactId>
</exclusion>
</exclusions>
<scope>compile</scope>
</dependency>

$ mkdir build
$ cd build
$ cmake ..
$ make

When compilation was successful then you can find the library in the
`build/src` directory.

usb4java searches for the library in the CLASSPATH directory
`org/libusb4java/<OS>-<ARCH>/`. On a 32 bit x86 linux machine for
example the directory name is `org/libusb4java/linux-x86`. Usually
you can find the required name in the exception thrown by usb4java when it
does not find the required library.
<dependency>
<groupId>ru.redrise</groupId>
<artifactId>libusb4java</artifactId>
<classifier>linux-x86-64</classifier>
<version>1.0.30</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.redrise</groupId>
<artifactId>libusb4java</artifactId>
<classifier>win32-x86-64</classifier>
<version>1.0.30</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.redrise</groupId>
<artifactId>libusb4java</artifactId>
<classifier>linux-arm</classifier>
<version>1.0.30</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.redrise</groupId>
<artifactId>libusb4java</artifactId>
<classifier>linux-aarch64</classifier>
<version>1.0.30</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.redrise</groupId>
<artifactId>libusb4java</artifactId>
<classifier>darwin-x86-64</classifier>
<version>1.0.30</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ru.redrise</groupId>
<artifactId>libusb4java</artifactId>
<classifier>darwin-aarch64</classifier>
<version>1.0.30</version>
<scope>compile</scope>
</dependency>
</dependencies>
```
Loading
Loading