diff --git a/.cmake/Modules/FindLibUsb.cmake b/.cmake/Modules/FindLibUsb.cmake
index f0f6e54..a67a4a1 100644
--- a/.cmake/Modules/FindLibUsb.cmake
+++ b/.cmake/Modules/FindLibUsb.cmake
@@ -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)
@@ -40,7 +45,15 @@ 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)
@@ -48,10 +61,13 @@ 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})
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e2bb4f8..463203a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -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
@@ -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
diff --git a/.gitignore b/.gitignore
index d291403..b6e6027 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ target
/build
/.vs
/out/build/x64-Debug
+target
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61156ed..561ae78 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
@@ -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()
diff --git a/README.md b/README.md
index ba882df..e481c67 100644
--- a/README.md
+++ b/README.md
@@ -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
+
+
+ org.usb4java
+ usb4java
+ 1.3.0
+
+
+ org.usb4java
+ libusb4java
+
+
+ compile
+
- $ 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/-/`. 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.
+
+ ru.redrise
+ libusb4java
+ linux-x86-64
+ 1.0.30
+ compile
+
+
+ ru.redrise
+ libusb4java
+ win32-x86-64
+ 1.0.30
+ compile
+
+
+ ru.redrise
+ libusb4java
+ linux-arm
+ 1.0.30
+ compile
+
+
+ ru.redrise
+ libusb4java
+ linux-aarch64
+ 1.0.30
+ compile
+
+
+ ru.redrise
+ libusb4java
+ darwin-x86-64
+ 1.0.30
+ compile
+
+
+ ru.redrise
+ libusb4java
+ darwin-aarch64
+ 1.0.30
+ compile
+
+
+```
diff --git a/ci/deploy.sh b/ci/deploy.sh
new file mode 100755
index 0000000..f4eee08
--- /dev/null
+++ b/ci/deploy.sh
@@ -0,0 +1,191 @@
+#!/usr/bin/env bash
+# Sign the prebuilt per-platform native JARs (from target/) with GPG and
+# install them into the local Maven repository (always). Deployment to the
+# remote release repository defined in pom.xml distributionManagement
+# (id=redrise) is performed only after explicit user confirmation.
+#
+# Usage:
+# bash ci/deploy.sh # uses VERSION from pom.xml, jars in target/
+# VERSION=1.0.30 DIR=target bash ci/deploy.sh
+#
+# Requires: mvn, gpg (a GPG signing key already selected, e.g. via
+# gpg-preset-passphrase or a cached agent). Remote credentials are taken from
+# the REPO_USERNAME / REPO_PASSWORD environment variables (only needed for
+# the remote deploy step; ~/.m2/settings.xml is NOT consulted).
+
+set -euo pipefail
+
+VERSION="${VERSION:-$(grep -m1 -oP '(?<=).+(?=)' pom.xml)}"
+DIR="${DIR:-target}"
+POM="pom.xml"
+
+# GAV coordinates (explicit, so deploy-file does NOT need -DpomFile: with
+# pomFile the plugin resolves the POM artifact from the remote repository,
+# which fails on the very first deploy of a version).
+GROUP_ID="$(grep -m1 -oP '(?<=).+(?=)' "$POM")"
+ARTIFACT_ID="$(grep -m1 -oP '(?<=).+(?=)' "$POM")"
+if [ -z "$GROUP_ID" ] || [ -z "$ARTIFACT_ID" ]; then
+ echo "could not resolve groupId/artifactId in $POM" >&2
+ exit 1
+fi
+
+# Derive CLASSIFIERS dynamically from the per-platform JARs present in DIR
+# (expected naming: libusb4java-$VERSION-.jar).
+CLASSIFIERS=()
+for j in "$DIR"/libusb4java-"$VERSION"-*.jar; do
+ [ -e "$j" ] || continue
+ c="$(basename "$j")"
+ c="${c#libusb4java-$VERSION-}"
+ c="${c%.jar}"
+ CLASSIFIERS+=("$c")
+done
+if [ ${#CLASSIFIERS[@]} -eq 0 ]; then
+ echo "no libusb4java-$VERSION-*.jar found in $DIR" >&2
+ exit 1
+fi
+
+# Repository coordinates from pom.xml distributionManagement.
+DM_BLOCK="$(awk '//,/<\/distributionManagement>/' "$POM")"
+REPO_ID="$(printf '%s\n' "$DM_BLOCK" | grep -m1 -oP '(?<=).*?(?=)')"
+REPO_URL="$(printf '%s\n' "$DM_BLOCK" | grep -m1 -oP '(?<=).*?(?=)')"
+if [ -z "$REPO_ID" ] || [ -z "$REPO_URL" ]; then
+ echo "could not resolve distributionManagement repository in $POM" >&2
+ exit 1
+fi
+
+sign() {
+ gpg --batch --yes --armor --detach-sign --output "$1.asc" "$1"
+}
+
+# 1) Sign + install the POM into the local repository
+sign "$POM"
+mvn -q install:install-file \
+ -Dfile="$POM" \
+ -DpomFile="$POM" \
+ -Dpackaging=pom
+
+# 2) Sign + install each platform JAR into the local repository
+for c in "${CLASSIFIERS[@]}"; do
+ f="$DIR/libusb4java-$VERSION-$c.jar"
+ if [ ! -f "$f" ]; then
+ echo "missing artifact: $f" >&2
+ exit 1
+ fi
+ sign "$f"
+ mvn -q install:install-file \
+ -Dfile="$f" \
+ -DpomFile="$POM" \
+ -Dpackaging=jar \
+ -Dclassifier="$c"
+ echo "installed: libusb4java-$VERSION-$c"
+done
+
+echo "Done: installed libusb4java $VERSION (pom + ${#CLASSIFIERS[@]} classifiers) into local m2"
+
+# 3) Remote deploy only with explicit user consent
+answer=""
+read -r -p "Deploy to remote repository ${REPO_URL} (id=${REPO_ID})? [y/N] " answer || true
+case "${answer,,}" in
+ y|yes) ;;
+ *)
+ echo "Remote deploy skipped"
+ exit 0
+ ;;
+esac
+
+# 4) Remote credentials from environment variables (never from settings.xml)
+if [ -z "${REPO_USERNAME:-}" ] || [ -z "${REPO_PASSWORD:-}" ]; then
+ echo "REPO_USERNAME / REPO_PASSWORD must be set for remote deploy" >&2
+ exit 1
+fi
+
+xml_escape() {
+ local s="$1"
+ s="${s//&/\&}"
+ s="${s//\<}"
+ s="${s//>/\>}"
+ s="${s//\"/\"}"
+ printf '%s' "$s"
+}
+
+U="$(xml_escape "$REPO_USERNAME")"
+P="$(xml_escape "$REPO_PASSWORD")"
+
+# Temporary settings file holding the server credentials; 0600 by default.
+TMP_SETTINGS="$(mktemp "${TMPDIR:-/tmp}/maven-settings.XXXXXX")"
+# deploy-file resolves the *current* Maven project's POM from the remote repo.
+# Launched from this project root that project is libusb4java, so on a first
+# deploy the (not-yet-present) POM 404s and the deploy fails. Run deploy-file
+# from a directory with no pom.xml so there is no current project and only the
+# explicitly-named artifacts are uploaded.
+NEUTRAL="$(mktemp -d "${TMPDIR:-/tmp}/deploy-file.XXXXXX")"
+trap 'rm -f "$TMP_SETTINGS"; rm -rf "$NEUTRAL"' EXIT
+ROOT="$(pwd)"
+POM_ABS="$ROOT/$POM"
+cd "$NEUTRAL"
+cat > "$TMP_SETTINGS" <
+
+
+ ${REPO_ID}
+ ${U}
+ ${P}
+
+
+
+EOF
+
+# 4b) The releases repository is immutable: it has no DELETE and re-PUTting an
+# existing artifact returns 400. deploy-file (re)generates the .md5/.sha1 for
+# every artifact it uploads, so to refresh a stale checksum the artifact (and
+# its .md5/.sha1/.asc) must be deleted first, then this script re-deploys it.
+REPO_BASE="${REPO_URL%/}/$(printf '%s' "$GROUP_ID" | tr '.' '/')/$ARTIFACT_ID/$VERSION"
+remote_exists() { [ "$(curl -s -o /dev/null -w '%{http_code}' "$1")" = "200" ]; }
+
+require_absent() {
+ # $1 = artifact base URL (no extension); $2 = display name.
+ if remote_exists "$1"; then
+ echo "ERROR: $2 already exists in the immutable repo." >&2
+ echo " Delete $2 (and its .md5/.sha1/.asc) from the repo, then re-run." >&2
+ exit 1
+ fi
+}
+
+# 5) Deploy the POM (+ signature side artifact) to the remote repository
+POM_URL="$REPO_BASE/$ARTIFACT_ID-$VERSION.pom"
+require_absent "$POM_URL" "$ARTIFACT_ID-$VERSION.pom"
+mvn -q -s "$TMP_SETTINGS" deploy:deploy-file \
+ -Dfile="$POM_ABS" \
+ -DgroupId="$GROUP_ID" \
+ -DartifactId="$ARTIFACT_ID" \
+ -Dversion="$VERSION" \
+ -Dpackaging=pom \
+ -Dfiles="${POM_ABS}.asc" \
+ -Dtypes=pom.asc \
+ -Dclassifiers= \
+ -Durl="$REPO_URL" \
+ -DrepositoryId="$REPO_ID"
+echo "deployed: $ARTIFACT_ID-$VERSION.pom"
+
+# 6) Deploy each platform JAR (+ signature side artifact) under its classifier
+for c in "${CLASSIFIERS[@]}"; do
+ f="$ROOT/$DIR/libusb4java-$VERSION-$c.jar"
+ JAR_URL="$REPO_BASE/$ARTIFACT_ID-$VERSION-$c.jar"
+ require_absent "$JAR_URL" "$ARTIFACT_ID-$VERSION-$c.jar"
+ mvn -q -s "$TMP_SETTINGS" deploy:deploy-file \
+ -Dfile="$f" \
+ -DgroupId="$GROUP_ID" \
+ -DartifactId="$ARTIFACT_ID" \
+ -Dversion="$VERSION" \
+ -Dpackaging=jar \
+ -Dclassifier="$c" \
+ -DgeneratePom=false \
+ -Dfiles="$f.asc" \
+ -Dtypes=jar.asc \
+ -Dclassifiers="$c" \
+ -Durl="$REPO_URL" \
+ -DrepositoryId="$REPO_ID"
+ echo "deployed: libusb4java-$VERSION-$c"
+done
+
+echo "Done: deployed libusb4java $VERSION (pom + ${#CLASSIFIERS[@]} classifiers) to repo id=${REPO_ID}"
diff --git a/ci/deps_dll.sh b/ci/deps_dll.sh
new file mode 100755
index 0000000..409efbb
--- /dev/null
+++ b/ci/deps_dll.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# Build a self-contained static libusb from source for Windows (no vcpkg).
+# Built with MSVC via the libusb msvc/ static project so it matches the MSVC
+# toolchain used to build libusb4java.dll. Runs under Git Bash; the prefix is
+# converted to a Windows path (cygpath -w) because CMake/MSVC needs one.
+set -euo pipefail
+
+# shellcheck source=ci/libusb_build.sh
+source ci/libusb_build.sh
+
+# Locate MSBuild via vswhere (present on the GH windows image).
+MSBUILD="$(vswhere -latest -find 'MSBuild\**\Bin\MSBuild.exe' | head -n1)"
+[ -n "${MSBUILD}" ] || { echo "ERROR: MSBuild not found via vswhere" >&2; exit 1; }
+
+# Build the static lib (libusb_static.vcxproj -> libusb-1.0.lib).
+# The .vcxproj lives inside the extracted libusb source tree, so pass its
+# absolute Windows path (cygpath -w). MSYS2_ARG_CONV_EXCL stops Git Bash from
+# mangling the backslash path and the /p:... arguments before they reach MSBuild.
+VCPROJ_WIN="$(cygpath -w "${LIBUSB_SRC}/msvc/libusb_static.vcxproj")"
+export MSYS2_ARG_CONV_EXCL="*"
+"${MSBUILD}" "${VCPROJ_WIN}" /p:Configuration=Release /p:Platform=x64 /p:RuntimeLibrary=MT /m /v:minimal
+
+# msbuild emits the .lib under /build////lib/
+LIB_ARTIFACT="$(find "${LIBUSB_SRC}/build" -name 'libusb-1.0.lib' 2>/dev/null | head -n1)"
+[ -n "${LIB_ARTIFACT}" ] && [ -f "${LIB_ARTIFACT}" ] || { echo "ERROR: libusb-1.0.lib not found after msbuild" >&2; exit 1; }
+
+# Stage into a conventional prefix: /lib/libusb-1.0.lib and
+# /include/libusb-1.0/libusb.h (mirrors `make install` on Unix).
+mkdir -p "${LIBUSB_PREFIX}/lib" "${LIBUSB_PREFIX}/include/libusb-1.0"
+cp "${LIB_ARTIFACT}" "${LIBUSB_PREFIX}/lib/libusb-1.0.lib"
+cp "${LIBUSB_SRC}/libusb/libusb.h" "${LIBUSB_SRC}/libusb/version.h" "${LIBUSB_SRC}/libusb/version_nano.h" "${LIBUSB_PREFIX}/include/libusb-1.0/"
+
+test -f "${LIBUSB_PREFIX}/lib/libusb-1.0.lib" || { echo "ERROR: libusb-1.0.lib not staged" >&2; exit 1; }
+test -f "${LIBUSB_PREFIX}/include/libusb-1.0/libusb.h" || { echo "ERROR: libusb-1.0/libusb.h not staged" >&2; exit 1; }
+
+# Version guard: the built libusb must match the workflow VERSION exactly.
+MAJOR="$(grep -m1 '^#define LIBUSB_MAJOR' "${LIBUSB_SRC}/libusb/version.h" | awk '{print $3}')"
+MINOR="$(grep -m1 '^#define LIBUSB_MINOR' "${LIBUSB_SRC}/libusb/version.h" | awk '{print $3}')"
+MICRO="$(grep -m1 '^#define LIBUSB_MICRO' "${LIBUSB_SRC}/libusb/version.h" | awk '{print $3}')"
+INSTALLED="${MAJOR}.${MINOR}.${MICRO}"
+if [ "${INSTALLED}" != "${LIBUSB_VERSION}" ]; then
+ echo "ERROR: built libusb version is '${INSTALLED}', expected '${LIBUSB_VERSION}'" >&2
+ exit 1
+fi
+
+# LIBUSB_ROOT (Windows path) -> FindLibUsb.cmake uses \lib and \include
+LIBUSB_ROOT_WIN="$(cygpath -w "${LIBUSB_PREFIX}")"
+echo "LIBUSB_ROOT=${LIBUSB_ROOT_WIN}" >> "$GITHUB_ENV"
+# Static libusb on Windows needs the WinUSB system library linked in
+echo "LIBUSB_LDFLAGS=setupapi.lib" >> "$GITHUB_ENV"
diff --git a/ci/deps_dylib.sh b/ci/deps_dylib.sh
new file mode 100755
index 0000000..e096113
--- /dev/null
+++ b/ci/deps_dylib.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+# Build a self-contained static libusb from source for macOS (no brew libusb).
+# macOS does not ship autoconf/automake/libtool, so install just the autotools
+# chain via brew (build tooling only -- libusb itself is still built from source).
+# libusb has no udev backend on macOS, so no --disable-udev is needed.
+set -euo pipefail
+
+# shellcheck source=ci/libusb_build.sh
+source ci/libusb_build.sh
+
+brew install autoconf automake libtool
+
+cd "${LIBUSB_SRC}"
+autoreconf -fi
+./configure --prefix="${LIBUSB_PREFIX}" --disable-shared --enable-static
+make -j"$(sysctl -n hw.ncpu)"
+make install
+
+test -f "${LIBUSB_PREFIX}/lib/libusb-1.0.a" || { echo "ERROR: static libusb-1.0.a not built" >&2; exit 1; }
+test -f "${LIBUSB_PREFIX}/include/libusb-1.0/libusb.h" || { echo "ERROR: libusb-1.0/libusb.h not installed" >&2; exit 1; }
+
+# Version guard: the built libusb must match the workflow VERSION exactly.
+INSTALLED="$(grep -m1 '^Version:' "${LIBUSB_PREFIX}/lib/pkgconfig/libusb-1.0.pc" | awk '{print $2}')"
+if [ "${INSTALLED}" != "${LIBUSB_VERSION}" ]; then
+ echo "ERROR: built libusb version is '${INSTALLED}', expected '${LIBUSB_VERSION}'" >&2
+ exit 1
+fi
+
+# LIBUSB_ROOT -> FindLibUsb.cmake uses /lib and /include as search hints
+echo "LIBUSB_ROOT=${LIBUSB_PREFIX}" >> "$GITHUB_ENV"
+# Static libusb on macOS needs these frameworks linked into libusb4java.dylib
+echo "LIBUSB_LDFLAGS=-framework IOKit -framework CoreFoundation -framework Security" >> "$GITHUB_ENV"
diff --git a/ci/deps_so.sh b/ci/deps_so.sh
new file mode 100755
index 0000000..73b3720
--- /dev/null
+++ b/ci/deps_so.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# Build a self-contained static libusb from source for Linux.
+# apt has no static libusb-1.0.a, so we build one. --disable-udev keeps the .a
+# free of a libudev dependency so libusb4java.so stays fully self-contained.
+set -euo pipefail
+
+# shellcheck source=ci/libusb_build.sh
+source ci/libusb_build.sh
+
+sudo apt update -y
+sudo apt install -y build-essential autoconf automake libtool pkg-config
+
+cd "${LIBUSB_SRC}"
+autoreconf -fi
+# -fPIC is required: libusb4java.so is a shared object and pulls libusb's
+# objects out of the static .a, so they must be position-independent.
+CFLAGS="-fPIC" ./configure --prefix="${LIBUSB_PREFIX}" --disable-shared --enable-static --disable-udev
+make -j"$(nproc)"
+make install
+
+test -f "${LIBUSB_PREFIX}/lib/libusb-1.0.a" || { echo "ERROR: static libusb-1.0.a not built" >&2; exit 1; }
+test -f "${LIBUSB_PREFIX}/include/libusb-1.0/libusb.h" || { echo "ERROR: libusb-1.0/libusb.h not installed" >&2; exit 1; }
+
+# Version guard: the built libusb must match the workflow VERSION exactly.
+INSTALLED="$(grep -m1 '^Version:' "${LIBUSB_PREFIX}/lib/pkgconfig/libusb-1.0.pc" | awk '{print $2}')"
+if [ "${INSTALLED}" != "${LIBUSB_VERSION}" ]; then
+ echo "ERROR: built libusb version is '${INSTALLED}', expected '${LIBUSB_VERSION}'" >&2
+ exit 1
+fi
+
+# LIBUSB_ROOT -> FindLibUsb.cmake uses /lib and /include as search hints
+echo "LIBUSB_ROOT=${LIBUSB_PREFIX}" >> "$GITHUB_ENV"
+# Static libusb on Linux needs pthread/rt linked into libusb4java.so
+echo "LIBUSB_LDFLAGS=-lpthread -lrt" >> "$GITHUB_ENV"
diff --git a/ci/libusb_build.sh b/ci/libusb_build.sh
new file mode 100755
index 0000000..91b7f80
--- /dev/null
+++ b/ci/libusb_build.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# Download + extract libusb $VERSION source into the workspace
+# Sourced by the per-platform deps_*.sh scripts. After sourcing, these are set:
+# LIBUSB_VERSION libusb version to build (single source of truth: workflow VERSION)
+# LIBUSB_BUILD_DIR workspace dir that holds the source tree
+# LIBUSB_PREFIX install prefix the platform build script must install into
+# LIBUSB_SRC extracted source root ($LIBUSB_BUILD_DIR/libusb-$LIBUSB_VERSION)
+set -euo pipefail
+
+# VERSION is the single source of truth, set in .github/workflows/ci.yml.
+LIBUSB_VERSION="${VERSION:?ERROR: VERSION is not set; define it in .github/workflows/ci.yml}"
+
+# On Windows (Git Bash) GITHUB_WORKSPACE is a Windows path (D:\a\...); the bash
+# tools in this script need a POSIX path, so convert it. On Linux/macOS it is
+# already POSIX and cygpath is absent, so leave it untouched.
+WORKSPACE="${GITHUB_WORKSPACE}"
+if [ -n "${MSYSTEM:-}" ]; then
+ WORKSPACE="$(cygpath -u "${GITHUB_WORKSPACE}")"
+fi
+LIBUSB_BUILD_DIR="${WORKSPACE}/libusb-build"
+LIBUSB_PREFIX="${LIBUSB_BUILD_DIR}/prefix"
+LIBUSB_SRC="${LIBUSB_BUILD_DIR}/libusb-${LIBUSB_VERSION}"
+
+rm -rf "${LIBUSB_BUILD_DIR}"
+mkdir -p "${LIBUSB_BUILD_DIR}"
+curl -fsSL "https://github.com/libusb/libusb/releases/download/v${LIBUSB_VERSION}/libusb-${LIBUSB_VERSION}.tar.bz2" \
+ | tar xj -C "${LIBUSB_BUILD_DIR}"
+
+test -d "${LIBUSB_SRC}" || { echo "ERROR: failed to download/extract libusb-${LIBUSB_VERSION}" >&2; exit 1; }
diff --git a/dists/README.md b/dists/README.md
deleted file mode 100644
index 6d15955..0000000
--- a/dists/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-This directory contains the build scripts used by the usb4java CI server to
-automatically build the native libraries shipped with usb4java.
-
-If you want to build your own native library for a platform which is not
-supported by usb4java out-of-the-box then this might be the wrong place for
-you. Follow the instructions in the README.md file in the root directory of
-the project instead.
-
-The bundle script can be used to create a distribution bundle ready to be
-uploaded to Sonatype Nexus. It requires already build and deployed SNAPSHOT
-versions of all the native JARs.
diff --git a/dists/bundle b/dists/bundle
deleted file mode 100755
index 85a9ae8..0000000
--- a/dists/bundle
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2018 Klaus Reimer
-# See LICENSE.md for licensing information.
-#
-
-# Exit on errors
-set -e
-
-# Go to project root directory
-cd "$(dirname $0)/.."
-
-# Get version from pom.xml
-VERSION=$(sed -nE '0,//s/.*(.*?)<\/version>.*/\1/p' pom.xml)
-
-# Determine SNAPSHOT version
-SNAPSHOT_VERSION=$(echo $VERSION | sed s/-SNAPSHOT//)-SNAPSHOT
-
-# Prepare bundle directory
-rm -rf target/bundle/
-mkdir -p target/bundle
-
-# Download latest snapshot platform JARs
-PLATFORMS="
- linux-x86
- linux-x86-64
- linux-arm
- linux-armel
- linux-aarch64
- win32-x86
- win32-x86-64
- darwin-x86-64
- darwin-aarch64
-"
-for PLATFORM in $PLATFORMS
-do
- mvn dependency:copy -Dartifact=org.usb4java:libusb4java:$SNAPSHOT_VERSION:jar:$PLATFORM \
- -DoutputDirectory=target/bundle/ -Dmdep.stripVersion=true
- mv target/bundle/libusb4java-$PLATFORM.jar target/bundle/libusb4java-$VERSION-$PLATFORM.jar
-done
-
-# Copy pom to bundle directory
-cp pom.xml target/bundle/libusb4java-$VERSION.pom
-
-# Sign all files
-for FILE in target/bundle/*
-do
- gpg -a --detach-sig $FILE
-done
-
-# Create bundle JAR file
-cd target/bundle
-jar cf ../libusb4java-$VERSION-bundle.jar *
diff --git a/dists/darwin/build b/dists/darwin/build
deleted file mode 100755
index a11de9e..0000000
--- a/dists/darwin/build
+++ /dev/null
@@ -1,96 +0,0 @@
-#1/bin/bash
-# ============================================================================
-# Build script for Mac OS X.
-#
-# The script automatically compiles the binary for x86-64 and aarch64.
-# Then it creates the corresponding JAR file in the target folder containing
-# both architecture builds.
-# The libusb sources are pulled from the GitHub tag matching the configured
-# version.
-#
-# Requirements: cmake, make, curl, jar
-# ============================================================================
-
-# Fail on all errors
-set -e
-
-# Software versions
-LIBUSB_VERSION=1.0.28
-
-# Determine OS
-OS=darwin
-
-# Determine directories
-cd "$(dirname $0)/../.."
-PROJECT_DIR="$(pwd)"
-TARGET_DIR="$PROJECT_DIR/target"
-JAR_FILE=$TARGET_DIR/libusb4java-$OS.jar
-
-# Download libusb from GitHub and unzip
-DOWNLOAD_DIR="$TARGET_DIR/downloads"
-
-# Clean up target directory
-rm -rf "$TARGET_DIR"
-
-# Create download directory if not already present
-mkdir -p "$DOWNLOAD_DIR"
-
-LIBUSB_TARBALL="v$LIBUSB_VERSION.zip"
-LIBUSB_SOURCE=https://github.com/libusb/libusb/archive/$LIBUSB_TARBALL
-LIBUSB_TARGET="$DOWNLOAD_DIR/$LIBUSB_TARBALL"
-if [ ! -f "$LIBUSB_TARGET" ]
-then
- curl -C - -o "$LIBUSB_TARGET.download" -L "$LIBUSB_SOURCE"
- mv -f "$LIBUSB_TARGET.download" "$LIBUSB_TARGET"
-fi
-
-build_architecture () {
-
- local ARCH_ID=$1
- local ARCH=$2
- echo "Building for platform $OS-$ARCH"
- local BUILD_DIR="$TARGET_DIR/build/darwin-$ARCH"
- local ROOT_DIR="$BUILD_DIR/root"
-
- # Standard compiler and linker flags
- local CFLAGS="-I$ROOT_DIR/include -arch $ARCH"
- local LDFLAGS="-L$ROOT_DIR/lib"
-
- # Export compiler and linker flags
- export CFLAGS LDFLAGS
-
- # Unzip libusb
- mkdir -p "$BUILD_DIR"
- cd "$BUILD_DIR"
- unzip "$LIBUSB_TARGET"
- mv "$BUILD_DIR/libusb-$LIBUSB_VERSION" "$BUILD_DIR/libusb"
- cd "$BUILD_DIR/libusb"
-
- # Build libusb
- autoreconf -i
- ./configure --disable-shared --enable-static --with-pic --prefix="$ROOT_DIR" --host=$ARCH
- make install-strip
-
- # Build libusb4java
- mkdir -p "$BUILD_DIR/libusb4java"
- cd "$BUILD_DIR/libusb4java"
- PKG_CONFIG_PATH="$ROOT_DIR/lib/pkgconfig" cmake "$PROJECT_DIR" \
- -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_INSTALL_PREFIX="" \
- -DCMAKE_OSX_ARCHITECTURES=$ARCH \
- -DLibUsb_USE_STATIC_LIBS=true
- make install/strip DESTDIR="$ROOT_DIR"
-
- # Create the JAR file
- mkdir -p "$BUILD_DIR/classes/org/usb4java/$OS-$ARCH_ID"
- cp "$ROOT_DIR/lib/libusb4java.dylib" "$BUILD_DIR/classes/org/usb4java/$OS-$ARCH_ID"
-
- if [ -f "$JAR_FILE" ]; then
- jar uf "$JAR_FILE" -C "$BUILD_DIR/classes" org
- else
- jar cf "$JAR_FILE" -C "$BUILD_DIR/classes" org
- fi
-}
-
-build_architecture x86-64 x86_64
-build_architecture aarch64 arm64
diff --git a/dists/linux/Dockerfile b/dists/linux/Dockerfile
deleted file mode 100644
index 695b9b5..0000000
--- a/dists/linux/Dockerfile
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (C) 2018 Klaus Reimer
-# See LICENSE.md for licensing information.
-#
-
-ARG DOCKER_ARCH
-FROM $DOCKER_ARCH/debian:bookworm
-
-ARG OS_ARCH
-ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-$OS_ARCH
-
-ENV LIBUSB_VERSION=1.0.28
-ENV EUDEV_VERSION=3.2.14
-
-# Copy optional qemu binaries
-ARG ARCH
-COPY target/build/linux-$ARCH/qemu* /usr/bin/
-
-# Install debian updates
-RUN apt update && apt upgrade -y
-
-# Install required debian packages
-RUN apt install -y gnome-icon-theme gcc cmake curl gperf bzip2 openjdk-17-jdk
-
-# Install eudev
-RUN mkdir -p /tmp/eudev; \
- cd /tmp/eudev; \
- curl -L https://github.com/eudev-project/eudev/releases/download/v$EUDEV_VERSION/eudev-$EUDEV_VERSION.tar.gz | tar xvz --strip-components 1; \
- ./configure \
- --disable-shared \
- --enable-static \
- --with-pic \
- --enable-split-usr \
- --disable-manpages \
- --disable-kmod \
- --disable-selinux \
- --disable-blkid \
- --prefix=/usr/local; \
- make install-strip; \
- rm -rf /tmp/eudev
-
-# Install libusb
-RUN mkdir -p /tmp/libusb; \
- cd /tmp/libusb; \
- curl -L https://github.com/libusb/libusb/releases/download/v$LIBUSB_VERSION/libusb-$LIBUSB_VERSION.tar.bz2 | tar xvj --strip-components 1; \
- ./configure \
- --disable-shared \
- --enable-static \
- --with-pic \
- --prefix=/usr/local; \
- make install-strip; \
- rm -rf /tmp/libusb
diff --git a/dists/linux/Dockerfile.arm b/dists/linux/Dockerfile.arm
deleted file mode 100644
index 20db99e..0000000
--- a/dists/linux/Dockerfile.arm
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright (C) 2018 Klaus Reimer
-# See LICENSE.md for licensing information.
-#
-
-FROM debian:stretch
-
-ENV LIBUSB_VERSION=1.0.24
-
-# Install debian updates
-RUN apt-get update && apt-get upgrade -y
-
-# Install required debian packages
-RUN apt-get install -y cmake curl gperf bzip2 gcj-6-jdk git
-
-# Install Raspberry Pi tools
-RUN cd /opt; \
- git clone --depth 1 https://github.com/raspberrypi/tools
-
-# Install eudev
-RUN mkdir -p /tmp/eudev; \
- cd /tmp/eudev; \
- curl -L http://dev.gentoo.org/~blueness/eudev/eudev-3.2.6.tar.gz | tar xvz --strip-components 1; \
- export PATH=/opt/tools/arm-bcm2708/arm-linux-gnueabihf/bin:$PATH; \
- ./configure \
- --host=arm-linux-gnueabihf \
- --disable-shared \
- --enable-static \
- --with-pic \
- --enable-split-usr \
- --disable-manpages \
- --disable-kmod \
- --disable-selinux \
- --disable-blkid \
- --prefix=/usr/local; \
- make install-strip; \
- rm -rf /tmp/eudev
-
-# Install libusb
-RUN mkdir -p /tmp/libusb; \
- cd /tmp/libusb; \
- curl -L https://github.com/libusb/libusb/releases/download/v$LIBUSB_VERSION/libusb-$LIBUSB_VERSION.tar.bz2 | tar xvj --strip-components 1; \
- export PATH=/opt/tools/arm-bcm2708/arm-linux-gnueabihf/bin:$PATH; \
- export CFLAGS=-I/usr/local/include; \
- export CPPFLAGS=-I/usr/local/include; \
- export LDFLAGS=-L/usr/local/lib; \
- ./configure \
- --host=arm-linux-gnueabihf \
- --disable-shared \
- --enable-static \
- --with-pic \
- --prefix=/usr/local; \
- make install-strip; \
- rm -rf /tmp/libusb
diff --git a/dists/linux/README.md b/dists/linux/README.md
deleted file mode 100644
index cd28f2f..0000000
--- a/dists/linux/README.md
+++ /dev/null
@@ -1,86 +0,0 @@
-Linux Build
-===========
-
-This build script automatically compiles the native libusb4java library for the given architecture. It is primarily
-written to be used on a X86-64 Debian machine but may work on other systems as well.
-
-The first build for a specific architecture takes a long time because a matching Docker image is created first. This
-image is based on Debian Stretch and is filled with all necessary tools and libraries to build libusb4java. The
-Docker image is cached so the next build for the same architecture will be much faster.
-
-
-## Requirements
-
-The following packages must be installed before running the build script:
-
- # apt install binfmt-support qemu-user-static
-
-[Docker] must be installed by following the official installation instructions.
-
-After installing Docker it is recommended to put your user into the docker group and logout and in again to apply the
-change. Then you are able to use docker without root privileges.
-
-
-## Parameters
-
-The first parameter of the build script defines the target platform architecture. This is for example `x86`, `x86-64`,
-`arm` or `aarch64`. The architecture naming convention of usb4java follows the one of the [Java Native Access] project.
-
-The second parameter is optional and defines the static qemu binary which is necessary for cross compiling.
-
-
-## Example usages
-
-Build a X86 (32 bit) library on a X86 or X86-64 host system:
-
- $ ./build x86
-
-Build a X86-64 library on a X86-64 host system:
-
- $ ./build x86-64
-
-Build a ARM-HF (32 bit) library:
-
- $ ./build arm /usr/bin/qemu-arm-static
-
-Build a AARCH64 (ARM 64 Bit) library:
-
- $ ./build aarch64 /usr/bin/qemu-aarch64-static
-
-In theory this works for many more architectures as long as there is a Debian Stretch docker image for this
-architecture and the architecture is supported by qemu. New entries in the architecture mapping in the build script
-might be needed in case the java architecture name differs from the Debian architecture name in the docker library.
-
-
-## Some notes about Docker
-
-### Disable bridge networking
-
-If you don't need Docker for anything else and you don't like Docker's default behavior of creating bridge networking
-devices and firewall rules then you might want to disable all this by creating the config file `/etc/docker/daemon.json`
-with the following content:
-
- {
- "bridge": "none",
- "iptables": false,
- "ip-masq": false,
- "ip-forward": false
- }
-
-Run `sudo systemctl restart docker` to apply the changes. The libusb4java build script uses host networking which
-doesn't need bridge network devices.
-
-
-### Cleaning up
-
-All the created Docker images uses a lot of disk space. You can remove them with `docker system prune -a`.
-
-
-## Known issues
-
-While the build script is able to create a binary for the ARM architecture this will not work on a Raspberry
-Pi 1. Would be nice to get it running, I tried for days, but I didn't succeed. That's why there is a special build
-script for ARM which uses the Raspberry Pi cross compiler toolchain.
-
-[Java Native Access]: https://github.com/java-native-access/jna/tree/master/dist/
-[Docker]: https://docs.docker.com/install/linux/docker-ce/debian/
diff --git a/dists/linux/build b/dists/linux/build
deleted file mode 100755
index c2db50b..0000000
--- a/dists/linux/build
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2018 Klaus Reimer
-# See LICENSE.md for licensing information.
-#
-
-# Exit on errors
-set -e
-
-# Go to base directory
-cd $(dirname $0)/../..
-
-# Show syntax help when called with wrong number of parameters
-if [ $# -lt 1 ] || [ $# -gt 2 ]
-then
- echo "Syntax: $0 ARCH [QEMU]"
- exit 1
-fi
-
-# Fetch CLI arguments and create some helper variables
-ARCH=$1
-QEMU=$2
-OS=linux
-TARGET=target
-BUILD=$TARGET/build/$OS-$ARCH
-
-# Map specified architecture to a debian docker image architecture
-case $ARCH in
- x86-64)
- DOCKER_ARCH=amd64
- OS_ARCH=amd64
- ;;
- x86)
- DOCKER_ARCH=i386
- OS_ARCH=i386
- ;;
- aarch64)
- DOCKER_ARCH=arm64v8
- OS_ARCH=arm64
- ;;
- arm)
- DOCKER_ARCH=arm32v7
- OS_ARCH=armhf
- ;;
- armel)
- DOCKER_ARCH=arm32v5
- OS_ARCH=armel
- ;;
- *)
- DOCKER_ARCH=$ARCH
- OS_ARCH=$ARCH
- ;;
-esac
-
-# Create build directory
-mkdir -p $BUILD
-
-# Copy qemu binary to build directory if specified
-if [ "$QEMU" != "" ]
-then
- cp -f $QEMU $BUILD/
-else
- # Dummy file to keep COPY in Dockerfile happy
- touch $BUILD/qemu-none
-fi
-
-# Build docker image
-docker build . \
- --network host \
- -f dists/linux/Dockerfile \
- --build-arg ARCH=$ARCH \
- --build-arg DOCKER_ARCH=$DOCKER_ARCH \
- --build-arg OS_ARCH=$OS_ARCH \
- -t usb4java-build-$ARCH
-
-# Compile libusb4java in docker image
-docker run \
- -u $(id -u $USER):$(id -g $USER) \
- --network host \
- --rm \
- -v $(pwd):/workspace \
- usb4java-build-$ARCH \
- /bin/bash -c "
- cd /workspace/$BUILD;
- cmake ../../.. \
- -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_INSTALL_PREFIX='' \
- -DLibUsb_LIBRARIES='/usr/local/lib/libusb-1.0.a;/usr/local/lib/libudev.a' \
- -DLibUsb_LDFLAGS='-pthread -lrt';
- make install/strip DESTDIR=/workspace/$BUILD
- "
-
-# Create the JAR file
-mkdir -p "$BUILD/classes/org/usb4java/$OS-$ARCH"
-cp "$BUILD/lib/libusb4java.so" "$BUILD/classes/org/usb4java/$OS-$ARCH"
-jar cf "$TARGET/libusb4java-$OS-$ARCH.jar" -C "$BUILD/classes" org
diff --git a/dists/linux/build-all b/dists/linux/build-all
deleted file mode 100755
index 911f0d5..0000000
--- a/dists/linux/build-all
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2018 Klaus Reimer
-# See LICENSE.md for licensing information.
-#
-
-# Exit on errors
-set -e
-
-# Go to base directory of linux build scripts
-cd $(dirname $0)
-
-# Build X86 library
-./build x86
-
-# Build X86-64 library
-./build x86-64
-
-# Build ARM 64-bit library (ARMv8 and higher)
-./build aarch64
-
-# Build ARM 32-bit library (ARMv7 and higher)
-./build arm
-
-# Build ARM 32-bit library (ARMv4T and higher)
-./build armel
diff --git a/dists/linux/build-arm b/dists/linux/build-arm
deleted file mode 100755
index 4652bbe..0000000
--- a/dists/linux/build-arm
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2018 Klaus Reimer
-# See LICENSE.md for licensing information.
-#
-
-# Exit on errors
-set -e
-
-# Go to base directory
-cd $(dirname $0)/../..
-
-# Create some helper variables
-TARGET=target
-BUILD=$TARGET/build/linux-arm-rpt
-
-# Create build directory
-mkdir -p $BUILD
-
-# Build docker image
-docker build . \
- --network host \
- -f dists/linux/Dockerfile.arm \
- -t usb4java-build-arm-rpt
-
-# Compile libusb4java in docker image
-docker run \
- -u $(id -u $USER):$(id -g $USER) \
- --network host \
- --rm \
- -v $(pwd):/workspace \
- usb4java-build-arm-rpt \
- /bin/bash -c "
- cd /workspace/$BUILD;
- export PATH=/opt/tools/arm-bcm2708/arm-linux-gnueabihf/bin:$PATH;
- JAVA_HOME=/usr/lib/jvm/java-gcj-6 cmake ../../.. \
- -DCMAKE_SYSTEM_NAME=Linux \
- -DCMAKE_SYSTEM_PROCESSOR=arm \
- -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
- -DCMAKE_BUILD_TYPE=Release \
- -DCMAKE_INSTALL_PREFIX='' \
- -DLibUsb_LIBRARIES='/usr/local/lib/libusb-1.0.a;/usr/local/lib/libudev.a' \
- -DLibUsb_LDFLAGS='-pthread -lrt';
- make install/strip DESTDIR=/workspace/$BUILD
- "
-
-# Create the JAR file
-mkdir -p "$BUILD/classes/org/usb4java/linux-arm"
-cp "$BUILD/lib/libusb4java.so" "$BUILD/classes/org/usb4java/linux-arm"
-jar cf "$TARGET/libusb4java-linux-arm.jar" -C "$BUILD/classes" org
diff --git a/dists/win32/build-all.bat b/dists/win32/build-all.bat
deleted file mode 100644
index 1a0ebda..0000000
--- a/dists/win32/build-all.bat
+++ /dev/null
@@ -1,15 +0,0 @@
-@echo off
-
-rem Variables - General
-for %%I in ("%~dp0.") do set "SCRIPT_DIR=%%~fI"
-set "BUILD_BAT=%SCRIPT_DIR%\build.bat"
-
-rem Variables - Visual Studio
-set "VSWHERE_EXE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
-set "VSWHERE_OPTIONS=-latest -property installationPath -format value"
-for /f "delims=" %%i in ('"%VSWHERE_EXE%" %VSWHERE_OPTIONS%') do set "VS_PATH=%%i"
-set "VSDEVCMD_BAT=%VS_PATH%\Common7\Tools\VsDevCmd.bat"
-
-rem Main
-cmd /c ""%VSDEVCMD_BAT%" && "%BUILD_BAT%""
-cmd /c ""%VSDEVCMD_BAT%" -host_arch=amd64 -arch=amd64 && set "PLATFORM=x64" && "%BUILD_BAT%""
\ No newline at end of file
diff --git a/dists/win32/build.bat b/dists/win32/build.bat
deleted file mode 100644
index 0dcaa73..0000000
--- a/dists/win32/build.bat
+++ /dev/null
@@ -1,96 +0,0 @@
-@echo off
-rem ======================================================================
-rem Build script for Windows.
-rem
-rem Execute the script inside the Visual Studio Command line prompt for
-rem 64 bit or 32 bit. The script automatically compiles the binary for
-rem the corresponding platform and creates the JAR file in the target
-rem folder.
-rem
-rem Dependencies: cmake, curl, jar and 7z must be callable via PATH.
-rem Visual Studio 2017 Build Tools must be installed.
-rem ======================================================================
-
-rem ----------------------------------------------------------------------
-rem Setup variables
-rem ----------------------------------------------------------------------
-
-set LIBUSB_VERSION=1.0.28
-
-set CURRENT=%cd%
-set PROJECT_DIR=%~dp0..\..
-set OS=win32
-if /i "%Platform%" == "x64" (
- set ARCH=x86-64
- set LIBUSB_ARCH=MS64
-) else (
- set ARCH=x86
- set LIBUSB_ARCH=MS32
-)
-set TARGET_DIR=%PROJECT_DIR%\target
-set BUILD_DIR=%TARGET_DIR%\build\%OS%-%ARCH%
-set ROOT_DIR=%BUILD_DIR%\root
-
-
-rem
-rem Compile libusb.
-rem We do this manually because we need the /MT option and the provided
-rem build script unfortunately only works with an old Windows DDK instead
-rem of using Visual Studio.
-rem
-
-set LIBUSB_NAME=libusb-%LIBUSB_VERSION%
-set LIBUSB_COMPRESSED_ARCHIVE=%LIBUSB_NAME%.tar.bz2
-set LIBUSB_ARCHIVE=v%LIBUSB_VERSION%.zip
-mkdir "%ROOT_DIR%"
-cd "%ROOT_DIR%
-curl -L -o "%LIBUSB_ARCHIVE%" https://github.com/libusb/libusb/archive/%LIBUSB_ARCHIVE% || goto :error
-7z -y x "%LIBUSB_ARCHIVE%" || goto :error
-cd "%LIBUSB_NAME%"
-mkdir build
-cd build
-cl /DHAVE_STRUCT_TIMESPEC /nologo /c /MT /I..\libusb /I..\msvc ..\libusb\*.c ..\libusb\os\windows*.c ..\libusb\os\*windows.c
-lib /nologo /out:libusb.lib *.obj
-
-
-rem ----------------------------------------------------------------------
-rem Build libusb4java
-rem ----------------------------------------------------------------------
-
-mkdir "%BUILD_DIR%"
-cd "%BUILD_DIR%"
-
-cmake "%PROJECT_DIR%" -G "NMake Makefiles" ^
- -DCMAKE_BUILD_TYPE=Release ^
- -DCMAKE_INSTALL_PREFIX="" ^
- -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /D NDEBUG" ^
- -DLibUsb_INCLUDE_DIRS="%ROOT_DIR%\%LIBUSB_NAME%\libusb" ^
- -DLibUsb_LIBRARIES="%ROOT_DIR%\%LIBUSB_NAME%\build\libusb.lib" || goto :error
-nmake || goto :error
-nmake install DESTDIR="%ROOT_DIR%" || goto :error
-
-
-rem ----------------------------------------------------------------------
-rem Create the JAR file
-rem ----------------------------------------------------------------------
-
-mkdir "classes\org\usb4java\%OS%-%ARCH%"
-copy "%ROOT_DIR%\lib\usb4java.dll" classes\org\usb4java\%OS%-%ARCH%\libusb4java.dll || goto :error
-jar cf "%TARGET_DIR%\libusb4java-%OS%-%ARCH%.jar" -C classes org || goto :error
-
-
-rem ----------------------------------------------------------------------
-rem Clean up and go back to original directory
-rem ----------------------------------------------------------------------
-
-cd "%CURRENT%"
-goto :end
-
-:error
-set ERRORCODE=%errorlevel%
-echo Failed with error #%ERRORCODE%
-cd "%CURRENT%"
-exit /b %ERRORCODE%
-
-:end
-echo Finished
diff --git a/pom.xml b/pom.xml
index da23b4b..a336a68 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,17 +2,17 @@
4.0.0
- org.usb4java
+ ru.redrise
libusb4java
pom
libusb4java
- 1.3.1-SNAPSHOT
- https://github.com/usb4java/libusb4java/
- The native JNI library used by usb4java
- 2011
+ 1.0.30
+ https://redrise.ru/
+ Libusb native JNI builds used by usb4java
+ 2026
- usb4java Team
- http://usb4java.org/
+ developersu
+ https://redrise.ru/
@@ -23,23 +23,13 @@
-
-
- Discussions
- usb4java+subscribe@googlegroups.com
- usb4java+unsubscribe@googlegroups.com
- usb4java@googlegroups.com
- http://groups.google.com/group/usb4java
-
-
-
kayahr
Klaus Reimer
k@ailis.de
- Developer
+ usb4java Team Developer
+1
http://www.ailis.de/~k/
@@ -49,11 +39,20 @@
Luca Longinotti
l@longi.li
- Developer
+ usb4java Team Developer
+1
http://l.longi.li/
+
+ developersu
+ Dmitry Isaenko
+
+ Standalone CI pipeline maintainer
+
+ +3
+ http://redrise.ru/
+
@@ -62,76 +61,47 @@
- scm:git:git://github.com/usb4java/${project.artifactId}.git
- scm:git:ssh://git@github.com/usb4java/${project.artifactId}.git
- http://github.com/usb4java/${project.artifactId}
+ scm:git:git://github.com/developersu/${project.artifactId}.git
+ scm:git:ssh://git@github.com/developersu/${project.artifactId}.git
+ http://github.com/developersu/${project.artifactId}
HEAD
GitHub
- https://github.com/usb4java/${project.artifactId}/issues
+ https://github.com/developersu/${project.artifactId}/issues
- 3.0.5
+ 3.6.3
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.22.0
-
org.apache.maven.plugins
maven-clean-plugin
- 3.1.0
-
-
- org.apache.maven.plugins
- maven-deploy-plugin
- 3.0.0-M1
+ 3.2.0
org.apache.maven.plugins
maven-install-plugin
- 3.0.0-M1
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.1.0
+ 3.1.2
org.apache.maven.plugins
- maven-resources-plugin
- 3.1.0
-
-
- org.apache.maven.plugins
- maven-site-plugin
- 3.7.1
+ maven-deploy-plugin
+ 3.1.2
-
+
- sonatype-snapshots
- Sonatype Snapshot Repository
- https://oss.sonatype.org/content/repositories/snapshots
- true
+ redrise
+ Redrise Release Repository
+ https://repo.redrise.ru/releases/
-
-
-
-
- sonatype-snapshots
- Sonatype Snapshot Repository
- https://oss.sonatype.org/content/repositories/snapshots
-
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a739520..1300f87 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,18 @@
file(GLOB_RECURSE USB4JAVA_SOURCES *.c)
add_library(usb4java SHARED ${USB4JAVA_SOURCES})
+# On Unix the .so/.dylib is a library artifact (LIBRARY_OUTPUT_DIRECTORY). On
+# Windows the .dll is a RUNTIME artifact and its import .lib uses
+# IMPORT_LIBRARY_OUTPUT_DIRECTORY, so set all of them to keep the artifact in
+# /out for every generator/config.
+set_target_properties(usb4java PROPERTIES
+ PREFIX "lib"
+ LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out
+ LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/out
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out
+ RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/out
+ IMPORT_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out
+ IMPORT_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/out
+)
target_link_libraries(usb4java ${LibUsb_LIBRARIES})
if(CMAKE_COMPILER_IS_GNUCC)
set_target_properties(usb4java PROPERTIES LINK_FLAGS -static-libgcc)