-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathbuild-hidapi.sh
executable file
·555 lines (481 loc) · 22 KB
/
build-hidapi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
#!/usr/bin/env bash
# Convenience script to build hidapi locally
# Directory structure is
# ~/Workspaces
# + Cpp
# + hidapi (https://github.com/libusb/hidapi)
# + Docker
# + dockcross (https://github.com/dockcross/dockcross)
# + Java
# + Personal
# + hid4java (https://github.com/gary-rowe/hid4java)
#
# Dependencies:
# - git
# - Docker Desktop
# - XCode v12.5.1 or higher for darwin-x86-64-aarch64 cross compiler support
#
# Place a symlink to this script in the root of ~/Workspaces
# cd ~/Workspaces
# ln -s Java/Personal/hid4java/build-hidapi.sh ./build-hidapi.sh
#
# Supported command line arguments are:
#
# all - build all variants
# windows - build all Windows variants
# linux - build all Linux variants
# darwin - build all macOS variants (not recommended)
# darwin-x86-64 - macOS 64-bit
# darwin-aarch64 - macOS ARM64
# linux-aarch64 - Linux ARMv8 64-bit
# linux-amd64 - Linux AMD 64-bit
# linux-arm - Linux ARMv6 hard float 32-bit (RPi)
# linux-armel - Linux ARMv5 soft float 32-bit
# linux-riscv64 - Linux RISC-V 64-bit
# linux-x86-64 - Linux x86 64-bit (same as AMD64)
# linux-x86 - Linux x86 32-bit
# win32-x86 - Windows 32-bit
# win32-x86-64 - Windows 64-bit
# win32-aarch64 - Windows 64-bit ARM64
#
# Set environment
hid4javaDir="${HOME}/Workspaces/Java/Personal/hid4java"
hidapiDir="${HOME}/Workspaces/Cpp/hidapi"
dockcrossDir="${HOME}/Workspaces/Docker/dockcross"
hardwareName=$(uname -m)
if [[ "${hardwareName}" == "arm64" ]]
then
platform="--platform linux/amd64"
else
platform=""
fi
# Console colours
red="\033[31m"
yellow="\033[33m"
green="\033[32m"
plain="\033[0m"
# Initial checks
# @Tresf: macOS deployment target checking
# See https://github.com/gary-rowe/hid4java/issues/120 for more details
if [[ "$1" == "all" ]] || [[ "$1" == "darwin" ]] || [[ "$1" == "darwin-aarch64" ]] || [[ "$1" == "darwin-x86-64" ]]
then
if [ -z "$SDKROOT" ] || [ -z "$MACOSX_DEPLOYMENT_TARGET" ];
then
echo -e "${yellow}WARNING: For production builds, please set \$SDKROOT and \$MACOSX_DEPLOYMENT_TARGET before building${plain}"
echo -e "${yellow}Continuing with default values${plain}"
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
if [[ "$1" == "all" ]] || [[ "$1" == "darwin" ]] || [[ "$1" == "darwin-aarch64" ]]
then
# Build for darwin-aarch64 with minimum of OS Big Sur (2020)
export MACOSX_DEPLOYMENT_TARGET="11.0"
else
# Build for darwin-x86-64 with minimum of OS Mavericks (2013)
export MACOSX_DEPLOYMENT_TARGET="10.9"
fi
fi
fi
# @Tresf: Function to do "make clean" without incurring issues during build
function git-clean {
echo -e "${yellow}Cleaning hidapi${plain}"
# Remove all untracked files (including project files)
git clean -fdx > /dev/null 2>&1 || exit
# Reset all tracked files
git reset --hard > /dev/null 2>&1 || exit
}
# Function to provide library file details
function report {
if [[ ! -f $1 ]]
then
echo -e "${red}File '$1' was not found.${plain}"
else
ls -la $1
file -b $1
echo -e "${green}---${plain}"
fi
}
echo -e "${green}------------------------------------------------------------------------${plain}"
echo -e "${yellow}Using '$1' to perform build${plain}"
echo -e "${green}------------------------------------------------------------------------${plain}"
if [[ "$1" == "update" ]]
then
echo -e "${green}Updating Dockcross${plain}"
cd ${dockcrossDir} || exit
git checkout master
git pull
# Windows cross compilers
# 64-bit (Intel)
echo -e "${green}Configuring Windows 64-bit${plain}"
docker run ${platform} --rm dockcross/windows-shared-x64 > ./dockcross-windows-shared-x64
chmod +x ./dockcross-windows-shared-x64
mv ./dockcross-windows-shared-x64 /usr/local/bin
# 32-bit (Intel)
echo -e "${green}Configuring Windows 32-bit${plain}"
docker run ${platform} --rm dockcross/windows-shared-x86 > ./dockcross-windows-shared-x86
chmod +x ./dockcross-windows-shared-x86
mv ./dockcross-windows-shared-x86 /usr/local/bin
# 64-bit (ARM64)
echo -e "${green}Configuring Windows 64-bit ARM64 (aarch64)${plain}"
docker run ${platform} --rm dockcross/windows-arm64 > ./dockcross-windows-arm64
chmod +x ./dockcross-windows-arm64
mv ./dockcross-windows-arm64 /usr/local/bin
echo -e "${green}Configuring Linux environments${plain}"
# Linux cross compilers
# 64 bit (Intel)
echo -e "${green}Configuring Linux 64-bit${plain}"
docker run ${platform} --rm dockcross/linux-x64 > ./dockcross-linux-x64
chmod +x ./dockcross-linux-x64
mv ./dockcross-linux-x64 /usr/local/bin
# 32 bit (Intel)
echo -e "${green}Configuring Linux 32-bit${plain}"
docker run ${platform} --rm dockcross/linux-x86 > ./dockcross-linux-x86
chmod +x ./dockcross-linux-x86
mv ./dockcross-linux-x86 /usr/local/bin
# ARM cross compilers
# @Tresf
# 32-bit ARMv5TE EABI "armel"
echo -e "${green}Configuring ARMv5TE EABI 32-bit${plain}"
docker run ${platform} --rm dockcross/linux-armv5 > ./dockcross-linux-armv5
chmod +x ./dockcross-linux-armv5
mv ./dockcross-linux-armv5 /usr/local/bin
# 32-bit ARMv6 EABI
echo -e "${green}Configuring ARMv6 EABI 32-bit${plain}"
docker run ${platform} --rm dockcross/linux-armv6 > ./dockcross-linux-armv6
chmod +x ./dockcross-linux-armv6
mv ./dockcross-linux-armv6 /usr/local/bin
# 32-bit ARMv7 hard float
echo -e "${green}Configuring ARMv7 32-bit${plain}"
docker run ${platform} --rm dockcross/linux-armv7 > ./dockcross-linux-armv7
chmod +x ./dockcross-linux-armv7
mv ./dockcross-linux-armv7 /usr/local/bin
# 64-bit (arm64, aarch64)
echo -e "${green}Configuring ARM 64-bit${plain}"
docker run ${platform} --rm dockcross/linux-arm64 > ./dockcross-linux-arm64
chmod +x ./dockcross-linux-arm64
mv ./dockcross-linux-arm64 /usr/local/bin
# RISC-V cross compilers
# @Tresf
# 64-bit (RISC-V)
echo -e "${green}Configuring RISC-V 64-bit${plain}"
docker run --rm dockcross/linux-riscv64 > ./dockcross-linux-riscv64
chmod +x ./dockcross-linux-riscv64
mv ./dockcross-linux-riscv64 /usr/local/bin
# HIDAPI latest release
echo -e "${green}Updating HIDAPI${plain}"
cd ${hidapiDir} || exit
git checkout master
git pull
else
echo -e "${yellow}Skipping updates${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# Build in hidapi project directory
cd ${hidapiDir} || exit
# Windows environments
# 64-bit x86-64
if [[ "$1" == "all" ]] || [[ "$1" == "windows" ]] || [[ "$1" == "win32-x86-64" ]]
then
echo -e "${green}Building Windows 64-bit${plain}" && git-clean
if ! dockcross-windows-shared-x64 bash -c 'sudo apt-get update && sudo apt-get --yes install libudev-dev libusb-1.0-0-dev && sudo ./bootstrap && sudo ./configure --host=x86_64-w64-mingw32 && sudo make';
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/win32-x86-64/hidapi.dll
exit
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/win32-x86-64
cp windows/.libs/libhidapi-0.dll ${hid4javaDir}/src/main/resources/win32-x86-64/hidapi.dll
fi
else
echo -e "${yellow}Skipping win32-x86-64${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# 64-bit ARM win32-aarch64
if [[ "$1" == "all" ]] || [[ "$1" == "windows" ]] || [[ "$1" == "win32-aarch64" ]]
then
echo -e "${green}Building Windows 64-bit ARM64 (aarch64)${plain}" && git-clean
if ! dockcross-windows-arm64 bash -c 'sudo apt-get update && sudo apt-get --yes install libudev-dev libusb-1.0-0-dev && sudo ./bootstrap && sudo ./configure --host=aarch64-w64-mingw32 && sudo make';
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/win32-aarch64/hidapi.dll
exit
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/win32-aarch64
cp windows/.libs/libhidapi-0.dll ${hid4javaDir}/src/main/resources/win32-aarch64/hidapi.dll
fi
else
echo -e "${yellow}Skipping win32-aarch64${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# 32-bit x86
if [[ "$1" == "all" ]] || [[ "$1" == "windows" ]] || [[ "$1" == "win32-x86" ]]
then
echo -e "${green}Building Windows 32-bit${plain}" && git-clean
if ! dockcross-windows-shared-x86 bash -c 'sudo ./bootstrap && sudo ./configure --host=i686-w64-mingw32 && sudo make';
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/win32-x86/hidapi.dll
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/win32-x86
cp windows/.libs/libhidapi-0.dll ${hid4javaDir}/src/main/resources/win32-x86/hidapi.dll
fi
else
echo -e "${yellow}Skipping win32-x86${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# Linux environments
# 64-bit (x86-64/amd64)
if [[ "$1" == "all" ]] || [[ "$1" == "linux" ]] || [[ "$1" == "linux-x86-64" ]]
then
echo -e "${green}Building Linux 64-bit${plain}" && git-clean
# Note the use of a double sudo apt-get update here
if ! dockcross-linux-x64 bash -c 'sudo apt-get update || sudo apt-get update && sudo apt-get --yes install libudev-dev libusb-1.0-0-dev && sudo ./bootstrap && sudo ./configure && sudo make';
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/linux-x86-64/libhidapi.so
rm ${hid4javaDir}/src/main/resources/linux-amd64/libhidapi.so
rm ${hid4javaDir}/src/main/resources/linux-x86-64/libhidapi-libusb.so
rm ${hid4javaDir}/src/main/resources/linux-amd64/libhidapi-libusb.so
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/linux-x86-64
cp linux/.libs/libhidapi-hidraw.so ${hid4javaDir}/src/main/resources/linux-x86-64/libhidapi.so
cp linux/.libs/libhidapi-hidraw.so ${hid4javaDir}/src/main/resources/linux-amd64/libhidapi.so
cp libusb/.libs/libhidapi-libusb.so ${hid4javaDir}/src/main/resources/linux-x86-64/libhidapi-libusb.so
cp libusb/.libs/libhidapi-libusb.so ${hid4javaDir}/src/main/resources/linux-amd64/libhidapi-libusb.so
fi
else
echo -e "${yellow}Skipping linux-x86-64${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# 32-bit
if [[ "$1" == "all" ]] || [[ "$1" == "linux" ]] || [[ "$1" == "linux-x86" ]]
then
echo -e "${green}Building Linux 32-bit${plain}" && git-clean
if ! dockcross-linux-x86 bash -c 'sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get --yes install libudev-dev libusb-1.0-0-dev libudev-dev:i386 libusb-1.0-0-dev:i386 && sudo ./bootstrap && sudo ./configure && sudo make';
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/linux-x86/libhidapi.so
rm ${hid4javaDir}/src/main/resources/linux-x86/libhidapi-libusb.so
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/linux-x86
cp linux/.libs/libhidapi-hidraw.so ${hid4javaDir}/src/main/resources/linux-x86/libhidapi.so
cp libusb/.libs/libhidapi-libusb.so ${hid4javaDir}/src/main/resources/linux-x86/libhidapi-libusb.so
fi
else
echo -e "${yellow}Skipping linux-x86${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# ARM environments
# 64-bit (arm64/aarch64)
if [[ "$1" == "all" ]] || [[ "$1" == "linux" ]] || [[ "$1" == "linux-aarch64" ]]
then
echo -e "${green}Building Linux ARM64/aarch64 ARMv8${plain}" && git-clean
if ! dockcross-linux-arm64 bash -c 'sudo dpkg --add-architecture arm64 && sudo apt-get update && sudo apt-get --yes install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libudev-dev:arm64 libusb-1.0-0-dev:arm64 && sudo ./bootstrap && sudo ./configure --host=aarch64-linux-gnu CC=aarch64-linux-gnu-gcc && sudo make';
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/linux-aarch64/libhidapi.so
rm ${hid4javaDir}/src/main/resources/linux-aarch64/libhidapi-libusb.so
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/linux-aarch64
cp linux/.libs/libhidapi-hidraw.so ${hid4javaDir}/src/main/resources/linux-aarch64/libhidapi.so
cp libusb/.libs/libhidapi-libusb.so ${hid4javaDir}/src/main/resources/linux-aarch64/libhidapi-libusb.so
fi
else
echo -e "${yellow}Skipping linux-aarch64${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# 32-bit ARMv6 hard float (linux-arm)
if [[ "$1" == "all" ]] || [[ "$1" == "linux" ]] || [[ "$1" == "linux-arm" ]]
then
echo -e "${yellow}Skipping linux-arm (use RPi direct instead)${plain}"
# It's much easier to just use the original hardware
else
echo -e "${yellow}Skipping linux-arm${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# @Tresf
# 32-bit ARM soft float (linux-armel)
if [[ "$1" == "all" ]] || [[ "$1" == "linux" ]] || [[ "$1" == "linux-armel" ]]
then
echo -e "${green}Building ARM soft float${plain}" && git-clean
make clean &> /dev/null
# Disabling building hidtest
sed -i'' -e 's/SUBDIRS \+= hidtest//g' Makefile.am
arch="armel"
deps="echo \"Obtaining $arch dependencies...\""
deps="$deps && sudo dpkg --add-architecture $arch"
deps="$deps && sudo apt-get update"
deps="$deps && sudo apt-get --yes install libudev-dev:$arch libusb-1.0-0-dev:$arch"
deps="$deps ; echo 'WARNING: Ignoring any errors from previous command'"
deps="$deps && cp /usr/include/libudev.h ./libudev.h"
deps="$deps && export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabi/pkgconfig/"
if ! dockcross-linux-armv5 bash -c "$deps && sudo ./bootstrap && sudo ./configure --host=aarch64-unknown-linux-gnueabi && sudo make";
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/linux-armel/libhidapi.so
rm ${hid4javaDir}/src/main/resources/linux-armel/libhidapi-libusb.so
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/linux-armel
cp linux/.libs/libhidapi-hidraw.so ${hid4javaDir}/src/main/resources/linux-armel/libhidapi.so
cp libusb/.libs/libhidapi-libusb.so ${hid4javaDir}/src/main/resources/linux-armel/libhidapi-libusb.so
fi
else
echo -e "${yellow}Skipping linux-armel${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# RISC-V environments
# @Tresf
# 64-bit (riscv64)
if [[ "$1" == "all" ]] || [[ "$1" == "linux" ]] || [[ "$1" == "linux-riscv64" ]]
then
echo -e "${green}Building Linux riscv64${plain}" && git-clean
make clean &> /dev/null
# Disabling building hidtest
sed -i'' -e 's/SUBDIRS \+= hidtest//g' Makefile.am
# risv64 hasn't reached debian stable, fetch from "sid"
arch=riscv64
debs=(
"libusb-1.0-0"
"libusb-1.0-0-dev"
"libhidapi-libusb0"
"libudev1"
"libudev-dev"
)
deps="echo \"Obtaining $arch dependencies from Debian sid...\""
deps="$deps && echo 'deb [arch=$arch] http://deb.debian.org/debian sid main' | sudo tee -a /etc/apt/sources.list"
deps="$deps && sudo apt-get update"
deps="$deps && mkdir -p debs && pushd debs"
deps="$deps && for deb in "${debs[@]}"; do echo \"- Downloading \$deb...\" && apt-get download \$deb:$arch && ar x \$deb* && tar -xf data.tar.xz && rm -f \$deb*.deb ; done"
deps="$deps && sudo cp -rf ./usr/* /usr/"
deps="$deps && popd"
deps="$deps && rm -rf debs"
deps="$deps && cp /usr/include/libudev.h ./libudev.h"
deps="$deps && export PKG_CONFIG_PATH=/usr/lib/$arch-linux-gnu/pkgconfig/"
if ! dockcross-linux-riscv64 bash -c "sudo $deps && sudo ./bootstrap && sudo ./configure --host=riscv64-unknown-linux-gnu && sudo make";
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/linux-riscv64/libhidapi.so
rm ${hid4javaDir}/src/main/resources/linux-riscv64/libhidapi-libusb.so
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/linux-riscv64
cp linux/.libs/libhidapi-hidraw.so ${hid4javaDir}/src/main/resources/linux-riscv64/libhidapi.so
cp libusb/.libs/libhidapi-libusb.so ${hid4javaDir}/src/main/resources/linux-riscv64/libhidapi-libusb.so
fi
else
echo -e "${yellow}Skipping linux-riscv64${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# macOS environments (require local build)
# Darwin ARM64 (local)
if [[ "$1" == "all" ]] || [[ "$1" == "darwin" ]] || [[ "$1" == "darwin-aarch64" ]]
then
# Check if build is possible with local environment
if [[ "${hardwareName}" == "x86_64" ]]
then
echo -e "${yellow}Building macOS Darwin x86 (x86-64) requires change of architecture.${plain}"
echo -e "${yellow} Re-run with 'arch -arm64 zsh ./build-hidapi.sh darwin-aarch64'${plain}"
else
echo -e "${green}Building macOS Darwin ARM64 (aarch64)${plain}" && git-clean
./bootstrap
./configure
if ! make;
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/darwin-aarch64/libhidapi.dylib
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/darwin-aarch64
cp mac/.libs/libhidapi.0.dylib ${hid4javaDir}/src/main/resources/darwin-aarch64/libhidapi.dylib
fi
fi
fi
# Darwin Intel (local)
if [[ "$1" == "all" ]] || [[ "$1" == "darwin" ]] || [[ "$1" == "darwin-x86-64" ]]
then
# Check if build is possible with local environment
if [[ "${hardwareName}" == "arm64" ]]
then
echo -e "${yellow}Building macOS Darwin x86 (x86-64) requires change of architecture.${plain}"
echo -e "${yellow} Re-run with 'arch -x86_64 zsh ./build-hidapi.sh darwin-x86-64'${plain}"
else
echo -e "${green}Building macOS Darwin Intel (x86-64)${plain}" && git-clean
make clean
./bootstrap
./configure
if ! make;
then
echo -e "${red}Failed${plain} - Removing damaged targets"
rm ${hid4javaDir}/src/main/resources/darwin-x86-64/libhidapi.dylib
else
echo -e "${green}OK${plain}"
mkdir -p ${hid4javaDir}/src/main/resources/darwin-x86-64
cp mac/.libs/libhidapi.0.dylib ${hid4javaDir}/src/main/resources/darwin-x86-64/libhidapi.dylib
fi
fi
else
echo -e "${yellow}Skipping darwin-x86-64${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"
# Report in hid4java project directory
cd ${hid4javaDir} || exit
# List all file info
if [[ "$1" == "update" ]]
then
echo -e "${yellow}Skipping file report${plain}"
else
echo -e "${green}Reporting on current hidapi libraries in hid4java:${plain}"
# Windows environments
echo -e "${green}Windows${plain}"
echo -e "${green}win32-x86-64${plain}"
report "src/main/resources/win32-x86-64/hidapi.dll"
echo -e "${green}win32-x86${plain}"
report "src/main/resources/win32-x86/hidapi.dll"
echo -e "${green}win32-aarch64${plain}"
report "src/main/resources/win32-aarch64/hidapi.dll"
echo -e "${green}------------------------------------------------------------------------${plain}"
# Linux environments
echo -e "${green}Linux${plain}"
echo -e "${green}linux-x86-64${plain}"
report "src/main/resources/linux-x86-64/libhidapi.so"
report "src/main/resources/linux-x86-64/libhidapi-libusb.so"
echo -e "${green}linux-amd64${plain}"
report "src/main/resources/linux-amd64/libhidapi.so"
report "src/main/resources/linux-amd64/libhidapi-libusb.so"
echo -e "${green}linux-x86${plain}"
report "src/main/resources/linux-x86/libhidapi.so"
report "src/main/resources/linux-x86/libhidapi-libusb.so"
echo -e "${green}------------------------------------------------------------------------${plain}"
# ARM
echo -e "${green}ARM${plain}"
echo -e "${green}linux-arm${plain}"
report "src/main/resources/linux-arm/libhidapi.so"
report "src/main/resources/linux-arm/libhidapi-libusb.so"
echo -e "${green}linux-armel${plain}"
report "src/main/resources/linux-armel/libhidapi.so"
report "src/main/resources/linux-armel/libhidapi-libusb.so"
echo -e "${green}linux-aarch64${plain}"
report "src/main/resources/linux-aarch64/libhidapi.so"
report "src/main/resources/linux-aarch64/libhidapi-libusb.so"
# RISC
echo -e "${green}linux-riscv64${plain}"
report "src/main/resources/linux-riscv64/libhidapi.so"
report "src/main/resources/linux-riscv64/libhidapi-libusb.so"
echo -e "${green}------------------------------------------------------------------------${plain}"
# macOS
echo -e "${green}macOS${plain}"
echo -e "${green}darwin-x86-64${plain}"
report "src/main/resources/darwin-x86-64/libhidapi.dylib"
otool -l src/main/resources/darwin-x86-64/libhidapi.dylib | grep -E 'LC_VERSION_MIN_MACOSX|LC_BUILD_VERSION' -A4
echo -e "${green}darwin-aarch64${plain}"
report "src/main/resources/darwin-aarch64/libhidapi.dylib"
otool -l src/main/resources/darwin-aarch64/libhidapi.dylib | grep -E 'LC_VERSION_MIN_MACOSX|LC_BUILD_VERSION' -A4
echo -e "${green}------------------------------------------------------------------------${plain}"
echo -e "${green}Done - Check all OK in summary above.${plain}"
fi
echo -e "${green}------------------------------------------------------------------------${plain}"