Date: Sunday, May 17, 2020 @ 23:40:36 Author: ffy00 Revision: 629148 archrelease: copy trunk to community-staging-x86_64
Added: android-tools/repos/community-staging-x86_64/ android-tools/repos/community-staging-x86_64/PKGBUILD (from rev 629147, android-tools/trunk/PKGBUILD) android-tools/repos/community-staging-x86_64/bash_completion.fastboot (from rev 629147, android-tools/trunk/bash_completion.fastboot) android-tools/repos/community-staging-x86_64/boringssl-disable-thirdpartydeps.patch (from rev 629147, android-tools/trunk/boringssl-disable-thirdpartydeps.patch) android-tools/repos/community-staging-x86_64/deployagent.jar (from rev 629147, android-tools/trunk/deployagent.jar) android-tools/repos/community-staging-x86_64/fix_build_core.patch (from rev 629147, android-tools/trunk/fix_build_core.patch) android-tools/repos/community-staging-x86_64/generate_build.rb (from rev 629147, android-tools/trunk/generate_build.rb) ----------------------------------------+ PKGBUILD | 93 +++++ bash_completion.fastboot | 90 +++++ boringssl-disable-thirdpartydeps.patch | 24 + fix_build_core.patch | 176 +++++++++++ generate_build.rb | 490 +++++++++++++++++++++++++++++++ 5 files changed, 873 insertions(+) Copied: android-tools/repos/community-staging-x86_64/PKGBUILD (from rev 629147, android-tools/trunk/PKGBUILD) =================================================================== --- community-staging-x86_64/PKGBUILD (rev 0) +++ community-staging-x86_64/PKGBUILD 2020-05-17 23:40:36 UTC (rev 629148) @@ -0,0 +1,93 @@ +# Maintainer: Anatol Pomozov +# Contributor: 謝致邦 <yek...@red54.com> +# Contributor: Alucryd <alucryd at gmail dot com> + +pkgname=android-tools +pkgver=30.0.0 +pkgrel=2 +tag=platform-tools-$pkgver +pkgdesc='Android platform tools' +arch=(x86_64) +url='http://tools.android.com/' +license=(Apache MIT) +depends=(pcre2 libusb protobuf brotli) +optdepends=('python: for mkbootimg script' + 'python2: for unpack_bootimg & avbtool scripts') +# it depends on 'vim' because of 'xxd' tool. +makedepends=(git clang gtest ruby cmake ninja go vim) +provides=(fastboot adb) +conflicts=(fastboot adb) +#_boringssl_commit=$(curl https://android.googlesource.com/platform/external/boringssl/+/refs/tags/$tag/BORINGSSL_REVISION?format=TEXT | base64 -d) +source=(git+https://android.googlesource.com/platform/frameworks/base#tag=$tag + git+https://android.googlesource.com/platform/frameworks/native#tag=$tag + git+https://android.googlesource.com/platform/system/core#tag=$tag + git+https://android.googlesource.com/platform/system/extras#tag=$tag + git+https://android.googlesource.com/platform/system/tools/mkbootimg#tag=$tag + git+https://android.googlesource.com/platform/external/selinux#tag=$tag + 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. +# 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 instructions: +# (See https://wiki.archlinux.org/index.php/Android for context) +# +# source build/envsetup.sh +# lunch full-eng +# mmm system/core/adb/ +# cp ./target/product/generic/system/framework/deployagent.jar . + deployagent.jar + fix_build_core.patch + boringssl-disable-thirdpartydeps.patch + bash_completion.fastboot) + # Bash completion file was taken from https://github.com/mbrubeck/android-completion +sha1sums=('SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + '4aec96639c5a16e75fac907bc5a8ea6a7efca047' + 'd9dfac30245faa0a96968b96f3acd9ad536f4910' + '70abd4483233ee481490b3369dbdd4977772c57f' + '1c025855a3e7ea351685843a0df45c52a7e674dd' + '7004dbd0c193668827174880de6f8434de8ceaee') + +prepare() { + cd "$srcdir"/core + patch -p1 < ../fix_build_core.patch + + cd "$srcdir"/avb + sed -i 's|/usr/bin/env python$|/usr/bin/env python2|g' avbtool + + cd "$srcdir"/mkbootimg + sed -i 's|/usr/bin/env python$|/usr/bin/env python2|g' unpack_bootimg.py + + cd "$srcdir"/boringssl + patch -p1 < ../boringssl-disable-thirdpartydeps.patch + mkdir -p "$srcdir"/boringssl/src/build +} + +build() { + (cd "$srcdir"/boringssl/src/build && cmake -GNinja ..; ninja crypto/libcrypto.a ssl/libssl.a) + + PLATFORM_TOOLS_VERSION="$pkgver-$pkgrel" ./generate_build.rb > build.ninja + ninja +} + +package() { + install -m755 -d "$pkgdir"/usr/bin + install -m755 -t "$pkgdir"/usr/bin fastboot adb mke2fs.android e2fsdroid ext2simg avb/avbtool + install -Dm 755 mkbootimg/mkbootimg.py "$pkgdir"/usr/bin/mkbootimg + install -Dm 755 mkbootimg/unpack_bootimg.py "$pkgdir"/usr/bin/unpack_bootimg + install -Dm 644 bash_completion.fastboot "$pkgdir"/usr/share/bash-completion/completions/fastboot +} Copied: android-tools/repos/community-staging-x86_64/bash_completion.fastboot (from rev 629147, android-tools/trunk/bash_completion.fastboot) =================================================================== --- community-staging-x86_64/bash_completion.fastboot (rev 0) +++ community-staging-x86_64/bash_completion.fastboot 2020-05-17 23:40:36 UTC (rev 629148) @@ -0,0 +1,90 @@ +## Bash completion for the Android SDK tools. +## +## Copyright (c) 2009 Matt Brubeck +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included in +## all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +## THE SOFTWARE. + + +function _fastboot() +{ + local cur prev opts cmds c subcommand device_selected + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="-w -s -p -c -i -b -n" + cmds="update flashall flash erase getvar boot devices \ + reboot reboot-bootloader oem continue" + subcommand="" + partition_list="boot recovery system userdata bootloader radio" + device_selected="" + + # Look for the subcommand. + c=1 + while [ $c -lt $COMP_CWORD ]; do + word="${COMP_WORDS[c]}" + if [ "$word" = "-s" ]; then + device_selected=true + fi + for cmd in $cmds; do + if [ "$cmd" = "$word" ]; then + subcommand="$word" + fi + done + c=$((++c)) + done + + case "${subcommand}" in + '') + case "${prev}" in + -s) + # Use 'fastboot devices' to list serial numbers. + COMPREPLY=( $(compgen -W "$(fastboot devices|cut -f1)" -- ${cur} ) ) + return 0 + ;; + esac + case "${cur}" in + -*) + COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) + return 0 + ;; + esac + if [ -z "$device_selected" ]; then + local num_devices=$(( $(fastboot devices 2>/dev/null|wc -l) )) + if [ "$num_devices" -gt "1" ]; then + # With multiple devices, you must choose a device first. + COMPREPLY=( $(compgen -W "-s" -- ${cur}) ) + return 0 + fi + fi + COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) ) + return 0 + ;; + flash) + # partition name + COMPREPLY=( $(compgen -W "${partition_list}" -- ${cur}) ) + return 0 + ;; + erase) + # partition name + COMPREPLY=( $(compgen -W "${partition_list}" -- ${cur}) ) + return 0 + ;; + esac +} +complete -o default -F _fastboot fastboot Copied: android-tools/repos/community-staging-x86_64/boringssl-disable-thirdpartydeps.patch (from rev 629147, android-tools/trunk/boringssl-disable-thirdpartydeps.patch) =================================================================== --- community-staging-x86_64/boringssl-disable-thirdpartydeps.patch (rev 0) +++ community-staging-x86_64/boringssl-disable-thirdpartydeps.patch 2020-05-17 23:40:36 UTC (rev 629148) @@ -0,0 +1,24 @@ +commit a05f7bad3f07a4041e7011a629858a8b0921e9e0 +Author: Anatol Pomozov <anatol.pomo...@gmail.com> +Date: Fri May 15 20:04:43 2020 -0700 + + Do not use third-party dependency as it is missing in Android's version of the repo + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 75bf9981..9ec8e81b 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -562,13 +562,6 @@ if(USE_CUSTOM_LIBCXX) + target_link_libraries(libcxx libcxxabi) + endif() + +-# Add minimal googletest targets. The provided one has many side-effects, and +-# googletest has a very straightforward build. +-add_library(boringssl_gtest third_party/googletest/src/gtest-all.cc) +-target_include_directories(boringssl_gtest PRIVATE third_party/googletest) +- +-include_directories(third_party/googletest/include) +- + # Declare a dummy target to build all unit tests. Test targets should inject + # themselves as dependencies next to the target definition. + add_custom_target(all_tests) Copied: android-tools/repos/community-staging-x86_64/deployagent.jar (from rev 629147, android-tools/trunk/deployagent.jar) =================================================================== (Binary files differ) Copied: android-tools/repos/community-staging-x86_64/fix_build_core.patch (from rev 629147, android-tools/trunk/fix_build_core.patch) =================================================================== --- community-staging-x86_64/fix_build_core.patch (rev 0) +++ community-staging-x86_64/fix_build_core.patch 2020-05-17 23:40:36 UTC (rev 629148) @@ -0,0 +1,176 @@ +diff --git a/adb/adb.cpp b/adb/adb.cpp +index 08d3904c71..a73362acec 100644 +--- a/adb/adb.cpp ++++ b/adb/adb.cpp +@@ -45,8 +45,6 @@ + #include <android-base/parsenetaddress.h> + #include <android-base/stringprintf.h> + #include <android-base/strings.h> +-#include <build/version.h> +-#include <platform_tools_version.h> + + #include "adb_auth.h" + #include "adb_io.h" +@@ -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" +- "Version %s-%s\n" ++ "Version %s\n" + "Installed as %s\n", + ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION, +- PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(), ++ PLATFORM_TOOLS_VERSION, + 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 05e210f607..99192831c5 100644 +--- a/adb/client/main.cpp ++++ b/adb/client/main.cpp +@@ -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(); +diff --git a/adb/client/usb_libusb.cpp b/adb/client/usb_libusb.cpp +index 07cbc9418c..6145392194 100644 +--- a/adb/client/usb_libusb.cpp ++++ b/adb/client/usb_libusb.cpp +@@ -30,7 +30,7 @@ + #include <thread> + #include <unordered_map> + +-#include <libusb/libusb.h> ++#include <libusb-1.0/libusb.h> + + #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 7f6e7230f4..808f2e0671 100644 +--- a/fastboot/fastboot.cpp ++++ b/fastboot/fastboot.cpp +@@ -59,10 +59,8 @@ + #include <android-base/stringprintf.h> + #include <android-base/strings.h> + #include <android-base/unique_fd.h> +-#include <build/version.h> + #include <libavb/libavb.h> + #include <liblp/liblp.h> +-#include <platform_tools_version.h> + #include <sparse/sparse.h> + #include <ziparchive/zip_archive.h> + +@@ -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") { +- fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str()); ++ fprintf(stdout, "fastboot version %s\n", PLATFORM_TOOLS_VERSION); + fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str()); + return 0; + #if !defined(_WIN32) +diff --git a/fastboot/fs.cpp b/fastboot/fs.cpp +index 8c0aa6bf4e..3ad5b53568 100644 +--- a/fastboot/fs.cpp ++++ b/fastboot/fs.cpp +@@ -117,7 +117,7 @@ static int generate_ext4_image(const char* fileName, long long partSize, + static constexpr int block_size = 4096; + const std::string exec_dir = android::base::GetExecutableDirectory(); + +- const std::string mke2fs_path = exec_dir + "/mke2fs"; ++ const std::string mke2fs_path = exec_dir + "/mke2fs.android"; + std::vector<const char*> mke2fs_args = {mke2fs_path.c_str(), "-t", "ext4", "-b"}; + + std::string block_size_str = std::to_string(block_size); +diff --git a/libcutils/include/cutils/threads.h b/libcutils/include/cutils/threads.h +index ba4846e33b..f3fccc4895 100644 +--- a/libcutils/include/cutils/threads.h ++++ b/libcutils/include/cutils/threads.h +@@ -33,8 +33,6 @@ extern "C" { + // Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows. + // + +-extern pid_t gettid(); +- + // + // 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> Copied: android-tools/repos/community-staging-x86_64/generate_build.rb (from rev 629147, android-tools/trunk/generate_build.rb) =================================================================== --- community-staging-x86_64/generate_build.rb (rev 0) +++ community-staging-x86_64/generate_build.rb 2020-05-17 23:40:36 UTC (rev 629148) @@ -0,0 +1,490 @@ +#!/usr/bin/ruby + +# 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) } +end + +# Compiles sources to *.o files. +# Returns array of output *.o filenames +def compile(sources, cflags, params = {}) + outputs = [] + for s in sources + ext = File.extname(s) + + case ext + when ".c" + cc = "cc" + when ".cpp", ".cc" + cc = "cxx" + else + raise "Unknown extension #{ext}" + end + + output = s + ".o" + outputs << output + order_deps = if params[:order_deps] + " || " + params[:order_deps].join(" ") + else + "" + end + + # TODO: try to build the tools with LLVM libc: -stdlib=libc++ + puts "build #{output}: #{cc} #{s}#{order_deps}\n cflags = #{cflags}" + end + + return outputs +end + +# Generate proto and compile it +def protoc(source) + basename = File.join(File.dirname(source), File.basename(source, ".proto")) + cfile = basename + ".pb.cc" + hfile = basename + ".pb.h" + ofile = cfile + ".o" + puts "build #{cfile} #{hfile}: protoc #{source}" + puts "build #{ofile}: cxx #{cfile}\n cflags = -I." + + return hfile, cfile, ofile +end + +# dir - directory where ninja file is located +# lib - static library path relative to dir +def subninja(dir, lib) + puts "subninja #{dir}build.ninja" + return lib.each { |l| dir + l } +end + +# Links object files +def link(output, objects, 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) + puts "build #{output}: genheader #{input}\n var = #{variable}" +end + +puts "# This set of commands generated by generate_build.rb script\n\n" +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" + +puts "" " +rule cc + command = $CC -std=gnu11 $CFLAGS $CPPFLAGS $cflags -c $in -o $out + +rule cxx + command = $CXX -std=gnu++2a $CXXFLAGS $CPPFLAGS $cflags -c $in -o $out + +rule link + command = $CXX $ldflags $LDFLAGS $in -o $out + +rule protoc + command = protoc --cpp_out=. $in + +rule genheader + command = (echo 'unsigned char $var[] = {' && xxd -i <$in && echo '};') > $out + + +" "" + +key_type_h, key_type_c, key_type_o = protoc("core/adb/proto/key_type.proto") + +adbdfiles = %w( + adb.cpp + adb_io.cpp + adb_listeners.cpp + adb_trace.cpp + adb_utils.cpp + fdevent/fdevent.cpp + fdevent/fdevent_poll.cpp + fdevent/fdevent_epoll.cpp + shell_service_protocol.cpp + sockets.cpp + transport.cpp + transport_local.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/src/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) + +deployagentscript_inc = "core/adb/client/deployagentscript.inc" +genheader("core/adb/fastdeploy/deployagent/deployagent.sh", "kDeployAgentScript", deployagentscript_inc) + +adbfiles = %w( + client/adb_client.cpp + client/adb_install.cpp + client/adb_wifi.cpp + client/auth.cpp + client/bugreport.cpp + client/commandline.cpp + client/console.cpp + 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/src/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 + TypeWrappers.cpp + ZipFileRO.cpp +) +libandroidfw = compile(expand("base/libs/androidfw", androidfwfiles), "-Icore/base/include -Ibase/libs/androidfw/include -Icore/libutils/include -Icore/liblog/include -Icore/libsystem/include -Inative/include -Icore/libcutils/include -Icore/libziparchive/include") + +basefiles = %w( + chrono_utils.cpp + errors_unix.cpp + file.cpp + liblog_symbols.cpp + logging.cpp + mapped_file.cpp + parsebool.cpp + parsenetaddress.cpp + stringprintf.cpp + strings.cpp + test_utils.cpp + threads.cpp +) +libbase = compile(expand("core/base", basefiles), "-DADB_HOST=1 -Icore/base/include -Icore/include") + +logfiles = %w( + log_event_list.cpp + log_event_write.cpp + logger_name.cpp + logger_write.cpp + logprint.cpp + properties.cpp +) +liblog = compile(expand("core/liblog", logfiles), "-DLIBLOG_LOG_TAG=1006 -D_XOPEN_SOURCE=700 -DFAKE_LOG_DEVICE=1 -Icore/log/include -Icore/include -Icore/base/include") + +cutilsfiles = %w( + android_get_control_file.cpp + canned_fs_config.cpp + fs_config.cpp + load_file.cpp + socket_inaddr_any_server_unix.cpp + socket_local_client_unix.cpp + socket_local_server_unix.cpp + socket_network_client_unix.cpp + sockets.cpp + sockets_unix.cpp + threads.cpp +) +libcutils = compile(expand("core/libcutils", cutilsfiles), "-D_GNU_SOURCE -Icore/libcutils/include -Icore/include -Icore/base/include") + +diagnoseusbfiles = %w( + diagnose_usb.cpp +) +libdiagnoseusb = compile(expand("core/diagnose_usb", diagnoseusbfiles), "-Icore/include -Icore/base/include -Icore/diagnose_usb/include") + +libcryptofiles = %w( + android_pubkey.c +) +libcrypto = compile(expand("core/libcrypto_utils", libcryptofiles), "-Icore/libcrypto_utils/include -Iboringssl/src/include") + +# TODO: make subninja working +#boringssl = subninja('boringssl/src/build/', ['ssl/libssl.a']) +boringssl = ["boringssl/src/build/crypto/libcrypto.a", "boringssl/src/build/ssl/libssl.a"] +boringssl_ldflags = "-Wl,--whole-archive " + boringssl.join(" ") + " -Wl,--no-whole-archive" + +fastbootfiles = %w( + bootimg_utils.cpp + fastboot.cpp + fastboot_driver.cpp + fs.cpp + main.cpp + socket.cpp + tcp.cpp + udp.cpp + usb_linux.cpp + util.cpp +) +libfastboot = compile(expand("core/fastboot", fastbootfiles), '-DPLATFORM_TOOLS_VERSION="\"$PLATFORM_TOOLS_VERSION\"" -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -DUSE_F2FS -Icore/base/include -Icore/include -Icore/adb -Icore/libsparse/include -Imkbootimg/include/bootimg -Iextras/ext4_utils/include -Iextras/f2fs_utils -Icore/libziparchive/include -Icore/fs_mgr/liblp/include -Icore/diagnose_usb/include -Iavb') + +fsmgrfiles = %w( + liblp/images.cpp + liblp/partition_opener.cpp + liblp/reader.cpp + liblp/utility.cpp + liblp/writer.cpp +) +libfsmgr = compile(expand("core/fs_mgr", fsmgrfiles), "-Icore/fs_mgr/liblp/include -Icore/base/include -Iextras/ext4_utils/include -Icore/libsparse/include") + +sparsefiles = %w( + backed_block.cpp + output_file.cpp + sparse.cpp + sparse_crc32.cpp + sparse_err.cpp + sparse_read.cpp +) +libsparse = compile(expand("core/libsparse", sparsefiles), "-Icore/libsparse/include -Icore/base/include") + +f2fsfiles = %w( +) +f2fs = compile(expand("extras/f2fs_utils", f2fsfiles), "-DHAVE_LINUX_TYPES_H -If2fs-tools/include -Icore/liblog/include") + +zipfiles = %w( + zip_archive.cc + zip_error.cpp + zip_cd_entry_map.cc +) +# 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 + SharedBuffer.cpp + String16.cpp + String8.cpp + VectorImpl.cpp + Unicode.cpp +) +libutil = compile(expand("core/libutils", utilfiles), "-Icore/include -Icore/base/include") + +ext4files = %w( + ext4_utils.cpp + wipe.cpp + ext4_sb.cpp +) +libext4 = compile(expand("extras/ext4_utils", ext4files), "-D_GNU_SOURCE -Icore/libsparse/include -Icore/include -Iselinux/libselinux/include -Iextras/ext4_utils/include -Icore/base/include") + +selinuxfiles = %w( + booleans.c + callbacks.c + canonicalize_context.c + check_context.c + disable.c + enabled.c + freecon.c + getenforce.c + init.c + label_backends_android.c + label.c + label_file.c + label_support.c + lgetfilecon.c + load_policy.c + lsetfilecon.c + matchpathcon.c + policyvers.c + regex.c + selinux_config.c + setenforce.c + setrans_client.c + seusers.c + sha1.c +) +libselinux = compile(expand("selinux/libselinux/src", selinuxfiles), "-DAUDITD_LOG_TAG=1003 -D_GNU_SOURCE -DHOST -DUSE_PCRE2 -DNO_PERSISTENTLY_STORED_PATTERNS -DDISABLE_SETRANS -DDISABLE_BOOL -DNO_MEDIA_BACKEND -DNO_X_BACKEND -DNO_DB_BACKEND -DPCRE2_CODE_UNIT_WIDTH=8 -Iselinux/libselinux/include -Iselinux/libsepol/include") + +libsepolfiles = %w( + assertion.c + avrule_block.c + avtab.c + conditional.c + constraint.c + context.c + context_record.c + debug.c + ebitmap.c + expand.c + hashtab.c + hierarchy.c + kernel_to_common.c + mls.c + optimize.c + policydb.c + policydb_convert.c + policydb_public.c + services.c + sidtab.c + symtab.c + util.c + write.c +) +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_ldflags + " -lz -lpcre2-8 -lpthread") + +# mke2fs.android - a ustom version of mke2fs that supports --android_sparse (FS#56955) +libext2fsfiles = %w( + lib/blkid/cache.c + lib/blkid/dev.c + lib/blkid/devname.c + lib/blkid/devno.c + lib/blkid/getsize.c + lib/blkid/llseek.c + lib/blkid/probe.c + lib/blkid/read.c + lib/blkid/resolve.c + lib/blkid/save.c + lib/blkid/tag.c + lib/e2p/encoding.c + lib/e2p/feature.c + lib/e2p/hashstr.c + lib/e2p/mntopts.c + lib/e2p/ostype.c + lib/e2p/parse_num.c + lib/e2p/uuid.c + lib/et/com_err.c + lib/et/error_message.c + lib/et/et_name.c + lib/ext2fs/alloc.c + lib/ext2fs/alloc_sb.c + lib/ext2fs/alloc_stats.c + lib/ext2fs/alloc_tables.c + lib/ext2fs/atexit.c + lib/ext2fs/badblocks.c + lib/ext2fs/bb_inode.c + lib/ext2fs/bitmaps.c + lib/ext2fs/bitops.c + lib/ext2fs/blkmap64_ba.c + lib/ext2fs/blkmap64_rb.c + lib/ext2fs/blknum.c + lib/ext2fs/block.c + lib/ext2fs/bmap.c + lib/ext2fs/closefs.c + lib/ext2fs/crc16.c + lib/ext2fs/crc32c.c + lib/ext2fs/csum.c + lib/ext2fs/dirblock.c + lib/ext2fs/dir_iterate.c + lib/ext2fs/expanddir.c + lib/ext2fs/ext2_err.c + lib/ext2fs/ext_attr.c + lib/ext2fs/extent.c + lib/ext2fs/fallocate.c + lib/ext2fs/fileio.c + lib/ext2fs/freefs.c + lib/ext2fs/gen_bitmap64.c + lib/ext2fs/gen_bitmap.c + lib/ext2fs/get_num_dirs.c + lib/ext2fs/getsectsize.c + lib/ext2fs/getsize.c + lib/ext2fs/hashmap.c + lib/ext2fs/i_block.c + lib/ext2fs/ind_block.c + lib/ext2fs/initialize.c + lib/ext2fs/inline.c + lib/ext2fs/inline_data.c + lib/ext2fs/inode.c + lib/ext2fs/io_manager.c + lib/ext2fs/ismounted.c + lib/ext2fs/link.c + lib/ext2fs/llseek.c + lib/ext2fs/lookup.c + lib/ext2fs/mkdir.c + lib/ext2fs/mkjournal.c + lib/ext2fs/mmp.c + lib/ext2fs/namei.c + lib/ext2fs/newdir.c + lib/ext2fs/nls_utf8.c + lib/ext2fs/openfs.c + lib/ext2fs/progress.c + lib/ext2fs/punch.c + lib/ext2fs/rbtree.c + lib/ext2fs/read_bb.c + lib/ext2fs/read_bb_file.c + lib/ext2fs/res_gdt.c + lib/ext2fs/rw_bitmaps.c + lib/ext2fs/sha512.c + lib/ext2fs/sparse_io.c + lib/ext2fs/symlink.c + lib/ext2fs/undo_io.c + lib/ext2fs/unix_io.c + lib/ext2fs/valid_blk.c + lib/support/dict.c + lib/support/mkquota.c + lib/support/parse_qtype.c + lib/support/plausible.c + lib/support/prof_err.c + lib/support/profile.c + lib/support/quotaio.c + lib/support/quotaio_tree.c + lib/support/quotaio_v2.c + lib/uuid/clear.c + lib/uuid/gen_uuid.c + lib/uuid/isnull.c + lib/uuid/pack.c + lib/uuid/parse.c + lib/uuid/unpack.c + lib/uuid/unparse.c + misc/create_inode.c +) +libext2fs = compile(expand("e2fsprogs", libext2fsfiles), "-Ie2fsprogs/lib -Ie2fsprogs/lib/ext2fs -Icore/libsparse/include") + +mke2fsfiles = %w( + misc/default_profile.c + misc/mke2fs.c + misc/mk_hugefiles.c + misc/util.c +) +mke2fs = compile(expand("e2fsprogs", mke2fsfiles), "-Ie2fsprogs/lib") + +link("mke2fs.android", mke2fs + libext2fs + libsparse + libbase + libzip + liblog + libutil, "-lpthread -lz") + +e2fsdroidfiles = %w( + contrib/android/basefs_allocator.c + contrib/android/base_fs.c + contrib/android/block_list.c + contrib/android/block_range.c + contrib/android/e2fsdroid.c + contrib/android/fsmap.c + contrib/android/perms.c +) +e2fsdroid = compile(expand("e2fsprogs", e2fsdroidfiles), "-Ie2fsprogs/lib -Ie2fsprogs/lib/ext2fs -Iselinux/libselinux/include -Icore/libcutils/include -Ie2fsprogs/misc") + +link("e2fsdroid", e2fsdroid + libext2fs + libsparse + libbase + libzip + liblog + libutil + libselinux + libsepol + libcutils, "-lz -lpthread -lpcre2-8") + +ext2simgfiles = %w( + contrib/android/ext2simg.c +) +ext2simg = compile(expand("e2fsprogs", ext2simgfiles), "-Ie2fsprogs/lib -Icore/libsparse/include") + +link("ext2simg", ext2simg + libext2fs + libsparse + libbase + libzip + liblog + libutil, "-lz -lpthread") + +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")