Last active
August 26, 2022 00:45
-
-
Save Ghostbird/566fbf92000b615934c0af8c6069ec94 to your computer and use it in GitHub Desktop.
Build libusb/hidapi for Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run this in a directory where you don't mind cloning a few git repositories. e.g. /tmp | |
if [[ -f ${AndroidNdkDirectory}/ndk-build ]] | |
then | |
git clone [email protected]:libusb/libusb.git | |
git clone [email protected]:libusb/hidapi.git | |
cd hidapi/android/jni | |
# Apply patch from my gist to point Android.mk to correct libusb directory. | |
curl https://gist.githubusercontent.com/Ghostbird/2485d23afc39fbdac3bda136a46e6577/raw/a0fcbfd4c49b7f78b5faeb4befe3e47d33e93d87/Android.mk.patch | git apply - | |
# Print the file and ask for the user to confirm that the patch was not ransomware | |
echo --- Android.mk --- | |
cat Android.mk | |
echo --- END OF FILE --- | |
echo If you\'re sure that Android.mk is still safe to run, press ENTER. | |
read -p "Otherwise, press Ctrl+C to abort" && ${AndroidNdkDirectory}/ndk-build | |
else | |
echo Please export "AndroidNdkDirectory" to point to the directory where your ndk-build binary is located. Then re-run this script. | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After running this script, the libraries are in
../libs/
relative to your working directory.