Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build scripts #16

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.14)

project(usb4java C)
set(PROJECT_VERSION 1.3.1)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ already includes prebuilt libraries for the following platforms:
* linux-x86
* linux-x86-64
* linux-arm
* linux-armel
* linux-aarch64
* win32-x86
* win32-x86-64
Expand Down
4 changes: 3 additions & 1 deletion dists/bundle
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ mkdir -p target/bundle

# Download latest snapshot platform JARs
PLATFORMS="
linux-x86-64
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
Expand Down
19 changes: 9 additions & 10 deletions dists/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
# See LICENSE.md for licensing information.
#

ARG DEBARCH
FROM $DEBARCH/debian:stretch
ARG DOCKER_ARCH
FROM $DOCKER_ARCH/debian:bullseye

ARG OS_ARCH
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-$OS_ARCH

ENV LIBUSB_VERSION=1.0.24
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-get update && apt-get upgrade -y

# Workaround for armhf architecture: This package can't be installed later as a
# dependency of gcj-6-jdk (Corrupt tarball error messages) but for some reason
# it works when it is installed beforehand
RUN apt-get install -y gnome-icon-theme
RUN apt update && apt upgrade -y

# Install required debian packages
RUN apt-get install -y gcc cmake curl gperf bzip2 gcj-6-jdk
RUN apt install -y gnome-icon-theme gcc cmake curl gperf bzip2 openjdk-11-jdk

# 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; \
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 \
Expand Down
25 changes: 19 additions & 6 deletions dists/linux/build
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,28 @@ BUILD=$TARGET/build/$OS-$ARCH
# Map specified architecture to a debian docker image architecture
case $ARCH in
x86-64)
DEBARCH=amd64
DOCKER_ARCH=amd64
OS_ARCH=amd64
;;
x86)
DEBARCH=i386
DOCKER_ARCH=i386
OS_ARCH=i386
;;
aarch64)
DOCKER_ARCH=arm64v8
OS_ARCH=arm64
;;
arm)
DEBARCH=armhf
DOCKER_ARCH=arm32v7
OS_ARCH=armhf
;;
armel)
DOCKER_ARCH=arm32v5
OS_ARCH=armel
;;
*)
DEBARCH=$ARCH
DOCKER_ARCH=$ARCH
OS_ARCH=$ARCH
;;
esac

Expand All @@ -57,7 +69,8 @@ docker build . \
--network host \
-f dists/linux/Dockerfile \
--build-arg ARCH=$ARCH \
--build-arg DEBARCH=$DEBARCH \
--build-arg DOCKER_ARCH=$DOCKER_ARCH \
--build-arg OS_ARCH=$OS_ARCH \
-t usb4java-build-$ARCH

# Compile libusb4java in docker image
Expand All @@ -69,7 +82,7 @@ docker run \
usb4java-build-$ARCH \
/bin/bash -c "
cd /workspace/$BUILD;
JAVA_HOME=/usr/lib/jvm/java-gcj-6 cmake ../../.. \
cmake ../../.. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX='' \
-DLibUsb_LIBRARIES='/usr/local/lib/libusb-1.0.a;/usr/local/lib/libudev.a' \
Expand Down
11 changes: 7 additions & 4 deletions dists/linux/build-all
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ cd $(dirname $0)
# Build X86-64 library
./build x86-64

# Build AARCH64 library
./build aarch64 /usr/bin/qemu-aarch64-static
# Build ARM 64-bit library (ARMv8 and higher)
./build aarch64

# Build ARM library
./build-arm
# Build ARM 32-bit library (ARMv7 and higher)
./build arm

# Build ARM 32-bit library (ARMv4T and higher)
./build armel
15 changes: 15 additions & 0 deletions dists/win32/build-all.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@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%""