[arch-commits] Commit in android-tools/trunk (3 files)

Anatol Pomozov anatolik at archlinux.org
Mon May 11 06:47:38 UTC 2020


    Date: Monday, May 11, 2020 @ 06:47:38
  Author: anatolik
Revision: 626247

upgpkg: android-tools 30.0.0-1

As usual a new update requires a lot of changes to the build script. This is
an inevitable price that we pay for partial mirroring of the Android build
system to reuse host-level software components.

Upstream android platform tools use libstdc++ from LLVM project. Arch does not
have this package in the repo thus we use libc++ for now.

There are minor source-level incompatibilities that are most likely caused by
the fact that we use libc++. Libc++ seems more strict when it comes to
including headers for particular POSIX functions. We have to patch "./core"
project and add required "#includes".

Android uses c++2a standard extensively including features that have been
added to compilers just recently. The latest release of android-tools
requires GCC10.

Android-tools requires boringssl. We compile libssl.a and libcrypo.a as static
libraries and then use it for linking with adb/fastboot. System openssl
libraries are not needed in this case.

Android uses an mdns library that is API incompatible with mdns we have at Arch.
Disable mdns-specific code for now.

Modified:
  android-tools/trunk/PKGBUILD
  android-tools/trunk/fix_build_core.patch
  android-tools/trunk/generate_build.rb

----------------------+
 PKGBUILD             |   20 +++++-----
 fix_build_core.patch |   94 +++++++++++++++++++++++++++++++++++++++++++------
 generate_build.rb    |   63 ++++++++++++++++++++++----------
 3 files changed, 138 insertions(+), 39 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2020-05-11 06:09:42 UTC (rev 626246)
+++ PKGBUILD	2020-05-11 06:47:38 UTC (rev 626247)
@@ -3,7 +3,7 @@
 # Contributor: Alucryd <alucryd at gmail dot com>
 
 pkgname=android-tools
-pkgver=29.0.6
+pkgver=30.0.0
 pkgrel=1
 tag=platform-tools-$pkgver
 pkgdesc='Android platform tools'
@@ -10,10 +10,10 @@
 arch=(x86_64)
 url='http://tools.android.com/'
 license=(Apache MIT)
-depends=(pcre2 libusb protobuf)
+depends=(pcre2 libusb protobuf brotli)
 optdepends=('python: for mkbootimg script'
             'python2: for unpack_bootimg & avbtool scripts')
-# depend on 'vim' for 'xxd' tool.
+# it depends on 'vim' because of 'xxd' tool.
 makedepends=(git clang gtest ruby cmake ninja go vim)
 provides=(fastboot adb)
 conflicts=(fastboot adb)
@@ -27,6 +27,7 @@
         git+https://android.googlesource.com/platform/external/f2fs-tools#tag=$tag
         git+https://android.googlesource.com/platform/external/e2fsprogs#tag=$tag
         git+https://android.googlesource.com/platform/external/avb#tag=$tag
+        #git+https://android.googlesource.com/platform/external/boringssl#tag=$tag
         git+https://boringssl.googlesource.com/boringssl#commit=$_boringssl_commit
         generate_build.rb
 # deployagent.jar is a library built from Android sources.
@@ -33,7 +34,7 @@
 # Building this java library requires a lot of dependencies:
 #  java, protobuf-java, dex compiler, Android base libs.
 # To avoid the complexity we prebuilt the lib from the Android sources directly
-# using following instructiuons:
+# using following instructions:
 #   (See https://wiki.archlinux.org/index.php/Android for context)
 # 
 #   source build/envsetup.sh
@@ -54,14 +55,12 @@
           'SKIP'
           'SKIP'
           'SKIP'
-          '37992d0d7547b7deb703f3232ec124a4c6b96aef'
+          '930c5d4b94f7cc09087fe599d4b868e7187abd74'
           'd9dfac30245faa0a96968b96f3acd9ad536f4910'
-          '31779cd6c0df710be9589bd2ee4f697f59b100fd'
+          '70abd4483233ee481490b3369dbdd4977772c57f'
           '7004dbd0c193668827174880de6f8434de8ceaee')
 
 prepare() {
-  PLATFORM_TOOLS_VERSION="$pkgver-$pkgrel" LDFLAGS='-Wl,-z,relro,-z,now' ./generate_build.rb > build.ninja
-
   cd "$srcdir"/core
   patch -p1 < ../fix_build_core.patch
 
@@ -71,10 +70,13 @@
   cd "$srcdir"/mkbootimg
   sed -i 's|/usr/bin/env python$|/usr/bin/env python2|g' unpack_bootimg.py
 
-  mkdir -p "$srcdir"/boringssl/build && cd "$srcdir"/boringssl/build && cmake -GNinja ..; ninja crypto/libcrypto.a
+  mkdir -p "$srcdir"/boringssl/build
 }
 
 build() {
+  (cd "$srcdir"/boringssl/build && cmake -GNinja ..; ninja crypto/libcrypto.a ssl/libssl.a)
+
+  PLATFORM_TOOLS_VERSION="$pkgver-$pkgrel" ./generate_build.rb > build.ninja
   ninja
 }
 

Modified: fix_build_core.patch
===================================================================
--- fix_build_core.patch	2020-05-11 06:09:42 UTC (rev 626246)
+++ fix_build_core.patch	2020-05-11 06:47:38 UTC (rev 626247)
@@ -1,8 +1,8 @@
 diff --git a/adb/adb.cpp b/adb/adb.cpp
-index 1ec145b25c..b6e943f6ee 100644
+index 08d3904c71..a73362acec 100644
 --- a/adb/adb.cpp
 +++ b/adb/adb.cpp
-@@ -44,8 +44,6 @@
+@@ -45,8 +45,6 @@
  #include <android-base/parsenetaddress.h>
  #include <android-base/stringprintf.h>
  #include <android-base/strings.h>
@@ -11,7 +11,7 @@
  
  #include "adb_auth.h"
  #include "adb_io.h"
-@@ -66,10 +64,10 @@ std::string adb_version() {
+@@ -74,10 +72,10 @@ std::string adb_version() {
      // Don't change the format of this --- it's parsed by ddmlib.
      return android::base::StringPrintf(
          "Android Debug Bridge version %d.%d.%d\n"
@@ -24,23 +24,34 @@
          android::base::GetExecutablePath().c_str());
  }
  
+diff --git a/adb/client/adb_wifi.cpp b/adb/client/adb_wifi.cpp
+index fa71028115..8c460f24fb 100644
+--- a/adb/client/adb_wifi.cpp
++++ b/adb/client/adb_wifi.cpp
+@@ -242,5 +242,6 @@ void adb_wifi_pair_device(const std::string& host, const std::string& password,
+     // Write to adb_known_hosts
+     write_known_host_to_file(device_guid);
+     // Try to auto-connect.
+-    adb_secure_connect_by_service_name(device_guid.c_str());
++    // ARCH: following function requires mdns code that is not compatible with mdns system library
++    // adb_secure_connect_by_service_name(device_guid.c_str());
+ }
 diff --git a/adb/client/main.cpp b/adb/client/main.cpp
-index 0c5c28f1b3..b6a1281521 100644
+index 05e210f607..99192831c5 100644
 --- a/adb/client/main.cpp
 +++ b/adb/client/main.cpp
-@@ -118,10 +118,6 @@ int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply
-     init_transport_registration();
+@@ -126,9 +126,6 @@ int adb_server_main(int is_daemon, const std::string& socket_spec, int ack_reply
      init_reconnect_handler();
  
+     adb_wifi_init();
 -    if (!getenv("ADB_MDNS") || strcmp(getenv("ADB_MDNS"), "0") != 0) {
 -        init_mdns_transport_discovery();
 -    }
--
+ 
      if (!getenv("ADB_USB") || strcmp(getenv("ADB_USB"), "0") != 0) {
          usb_init();
-     } else {
 diff --git a/adb/client/usb_libusb.cpp b/adb/client/usb_libusb.cpp
-index 53f01a0ce5..b4c3aadc28 100644
+index 07cbc9418c..6145392194 100644
 --- a/adb/client/usb_libusb.cpp
 +++ b/adb/client/usb_libusb.cpp
 @@ -30,7 +30,7 @@
@@ -52,8 +63,57 @@
  
  #include <android-base/file.h>
  #include <android-base/logging.h>
+diff --git a/adb/crypto/x509_generator.cpp b/adb/crypto/x509_generator.cpp
+index 43b8153048..6900b3a497 100644
+--- a/adb/crypto/x509_generator.cpp
++++ b/adb/crypto/x509_generator.cpp
+@@ -17,6 +17,7 @@
+ #include "adb/crypto/x509_generator.h"
+ 
+ #include <vector>
++#include <string.h>
+ 
+ #include <android-base/logging.h>
+ #include <crypto_utils/android_pubkey.h>
+diff --git a/adb/pairing_auth/aes_128_gcm.cpp b/adb/pairing_auth/aes_128_gcm.cpp
+index 51520d814d..2d5f86fa81 100644
+--- a/adb/pairing_auth/aes_128_gcm.cpp
++++ b/adb/pairing_auth/aes_128_gcm.cpp
+@@ -23,6 +23,8 @@
+ #include <openssl/hkdf.h>
+ #include <openssl/rand.h>
+ 
++#include <string.h>
++
+ namespace adb {
+ namespace pairing {
+ 
+diff --git a/adb/pairing_auth/pairing_auth.cpp b/adb/pairing_auth/pairing_auth.cpp
+index 0ac04e6913..de2aa740ea 100644
+--- a/adb/pairing_auth/pairing_auth.cpp
++++ b/adb/pairing_auth/pairing_auth.cpp
+@@ -21,6 +21,7 @@
+ #include <openssl/curve25519.h>
+ #include <openssl/mem.h>
+ 
++#include <string.h>
+ #include <iomanip>
+ #include <sstream>
+ #include <vector>
+diff --git a/adb/tls/tls_connection.cpp b/adb/tls/tls_connection.cpp
+index 853cdac08c..3613c3768b 100644
+--- a/adb/tls/tls_connection.cpp
++++ b/adb/tls/tls_connection.cpp
+@@ -18,6 +18,7 @@
+ 
+ #include <algorithm>
+ #include <vector>
++#include <limits.h>
+ 
+ #include <android-base/logging.h>
+ #include <android-base/strings.h>
 diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
-index 2fe3b1a9e0..a61b221ce3 100644
+index 7f6e7230f4..808f2e0671 100644
 --- a/fastboot/fastboot.cpp
 +++ b/fastboot/fastboot.cpp
 @@ -59,10 +59,8 @@
@@ -67,7 +127,7 @@
  #include <sparse/sparse.h>
  #include <ziparchive/zip_archive.h>
  
-@@ -1783,7 +1781,7 @@ int FastBootTool::Main(int argc, char* argv[]) {
+@@ -1799,7 +1797,7 @@ int FastBootTool::Main(int argc, char* argv[]) {
                  setvbuf(stdout, nullptr, _IONBF, 0);
                  setvbuf(stderr, nullptr, _IONBF, 0);
              } else if (name == "version") {
@@ -102,3 +162,15 @@
  //
  // Deprecated: use `_Thread_local` in C or `thread_local` in C++.
  //
+diff --git a/libziparchive/zip_cd_entry_map.h b/libziparchive/zip_cd_entry_map.h
+index 4957f754e7..1cfb74dd5b 100644
+--- a/libziparchive/zip_cd_entry_map.h
++++ b/libziparchive/zip_cd_entry_map.h
+@@ -17,6 +17,7 @@
+ #pragma once
+ 
+ #include <stdint.h>
++#include <stdlib.h>
+ 
+ #include <map>
+ #include <memory>

Modified: generate_build.rb
===================================================================
--- generate_build.rb	2020-05-11 06:09:42 UTC (rev 626246)
+++ generate_build.rb	2020-05-11 06:47:38 UTC (rev 626247)
@@ -1,8 +1,8 @@
 #!/usr/bin/ruby
 
-# Android build system is complicated and does not allow to build
-# separate parts easily.
-# This script tries to mimic Android build rules.
+# Android has a huge and monolithic build system that does not allow to build
+# components separately.
+# This script tries to mimic Android build system for a small subset of source.
 
 def expand(dir, files)
   files.map { |f| File.join(dir, f) }
@@ -18,10 +18,8 @@
     case ext
     when ".c"
       cc = "cc"
-      lang_flags = "-std=gnu11 $CFLAGS $CPPFLAGS"
     when ".cpp", ".cc"
       cc = "cxx"
-      lang_flags = "-std=gnu++2a $CXXFLAGS $CPPFLAGS"
     else
       raise "Unknown extension #{ext}"
     end
@@ -34,7 +32,8 @@
         ""
       end
 
-    puts "build #{output}: #{cc} #{s}#{order_deps}\n    cflags = #{lang_flags} #{cflags}"
+    # TODO: try to build the tools with LLVM libc: -stdlib=libc++
+    puts "build #{output}: #{cc} #{s}#{order_deps}\n    cflags = #{cflags}"
   end
 
   return outputs
@@ -47,7 +46,7 @@
   hfile = basename + ".pb.h"
   ofile = cfile + ".o"
   puts "build #{cfile} #{hfile}: protoc #{source}"
-  puts "build #{ofile}: cc #{cfile}\n    cflags = -std=gnu++2a $CXXFLAGS $CPPFLAGS -I."
+  puts "build #{ofile}: cxx #{cfile}\n    cflags = -I."
 
   return hfile, cfile, ofile
 end
@@ -61,7 +60,8 @@
 
 # Links object files
 def link(output, objects, ldflags)
-  puts "build #{output}: link #{objects.join(" ")}\n    ldflags = #{ldflags} $LDFLAGS"
+  # TODO: try to build the tools with LLVM libc: -stdlib=libc++
+  puts "build #{output}: link #{objects.join(" ")}\n    ldflags = #{ldflags}"
 end
 
 def genheader(input, variable, output)
@@ -72,6 +72,7 @@
 puts "CC = #{ENV["CC"] || "clang"}"
 puts "CXX = #{ENV["CXX"] || "clang++"}\n\n"
 puts "CFLAGS = #{ENV["CFLAGS"]}"
+puts "CPPFLAGS = #{ENV["CPPFLAGS"]}"
 puts "CXXFLAGS = #{ENV["CXXFLAGS"]}"
 puts "LDFLAGS = #{ENV["LDFLAGS"]}"
 puts "PLATFORM_TOOLS_VERSION = #{ENV["PLATFORM_TOOLS_VERSION"]}\n\n"
@@ -78,10 +79,10 @@
 
 puts "" "
 rule cc
-  command = $CC $cflags -c $in -o $out
+  command = $CC -std=gnu11 $CFLAGS $CPPFLAGS $cflags -c $in -o $out
 
 rule cxx
-  command = $CXX $cflags -c $in -o $out
+  command = $CXX -std=gnu++2a $CXXFLAGS $CPPFLAGS $cflags -c $in -o $out
 
 rule link
   command = $CXX $ldflags $LDFLAGS $in -o $out
@@ -95,6 +96,8 @@
 
 " ""
 
+key_type_h, key_type_c, key_type_o = protoc("core/adb/proto/key_type.proto")
+
 adbdfiles = %w(
   adb.cpp
   adb_io.cpp
@@ -108,12 +111,14 @@
   sockets.cpp
   transport.cpp
   transport_local.cpp
-  transport_usb.cpp
   types.cpp
 )
-libadbd = compile(expand("core/adb", adbdfiles), '-DPLATFORM_TOOLS_VERSION="\"$PLATFORM_TOOLS_VERSION\"" -DADB_HOST=1 -Icore/include -Icore/base/include -Icore/adb -Icore/libcrypto_utils/include -Iboringssl/include -Icore/diagnose_usb/include')
+libadbd = compile(expand("core/adb", adbdfiles), '-DPLATFORM_TOOLS_VERSION="\"$PLATFORM_TOOLS_VERSION\"" -DADB_HOST=1 -Icore/include -Icore/base/include -Icore/adb -Icore/libcrypto_utils/include -Iboringssl/include -Icore/diagnose_usb/include -Icore/adb/crypto/include -Icore/adb/proto -Icore/adb/tls/include', :order_deps => [key_type_h])
 
 apkent_h, apkent_c, apkent_o = protoc("core/adb/fastdeploy/proto/ApkEntry.proto")
+app_processes_h, app_processes_c, app_processes_o = protoc("core/adb/proto/app_processes.proto")
+adb_known_hosts_h, adb_known_hosts_c, adb_known_hosts_o = protoc("core/adb/proto/adb_known_hosts.proto")
+pairing_h, pairing_c, pairing_o = protoc("core/adb/proto/pairing.proto")
 
 deployagent_inc = "core/adb/client/deployagent.inc"
 genheader("deployagent.jar", "kDeployAgent", deployagent_inc)
@@ -124,6 +129,7 @@
 adbfiles = %w(
   client/adb_client.cpp
   client/adb_install.cpp
+  client/adb_wifi.cpp
   client/auth.cpp
   client/bugreport.cpp
   client/commandline.cpp
@@ -131,22 +137,35 @@
   client/fastdeploy.cpp
   client/fastdeploycallbacks.cpp
   client/file_sync_client.cpp
+  client/incremental.cpp
+  client/incremental_server.cpp
+  client/incremental_utils.cpp
   client/line_printer.cpp
   client/main.cpp
+  client/pairing/pairing_client.cpp
+  client/transport_usb.cpp
   client/usb_dispatch.cpp
   client/usb_libusb.cpp
   client/usb_linux.cpp
+  crypto/key.cpp
+  crypto/rsa_2048_key.cpp
+  crypto/x509_generator.cpp
   fastdeploy/deploypatchgenerator/apk_archive.cpp
   fastdeploy/deploypatchgenerator/deploy_patch_generator.cpp
   fastdeploy/deploypatchgenerator/patch_utils.cpp
+  pairing_auth/aes_128_gcm.cpp
+  pairing_auth/pairing_auth.cpp
+  pairing_connection/pairing_connection.cpp
   services.cpp
   socket_spec.cpp
   sysdeps/errno.cpp
   sysdeps/posix/network.cpp
   sysdeps_unix.cpp
+  tls/adb_ca_list.cpp
+  tls/tls_connection.cpp
 )
-libadb = compile(expand("core/adb", adbfiles), "-D_GNU_SOURCE -DADB_HOST=1 -Icore/include -Icore/base/include -Icore/adb -Icore/libcrypto_utils/include -Iboringssl/include -Ibase/libs/androidfw/include -Inative/include", :order_deps => [apkent_h, deployagent_inc, deployagentscript_inc])
-
+libadb = compile(expand("core/adb", adbfiles), "-D_GNU_SOURCE -DADB_HOST=1 -Icore/include -Icore/base/include -Icore/adb -Icore/libcrypto_utils/include -Iboringssl/include -Ibase/libs/androidfw/include -Inative/include -Icore/adb/crypto/include -Icore/adb/proto -Icore/adb/tls/include -Icore/adb/pairing_connection/include -Icore/libziparchive/include -Icore/adb/pairing_auth/include",
+    :order_deps => [apkent_h, key_type_h, app_processes_h, adb_known_hosts_h, pairing_h, deployagent_inc, deployagentscript_inc])
 androidfwfiles = %w(
   LocaleData.cpp
   ResourceTypes.cpp
@@ -162,6 +181,7 @@
   liblog_symbols.cpp
   logging.cpp
   mapped_file.cpp
+  parsebool.cpp
   parsenetaddress.cpp
   stringprintf.cpp
   strings.cpp
@@ -206,8 +226,9 @@
 libcrypto = compile(expand("core/libcrypto_utils", libcryptofiles), "-Icore/libcrypto_utils/include -Iboringssl/include")
 
 # TODO: make subninja working
-#boringssl = subninja('boringssl/build/', ['crypto/libcrypto.a'])
-boringssl = ["boringssl/build/crypto/libcrypto.a"]
+#boringssl = subninja('boringssl/build/', ['ssl/libssl.a'])
+boringssl = ["boringssl/build/crypto/libcrypto.a", "boringssl/build/ssl/libssl.a"]
+boringssl_ldflags = "-Wl,--whole-archive " + boringssl.join(" ") + " -Wl,--no-whole-archive"
 
 fastbootfiles = %w(
   bootimg_utils.cpp
@@ -248,8 +269,12 @@
 
 zipfiles = %w(
   zip_archive.cc
+  zip_error.cpp
+  zip_cd_entry_map.cc
 )
-libzip = compile(expand("core/libziparchive", zipfiles), "-Icore/base/include -Icore/include -Icore/libziparchive/include")
+# we use -std=c++17 as this lib currently does not compile with c++20 standard due to
+# https://stackoverflow.com/questions/37618213/when-is-a-private-constructor-not-a-private-constructor/57430419#57430419
+libzip = compile(expand("core/libziparchive", zipfiles), "-std=c++17 -Icore/base/include -Icore/include -Icore/libziparchive/include")
 
 utilfiles = %w(
   FileMap.cpp
@@ -323,7 +348,7 @@
 )
 libsepol = compile(expand("selinux/libsepol/src", libsepolfiles), "-Iselinux/libsepol/include -Iselinux/libsepol/src")
 
-link("fastboot", libfsmgr + libsparse + libzip + libcutils + liblog + libutil + libbase + libext4 + f2fs + libselinux + libsepol + libfastboot + libdiagnoseusb + boringssl, "-lz -lpcre2-8 -lpthread -ldl")
+link("fastboot", libfsmgr + libsparse + libzip + libcutils + liblog + libutil + libbase + libext4 + f2fs + libselinux + libsepol + libfastboot + libdiagnoseusb, boringssl_ldflags + " -lz -lpcre2-8 -lpthread")
 
 # mke2fs.android - a ustom version of mke2fs that supports --android_sparse (FS#56955)
 libext2fsfiles = %w(
@@ -462,4 +487,4 @@
 
 link("ext2simg", ext2simg + libext2fs + libsparse + libbase + libzip + liblog + libutil, "-lz -lpthread")
 
-link("adb", libbase + liblog + libcutils + libutil + libadbd + libadb + libdiagnoseusb + libcrypto + boringssl + libandroidfw + libzip + [apkent_o], "-lpthread -lusb-1.0 -lprotobuf-lite -lz")
+link("adb", libbase + liblog + libcutils + libutil + libadbd + libadb + libdiagnoseusb + libcrypto + libandroidfw + libzip + [apkent_o, key_type_o, app_processes_o, adb_known_hosts_o, pairing_o], boringssl_ldflags + " -lpthread -lusb-1.0 -lprotobuf -lz -llz4 -lbrotlidec -lbrotlienc")



More information about the arch-commits mailing list