diff options
author | Matteo Bernardini <ponce@slackbuilds.org> | 2019-12-16 21:55:14 +0100 |
---|---|---|
committer | Robby Workman <rworkman@slackbuilds.org> | 2021-04-17 23:08:05 -0500 |
commit | 7d3366c7e83c3a15f9406c3b692ac38379bfcb32 (patch) | |
tree | dca0c5ef7764473fd859d1888935bb9f3cfdafb9 | |
parent | 157359879952edbfb9dd46a6b2a0fc6f3c0b9da8 (diff) |
development/android-studio: Updated for version 29.0.5.
Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
-rw-r--r-- | development/android-tools/README | 4 | ||||
-rw-r--r-- | development/android-tools/android-tools.SlackBuild | 70 | ||||
-rw-r--r-- | development/android-tools/android-tools.info | 36 | ||||
-rw-r--r-- | development/android-tools/bash_completion.fastboot | 90 | ||||
-rw-r--r-- | development/android-tools/fix_build_core.patch | 155 | ||||
-rw-r--r-- | development/android-tools/fix_build_selinux.patch | 26 | ||||
-rw-r--r-- | development/android-tools/generate_build.rb | 461 |
7 files changed, 568 insertions, 274 deletions
diff --git a/development/android-tools/README b/development/android-tools/README index e7d793fe8426..fa0406782b92 100644 --- a/development/android-tools/README +++ b/development/android-tools/README @@ -1,2 +1,2 @@ -These are the adb, fastboot, mkbootimg and make_ext4fs tools from the -android sdk. +These are the adb, fastboot, mkbootimg, unpack_bootimg, mke2fs.android, +e2fsdroid, avbtool and ext2simg tools from the android sdk. diff --git a/development/android-tools/android-tools.SlackBuild b/development/android-tools/android-tools.SlackBuild index 8e141f5fbdfd..8fde5c30a4e2 100644 --- a/development/android-tools/android-tools.SlackBuild +++ b/development/android-tools/android-tools.SlackBuild @@ -25,13 +25,17 @@ PRGNAM=android-tools -VERSION=${VERSION:-8.0.0_r24} -SRC1=core-6cd85e2a89347e0a107f59e38ece61fa19e6da78.tar.gz -SRC2=extras-af2dce5151ad478673401211dd71ae1579d2b5be.tar.gz -SRC3=selinux-be29c2550c3ff6551a56048c075a88da01b46cab.tar.gz -SRC4=f2fs-tools-b8baf1712d991541141bb0bdddd625f527e6d41f.tar.gz -SRC5=boringssl-58e449904e248f34bdfc2be7a609c58bcb0257b7.tar.gz - +VERSION=${VERSION:-29.0.5} +SRC1=avb-355c69ae673220da533696c44acbfa489702d1ff.tar.gz +SRC2=base-d634d2306033599c00b83e68c9ecb60e3206d40c.tar.gz +SRC3=boringssl-a7a75f208caea8a303615724d4cc5f4e8dfb9695.tar.gz +SRC4=core-fa4254a53a368a8f9b6604442eace6a7b6b63b6d.tar.gz +SRC5=e2fsprogs-5fab03bbdc3789515748af8181b9e82dd99beb3b.tar.gz +SRC6=extras-6748c3dd53494096ffeebfeeb12e3b3efad90a83.tar.gz +SRC7=f2fs-tools-39ec3b4c2edc136d32392ddc7a7f222b4c68e88c.tar.gz +SRC8=mkbootimg-e29814dcf6434e8d14379062e4ea1c1b58ff11d0.tar.gz +SRC9=native-b9005758dcf78f89c6640ffb119b5b527a417928.tar.gz +SRC10=selinux-9e188fde016babc76150098e0ab288e053cf92e2.tar.gz BUILD=${BUILD:-1} TAG=${TAG:-_SBo} @@ -71,34 +75,36 @@ rm -rf $TMP/android-tools mkdir $TMP/android-tools cd $TMP/android-tools +mkdir avb +tar -xvf $CWD/$SRC1 -C avb +mkdir base +tar -xvf $CWD/$SRC2 -C base +mkdir boringssl +tar -xvf $CWD/$SRC3 -C boringssl mkdir core -tar -xvf $CWD/$SRC1 -C core +tar -xvf $CWD/$SRC4 -C core +mkdir e2fsprogs +tar -xvf $CWD/$SRC5 -C e2fsprogs mkdir extras -tar -xvf $CWD/$SRC2 -C extras -mkdir selinux -tar -xvf $CWD/$SRC3 -C selinux +tar -xvf $CWD/$SRC6 -C extras mkdir f2fs-tools -tar -xvf $CWD/$SRC4 -C f2fs-tools -mkdir boringssl -tar -xvf $CWD/$SRC5 -C boringssl - -#git clone --branch android-$VERSION --depth 1 https://android.googlesource.com/platform/system/core -#git clone --branch android-$VERSION --depth 1 https://android.googlesource.com/platform/system/extras -#git clone --branch android-$VERSION --depth 1 https://android.googlesource.com/platform/external/libselinux -#git clone --branch android-$VERSION --depth 1 https://android.googlesource.com/platform/external/f2fs-tools +tar -xvf $CWD/$SRC7 -C f2fs-tools +mkdir mkbootimg +tar -xvf $CWD/$SRC8 -C mkbootimg +mkdir native +tar -xvf $CWD/$SRC9 -C native +mkdir selinux +tar -xvf $CWD/$SRC10 -C selinux +cp -a $CWD/deployagent.jar . # generate_build.rb borrowed from Arch Linux # And thanks to Alan Alberghini for the make_ext4fs patch. -PKGVER=$VERSION ruby $CWD/generate_build.rb > build.ninja +PKGVER=$VERSION LDFLAGS='-Wl,-z,relro,-z,now' ruby $CWD/generate_build.rb > build.ninja cd core patch -p1 < $CWD/fix_build_core.patch cd .. -cd selinux -patch -p1 < $CWD/fix_build_selinux.patch -cd .. - chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ @@ -110,16 +116,22 @@ find . \ mkdir -p boringssl/build cd boringssl/build cmake -GNinja .. -ninja +ninja crypto/libcrypto.a cd ../.. ninja mkdir -p $PKG/usr/bin -install -Dm 755 adb $PKG/usr/bin/adb -install -Dm 755 fastboot $PKG/usr/bin/fastboot -install -Dm 755 core/mkbootimg/mkbootimg $PKG/usr/bin/mkbootimg -install -Dm 755 make_ext4fs $PKG/usr/bin/make_ext4fs +install -D -m 0755 adb $PKG/usr/bin/adb +install -D -m 0755 fastboot $PKG/usr/bin/fastboot +install -D -m 0755 mke2fs.android $PKG/usr/bin/mke2fs.android +install -D -m 0755 e2fsdroid $PKG/usr/bin/e2fsdroid +install -D -m 0755 ext2simg $PKG/usr/bin/ext2simg +install -D -m 0755 avb/avbtool $PKG/usr/bin/avbtool +install -D -m 0755 mkbootimg/mkbootimg.py $PKG/usr/bin/mkbootimg +install -D -m 0755 mkbootimg/unpack_bootimg.py $PKG/usr/bin/unpack_bootimg + +install -D -m 0644 $CWD/bash_completion.fastboot $PKG/usr/share/bash-completion/completions/fastboot find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true diff --git a/development/android-tools/android-tools.info b/development/android-tools/android-tools.info index ba44d787e200..7d268581cdeb 100644 --- a/development/android-tools/android-tools.info +++ b/development/android-tools/android-tools.info @@ -1,18 +1,30 @@ PRGNAM="android-tools" -VERSION="8.0.0_r24" +VERSION="29.0.5" HOMEPAGE="http://developer.android.com/sdk/" -DOWNLOAD="https://sourceforge.net/projects/slackbuildsdirectlinks/files/android-tools/8.0.0_r24/core-6cd85e2a89347e0a107f59e38ece61fa19e6da78.tar.gz \ - https://sourceforge.net/projects/slackbuildsdirectlinks/files/android-tools/8.0.0_r24/extras-af2dce5151ad478673401211dd71ae1579d2b5be.tar.gz \ - https://sourceforge.net/projects/slackbuildsdirectlinks/files/android-tools/8.0.0_r24/f2fs-tools-b8baf1712d991541141bb0bdddd625f527e6d41f.tar.gz \ - https://sourceforge.net/projects/slackbuildsdirectlinks/files/android-tools/8.0.0_r24/selinux-be29c2550c3ff6551a56048c075a88da01b46cab.tar.gz \ - https://sourceforge.net/projects/slackbuildsdirectlinks/files/android-tools/8.0.0_r24/boringssl-58e449904e248f34bdfc2be7a609c58bcb0257b7.tar.gz" -MD5SUM="b5b3857b5edae7305f5348e1db148b61 \ - 19bdc27835ed340fdbb4205d6af8e721 \ - 2ebe16bb82a5b24706d78d9e16d66f6e \ - 0599c72a1ff3142ad6baed8886d074a3 \ - 83ed1371eee7769f29b767c217e865e7" +DOWNLOAD="http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/avb-355c69ae673220da533696c44acbfa489702d1ff.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/base-d634d2306033599c00b83e68c9ecb60e3206d40c.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/boringssl-a7a75f208caea8a303615724d4cc5f4e8dfb9695.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/core-fa4254a53a368a8f9b6604442eace6a7b6b63b6d.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/e2fsprogs-5fab03bbdc3789515748af8181b9e82dd99beb3b.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/extras-6748c3dd53494096ffeebfeeb12e3b3efad90a83.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/f2fs-tools-39ec3b4c2edc136d32392ddc7a7f222b4c68e88c.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/mkbootimg-e29814dcf6434e8d14379062e4ea1c1b58ff11d0.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/native-b9005758dcf78f89c6640ffb119b5b527a417928.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/selinux-9e188fde016babc76150098e0ab288e053cf92e2.tar.gz \ + http://ponce.cc/slackware/sources/repo/android-tools/29.0.5/deployagent.jar" +MD5SUM="6800e83627f1046be645fc8c7ba027d5 \ + e816083df667905b865c248a8a20c2e7 \ + a20c134ee4310e600384b7d0a60c2db6 \ + 34fb01c210c7371833da14f1d7a970e6 \ + 3b559a1c803c94079b177065b7424457 \ + cdd9d7b4956e5da607bb1e94cb929065 \ + 880a1708785515fe1447b1bf6b020093 \ + f912725e4d01596c2a2d0fa3fe772d8e \ + 3daf9cf55dceb85ca06ae116e61800b4 \ + 28a8438bc0856def465f6456781a5275 \ + bb500620af2f3716a61100f7b5c445fa" DOWNLOAD_x86_64="" MD5SUM_x86_64="" -REQUIRES="gtest ninja pcre2" +REQUIRES="gtest ninja pcre2 protobuf3" MAINTAINER="Philip van der Hoeven" EMAIL="philip@vd-hoeven.nl" diff --git a/development/android-tools/bash_completion.fastboot b/development/android-tools/bash_completion.fastboot new file mode 100644 index 000000000000..bc59ee863671 --- /dev/null +++ b/development/android-tools/bash_completion.fastboot @@ -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 diff --git a/development/android-tools/fix_build_core.patch b/development/android-tools/fix_build_core.patch index b67a54019918..fede1c09cc11 100644 --- a/development/android-tools/fix_build_core.patch +++ b/development/android-tools/fix_build_core.patch @@ -1,16 +1,49 @@ +diff --git a/adb/adb.cpp b/adb/adb.cpp +index 1ec145b25c..b6e943f6ee 100644 +--- a/adb/adb.cpp ++++ b/adb/adb.cpp +@@ -44,8 +44,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" +@@ -66,10 +64,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/main.cpp b/adb/client/main.cpp +index 0c5c28f1b3..b6a1281521 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(); + init_reconnect_handler(); + +- 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 7025f283c..66fad6564 100644 +index 53f01a0ce5..b4c3aadc28 100644 --- a/adb/client/usb_libusb.cpp +++ b/adb/client/usb_libusb.cpp -@@ -21,6 +21,7 @@ - #include <stdint.h> - - #include <atomic> -+#include <condition_variable> - #include <chrono> - #include <memory> - #include <mutex> -@@ -28,7 +29,7 @@ +@@ -30,7 +30,7 @@ #include <thread> #include <unordered_map> @@ -19,63 +52,53 @@ index 7025f283c..66fad6564 100644 #include <android-base/file.h> #include <android-base/logging.h> -diff --git a/adb/sysdeps/posix/network.cpp b/adb/sysdeps/posix/network.cpp -index 45da5af4a..516c716d9 100644 ---- a/adb/sysdeps/posix/network.cpp -+++ b/adb/sysdeps/posix/network.cpp -@@ -16,6 +16,7 @@ - - #include "sysdeps/network.h" - -+#include <cstring> - #include <errno.h> - #include <netinet/in.h> - #include <sys/socket.h> -diff --git a/base/errors_unix.cpp b/base/errors_unix.cpp -index 296995efe..48269b675 100644 ---- a/base/errors_unix.cpp -+++ b/base/errors_unix.cpp -@@ -17,6 +17,7 @@ - #include "android-base/errors.h" - - #include <errno.h> -+#include <string.h> +diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp +index 2fe3b1a9e0..a61b221ce3 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> - namespace android { - namespace base { -diff --git a/base/file.cpp b/base/file.cpp -index 2f697a1cc..81aef5758 100644 ---- a/base/file.cpp -+++ b/base/file.cpp -@@ -22,6 +22,7 @@ - #include <sys/stat.h> - #include <sys/types.h> - #include <unistd.h> -+#include <string.h> +@@ -1783,7 +1781,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(); - #include <memory> - #include <mutex> -diff --git a/base/logging.cpp b/base/logging.cpp -index 6357b4ba7..3c7dbce13 100644 ---- a/base/logging.cpp -+++ b/base/logging.cpp -@@ -23,6 +23,7 @@ - #include <fcntl.h> - #include <libgen.h> - #include <time.h> -+#include <string.h> +- 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"}; - // For getprogname(3) or program_invocation_short_name. - #if defined(__ANDROID__) || defined(__APPLE__) -diff --git a/libsparse/sparse_read.cpp b/libsparse/sparse_read.cpp -index bd668735a..76cf43299 100644 ---- a/libsparse/sparse_read.cpp -+++ b/libsparse/sparse_read.cpp -@@ -18,6 +18,7 @@ - #define _LARGEFILE64_SOURCE 1 + 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. + // - #include <algorithm> -+#include <cstring> - #include <inttypes.h> - #include <fcntl.h> - #include <stdarg.h> +-extern pid_t gettid(); +- + // + // Deprecated: use `_Thread_local` in C or `thread_local` in C++. + // diff --git a/development/android-tools/fix_build_selinux.patch b/development/android-tools/fix_build_selinux.patch deleted file mode 100644 index 429f87ce57ee..000000000000 --- a/development/android-tools/fix_build_selinux.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/libsepol/src/private.h b/libsepol/src/private.h -index b884c23b..447fa64b 100644 ---- a/libsepol/src/private.h -+++ b/libsepol/src/private.h -@@ -14,7 +14,7 @@ - #endif - - #include <errno.h> --#include <dso.h> -+#include "dso.h" - - #ifdef __APPLE__ - #define __BYTE_ORDER BYTE_ORDER -diff --git a/libsepol/src/util.c b/libsepol/src/util.c -index b00251c6..68e7c6a0 100644 ---- a/libsepol/src/util.c -+++ b/libsepol/src/util.c -@@ -27,7 +27,7 @@ - #include <sepol/policydb/flask_types.h> - #include <sepol/policydb/policydb.h> - #include <sepol/policydb/util.h> --#include <dso.h> -+#include "dso.h" - - struct val_to_name { - unsigned int val; diff --git a/development/android-tools/generate_build.rb b/development/android-tools/generate_build.rb index cb3e1e685c58..2c74ee00cc87 100644 --- a/development/android-tools/generate_build.rb +++ b/development/android-tools/generate_build.rb @@ -5,57 +5,78 @@ # This script tries to mimic Android build rules. def expand(dir, files) - files.map{|f| File.join(dir,f)} + files.map { |f| File.join(dir, f) } end # Compiles sources to *.o files. # Returns array of output *.o filenames -def compile(sources, cflags) +def compile(sources, cflags, params = {}) outputs = [] for s in sources ext = File.extname(s) case ext - when '.c' - cc = 'cc' - lang_flags = '-std=gnu11 $CFLAGS $CPPFLAGS' - when '.cpp', '.cc' - cc = 'cxx' - lang_flags = '-std=gnu++14 $CXXFLAGS $CPPFLAGS' + 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}" + raise "Unknown extension #{ext}" end - output = s + '.o' + output = s + ".o" outputs << output - puts "build #{output}: #{cc} #{s}\n cflags = #{lang_flags} #{cflags}" + order_deps = if params[:order_deps] + " || " + params[:order_deps].join(" ") + else + "" + end + + puts "build #{output}: #{cc} #{s}#{order_deps}\n cflags = #{lang_flags} #{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}: cc #{cfile}\n cflags = -std=gnu++2a $CXXFLAGS $CPPFLAGS -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} + return lib.each { |l| dir + l } end # Links object files def link(output, objects, ldflags) - puts "build #{output}: link #{objects.join(' ')}\n ldflags = #{ldflags} $LDFLAGS" + puts "build #{output}: link #{objects.join(" ")}\n ldflags = #{ldflags} $LDFLAGS" 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 "CXXFLAGS = #{ENV['CXXFLAGS']}" -puts "LDFLAGS = #{ENV['LDFLAGS']}" -puts "PKGVER = #{ENV['PKGVER']}\n\n" - +def genheader(input, variable, output) + puts "build #{output}: genheader #{input}\n var = #{variable}" +end -puts """ +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 "CXXFLAGS = #{ENV["CXXFLAGS"]}" +puts "LDFLAGS = #{ENV["LDFLAGS"]}" +puts "PLATFORM_TOOLS_VERSION = #{ENV["PLATFORM_TOOLS_VERSION"]}\n\n" + +puts "" " rule cc command = $CC $cflags -c $in -o $out @@ -65,8 +86,14 @@ rule cxx 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 -""" + +" "" adbdfiles = %w( adb.cpp @@ -74,210 +101,366 @@ adbdfiles = %w( adb_listeners.cpp adb_trace.cpp adb_utils.cpp - bugreport.cpp - line_printer.cpp + fdevent/fdevent.cpp + fdevent/fdevent_poll.cpp + fdevent/fdevent_epoll.cpp + shell_service_protocol.cpp sockets.cpp transport.cpp transport_local.cpp transport_usb.cpp - transport_mdns_unsupported.cpp - fdevent.cpp - adb_auth_host.cpp - shell_service_protocol.cpp ) -libadbd = compile(expand('core/adb', adbdfiles), '-DADB_VERSION="\"$PKGVER\"" -DADB_HOST=1 -Icore/include -Icore/base/include -Icore/adb -Icore/libcrypto_utils/include -Iboringssl/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') + +apkent_h, apkent_c, apkent_o = protoc("core/adb/fastdeploy/proto/ApkEntry.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( - console.cpp - socket_spec.cpp - commandline.cpp - adb_client.cpp - services.cpp - file_sync_client.cpp - sysdeps_unix.cpp - sysdeps/errno.cpp - sysdeps/posix/network.cpp + client/adb_client.cpp + client/adb_install.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/line_printer.cpp client/main.cpp client/usb_dispatch.cpp - client/usb_linux.cpp client/usb_libusb.cpp + client/usb_linux.cpp + fastdeploy/deploypatchgenerator/apk_archive.cpp + fastdeploy/deploypatchgenerator/deploy_patch_generator.cpp + fastdeploy/deploypatchgenerator/patch_utils.cpp + services.cpp + socket_spec.cpp + sysdeps/errno.cpp + sysdeps/posix/network.cpp + sysdeps_unix.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]) + +androidfwfiles = %w( + LocaleData.cpp + ResourceTypes.cpp + TypeWrappers.cpp + ZipFileRO.cpp ) -libadb = compile(expand('core/adb', adbfiles), '-D_GNU_SOURCE -DADB_HOST=1 -Icore/include -Icore/base/include -Icore/adb') +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 logging.cpp + mapped_file.cpp parsenetaddress.cpp stringprintf.cpp strings.cpp - errors_unix.cpp test_utils.cpp + threads.cpp ) -libbase = compile(expand('core/base', basefiles), '-DADB_HOST=1 -Icore/base/include -Icore/include') +libbase = compile(expand("core/base", basefiles), "-DADB_HOST=1 -Icore/base/include -Icore/include") logfiles = %w( - log_event_write.c - fake_log_device.c - log_event_list.c - logger_write.c - config_write.c - config_read.c - logger_lock.c - local_logger.c - fake_writer.c - logger_name.c - stderr_write.c - logprint.c + fake_log_device.cpp + fake_writer.cpp + log_event_list.cpp + log_event_write.cpp + logger_lock.cpp + logger_name.cpp + logger_write.cpp + logprint.cpp ) -liblog = compile(expand('core/liblog', logfiles), '-DLIBLOG_LOG_TAG=1006 -D_XOPEN_SOURCE=700 -DFAKE_LOG_DEVICE=1 -Icore/log/include -Icore/include') +liblog = compile(expand("core/liblog", logfiles), "-DLIBLOG_LOG_TAG=1006 -D_XOPEN_SOURCE=700 -DFAKE_LOG_DEVICE=1 -Icore/log/include -Icore/include") cutilsfiles = %w( - load_file.c - canned_fs_config.c + android_get_control_file.cpp + canned_fs_config.cpp fs_config.cpp - socket_local_client_unix.c - socket_network_client_unix.c - socket_local_server_unix.c - sockets_unix.cpp - socket_inaddr_any_server_unix.c + 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 - android_get_control_file.cpp - threads.c + sockets_unix.cpp + threads.cpp ) -libcutils = compile(expand('core/libcutils', cutilsfiles), '-D_GNU_SOURCE -Icore/include -Icore/libcutils/include') +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/adb', diagnoseusbfiles), '-Icore/include -Icore/base/include') +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/include') +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'] - -link('adb', libbase + liblog + libcutils + libadbd + libadb + libdiagnoseusb + libcrypto + boringssl, '-lpthread -lusb-1.0') - +boringssl = ["boringssl/build/crypto/libcrypto.a"] fastbootfiles = %w( - protocol.cpp - engine.cpp bootimg_utils.cpp fastboot.cpp - util.cpp + fastboot_driver.cpp fs.cpp - usb_linux.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 ) -libfastboot = compile(expand('core/fastboot', fastbootfiles), '-DFASTBOOT_VERSION="\"$PKGVER\"" -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -DUSE_F2FS -Icore/base/include -Icore/include -Icore/adb -Icore/libsparse/include -Icore/mkbootimg -Iextras/ext4_utils/include -Iextras/f2fs_utils') +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.c - output_file.c - sparse.c - sparse_crc32.c - sparse_err.c + 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') +libsparse = compile(expand("core/libsparse", sparsefiles), "-Icore/libsparse/include -Icore/base/include") f2fsfiles = %w( - f2fs_utils.c - f2fs_ioutils.c - f2fs_dlutils.c ) -f2fs = compile(expand('extras/f2fs_utils', f2fsfiles), '-Iextras/f2fs_utils -If2fs-tools/include -If2fs-tools/mkfs -Icore/libsparse/include -Iselinux/libselinux/include') +f2fs = compile(expand("extras/f2fs_utils", f2fsfiles), "-DHAVE_LINUX_TYPES_H -If2fs-tools/include -Icore/liblog/include") zipfiles = %w( zip_archive.cc ) -libzip = compile(expand('core/libziparchive', zipfiles), '-Icore/base/include -Icore/include') +libzip = compile(expand("core/libziparchive", zipfiles), "-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') +libutil = compile(expand("core/libutils", utilfiles), "-Icore/include -Icore/base/include") ext4files = %w( - make_ext4fs.c - ext4fixup.c - ext4_utils.c - allocate.c - contents.c - extent.c - indirect.c - sha1.c - wipe.c - crc16.c - ext4_sb.c -) -libext4 = compile(expand('extras/ext4_utils', ext4files), '-D_GNU_SOURCE -Icore/libsparse/include -Icore/include -Iselinux/libselinux/include -Iextras/ext4_utils/include -DANDROID -DHOST=1') - -make_ext4files = %w( - make_ext4fs_main.c + ext4_utils.cpp + wipe.cpp + ext4_sb.cpp ) -libmake_ext4 = compile(expand('extras/ext4_utils', make_ext4files), '-DANDROID -Icore/libsparse/include -Icore/include -Iselinux/libselinux/include -Iextras/ext4_utils/include -DHOST=1') +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 - setrans_client.c - regex.c - matchpathcon.c - selinux_config.c - label_backends_android.c - canonicalize_context.c - lsetfilecon.c - policyvers.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 - booleans.c - disable.c - enabled.c - getenforce.c - setenforce.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') +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( - policydb_public.c - genbools.c - debug.c - policydb.c - conditional.c - services.c - ebitmap.c - util.c assertion.c + avrule_block.c avtab.c - hashtab.c - sidtab.c + conditional.c + constraint.c context.c - genusers.c context_record.c + debug.c + ebitmap.c + expand.c + genbools.c + genusers.c + hashtab.c + hierarchy.c + kernel_to_common.c mls.c - avrule_block.c - symtab.c + policydb.c policydb_convert.c + policydb_public.c + services.c + sidtab.c + symtab.c + util.c write.c - constraint.c - expand.c - hierarchy.c ) -libsepol = compile(expand('selinux/libsepol/src', libsepolfiles), '-Iselinux/libsepol/include') +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") + +# 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('fastboot', libsparse + libzip + libcutils + liblog + libutil + libbase + libext4 + f2fs + libselinux + libsepol + libfastboot + libdiagnoseusb, '-lz -lpcre2-8 -lpthread -ldl') -link('make_ext4fs', libmake_ext4 + libzip + libcutils + liblog + libutil + libbase + libext4 + libselinux + libsepol + libsparse, '-lz -lpcre2-8 -lpthread') +link("adb", libbase + liblog + libcutils + libutil + libadbd + libadb + libdiagnoseusb + libcrypto + boringssl + libandroidfw + libzip + [apkent_o], "-lpthread -lusb-1.0 -lprotobuf-lite -lz") |