nmeum / android-tools

Unoffical CMake-based build system for android command line utilities
Apache License 2.0
191 stars 57 forks source link

Build fails with "[Makefile:156: all] Error 2" on Ubuntu 22.04 #58

Closed HMaker closed 2 years ago

HMaker commented 2 years ago

I tried to build ADB on a docker image:

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends build-essential gdb wget tar xz-utils golang-go perl \
        ca-certificates liblz4-dev libbrotli-dev libpcre3 libpcre3-dev libzstd-dev libgtest-dev \
        libusb-1.0.0-dev protobuf-compiler libssl-dev libprotobuf-dev

RUN wget -q --show-progress --progress=bar https://cmake.org/files/v3.23/cmake-3.23.1.tar.gz \
    && tar -xvf cmake-3.23.1.tar.gz \
    && cd cmake-3.23.1 \
    && ./configure && make -j 12 && make install \
    && cd ..

ENV CFLAGS="-O0 -ggdb3 -fvar-tracking"
RUN wget -q --show-progress --progress=bar https://github.com/nmeum/android-tools/releases/download/31.0.3p1/android-tools-31.0.3p1.tar.xz \
    && tar -xvf android-tools-31.0.3p1.tar.xz
RUN mkdir android-tools-31.0.3p1/build && cd android-tools-31.0.3p1/build \
     && cmake .. && make -j 12 VERBOSE=1

CMD ["bash"]

but it results in error:

[ 20%] Linking CXX static library liblibadb.a
cd /android-tools-31.0.3p1/build/vendor && /usr/local/bin/cmake -P CMakeFiles/libadb.dir/cmake_clean_target.cmake
cd /android-tools-31.0.3p1/build/vendor && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/libadb.dir/link.txt --verbose=1
/usr/bin/ar qc liblibadb.a CMakeFiles/libadb.dir/adb/client/adb_client.cpp.o CMakeFiles/libadb.dir/adb/client/adb_install.cpp.o CMakeFiles/libadb.dir/adb/client/adb_wifi.cpp.o CMakeFiles/libadb.dir/adb/client/auth.cpp.o CMakeFiles/libadb.dir/adb/client/bugreport.cpp.o CMakeFiles/libadb.dir/adb/client/commandline.cpp.o CMakeFiles/libadb.dir/adb/client/console.cpp.o CMakeFiles/libadb.dir/adb/client/file_sync_client.cpp.o CMakeFiles/libadb.dir/adb/client/incremental.cpp.o CMakeFiles/libadb.dir/adb/client/incremental_server.cpp.o CMakeFiles/libadb.dir/adb/client/incremental_utils.cpp.o CMakeFiles/libadb.dir/adb/client/line_printer.cpp.o CMakeFiles/libadb.dir/adb/client/main.cpp.o CMakeFiles/libadb.dir/adb/client/pairing/pairing_client.cpp.o CMakeFiles/libadb.dir/adb/client/usb_libusb.cpp.o CMakeFiles/libadb.dir/adb/client/usb_linux.cpp.o CMakeFiles/libadb.dir/adb/pairing_auth/aes_128_gcm.cpp.o CMakeFiles/libadb.dir/adb/pairing_auth/pairing_auth.cpp.o CMakeFiles/libadb.dir/adb/pairing_connection/pairing_connection.cpp.o CMakeFiles/libadb.dir/adb/services.cpp.o CMakeFiles/libadb.dir/adb/socket_spec.cpp.o CMakeFiles/libadb.dir/adb/sysdeps_unix.cpp.o CMakeFiles/libadb.dir/adb/sysdeps/errno.cpp.o CMakeFiles/libadb.dir/adb/sysdeps/posix/network.cpp.o CMakeFiles/libadb.dir/app_processes.pb.cc.o CMakeFiles/libadb.dir/adb_known_hosts.pb.cc.o CMakeFiles/libadb.dir/key_type.pb.cc.o CMakeFiles/libadb.dir/pairing.pb.cc.o
/usr/bin/ranlib liblibadb.a
make[2]: Leaving directory '/android-tools-31.0.3p1/build'
[ 20%] Built target libadb
make[1]: Leaving directory '/android-tools-31.0.3p1/build'
make: *** [Makefile:156: all] Error 2

it's at line $(MAKE) -f CMakeFiles/Makefile2 all of Makefile generated by CMake. Maybe this came from /usr/bin/ranlib liblibadb.a? I don't understand what this make error means.

HMaker commented 2 years ago

Ok I found the reason, the concurrent build hide the real error, running witn make -j 1 shown that libpcre2 wasn't installed (I had libpcre3). Should we make explicit PCRE2 is needed?

nmeum commented 2 years ago

Despite its name libpcre3 seems to be a legacy package. From the Debian package description:

New packages should use the newer pcre2 packages, and existing packages should migrate to pcre2.

so I am not sure what the purpose of the Debian libpcre3 package is.

However, feel free to send a PR which modifies the README to clarify that we depend on pcre2.