nmeum / android-tools

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

Update to platform-tools-31.0.2 #29

Closed nmeum closed 3 years ago

nmeum commented 3 years ago

To-Do:

Fixes #28

AKotov-dev commented 3 years ago

I became interested and took the liberty of adding corrections from the one given at diff: https://android.googlesource.com/platform/packages/modules/adb.git/+/af25bde7a294488109603270315e3fa182ce094a%5E%21/#F0

diff --git a/socket_spec.cpp b/socket_spec.cpp
index 5cad70d..926d70f 100644
--- a/socket_spec.cpp
+++ b/socket_spec.cpp
@@ -222,6 +222,7 @@
         }

         if (fd->get() > 0) {
+            set_tcp_keepalive(fd->get(), 1);
             disable_tcp_nagle(fd->get());
             if (port) {
                 *port = port_value;

Added a line set_tcp_keepalive(fd->get(), 1); to file ./android-tools/vendor/adb/socket_spec.cpp and rebuilt it all over again. With this fix, everything works fine and the device is displayed, as it should, in the offline state. :)

It's kind of weird... nmeum, why didn't this fix go in automatically?

nmeum commented 3 years ago

Looks like I checked out the wrong tag for some submodules, will fix that later.

nmeum commented 3 years ago

@AKotov-dev should be fixed now (hopefully) :)

AKotov-dev commented 3 years ago

@nmeum

mkdir ./build && cd ./build

# Attempt-1
cmake ..
...
...
-- Applying patches for: base
Applying: LoadedArsc: un-const T in std::vector<T>
Applying: PosixUtils: don't use reserved name std{out,err} for variables
Applying: AssetManager2: Align creation of FindEntryResult with declaration
-- Applying patches for: core
error: error applying changes: llkd/include/llkd.h:63
error: llkd/include/llkd.h: failed to apply patch
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: Fix inclusion of stdatomic.h with g++
Applying: group_member is a nonstandard GNU extension
Applying: socket.h: include sys/select.h for fd_set used in socket.cpp
Applying: fastboot: make mke2fs_path configurable
Applying: libcutils: include sys/select.h for timeval
Applying: Don't include version.h
Applying: Include cstring in various file missing it
Applying: Vector: don't assign to const object
Applying: Don't use the internal glibc header sys/cdefs.h
Error applying changes to 0009 Don't use the internal glibc header sys/cdefs.h
When you resolve this issue, run «git am --continue».
If you want to skip this patch, then run «git am --skip».
To go back to the previous branch and stop applying the changes, run «git am --abort».
CMake Error at vendor/CMakeLists.txt:30 (message):
  Couldn't apply patches for core

-- Configuring incomplete, errors occurred!
See also "/111/android-tools-31.0.2/android-tools/build/CMakeFiles/CMakeOutput.log".

# Attempt-2
cmake ..
-- Applying patches for: adb
Applying: Don't use the internal glibc header sys/cdefs.h
Applying: adb: disable mdns transport support
Applying: fdevent: missing atomic include
Applying: Define clang-only nullability specifiers when __clang__ is not defined
Applying: Include libusb-1.0/libusb.h instead of libusb/libusb.h
Applying: Include string.h in various file missing it
Applying: adb.cpp: fix warning regarding execl(3) invocation
Applying: usb_linux.cpp: include sys/sysmacros.h for minor/major
Applying: adb: Reduce fallback size for _SC_GETPW_R_SIZE_MAX
Applying: sysdeps: don't over eager constexpr
Applying: Don't include version.h
Applying: Include cstring in various file missing it
Applying: adb: disable fastdeploy support
Applying: include climits where necessary for INT_MAX
Applying: types.h: Fix ambiguous reference to weak_ptr
Applying: adb: disable mDNS
Applying: adb_wifi: remove mDNS
Applying: pairing_auth: include <cstring> for memcpy
Applying: adb_mdns: Don't use _Nonnull
-- Applying patches for: base
Applying: LoadedArsc: un-const T in std::vector<T>
Applying: PosixUtils: don't use reserved name std{out,err} for variables
Applying: AssetManager2: Align creation of FindEntryResult with declaration
-- Applying patches for: core
fatal: previous rebase directory /111/android-tools-31.0.2/android-tools/.git/modules/core/rebase-apply still exists, but give to mbox.

CMake Error at vendor/CMakeLists.txt:30 (message):
  Couldn't apply patches for core

For the purity of the experiment, I tried downloading/cloning twice. Output of cmake .. Additionally, I attach the file CMakeOutput.log: https://cloud.mail.ru/public/gKRe/PJ9JKKZ11

nmeum, I feel that the truth is somewhere near. :)

nmeum commented 3 years ago

Looks like some submodules are in a bad state (you can check them individually with git status). In the main repo none of the submodules should be marked as modified/changed in the git status output, you can also reset them with git submodule update --init.

Have you tried a clean build with a clean checkout? For example:

cd /tmp
git clone --recursive -b platform-tools-31.0.2 https://github.com/nmeum/android-tools
cd android-tools
mkdir build
cd build
cmake ..
make
AKotov-dev commented 3 years ago

Every new build is completely new. I always completely delete the directory rm -rf ./android-tools with all the contents and recreate/clone everything again. Now I repeated everything from the beginning to the end for the third time - the result is the same.

Total downloaded/cloned ~7GB...

# After the end of cloning:
Defining changes: 100% (17792/17792), done.
Submodule on the way «vendor/adb»: state selected «93acca4dfa6f59e85f86442a160e57e0d3208176»
Submodule on the way «vendor/avb»: state selected «f2cc0562cd31bbc584e3bd61d80c082b31520ec1»
Submodule on the way «vendor/base»: state selected «9a460c961bb1e6e15b886f1d48681ca159c2de15»
Submodule on the way «vendor/boringssl»: state selected «c1e156ae16fa8b61af9b5d2b74e59d3f86e141be»
Submodule on the way «vendor/core»: state selected «fc1e6adc6f9d552cb2305a22d9d4de39af0038d7»
Submodule on the way «vendor/e2fsprogs»: state selected «584ac7d2ccbd9760e83af43c2cdb9bf495404c1f»
Submodule on the way «vendor/extras»: state selected «f79ba08eb13c46466b1b44d76ca97e530d06261d»
Submodule on the way «vendor/f2fs-tools»: state selected «df24542a7c67c8d09d2b0c946028af11f8afa557»
Submodule on the way «vendor/incremental_delivery»: state selected «d8df24315af647a3a97bc6544107cfcfc1a31866»
Submodule on the way «vendor/libbase»: state selected «18f8b14dac2bacf3a3cdc7d9e54dbd2888043e0d»
Submodule on the way «vendor/libziparchive»: state selected «b97a38bd72a1534f99d08a48fc92606f8e67f4f2»
Submodule on the way «vendor/logging»: state selected «26849884bcd3002c4cf74a819f42ace46ad7a6c5»
Submodule on the way «vendor/mkbootimg»: state selected «b6ef0d18503fc92bf92cb07400739ec158e6c1a2»
Submodule on the way «vendor/native»: state selected «a4a1fd3132e8ad535d091bfc4f83742d39eb3030»
Submodule on the way «vendor/selinux»: state selected «e3153f6df50bb06cb215be672b9043e33f638152»
cd ./android-tools
git submodule update --init

mkdir ./build && cd ./build && cmake ..

-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Perl: /usr/bin/perl (found version "5.32.1") 
-- Checking for module 'libunwind-generic'
--   Found libunwind-generic, version 1.5.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Applying patches for: adb
Applying: Don't use the internal glibc header sys/cdefs.h
Applying: adb: disable mdns transport support
Applying: fdevent: missing atomic include
Applying: Define clang-only nullability specifiers when __clang__ is not defined
Applying: Include libusb-1.0/libusb.h instead of libusb/libusb.h
Applying: Include string.h in various file missing it
Applying: adb.cpp: fix warning regarding execl(3) invocation
Applying: usb_linux.cpp: include sys/sysmacros.h for minor/major
Applying: adb: Reduce fallback size for _SC_GETPW_R_SIZE_MAX
Applying: sysdeps: don't over eager constexpr
Applying: Don't include version.h
Applying: Include cstring in various file missing it
Applying: adb: disable fastdeploy support
Applying: include climits where necessary for INT_MAX
Applying: types.h: Fix ambiguous reference to weak_ptr
Applying: adb: disable mDNS
Applying: adb_wifi: remove mDNS
Applying: pairing_auth: include <cstring> for memcpy
Applying: adb_mdns: Don't use _Nonnull
-- Applying patches for: base
Applying: LoadedArsc: un-const T in std::vector<T>
Applying: PosixUtils: don't use reserved name std{out,err} for variables
Applying: AssetManager2: Align creation of FindEntryResult with declaration
-- Applying patches for: core
error: error applying changes: llkd/include/llkd.h:63
error: llkd/include/llkd.h: failed to apply patch
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: Fix inclusion of stdatomic.h with g++
Applying: group_member is a nonstandard GNU extension
Applying: socket.h: include sys/select.h for fd_set used in socket.cpp
Applying: fastboot: make mke2fs_path configurable
Applying: libcutils: include sys/select.h for timeval
Applying: Don't include version.h
Applying: Include cstring in various file missing it
Applying: Vector: don't assign to const object
Applying: Don't use the internal glibc header sys/cdefs.h
Error applying changes to 0009 Don't use the internal glibc header sys/cdefs.h
When you resolve this issue, run «git am --continue».
If you want to skip this patch, then run «git am --skip».
To go back to the previous branch and stop applying the changes, run «git am --abort».
CMake Error at vendor/CMakeLists.txt:30 (message):
  Couldn't apply patches for core

-- Configuring incomplete, errors occurred!
See also "/222/android-tools/build/CMakeFiles/CMakeOutput.log".

And here it turns out some bad thing...

nmeum commented 3 years ago

Can you try again with commit https://github.com/nmeum/android-tools/pull/29/commits/332594b02d0bdcbb12afa7f98f56b0ba2a8d3096? :)

AKotov-dev commented 3 years ago

@nmeum Hooray, it's working! :) Now everything is assembled without errors and the "offline" state is also tracked correctly. That was cool! Thank you very much for your work. I look forward to the release of v31.0.2 to please the maintainers, to get the new package as soon as possible.

Sincerely, Alex

nmeum commented 3 years ago

Did tests with clang, will do further tests before doing the next release.