CMake: Add option to use bundled libusb library #228
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
name: build | |
on: [push, pull_request] | |
jobs: | |
upload-src: | |
name: Upload the source | |
runs-on: ubuntu-latest | |
steps: | |
- name: prep ubuntu | |
run: | | |
sudo apt-get update | |
DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq \ | |
${{ matrix.pkgs }} cmake git golang libbrotli-dev \ | |
libgtest-dev liblz4-dev libpcre2-dev libprotobuf-dev libunwind-dev \ | |
libzstd-dev make pandoc pkg-config | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: git config | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Your Name" | |
- name: get vendor modules | |
run: | | |
cd vendor/boringssl | |
go mod vendor | |
- name: generate man page | |
run: | | |
cd vendor/adb/docs/user | |
pandoc -s -t man adb.1.md -o adb.1 | |
- name: build & install | |
run: | | |
mkdir build && cd build | |
cmake \ | |
-DANDROID_TOOLS_USE_BUNDLED_FMT=ON \ | |
-DANDROID_TOOLS_USE_BUNDLED_LIBUSB=ON \ | |
.. | |
make package_source | |
for x in sha1sum sha256sum sha512sum b2sum; do | |
printf "$x " && $x ${{ github.workspace }}/build/android-tools-*.tar.xz | cut -d " " -f 1 | |
done | |
- name: upload package_source | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package_source | |
path: ${{ github.workspace }}/build/android-tools-*.tar.xz | |
linux: | |
runs-on: ubuntu-latest | |
needs: [upload-src] | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: "opensuse/leap:latest" | |
pkgs: "clang gcc11-c++" | |
env1: "CC=clang CXX=clang++" | |
- os: "opensuse/tumbleweed" | |
pkgs: "gcc gcc-c++" | |
- os: "opensuse/tumbleweed" | |
pkgs: clang | |
env1: "CC=clang CXX=clang++" | |
- os: "archlinux:base" | |
pkgs: gcc | |
- os: "archlinux:base" | |
pkgs: clang | |
env1: "CC=clang CXX=clang++" | |
- os: "ubuntu:20.04" | |
pkgs: "gcc-10 g++-10" | |
env1: "CC=gcc-10 CXX=g++-10" | |
- os: "ubuntu:20.04" | |
pkgs: "clang-11 libstdc++-10-dev" | |
env1: "CC=clang-11 CXX=clang++-11" | |
- os: "alpine" | |
pkgs: "gcc" | |
env1: "CC=gcc CXX=g++" | |
- os: "fedora:latest" | |
pkgs: "gcc gcc-g++" | |
- os: "fedora:rawhide" | |
pkgs: "gcc gcc-g++" | |
container: | |
image: ${{ matrix.os }} | |
# New versions of glibc use the new clone3() syscall which has not | |
# yet been whitelisted in GitHub's secomp profile. To prevent jobs | |
# using these distros from failing (e.g. openSUSE) change the | |
# secomp policy. | |
# | |
# See https://github.com/nmeum/android-tools/pull/48#issuecomment-944893176 | |
options: --security-opt seccomp=unconfined | |
steps: | |
- name: prep opensuse | |
if: startsWith(matrix.os, 'opensuse') | |
run: | | |
zypper -n ref | |
zypper -n in ${{ matrix.pkgs }} cmake git go gtest pcre2-devel pkgconfig \ | |
'pkgconfig(libbrotlicommon)' 'pkgconfig(liblz4)' \ | |
'pkgconfig(libunwind-generic)' \ | |
'pkgconfig(libzstd)' 'pkgconfig(protobuf)' ninja tar xz | |
- name: prep archlinux | |
if: startsWith(matrix.os, 'archlinux') | |
run: | | |
pacman -Syu --needed --noconfirm \ | |
${{ matrix.pkgs }} brotli cmake git go gtest libunwind \ | |
lz4 pcre2 pkgconfig protobuf zstd ninja | |
- name: prep ubuntu | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
apt-get update | |
DEBIAN_FRONTEND=noninteractive apt-get install -yq \ | |
${{ matrix.pkgs }} cmake git golang libbrotli-dev \ | |
libgtest-dev liblz4-dev libpcre2-dev libprotobuf-dev libunwind-dev \ | |
libzstd-dev pkg-config protobuf-compiler ninja-build | |
- name: prep alpine | |
if: startsWith(matrix.os, 'alpine') | |
run: | | |
apk add build-base pcre2-dev linux-headers gtest-dev samurai \ | |
go git perl cmake protobuf-dev brotli-dev zstd-dev lz4-dev | |
- name: prep fedora | |
if: startsWith(matrix.os, 'fedora') | |
run: | | |
dnf install -y ${{ matrix.pkgs }} cmake ninja-build perl git golang \ | |
brotli-devel gtest-devel lz4-devel pcre2-devel protobuf-devel \ | |
libzstd-devel tar xz | |
- name: download source | |
uses: actions/download-artifact@v4 | |
with: | |
name: package_source | |
- name: build & install | |
run: | | |
export GOFLAGS="-mod=vendor" | |
tar -xf android-tools-*.tar.xz | |
cd android-tools-*/ | |
test -n "${{ matrix.env1 }}" && export ${{ matrix.env1 }} | |
test -n "${{ matrix.env2 }}" && export ${{ matrix.env2 }} | |
mkdir build && cd build | |
cmake \ | |
-DCMAKE_C_FLAGS="$CFLAGS" \ | |
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DANDROID_TOOLS_USE_BUNDLED_FMT=ON \ | |
-DANDROID_TOOLS_USE_BUNDLED_LIBUSB=ON \ | |
-GNinja \ | |
.. | |
ninja --verbose | |
echo -e "\n### make install ###\n" | |
cmake --install . --prefix /usr/local | |
echo -e "\n### all done ###\n" | |
- name: check | |
run: | | |
/usr/local/bin/adb --version | |
/usr/local/bin/fastboot --version | |
/usr/local/bin/make_f2fs -V | |
/usr/local/bin/sload_f2fs -V | |
macos: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macos-12, macos-13, macos-14] | |
runs-on: ${{ matrix.os }} | |
needs: [upload-src] | |
steps: | |
# github actions overwrites brew's python. Force it to reassert itself, by running in a separate step. | |
# Borrowed from https://github.com/mesonbuild/meson/blob/master/.github/workflows/macos.yml#L87-L92 | |
- name: unbreak python in github actions | |
run: | | |
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete | |
sudo rm -rf /Library/Frameworks/Python.framework/ | |
brew install --force python3 && brew unlink python3 && brew unlink python3 && brew link --overwrite python3 | |
- name: prep macos | |
run: | | |
rm -rf /opt/homebrew/include/openssl /usr/local/opt/openssl /usr/local/include/openssl | |
brew install --overwrite --quiet brotli cmake go googletest lz4 \ | |
ninja pcre2 protobuf zstd | |
- name: download source | |
uses: actions/download-artifact@v4 | |
with: | |
name: package_source | |
- name: build & install | |
run: | | |
tar -xf android-tools-*.tar.xz | |
cd android-tools-*/ | |
mkdir build && cd build | |
cmake \ | |
-DCMAKE_C_FLAGS="$CFLAGS" \ | |
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX=$HOME/android-tools \ | |
-DANDROID_TOOLS_USE_BUNDLED_FMT=ON \ | |
-DANDROID_TOOLS_USE_BUNDLED_LIBUSB=ON \ | |
-GNinja \ | |
.. | |
ninja --verbose | |
echo -e "\n### make install ###\n" | |
cmake --install . | |
echo -e "\n### all done ###\n" | |
- name: check | |
run: | | |
$HOME/android-tools/bin/adb --version | |
$HOME/android-tools/bin/fastboot --version | |
$HOME/android-tools/bin/make_f2fs -V | |
$HOME/android-tools/bin/sload_f2fs -V |