├── .github └── workflows │ └── build.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── README.md ├── completions ├── CMakeLists.txt ├── README.md └── bash │ ├── CMakeLists.txt │ ├── adb.in │ └── fastboot.in ├── patches ├── adb │ ├── 0001-Don-t-use-the-internal-glibc-header-sys-cdefs.h.patch │ ├── 0002-adb-disable-mdns-transport-support.patch │ ├── 0003-adb-include-missing-headers.patch │ ├── 0004-Define-clang-only-nullability-specifiers-when-__clan.patch │ ├── 0005-Include-libusb-1.0-libusb.h-instead-of-libusb-libusb.patch │ ├── 0006-Include-string.h-in-various-file-missing-it.patch │ ├── 0007-adb-Fix-unknown-__xx_write-member-in-std-ostream.patch │ ├── 0008-adb-Disable-bonjour-check.patch │ ├── 0009-adb-Reduce-fallback-size-for-_SC_GETPW_R_SIZE_MAX.patch │ ├── 0010-sysdeps-don-t-over-eager-constexpr.patch │ ├── 0013-adb-disable-fastdeploy-support.patch │ ├── 0015-types.h-Fix-ambiguous-reference-to-weak_ptr.patch │ ├── 0016-adb-disable-mDNS.patch │ ├── 0017-adb_wifi-remove-mDNS.patch │ ├── 0020-Fix-compilation-with-libusb-1.0.24.patch │ ├── 0023-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch │ └── 0026-Drop-compile-static-check.patch ├── boringssl │ ├── 0001-boringssl-Add support for loongarch.patch │ ├── 0001-boringssl-Workaround-compiler-error-with-gcc-14-and-.patch │ └── 0012-CMakeLists.txt-Disable-Werror-by-default.patch ├── core │ ├── 0001-Fix-inclusion-of-stdatomic.h-with-g.patch │ ├── 0004-fastboot-make-mke2fs_path-configurable.patch │ ├── 0009-Don-t-use-the-internal-glibc-header-sys-cdefs.h.patch │ ├── 0011-core-include-missing-headers.patch │ └── 0012-Add-explicit-import-for-algorithm.patch ├── extras │ ├── 0001-Don-t-use-the-internal-glibc-header-sys-cdefs.h.patch │ ├── 0002-libjsonpbparse-Fix-build-after-protobuf-util-Status-.patch │ └── 0003-extras-libjsonpb-Fix-incompatibility-with-protobuf-v.patch ├── libbase │ ├── 0001-android-base-endian.h-fix-build-on-musl.patch │ ├── 0002-remove-glibc-internal-headers-cdefs.h.patch │ ├── 0003-logging.h-only-activate-ostream-warnings-when-clang-.patch │ ├── 0004-Don-t-use-thread-safety-annotations-with-gcc.patch │ └── 0006-remove-usage-of-__builtin_available.patch ├── libziparchive │ └── 0001-remove-glibc-internal-header-cdefs.h.patch └── logging │ ├── 0001-Don-t-use-the-internal-glibc-header-sys-cdefs.h.patch │ ├── 0002-Fix-inclusion-of-stdatomic.h-with-g.patch │ └── 0004-fix-initializer-element-is-not-constant-error-when-b.patch ├── platform_tools_version.h.in ├── vendor ├── CMakeLists.adb.txt ├── CMakeLists.avb.txt ├── CMakeLists.f2fstools.txt ├── CMakeLists.fastboot.txt ├── CMakeLists.libbase.txt ├── CMakeLists.libufdt.txt ├── CMakeLists.libusb.txt ├── CMakeLists.mkbootimg.txt ├── CMakeLists.mke2fs.txt ├── CMakeLists.partition.txt ├── CMakeLists.sparse.txt └── CMakeLists.txt └── version.h.in /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | upload-src: 7 | name: Upload the source 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: prep ubuntu 11 | run: | 12 | sudo apt-get update 13 | DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq \ 14 | ${{ matrix.pkgs }} cmake git golang libbrotli-dev \ 15 | libgtest-dev liblz4-dev libpcre2-dev libprotobuf-dev libunwind-dev \ 16 | libzstd-dev make pandoc pkg-config protobuf-compiler xz-utils 17 | - name: checkout 18 | uses: actions/checkout@v4 19 | with: 20 | submodules: true 21 | - name: git config 22 | run: | 23 | git config --global user.email "you@example.com" 24 | git config --global user.name "Your Name" 25 | - name: get vendor modules 26 | run: | 27 | cd vendor/boringssl 28 | go mod vendor 29 | - name: generate man page 30 | run: | 31 | cd vendor/adb/docs/user 32 | pandoc -s -t man adb.1.md -o adb.1 33 | - name: build & install 34 | run: | 35 | export SOURCE_DATE_EPOCH=$(date +%s) 36 | echo "SOURCE_DATE_EPOCH: ${SOURCE_DATE_EPOCH}" 37 | cmake \ 38 | -DANDROID_TOOLS_USE_BUNDLED_FMT=ON \ 39 | -DANDROID_TOOLS_USE_BUNDLED_LIBUSB=ON \ 40 | -B build 41 | cmake --build build --target package_source 42 | for x in sha1sum sha256sum sha512sum b2sum; do 43 | printf "$x " && $x ${{ github.workspace }}/build/android-tools-*.tar.xz | cut -d " " -f 1 44 | done 45 | - name: upload package_source 46 | uses: actions/upload-artifact@v4 47 | with: 48 | name: package_source 49 | path: ${{ github.workspace }}/build/android-tools-*.tar.xz 50 | 51 | linux: 52 | runs-on: ubuntu-latest 53 | needs: [upload-src] 54 | strategy: 55 | fail-fast: false 56 | matrix: 57 | include: 58 | - os: "opensuse/leap:latest" 59 | pkgs: "clang gcc11-c++" 60 | env1: "CC=clang CXX=clang++" 61 | - os: "opensuse/tumbleweed" 62 | pkgs: "gcc gcc-c++" 63 | - os: "opensuse/tumbleweed" 64 | pkgs: clang 65 | env1: "CC=clang CXX=clang++" 66 | - os: "archlinux:base" 67 | pkgs: gcc 68 | - os: "archlinux:base" 69 | pkgs: clang 70 | env1: "CC=clang CXX=clang++" 71 | - os: "ubuntu:24.04" 72 | pkgs: "gcc-10 g++-10" 73 | env1: "CC=gcc-10 CXX=g++-10" 74 | - os: "ubuntu:24.04" 75 | pkgs: "clang-15 libstdc++-10-dev" 76 | env1: "CC=clang-15 CXX=clang++-15" 77 | - os: "alpine" 78 | pkgs: "gcc" 79 | env1: "CC=gcc CXX=g++" 80 | - os: "fedora:latest" 81 | pkgs: "gcc gcc-g++" 82 | - os: "fedora:rawhide" 83 | pkgs: "gcc gcc-g++" 84 | 85 | container: 86 | image: ${{ matrix.os }} 87 | # New versions of glibc use the new clone3() syscall which has not 88 | # yet been whitelisted in GitHub's secomp profile. To prevent jobs 89 | # using these distros from failing (e.g. openSUSE) change the 90 | # secomp policy. 91 | # 92 | # See https://github.com/nmeum/android-tools/pull/48#issuecomment-944893176 93 | options: --security-opt seccomp=unconfined 94 | 95 | steps: 96 | - name: prep opensuse 97 | if: startsWith(matrix.os, 'opensuse') 98 | run: | 99 | zypper -n ref 100 | zypper -n in ${{ matrix.pkgs }} cmake git go gtest pcre2-devel pkgconfig \ 101 | 'pkgconfig(libbrotlicommon)' 'pkgconfig(liblz4)' \ 102 | 'pkgconfig(libunwind-generic)' \ 103 | 'pkgconfig(libzstd)' 'pkgconfig(protobuf)' ninja tar xz zlib-devel 104 | 105 | - name: prep archlinux 106 | if: startsWith(matrix.os, 'archlinux') 107 | run: | 108 | pacman -Syu --needed --noconfirm \ 109 | ${{ matrix.pkgs }} brotli cmake git go gtest libunwind \ 110 | lz4 pcre2 pkgconfig protobuf zstd ninja 111 | 112 | - name: prep ubuntu 113 | if: startsWith(matrix.os, 'ubuntu') 114 | run: | 115 | apt-get update 116 | DEBIAN_FRONTEND=noninteractive apt-get install -yq \ 117 | ${{ matrix.pkgs }} cmake git golang libbrotli-dev \ 118 | libgtest-dev liblz4-dev libpcre2-dev libprotobuf-dev libunwind-dev \ 119 | libzstd-dev pkg-config protobuf-compiler ninja-build xz-utils 120 | 121 | - name: prep alpine 122 | if: startsWith(matrix.os, 'alpine') 123 | run: | 124 | apk add build-base pcre2-dev linux-headers gtest-dev samurai \ 125 | go git perl cmake protobuf-dev brotli-dev zstd-dev lz4-dev 126 | 127 | - name: prep fedora 128 | if: startsWith(matrix.os, 'fedora') 129 | run: | 130 | dnf install -y ${{ matrix.pkgs }} cmake ninja-build perl git golang \ 131 | brotli-devel gtest-devel lz4-devel pcre2-devel protobuf-devel \ 132 | libzstd-devel tar xz 133 | 134 | - name: download source 135 | uses: actions/download-artifact@v4 136 | with: 137 | name: package_source 138 | 139 | - name: build & install 140 | run: | 141 | export GOFLAGS="-mod=vendor" 142 | tar -xf android-tools-*.tar.xz 143 | cd android-tools-*/ 144 | test -n "${{ matrix.env1 }}" && export ${{ matrix.env1 }} 145 | test -n "${{ matrix.env2 }}" && export ${{ matrix.env2 }} 146 | mkdir build && cd build 147 | cmake \ 148 | -DCMAKE_C_FLAGS="$CFLAGS" \ 149 | -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ 150 | -DCMAKE_BUILD_TYPE=Release \ 151 | -DANDROID_TOOLS_USE_BUNDLED_FMT=ON \ 152 | -DANDROID_TOOLS_USE_BUNDLED_LIBUSB=ON \ 153 | -GNinja \ 154 | .. 155 | ninja --verbose 156 | echo -e "\n### make install ###\n" 157 | cmake --install . --prefix /usr/local 158 | echo -e "\n### all done ###\n" 159 | 160 | - name: check 161 | run: | 162 | /usr/local/bin/adb --version 163 | /usr/local/bin/fastboot --version 164 | /usr/local/bin/make_f2fs -V 165 | /usr/local/bin/sload_f2fs -V 166 | 167 | macos: 168 | strategy: 169 | fail-fast: false 170 | matrix: 171 | os: [macos-13, macos-14, macos-15] 172 | runs-on: ${{ matrix.os }} 173 | needs: [upload-src] 174 | steps: 175 | # github actions overwrites brew's python. Force it to reassert itself, by running in a separate step. 176 | # Borrowed from https://github.com/mesonbuild/meson/blob/master/.github/workflows/macos.yml#L87-L92 177 | - name: unbreak python in github actions 178 | run: | 179 | find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete 180 | sudo rm -rf /Library/Frameworks/Python.framework/ 181 | brew install --force python3 && brew unlink python3 && brew unlink python3 && brew link --overwrite python3 182 | - name: prep macos 183 | run: | 184 | rm -rf /opt/homebrew/include/openssl /usr/local/opt/openssl /usr/local/include/openssl 185 | brew install --overwrite --quiet brotli cmake go googletest lz4 \ 186 | ninja pcre2 protobuf zstd 187 | 188 | - name: download source 189 | uses: actions/download-artifact@v4 190 | with: 191 | name: package_source 192 | 193 | - name: build & install 194 | run: | 195 | tar -xf android-tools-*.tar.xz 196 | cd android-tools-*/ 197 | mkdir build && cd build 198 | cmake \ 199 | -DCMAKE_C_FLAGS="$CFLAGS" \ 200 | -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ 201 | -DCMAKE_BUILD_TYPE=Release \ 202 | -DCMAKE_INSTALL_PREFIX=$HOME/android-tools \ 203 | -DANDROID_TOOLS_USE_BUNDLED_FMT=ON \ 204 | -DANDROID_TOOLS_USE_BUNDLED_LIBUSB=ON \ 205 | -GNinja \ 206 | .. 207 | ninja --verbose 208 | echo -e "\n### make install ###\n" 209 | cmake --install . 210 | echo -e "\n### all done ###\n" 211 | 212 | - name: check 213 | run: | 214 | $HOME/android-tools/bin/adb --version 215 | $HOME/android-tools/bin/fastboot --version 216 | $HOME/android-tools/bin/make_f2fs -V 217 | $HOME/android-tools/bin/sload_f2fs -V 218 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | .idea 3 | .vscode 4 | 5 | /cmake-build-debug/ 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "core"] 2 | shallow = true 3 | path = vendor/core 4 | url = https://android.googlesource.com/platform/system/core.git 5 | [submodule "extras"] 6 | shallow = true 7 | path = vendor/extras 8 | url = https://android.googlesource.com/platform/system/extras.git 9 | [submodule "selinux"] 10 | shallow = true 11 | path = vendor/selinux 12 | url = https://android.googlesource.com/platform/external/selinux.git 13 | [submodule "f2fs-tools"] 14 | shallow = true 15 | path = vendor/f2fs-tools 16 | url = https://android.googlesource.com/platform/external/f2fs-tools.git 17 | [submodule "e2fsprogs"] 18 | shallow = true 19 | path = vendor/e2fsprogs 20 | url = https://android.googlesource.com/platform/external/e2fsprogs.git 21 | [submodule "boringssl"] 22 | shallow = true 23 | path = vendor/boringssl 24 | url = https://boringssl.googlesource.com/boringssl.git 25 | [submodule "vendor/mkbootimg"] 26 | shallow = true 27 | path = vendor/mkbootimg 28 | url = https://android.googlesource.com/platform/system/tools/mkbootimg 29 | [submodule "vendor/avb"] 30 | shallow = true 31 | path = vendor/avb 32 | url = https://android.googlesource.com/platform/external/avb 33 | [submodule "vendor/libbase"] 34 | shallow = true 35 | path = vendor/libbase 36 | url = https://android.googlesource.com/platform/system/libbase 37 | [submodule "vendor/libziparchive"] 38 | shallow = true 39 | path = vendor/libziparchive 40 | url = https://android.googlesource.com/platform/system/libziparchive 41 | [submodule "vendor/adb"] 42 | shallow = true 43 | path = vendor/adb 44 | url = https://android.googlesource.com/platform/packages/modules/adb.git 45 | [submodule "vendor/logging"] 46 | shallow = true 47 | path = vendor/logging 48 | url = https://android.googlesource.com/platform/system/logging.git 49 | [submodule "vendor/fmtlib"] 50 | shallow = true 51 | path = vendor/fmtlib 52 | url = https://android.googlesource.com/platform/external/fmtlib.git 53 | [submodule "vendor/libufdt"] 54 | shallow = true 55 | path = vendor/libufdt 56 | url = https://android.googlesource.com/platform/system/libufdt.git 57 | [submodule "vendor/libusb"] 58 | shallow = true 59 | path = vendor/libusb 60 | url = https://android.googlesource.com/platform/external/libusb.git 61 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12.0) 2 | project(android-tools) 3 | 4 | # To ease installation of utility files such as bash completions, etc. 5 | # See: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html 6 | include(GNUInstallDirs) 7 | 8 | # Option to enable or disable patching vendor projects using patches directory. 9 | # This helps to build vendor projects with or without any patching. Also if any 10 | # files are changed in vendor projects those can be retained with this option. 11 | option(ANDROID_TOOLS_PATCH_VENDOR "Patch vendor projects using patches directory" ON) 12 | option(ANDROID_TOOLS_USE_BUNDLED_FMT "Use bundled fmt library instead of system provided one" OFF) 13 | option(ANDROID_TOOLS_USE_BUNDLED_LIBUSB "Use bundled libusb library instead of system provided one" OFF) 14 | option(ANDROID_TOOLS_LIBUSB_ENABLE_UDEV "Enable udev for device enumeration and hotplug support" OFF) 15 | 16 | # Install bash/zsh completion files. 17 | set(COMPLETION_COMMON_DIR "${CMAKE_INSTALL_FULL_DATADIR}/android-tools/completions") 18 | add_subdirectory(completions) 19 | 20 | # Android provides it's own version of mke2fs which is incompatible with 21 | # the version shipped by e2fsprogs. To prevent a name clash we install 22 | # androids version of mke2fs under a different name. This name can be 23 | # configured here. 24 | # 25 | # See also: https://bugs.archlinux.org/task/56955 26 | set(ANDROID_MKE2FS_NAME "mke2fs.android") 27 | 28 | # Version of android-tools and the version of boringssl being used. 29 | # See: https://android.googlesource.com/platform/external/boringssl/+/platform-tools-${ANDROID_VERSION}/BORINGSSL_REVISION 30 | set(ANDROID_VERSION 35.0.2) 31 | set(BORINGSSL_VERSION 9cffd74fdb65c69506a0ce1b19420a67ad0cb19e) 32 | 33 | # Vendor string used in version outputs. 34 | set(ANDROID_VENDOR android-tools) 35 | 36 | configure_file(version.h.in vendor/build/version.h @ONLY) 37 | configure_file(platform_tools_version.h.in vendor/platform_tools_version.h @ONLY) 38 | 39 | # The CMakeLists.txt in the vendor subdirectory is responsible for 40 | # patching, building and installing the software. 41 | set(ANDROID_PATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/patches) 42 | add_subdirectory(vendor) 43 | 44 | # CPack configuration for creating source tarballs which already include 45 | # patched versions of the vendored dependencies. 46 | set(CPACK_SOURCE_GENERATOR "TXZ") 47 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${ANDROID_VERSION}") 48 | set(CPACK_SOURCE_IGNORE_FILES "/patches/" "/build/" "/.git/" "/.github/" "/tests/" 49 | "/testdata/" "/extras/simpleperf/scripts/" "/extras/simpleperf/demo/" 50 | "aes_128_gcm.txt" "aes_256_gcm.txt" 51 | "/fuzz/" 52 | "/wycheproof_testvectors/" 53 | "\\\\.apk$" 54 | "\\\\.bz2$" 55 | "\\\\.clang-format$" 56 | "\\\\.data$" 57 | "\\\\.git$" 58 | "\\\\.html$" 59 | "\\\\.orig$" 60 | "\\\\.pdf$" 61 | "\\\\.pem$" 62 | "\\\\.png$" 63 | "\\\\.rej$" 64 | "\\\\.so$" 65 | "\\\\.tar$" 66 | "\\\\.tar\\\\..*$" 67 | "\\\\.tgz$" 68 | "\\\\.zip$" 69 | ) 70 | include(CPack) 71 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-tools 2 | 3 | Git repository to make it easier to package certain command line 4 | utilities provided by [android-tools][android-tools]. 5 | 6 | # Motivation 7 | 8 | [Many][void-linux] [Linux][arch-linux] [distributions][alpine-linux] have 9 | [a package called android-tools][repology] which ships essential Android command 10 | line tools like adb or fastboot. Sadly the upstream build system for 11 | those tools is rather complex and doesn't allow building the command 12 | line tools only. 13 | 14 | Linux distributions therefore mostly ship their own build systems for 15 | building the command line utilities. This repository aims to make 16 | packaging of android command utilities easier by providing a simple 17 | CMake based build system and a ready-to-use tarball which doesn't 18 | require cloning all of the required git repositories manually. Besides 19 | this makes it easy to collect all patches required to build standalone 20 | Android command line utilities in a central place. 21 | 22 | # Status 23 | 24 | Currently the following tools are supported: 25 | 26 | * adb 27 | * fastboot 28 | * mke2fs.android (required by fastboot) 29 | * simg2img, img2simg, append2simg 30 | * lpdump, lpmake, lpadd, lpflash, lpunpack 31 | * mkbootimg, unpack_bootimg, repack_bootimg, avbtool 32 | * mkdtboimg 33 | 34 | The build system itself works quite well and is already being used for 35 | the Alpine Linux [android-tools package][alpine-linux] which I maintain. 36 | 37 | I personally don't use any android-tools except adb and fastboot. Thus 38 | my motivation to add support for additional tools is rather low at the 39 | moment. However, patches adding support for new tools in a clean way are 40 | welcome. Additionally, patches needed to make the software compile on 41 | other Linux distributions are welcome as well. Please create new patches 42 | using `git format-patch --no-numbered --no-signature …`. 43 | 44 | # Dependencies 45 | 46 | The following libraries are required by android-tools: 47 | 48 | 1. [libusb][libusb] 49 | 2. [PCRE][PCRE] 50 | 3. [Google Test][gtest] 51 | 4. [protobuf][protobuf] 52 | 5. [brotli][brotli] 53 | 6. [zstd][zstd] 54 | 7. [lz4][lz4] 55 | 56 | Python 3 is optionally needed as a run-time dependency in order to use 57 | the `mkbootimg`, `unpack_bootimg`, and `repack_bootimg` scripts which 58 | are all written in Python. 59 | 60 | Additionally the following software is required at compile-time: 61 | 62 | 1. A C and C++ compiler (either [GCC][gcc] >= 10.X or [clang][clang]) 63 | 2. The [Go compiler][golang] 64 | 3. [CMake][cmake] 65 | 4. [Perl][perl] 66 | 67 | *Currently the build system doesn't check whether all of these are installed.* 68 | 69 | # Installation 70 | 71 | Source tarballs containing an already patched version of all vendored 72 | dependencies are available on the [GitHub Release Page][release-page]. 73 | 74 | These tarballs should be used for packaging and general installation. 75 | After the tarball was downloaded and extracted android-tools can be 76 | build and installed as follows: 77 | 78 | $ mkdir build && cd build 79 | $ cmake .. 80 | $ make 81 | $ make install 82 | 83 | # Generating tarballs 84 | 85 | New source tarballs can be created from the Git repository using: 86 | 87 | $ mkdir build && cd build 88 | $ cmake .. 89 | $ make package_source 90 | 91 | Before a new release is uploaded a new `git-tag(1)` should be created 92 | for the release. Afterwards the tarball can be uploaded to the [GitHub 93 | Release Page][release-page]. 94 | 95 | # See also 96 | 97 | [The build script][android-tools-legacy] for android platform tools by [Anatol Pomozov][anatol.pomozov] 98 | which inspired this project. Most definitions in the `CMakeLists.txt` 99 | have been copied from Anatol's ruby script. 100 | 101 | [android-tools]: https://developer.android.com/tools/releases/platform-tools 102 | [void-linux]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/android-tools 103 | [arch-linux]: https://archlinux.org/packages/extra/x86_64/android-tools/ 104 | [alpine-linux]: https://pkgs.alpinelinux.org/package/edge/community/x86_64/android-tools 105 | [repology]: https://repology.org/project/android-tools/versions 106 | [release-page]: https://github.com/nmeum/android-tools/releases 107 | [libusb]: https://libusb.info/ 108 | [PCRE]: https://pcre.sourceforge.net/ 109 | [gtest]: https://github.com/google/googletest 110 | [gcc]: https://gcc.gnu.org/ 111 | [clang]: https://clang.llvm.org/ 112 | [golang]: https://go.dev/ 113 | [cmake]: https://cmake.org/ 114 | [perl]: https://www.perl.org/ 115 | [protobuf]: https://github.com/protocolbuffers/protobuf 116 | [brotli]: https://github.com/google/brotli 117 | [zstd]: https://facebook.github.io/zstd/ 118 | [lz4]: https://github.com/lz4/lz4 119 | [android-tools-legacy]: https://github.com/anatol/android-platform-tools-build 120 | [anatol.pomozov]: https://github.com/anatol 121 | -------------------------------------------------------------------------------- /completions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(bash) 2 | -------------------------------------------------------------------------------- /completions/README.md: -------------------------------------------------------------------------------- 1 | The AOSP android tools codebase provides generic completion files which 2 | can be used by both bash and zsh but require a `check_type` function to 3 | be provided. We install these generic files to a common directory 4 | (`COMPLETION_COMMON_DIR`) and source them from specific files created 5 | for bash/zsh which provide the `check_type` function. 6 | 7 | For more information see [#22](https://github.com/nmeum/android-tools/issues/22). 8 | -------------------------------------------------------------------------------- /completions/bash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BASH_COMPLETION_DIR "${CMAKE_INSTALL_FULL_DATADIR}/bash-completion/completions") 2 | 3 | configure_file(adb.in adb) 4 | configure_file(fastboot.in fastboot) 5 | 6 | install(FILES 7 | "${CMAKE_CURRENT_BINARY_DIR}/adb" 8 | "${CMAKE_CURRENT_BINARY_DIR}/fastboot" 9 | DESTINATION "${BASH_COMPLETION_DIR}") 10 | -------------------------------------------------------------------------------- /completions/bash/adb.in: -------------------------------------------------------------------------------- 1 | # Bash completions for adb. 2 | # See https://github.com/nmeum/android-tools/issues/22 3 | 4 | function check_type() { 5 | type -t "$1" 6 | } 7 | 8 | source "@COMPLETION_COMMON_DIR@/adb" 9 | -------------------------------------------------------------------------------- /completions/bash/fastboot.in: -------------------------------------------------------------------------------- 1 | # Bash completions for fastboot. 2 | # See https://github.com/nmeum/android-tools/issues/22 3 | 4 | function check_type() { 5 | type -t "$1" 6 | } 7 | 8 | source "@COMPLETION_COMMON_DIR@/fastboot" 9 | -------------------------------------------------------------------------------- /patches/adb/0001-Don-t-use-the-internal-glibc-header-sys-cdefs.h.patch: -------------------------------------------------------------------------------- 1 | From 2617c39ef3be43e477bea2d47d95e2540e000029 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Fri, 28 May 2021 11:26:01 +0200 4 | Subject: [PATCH] Don't use the internal glibc header sys/cdefs.h 5 | 6 | https://wiki.musl-libc.org/faq.html#Q:-When-compiling-something-against-musl,-I-get-error-messages-about 7 | --- 8 | pairing_auth/include/adb/pairing/pairing_auth.h | 9 ++++++--- 9 | .../include/adb/pairing/pairing_connection.h | 9 ++++++--- 10 | pairing_connection/include/adb/pairing/pairing_server.h | 9 ++++++--- 11 | 3 files changed, 18 insertions(+), 9 deletions(-) 12 | 13 | diff --git a/pairing_auth/include/adb/pairing/pairing_auth.h b/pairing_auth/include/adb/pairing/pairing_auth.h 14 | index ee0412fb..83f40a9f 100644 15 | --- a/pairing_auth/include/adb/pairing/pairing_auth.h 16 | +++ b/pairing_auth/include/adb/pairing/pairing_auth.h 17 | @@ -18,13 +18,14 @@ 18 | 19 | #include 20 | #include 21 | -#include 22 | 23 | #if !defined(__INTRODUCED_IN) 24 | #define __INTRODUCED_IN(__api_level) /* nothing */ 25 | #endif 26 | 27 | -__BEGIN_DECLS 28 | +#ifdef __cplusplus 29 | +extern "C" { 30 | +#endif 31 | 32 | /** 33 | * PairingAuthCtx is a wrapper around the SPAKE2 protocol + cipher initialization 34 | @@ -181,4 +182,6 @@ size_t pairing_auth_safe_decrypted_size(PairingAuthCtx* ctx, const uint8_t* buf, 35 | bool pairing_auth_decrypt(PairingAuthCtx* ctx, const uint8_t* inbuf, size_t inlen, uint8_t* outbuf, 36 | size_t* outlen) __INTRODUCED_IN(30); 37 | 38 | -__END_DECLS 39 | +#ifdef __cplusplus 40 | +} 41 | +#endif 42 | diff --git a/pairing_connection/include/adb/pairing/pairing_connection.h b/pairing_connection/include/adb/pairing/pairing_connection.h 43 | index 98764171..8e63db7b 100644 44 | --- a/pairing_connection/include/adb/pairing/pairing_connection.h 45 | +++ b/pairing_connection/include/adb/pairing/pairing_connection.h 46 | @@ -18,7 +18,6 @@ 47 | 48 | #include 49 | #include 50 | -#include 51 | 52 | #if !defined(__INTRODUCED_IN) 53 | #define __INTRODUCED_IN(__api_level) /* nothing */ 54 | @@ -35,7 +34,9 @@ 55 | // 56 | // If both sides have authenticated, they will exchange their peer information 57 | // (see #PeerInfo). 58 | -__BEGIN_DECLS 59 | +#ifdef __cplusplus 60 | +extern "C" { 61 | +#endif 62 | 63 | const uint32_t kMaxPeerInfoSize = 8192; 64 | struct PeerInfo { 65 | @@ -125,4 +126,6 @@ PairingConnectionCtx* pairing_connection_server_new(const uint8_t* pswd, size_t 66 | // @param ctx the PairingConnectionCtx instance to destroy. Will abort if null. 67 | void pairing_connection_destroy(PairingConnectionCtx* ctx) __INTRODUCED_IN(30); 68 | 69 | -__END_DECLS 70 | +#ifdef __cplusplus 71 | +} 72 | +#endif 73 | diff --git a/pairing_connection/include/adb/pairing/pairing_server.h b/pairing_connection/include/adb/pairing/pairing_server.h 74 | index 9e7b69fc..babff948 100644 75 | --- a/pairing_connection/include/adb/pairing/pairing_server.h 76 | +++ b/pairing_connection/include/adb/pairing/pairing_server.h 77 | @@ -18,7 +18,6 @@ 78 | 79 | #include 80 | #include 81 | -#include 82 | 83 | #include 84 | #include 85 | @@ -31,7 +30,9 @@ 86 | #define __INTRODUCED_IN(__api_level) /* nothing */ 87 | #endif 88 | 89 | -__BEGIN_DECLS 90 | +#ifdef __cplusplus 91 | +extern "C" { 92 | +#endif 93 | 94 | // PairingServerCtx is a wrapper around the #PairingConnectionCtx APIs, 95 | // which handles multiple client connections. 96 | @@ -106,4 +107,6 @@ PairingServerCtx* pairing_server_new_no_cert(const uint8_t* pswd, size_t pswd_le 97 | // @param ctx the PairingServerCtx instance to destroy. 98 | void pairing_server_destroy(PairingServerCtx* ctx) __INTRODUCED_IN(30); 99 | 100 | -__END_DECLS 101 | +#ifdef __cplusplus 102 | +} 103 | +#endif 104 | -------------------------------------------------------------------------------- /patches/adb/0002-adb-disable-mdns-transport-support.patch: -------------------------------------------------------------------------------- 1 | From f5ae19ccd3e8a38849628c3b80de33786a4343c9 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Sun, 1 Sep 2019 15:04:18 +0000 4 | Subject: [PATCH] adb: disable mdns transport support 5 | 6 | Would require patching the MDNS code as well. 7 | --- 8 | client/main.cpp | 3 --- 9 | 1 file changed, 3 deletions(-) 10 | 11 | diff --git a/client/main.cpp b/client/main.cpp 12 | index 4fa58faf..c14b3463 100644 13 | --- a/client/main.cpp 14 | +++ b/client/main.cpp 15 | @@ -132,10 +132,6 @@ int adb_server_main(int is_daemon, const std::string& socket_spec, const char* o 16 | 17 | init_reconnect_handler(); 18 | 19 | - if (!getenv("ADB_MDNS") || strcmp(getenv("ADB_MDNS"), "0") != 0) { 20 | - init_mdns_transport_discovery(); 21 | - } 22 | - 23 | if (!getenv("ADB_USB") || strcmp(getenv("ADB_USB"), "0") != 0) { 24 | if (is_libusb_enabled()) { 25 | libusb::usb_init(); 26 | -------------------------------------------------------------------------------- /patches/adb/0003-adb-include-missing-headers.patch: -------------------------------------------------------------------------------- 1 | From c37bd188a394b36ecb5aa5eeac9469fc5ef4473a Mon Sep 17 00:00:00 2001 2 | From: Biswapriyo Nath 3 | Date: Thu, 1 Feb 2024 19:39:48 +0530 4 | Subject: [PATCH] adb include missing headers 5 | 6 | --- 7 | sysdeps/uio.h | 1 + 8 | 1 file changed, 1 insertion(+) 9 | 10 | diff --git a/sysdeps/uio.h b/sysdeps/uio.h 11 | index f3ace64..266a20b 100644 12 | --- a/sysdeps/uio.h 13 | +++ b/sysdeps/uio.h 14 | @@ -34,6 +34,7 @@ ssize_t adb_writev(borrowed_fd fd, const adb_iovec* iov, int iovcnt); 15 | 16 | #else 17 | 18 | +#include 19 | #include 20 | using adb_iovec = struct iovec; 21 | inline ssize_t adb_writev(borrowed_fd fd, const adb_iovec* iov, int iovcnt) { 22 | -- 23 | 2.43.0 24 | 25 | -------------------------------------------------------------------------------- /patches/adb/0004-Define-clang-only-nullability-specifiers-when-__clan.patch: -------------------------------------------------------------------------------- 1 | From 0eddc30a5913401262df2830b28e8dadaf1d0c26 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Tue, 27 Feb 2018 17:48:49 +0100 4 | Subject: [PATCH] Define clang-only nullability specifiers when __clang__ is 5 | not defined 6 | 7 | --- 8 | adb_mdns.h | 6 ++++++ 9 | sysdeps.h | 6 ++++++ 10 | 2 files changed, 12 insertions(+) 11 | 12 | diff --git a/adb_mdns.h b/adb_mdns.h 13 | index a015f53..0e8fc4e 100644 14 | --- a/adb_mdns.h 15 | +++ b/adb_mdns.h 16 | @@ -21,6 +21,12 @@ 17 | #include 18 | #include 19 | 20 | +// Clang-only nullability specifiers 21 | +#ifndef __clang__ 22 | +#define _Nonnull 23 | +#define _Nullable 24 | +#endif 25 | + 26 | // The rules for Service Names [RFC6335] state that they may be no more 27 | // than fifteen characters long (not counting the mandatory underscore), 28 | // consisting of only letters, digits, and hyphens, must begin and end 29 | diff --git a/sysdeps.h b/sysdeps.h 30 | index 5ba85b4d..2115a32b 100644 31 | --- a/sysdeps.h 32 | +++ b/sysdeps.h 33 | @@ -55,6 +55,12 @@ static inline void* mempcpy(void* dst, const void* src, size_t n) { 34 | 35 | std::optional network_peek(borrowed_fd fd); 36 | 37 | +// Clang-only nullability specifiers 38 | +#ifndef __clang__ 39 | +#define _Nonnull 40 | +#define _Nullable 41 | +#endif 42 | + 43 | #ifdef _WIN32 44 | 45 | #include 46 | -------------------------------------------------------------------------------- /patches/adb/0005-Include-libusb-1.0-libusb.h-instead-of-libusb-libusb.patch: -------------------------------------------------------------------------------- 1 | From 104860b6b131d8c45345dfd5c446afe11bca4d18 Mon Sep 17 00:00:00 2001 2 | From: Anatol Pomozov 3 | Date: Fri, 25 Aug 2017 23:30:34 +0000 4 | Subject: [PATCH] Include libusb-1.0/libusb.h instead of libusb/libusb.h 5 | 6 | --- 7 | client/usb_libusb.cpp | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/client/usb_libusb.cpp b/client/usb_libusb.cpp 11 | index e0b0104a..bcfb03af 100644 12 | --- a/client/usb_libusb.cpp 13 | +++ b/client/usb_libusb.cpp 14 | @@ -36,7 +36,11 @@ 15 | #include 16 | #include 17 | 18 | +#ifdef ANDROID_TOOLS_USE_BUNDLED_LIBUSB 19 | #include 20 | +#else 21 | +#include 22 | +#endif 23 | 24 | #include 25 | #include 26 | 27 | -------------------------------------------------------------------------------- /patches/adb/0006-Include-string.h-in-various-file-missing-it.patch: -------------------------------------------------------------------------------- 1 | From 27e41fc05d0a4cd86833fd23962a4c8a7dd32e2b Mon Sep 17 00:00:00 2001 2 | From: Anatol Pomozov 3 | Date: Fri, 25 Aug 2017 23:30:34 +0000 4 | Subject: [PATCH] Include string.h in various file missing it 5 | 6 | Most of these need string.h for strerror(3). 7 | --- 8 | sysdeps/posix/network.cpp | 1 + 9 | 1 file changed, 1 insertion(+) 10 | 11 | diff --git a/sysdeps/posix/network.cpp b/sysdeps/posix/network.cpp 12 | index a4d9013d..ec4c7c8e 100644 13 | --- a/sysdeps/posix/network.cpp 14 | +++ b/sysdeps/posix/network.cpp 15 | @@ -22,6 +22,7 @@ 16 | #include 17 | 18 | #include 19 | +#include 20 | 21 | #include 22 | #include 23 | -------------------------------------------------------------------------------- /patches/adb/0007-adb-Fix-unknown-__xx_write-member-in-std-ostream.patch: -------------------------------------------------------------------------------- 1 | From bfd129ad4c023ffec8a16c1dbd8f1efebd68ff7b Mon Sep 17 00:00:00 2001 2 | From: Biswapriyo Nath 3 | Date: Sat, 10 Aug 2024 20:24:00 +0000 4 | Subject: [PATCH] adb: Fix unknown __xx_write member in std::ostream 5 | 6 | This fixes the following compiler error. 7 | 8 | sysdeps.h:559:17: error: 'std::ostream` {aka 'class std::basic_ostream`} has no member named '___xxx_write` 9 | 559 | #define write ___xxx_write 10 | | ^~~~~~~~~~~~ 11 | --- 12 | sysdeps.h | 2 ++ 13 | 1 file changed, 2 insertions(+) 14 | 15 | diff --git a/sysdeps.h b/sysdeps.h 16 | index e87501c..af548c5 100644 17 | --- a/sysdeps.h 18 | +++ b/sysdeps.h 19 | @@ -555,8 +555,10 @@ static inline int adb_pwrite(int fd, const void* buf, size_t len, off64_t offset 20 | #endif 21 | } 22 | 23 | +#ifdef write 24 | #undef write 25 | #define write ___xxx_write 26 | +#endif 27 | #undef pwrite 28 | #define pwrite ___xxx_pwrite 29 | 30 | -------------------------------------------------------------------------------- /patches/adb/0008-adb-Disable-bonjour-check.patch: -------------------------------------------------------------------------------- 1 | From bedc0c38148add6841832f0815fb589c78cc16f7 Mon Sep 17 00:00:00 2001 2 | From: Biswapriyo Nath 3 | Date: Sun, 11 Aug 2024 04:47:21 +0000 4 | Subject: [PATCH] adb: Disable bonjour check 5 | 6 | --- 7 | adb.cpp | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/adb.cpp b/adb.cpp 11 | index 225ddaf..1be30eb 100644 12 | --- a/adb.cpp 13 | +++ b/adb.cpp 14 | @@ -1319,7 +1319,7 @@ HostRequestResult handle_host_request(std::string_view service, TransportType ty 15 | } 16 | status.set_usb_backend_forced(getenv("ADB_LIBUSB") != nullptr); 17 | 18 | - if (using_bonjour()) { 19 | + if (false) { 20 | status.set_mdns_backend(adb::proto::AdbServerStatus::BONJOUR); 21 | } else { 22 | status.set_mdns_backend(adb::proto::AdbServerStatus::OPENSCREEN); 23 | -- 24 | 2.46.0 25 | 26 | -------------------------------------------------------------------------------- /patches/adb/0009-adb-Reduce-fallback-size-for-_SC_GETPW_R_SIZE_MAX.patch: -------------------------------------------------------------------------------- 1 | From 03abccae95cf9fb2383dfddfbd27fa4f236998d3 Mon Sep 17 00:00:00 2001 2 | From: Robert Yang 3 | Date: Wed, 24 Oct 2018 09:48:40 -0400 4 | Subject: [PATCH] adb: Reduce fallback size for _SC_GETPW_R_SIZE_MAX 5 | 6 | See: https://github.com/nmeum/android-tools/pull/5#discussion_r227946282 7 | --- 8 | adb_utils.cpp | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/adb_utils.cpp b/adb_utils.cpp 12 | index d1910f1c..593448a0 100644 13 | --- a/adb_utils.cpp 14 | +++ b/adb_utils.cpp 15 | @@ -294,7 +294,7 @@ std::string adb_get_homedir_path() { 16 | struct passwd* result; 17 | int pwent_max = sysconf(_SC_GETPW_R_SIZE_MAX); 18 | if (pwent_max == -1) { 19 | - pwent_max = 16384; 20 | + pwent_max = 1024; 21 | } 22 | std::vector buf(pwent_max); 23 | int rc = getpwuid_r(getuid(), &pwent, buf.data(), buf.size(), &result); 24 | -------------------------------------------------------------------------------- /patches/adb/0010-sysdeps-don-t-over-eager-constexpr.patch: -------------------------------------------------------------------------------- 1 | From 65f707c9346930130df073551aecf0eefe73a9ea Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= 3 | 4 | Date: Sat, 31 Oct 2020 21:59:34 +0700 5 | Subject: [PATCH] sysdeps: don't over eager constexpr 6 | 7 | Older gcc (at least 9.3.0) hasn't catched up on this relaxation of 8 | constexpr. 9 | --- 10 | sysdeps.h | 2 +- 11 | 1 file changed, 1 insertion(+), 1 deletion(-) 12 | 13 | diff --git a/sysdeps.h b/sysdeps.h 14 | index 2115a32b..316afe71 100644 15 | --- a/sysdeps.h 16 | +++ b/sysdeps.h 17 | @@ -753,7 +753,7 @@ static inline int cast_handle_to_int(int fd) { 18 | class Process { 19 | public: 20 | constexpr explicit Process(pid_t pid) : pid_(pid) {} 21 | - constexpr Process(Process&& other) : pid_(std::exchange(other.pid_, -1)) {} 22 | + Process(Process&& other) : pid_(std::exchange(other.pid_, -1)) {} 23 | 24 | constexpr explicit operator bool() const { return pid_ >= 0; } 25 | 26 | -------------------------------------------------------------------------------- /patches/adb/0013-adb-disable-fastdeploy-support.patch: -------------------------------------------------------------------------------- 1 | From 5849a4b0533969a31311c6d00216145ad955af15 Mon Sep 17 00:00:00 2001 2 | From: Minecrell 3 | Date: Thu, 27 Feb 2020 14:06:16 +0100 4 | Subject: [PATCH] adb: disable fastdeploy support 5 | 6 | The "fastdeploy" support in ADB seems extremely complicated, it requires 7 | additional dependencies on protobuf and Java, 8 | see: https://git.archlinux.org/svntogit/community.git/commit/trunk/PKGBUILD?h=packages/android-tools&id=18cab8db85b81471e3beb90a0543945fb31f84bb 9 | 10 | For now lets just disable it (like it was on platform-tools-29.0.4). 11 | If someone wants to make it work, feel free to :) 12 | --- 13 | client/adb_install.cpp | 10 ++++++++++ 14 | client/fastdeploy.h | 4 ++++ 15 | 2 files changed, 14 insertions(+) 16 | 17 | diff --git a/client/adb_install.cpp b/client/adb_install.cpp 18 | index 97debae1..35278e2f 100644 19 | --- a/client/adb_install.cpp 20 | +++ b/client/adb_install.cpp 21 | @@ -185,6 +185,7 @@ static int install_app_streamed(int argc, const char** argv, bool use_fastdeploy 22 | } 23 | 24 | if (use_fastdeploy) { 25 | +#if defined(ENABLE_FASTDEPLOY) 26 | auto metadata = extract_metadata(file); 27 | if (metadata.has_value()) { 28 | // pass all but 1st (command) and last (apk path) parameters through to pm for 29 | @@ -193,6 +194,9 @@ static int install_app_streamed(int argc, const char** argv, bool use_fastdeploy 30 | auto patchFd = install_patch(pm_args.size(), pm_args.data()); 31 | return stream_patch(file, std::move(metadata.value()), std::move(patchFd)); 32 | } 33 | +#else 34 | + error_exit("fastdeploy is disabled"); 35 | +#endif 36 | } 37 | 38 | struct stat sb; 39 | @@ -280,6 +284,7 @@ static int install_app_legacy(int argc, const char** argv, bool use_fastdeploy) 40 | argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */ 41 | 42 | if (use_fastdeploy) { 43 | +#if defined(ENABLE_FASTDEPLOY) 44 | auto metadata = extract_metadata(apk_file[0]); 45 | if (metadata.has_value()) { 46 | auto patchFd = apply_patch_on_device(apk_dest.c_str()); 47 | @@ -285,6 +285,9 @@ static int install_app_legacy(int argc, const char** argv, bool use_fastdeploy) 48 | 49 | return status; 50 | } 51 | +#else 52 | + error_exit("fastdeploy is disabled"); 53 | +#endif 54 | } 55 | 56 | if (do_sync_push(apk_file, apk_dest.c_str(), false, CompressionType::Any, false, false)) { 57 | @@ -494,6 +497,7 @@ int install_app(int argc, const char** argv) { 58 | error_exit("Attempting to use streaming install on unsupported device"); 59 | } 60 | 61 | +#if defined(ENABLE_FASTDEPLOY) 62 | if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) { 63 | fprintf(stderr, 64 | "Fast Deploy is only compatible with devices of API version %d or higher, " 65 | @@ -507,6 +516,7 @@ int install_app(int argc, const char** argv) { 66 | use_fastdeploy = false; 67 | } 68 | fastdeploy_set_agent_update_strategy(agent_update_strategy); 69 | +#endif 70 | 71 | if (passthrough_argv.size() < 2) { 72 | error_exit("install requires an apk argument"); 73 | diff --git a/client/fastdeploy.h b/client/fastdeploy.h 74 | index 830aeb2c..25f3f9ef 100644 75 | --- a/client/fastdeploy.h 76 | +++ b/client/fastdeploy.h 77 | @@ -16,12 +16,14 @@ 78 | 79 | #pragma once 80 | 81 | +#if defined(ENABLE_FASTDEPLOY) 82 | #include "adb_unique_fd.h" 83 | 84 | #include "fastdeploy/proto/ApkEntry.pb.h" 85 | 86 | #include 87 | #include 88 | +#endif 89 | 90 | enum FastDeploy_AgentUpdateStrategy { 91 | FastDeploy_AgentUpdateAlways, 92 | @@ -29,6 +31,7 @@ enum FastDeploy_AgentUpdateStrategy { 93 | FastDeploy_AgentUpdateDifferentVersion 94 | }; 95 | 96 | +#if defined(ENABLE_FASTDEPLOY) 97 | void fastdeploy_set_agent_update_strategy(FastDeploy_AgentUpdateStrategy agent_update_strategy); 98 | int get_device_api_level(); 99 | 100 | @@ -37,3 +40,4 @@ unique_fd install_patch(int argc, const char** argv); 101 | unique_fd apply_patch_on_device(const char* output_path); 102 | int stream_patch(const char* apk_path, com::android::fastdeploy::APKMetaData metadata, 103 | unique_fd patch_fd); 104 | +#endif 105 | -------------------------------------------------------------------------------- /patches/adb/0015-types.h-Fix-ambiguous-reference-to-weak_ptr.patch: -------------------------------------------------------------------------------- 1 | From 24a926ea3caf56d72158c5d577d0c7c059567f33 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Sat, 7 Mar 2020 13:48:50 +0100 4 | Subject: [PATCH] types.h: Fix ambiguous reference to weak_ptr 5 | 6 | Without this patch the build fails with: 7 | 8 | error: reference to 'weak_ptr' is ambiguous 9 | 10 | As there also seems to be a definition of weak_ptr in the std namespace. 11 | --- 12 | types.h | 6 +++--- 13 | 1 file changed, 3 insertions(+), 3 deletions(-) 14 | 15 | diff --git a/types.h b/types.h 16 | index be9fb1f6..a5747d05 100644 17 | --- a/types.h 18 | +++ b/types.h 19 | @@ -346,13 +346,13 @@ struct enable_weak_from_this { 20 | } 21 | } 22 | 23 | - weak_ptr weak() { return weak_ptr(static_cast(this)); } 24 | + ::weak_ptr weak() { return ::weak_ptr(static_cast(this)); } 25 | 26 | void schedule_deletion() { 27 | fdevent_run_on_looper([this]() { delete static_cast(this); }); 28 | } 29 | 30 | private: 31 | - friend struct weak_ptr; 32 | - std::vector*> weak_ptrs_; 33 | + friend struct ::weak_ptr; 34 | + std::vector<::weak_ptr*> weak_ptrs_; 35 | }; 36 | -------------------------------------------------------------------------------- /patches/adb/0016-adb-disable-mDNS.patch: -------------------------------------------------------------------------------- 1 | From 481ad29f9ac31c352d78d3bbab805921823f4fde Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= 3 | 4 | Date: Sun, 1 Nov 2020 15:51:35 +0700 5 | Subject: [PATCH] adb: disable mDNS 6 | 7 | --- 8 | adb.cpp | 15 --------------- 9 | client/main.cpp | 2 -- 10 | socket_spec.cpp | 25 +------------------------ 11 | 3 files changed, 1 insertion(+), 41 deletions(-) 12 | 13 | diff --git a/adb.cpp b/adb.cpp 14 | index c1bb8f42..cbabfe8f 100644 15 | --- a/adb.cpp 16 | +++ b/adb.cpp 17 | @@ -1131,21 +1131,6 @@ void adb_set_reject_kill_server(bool value) { 18 | } 19 | 20 | static bool handle_mdns_request(std::string_view service, int reply_fd) { 21 | - if (!android::base::ConsumePrefix(&service, "mdns:")) { 22 | - return false; 23 | - } 24 | - 25 | - if (service == "check") { 26 | - std::string check = mdns_check(); 27 | - SendOkay(reply_fd, check); 28 | - return true; 29 | - } 30 | - if (service == "services") { 31 | - std::string services_list = mdns_list_discovered_services(); 32 | - SendOkay(reply_fd, services_list); 33 | - return true; 34 | - } 35 | - 36 | return false; 37 | } 38 | 39 | diff --git a/client/main.cpp b/client/main.cpp 40 | index c14b3463..552042e1 100644 41 | --- a/client/main.cpp 42 | +++ b/client/main.cpp 43 | @@ -68,11 +68,9 @@ void adb_server_cleanup() { 44 | // 1. close_smartsockets, so that we don't get any new clients 45 | // 2. kick_all_transports, to avoid writing only part of a packet to a transport. 46 | // 3. usb_cleanup, to tear down the USB stack. 47 | - // 4. mdns_cleanup, to tear down mdns stack. 48 | close_smartsockets(); 49 | kick_all_transports(); 50 | usb_cleanup(); 51 | - mdns_cleanup(); 52 | } 53 | 54 | static void intentionally_leak() { 55 | diff --git a/socket_spec.cpp b/socket_spec.cpp 56 | index c93b0230..4d3aa28d 100644 57 | --- a/socket_spec.cpp 58 | +++ b/socket_spec.cpp 59 | @@ -195,30 +195,7 @@ bool socket_spec_connect(unique_fd* fd, std::string_view address, int* port, std 60 | if (tcp_host_is_local(hostname)) { 61 | fd->reset(network_loopback_client(port_value, SOCK_STREAM, error)); 62 | } else { 63 | -#if ADB_HOST 64 | - // Check if the address is an mdns service we can connect to. 65 | - if (auto mdns_info = mdns_get_connect_service_info(std::string(address.substr(4))); 66 | - mdns_info != std::nullopt) { 67 | - fd->reset(network_connect(mdns_info->addr, mdns_info->port, SOCK_STREAM, 0, error)); 68 | - if (fd->get() != -1) { 69 | - // TODO(joshuaduong): We still show the ip address for the serial. Change it to 70 | - // use the mdns instance name, so we can adjust to address changes on 71 | - // reconnects. 72 | - port_value = mdns_info->port; 73 | - if (serial) { 74 | - *serial = android::base::StringPrintf("%s.%s", 75 | - mdns_info->service_name.c_str(), 76 | - mdns_info->service_type.c_str()); 77 | - } 78 | - } 79 | - } else { 80 | - fd->reset(network_connect(hostname, port_value, SOCK_STREAM, 0, error)); 81 | - } 82 | -#else 83 | - // Disallow arbitrary connections in adbd. 84 | - *error = "adbd does not support arbitrary tcp connections"; 85 | - return false; 86 | -#endif 87 | + fd->reset(network_connect(hostname, port_value, SOCK_STREAM, 0, error)); 88 | } 89 | 90 | if (fd->get() > 0) { 91 | -------------------------------------------------------------------------------- /patches/adb/0017-adb_wifi-remove-mDNS.patch: -------------------------------------------------------------------------------- 1 | From 24ff9a87be032e15d0e417560d182e3831cadb78 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= 3 | 4 | Date: Sun, 1 Nov 2020 19:44:01 +0700 5 | Subject: [PATCH] adb_wifi: remove mDNS 6 | 7 | --- 8 | client/adb_wifi.cpp | 10 ++-------- 9 | 1 file changed, 2 insertions(+), 8 deletions(-) 10 | 11 | diff --git a/client/adb_wifi.cpp b/client/adb_wifi.cpp 12 | index e3e853a7..4a9a2055 100644 13 | --- a/client/adb_wifi.cpp 14 | +++ b/client/adb_wifi.cpp 15 | @@ -180,9 +180,7 @@ bool adb_wifi_is_known_host(const std::string& host) { 16 | 17 | void adb_wifi_pair_device(const std::string& host, const std::string& password, 18 | std::string& response) { 19 | - auto mdns_info = mdns_get_pairing_service_info(host); 20 | - 21 | - if (!mdns_info.has_value()) { 22 | + if (true) { 23 | // Check the address for a valid address and port. 24 | std::string parsed_host; 25 | std::string err; 26 | @@ -225,10 +223,7 @@ void adb_wifi_pair_device(const std::string& host, const std::string& password, 27 | 28 | PairingResultWaiter waiter; 29 | std::unique_lock lock(waiter.mutex_); 30 | - if (!client->Start(mdns_info.has_value() 31 | - ? android::base::StringPrintf("%s:%d", mdns_info->addr.c_str(), 32 | - mdns_info->port) 33 | - : host, 34 | + if (!client->Start(host, 35 | waiter.OnResult, &waiter)) { 36 | response = "Failed: Unable to start pairing client."; 37 | return; 38 | @@ -251,5 +246,4 @@ void adb_wifi_pair_device(const std::string& host, const std::string& password, 39 | // Write to adb_known_hosts 40 | write_known_host_to_file(device_guid); 41 | // Try to auto-connect. 42 | - adb_secure_connect_by_service_name(device_guid); 43 | } 44 | -------------------------------------------------------------------------------- /patches/adb/0020-Fix-compilation-with-libusb-1.0.24.patch: -------------------------------------------------------------------------------- 1 | From 3e2a37b3886200951a7c3bebe149219c67198df6 Mon Sep 17 00:00:00 2001 2 | From: jershell 3 | Date: Mon, 6 Jun 2022 16:29:40 +0300 4 | Subject: [PATCH] fix for Fix-compilation-with-libusb 5 | 6 | --- 7 | client/usb_libusb.cpp | 6 +++--- 8 | 1 file changed, 3 insertions(+), 3 deletions(-) 9 | 10 | diff --git a/client/usb_libusb.cpp b/client/usb_libusb.cpp 11 | index e0b0104a..a66474b3 100644 12 | --- a/client/usb_libusb.cpp 13 | +++ b/client/usb_libusb.cpp 14 | @@ -295,7 +295,7 @@ struct LibusbConnection : public Connection { 15 | read->active = true; 16 | int rc = libusb_submit_transfer(read->transfer); 17 | if (rc != 0) { 18 | - LOG(ERROR) << "libusb_submit_transfer failed: " << libusb_strerror(rc); 19 | + LOG(ERROR) << "libusb_submit_transfer failed: " << libusb_strerror(static_cast(rc)); 20 | } 21 | } 22 | 23 | @@ -318,7 +318,7 @@ struct LibusbConnection : public Connection { 24 | if (rc == 0) { 25 | writes_[write->id] = std::move(write); 26 | } else { 27 | - LOG(ERROR) << "libusb_submit_transfer failed: " << libusb_strerror(rc); 28 | + LOG(ERROR) << "libusb_submit_transfer failed: " << libusb_strerror(static_cast(rc)); 29 | libusb_free_transfer(write->transfer); 30 | } 31 | } 32 | @@ -503,7 +503,7 @@ struct LibusbConnection : public Connection { 33 | int rc = libusb_open(device_.get(), &handle_raw); 34 | if (rc != 0) { 35 | // TODO: Handle no permissions. 36 | - LOG_ERR(error, "failed to open device: %s", libusb_strerror(rc)); 37 | + LOG_ERR(error, "failed to open device: %s", libusb_strerror(static_cast(rc))); 38 | return false; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /patches/adb/0023-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch: -------------------------------------------------------------------------------- 1 | From c830c90995fc0877348e2ed9cdeccf9b739138d2 Mon Sep 17 00:00:00 2001 2 | From: Anatol Pomozov 3 | Date: Mon, 10 Oct 2022 10:47:57 -0700 4 | Subject: [PATCH] Update usage of usbdevfs_urb to match new kernel UAPI 5 | MIME-Version: 1.0 6 | Content-Type: text/plain; charset=UTF-8 7 | Content-Transfer-Encoding: 8bit 8 | 9 | Linux kernel API has been changed by commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members") 10 | where zero-length array iso_frame_desc in struct usbdevfs_urb was replaced with a proper flexible-array member. 11 | 12 | Current USB API usage causes a compilation error at Linux 6.0: 13 | 14 | In file included from /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:28: 15 | /usr/include/linux/usbdevice_fs.h:134:41: error: flexible array member ‘usbdevfs_urb::iso_frame_desc’ not at end of ‘struct usb_handle’ 16 | 134 | struct usbdevfs_iso_packet_desc iso_frame_desc[]; 17 | | ^~~~~~~~~~~~~~ 18 | /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:76:18: note: next member ‘usbdevfs_urb usb_handle::urb_out’ declared here 19 | 76 | usbdevfs_urb urb_out; 20 | | ^~~~~~~ 21 | /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:61:8: note: in the definition of ‘struct usb_handle’ 22 | 61 | struct usb_handle { 23 | | ^~~~~~~~~~ 24 | 25 | Fix it by using pointers to a struct with flexible-array members. 26 | Current fix works both with the old and the new API. 27 | 28 | See https://github.com/nmeum/android-tools/issues/74 for more context. 29 | 30 | Tested: built on Linux against kernel 5.19 and 6.0; 'adb shell' over USB 31 | cable 32 | Acked-by: Gustavo A. R. Silva gustavoars@kernel.org 33 | Change-Id: I7f0f7b35d9a3ab980d3520b541b60c7857a6b101 34 | Signed-off-by: Anatol Pomozov 35 | --- 36 | client/usb_linux.cpp | 24 ++++++++++++++---------- 37 | 1 file changed, 14 insertions(+), 10 deletions(-) 38 | 39 | diff --git a/client/usb_linux.cpp b/client/usb_linux.cpp 40 | index 7f926266..235a21be 100644 41 | --- a/client/usb_linux.cpp 42 | +++ b/client/usb_linux.cpp 43 | @@ -76,8 +76,8 @@ struct usb_handle { 44 | // to fill in those values, ignore this warning. 45 | #pragma clang diagnostic push 46 | #pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end" 47 | - usbdevfs_urb urb_in; 48 | - usbdevfs_urb urb_out; 49 | + usbdevfs_urb *urb_in; 50 | + usbdevfs_urb *urb_out; 51 | #pragma clang diagnostic pop 52 | 53 | bool urb_in_busy = false; 54 | @@ -303,7 +303,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) { 55 | std::unique_lock lock(h->mutex); 56 | D("++ usb_bulk_write ++"); 57 | 58 | - usbdevfs_urb* urb = &h->urb_out; 59 | + usbdevfs_urb* urb = h->urb_out; 60 | memset(urb, 0, sizeof(*urb)); 61 | urb->type = USBDEVFS_URB_TYPE_BULK; 62 | urb->endpoint = h->ep_out; 63 | @@ -342,7 +342,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { 64 | std::unique_lock lock(h->mutex); 65 | D("++ usb_bulk_read ++"); 66 | 67 | - usbdevfs_urb* urb = &h->urb_in; 68 | + usbdevfs_urb* urb = h->urb_in; 69 | memset(urb, 0, sizeof(*urb)); 70 | urb->type = USBDEVFS_URB_TYPE_BULK; 71 | urb->endpoint = h->ep_in; 72 | @@ -387,7 +387,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { 73 | } 74 | D("[ urb @%p status = %d, actual = %d ]", out, out->status, out->actual_length); 75 | 76 | - if (out == &h->urb_in) { 77 | + if (out == h->urb_in) { 78 | D("[ reap urb - IN complete ]"); 79 | h->urb_in_busy = false; 80 | if (urb->status != 0) { 81 | @@ -396,7 +396,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { 82 | } 83 | return urb->actual_length; 84 | } 85 | - if (out == &h->urb_out) { 86 | + if (out == h->urb_out) { 87 | D("[ reap urb - OUT compelete ]"); 88 | h->urb_out_busy = false; 89 | h->cv.notify_all(); 90 | @@ -500,10 +500,10 @@ void usb_kick(usb_handle* h) { 91 | ** but this ensures that a reader blocked on REAPURB 92 | ** will get unblocked 93 | */ 94 | - ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_in); 95 | - ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_out); 96 | - h->urb_in.status = -ENODEV; 97 | - h->urb_out.status = -ENODEV; 98 | + ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_in); 99 | + ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_out); 100 | + h->urb_in->status = -ENODEV; 101 | + h->urb_out->status = -ENODEV; 102 | h->urb_in_busy = false; 103 | h->urb_out_busy = false; 104 | h->cv.notify_all(); 105 | @@ -519,6 +519,8 @@ int usb_close(usb_handle* h) { 106 | 107 | D("-- usb close %p (fd = %d) --", h, h->fd); 108 | 109 | + delete h->urb_in; 110 | + delete h->urb_out; 111 | delete h; 112 | 113 | return 0; 114 | @@ -572,6 +574,8 @@ static void register_device(const char* dev_name, const char* dev_path, unsigned 115 | usb->ep_out = ep_out; 116 | usb->zero_mask = zero_mask; 117 | usb->max_packet_size = max_packet_size; 118 | + usb->urb_in = new usbdevfs_urb; 119 | + usb->urb_out = new usbdevfs_urb; 120 | 121 | // Initialize mark so we don't get garbage collected after the device scan. 122 | usb->mark = true; 123 | -- 124 | 2.38.0 125 | 126 | -------------------------------------------------------------------------------- /patches/adb/0026-Drop-compile-static-check.patch: -------------------------------------------------------------------------------- 1 | From 4c9629c66710d7ed4ec684f231406dd54c91ef98 Mon Sep 17 00:00:00 2001 2 | From: Anatol Pomozov 3 | Date: Tue, 19 Mar 2024 16:46:39 -0700 4 | Subject: [PATCH] Drop compile static check 5 | 6 | This static check does not work well with libstdc++. It is not entirely 7 | clear if this check error is valid or just clang being too strict. 8 | 9 | See https://github.com/nmeum/android-tools/pull/132#issuecomment-1949786658 10 | --- 11 | types.h | 1 - 12 | 1 file changed, 1 deletion(-) 13 | 14 | diff --git a/types.h b/types.h 15 | index 2865969f..6335d16f 100644 16 | --- a/types.h 17 | +++ b/types.h 18 | @@ -232,7 +232,6 @@ struct IOVector { 19 | 20 | size_t offset = 0; 21 | iterate_blocks([&offset, &result](const char* data, size_t len) { 22 | - static_assert(std::is_standard_layout()); 23 | memcpy(&result[offset], data, len); 24 | offset += len; 25 | }); 26 | -- 27 | 2.44.0 28 | 29 | -------------------------------------------------------------------------------- /patches/boringssl/0001-boringssl-Add support for loongarch.patch: -------------------------------------------------------------------------------- 1 | From 9c18fe1eeef6ce09c027abaa5355efab449fce4c Mon Sep 17 00:00:00 2001 2 | From: wuruilong 3 | Date: Thu, 4 Jul 2024 12:32:15 +0000 4 | Subject: [PATCH] Add support for loongarch 5 | 6 | --- 7 | crypto/fipsmodule/rand/getrandom_fillin.h | 2 ++ 8 | include/openssl/target.h | 3 +++ 9 | 2 files changed, 5 insertions(+) 10 | 11 | diff --git a/crypto/fipsmodule/rand/getrandom_fillin.h b/crypto/fipsmodule/rand/getrandom_fillin.h 12 | index 0f290e9637..3eac6d2f8f 100644 13 | --- a/crypto/fipsmodule/rand/getrandom_fillin.h 14 | +++ b/crypto/fipsmodule/rand/getrandom_fillin.h 15 | @@ -30,6 +30,8 @@ 16 | #define EXPECTED_NR_getrandom 278 17 | #elif defined(OPENSSL_ARM) 18 | #define EXPECTED_NR_getrandom 384 19 | +#elif defined(OPENSSL_LOONG64) 20 | +#define EXPECTED_NR_getrandom 278 21 | #elif defined(OPENSSL_RISCV64) 22 | #define EXPECTED_NR_getrandom 278 23 | #endif 24 | diff --git a/include/openssl/target.h b/include/openssl/target.h 25 | index 2760f52ce8..bc944d2b9c 100644 26 | --- a/include/openssl/target.h 27 | +++ b/include/openssl/target.h 28 | @@ -34,6 +34,9 @@ 29 | #elif defined(__ARMEL__) || defined(_M_ARM) 30 | #define OPENSSL_32_BIT 31 | #define OPENSSL_ARM 32 | +#elif defined(__loongarch64) 33 | +#define OPENSSL_64_BIT 34 | +#define OPENSSL_LOONG64 35 | #elif defined(__MIPSEL__) && !defined(__LP64__) 36 | #define OPENSSL_32_BIT 37 | #define OPENSSL_MIPS 38 | -------------------------------------------------------------------------------- /patches/boringssl/0001-boringssl-Workaround-compiler-error-with-gcc-14-and-.patch: -------------------------------------------------------------------------------- 1 | From 81759a376a14b910b0dcc5d3e07934522fe523ed Mon Sep 17 00:00:00 2001 2 | From: Biswapriyo Nath 3 | Date: Wed, 24 Apr 2024 17:40:51 +0000 4 | Subject: [PATCH] boringssl: Workaround compiler error with gcc-14 and _Generic 5 | 6 | This workarounds the following compiler error: 7 | 8 | internal.h: In function 'uint32_t CRYPTO_addc_u32(uint32_t, uint32_t, uint32_t, uint32_t*)': 9 | internal.h:1151:7: error: expected primary-expression before 'unsigned' 10 | 1151 | unsigned: __builtin_addc, \ 11 | | ^~~~~~~~ 12 | internal.h:1158:10: note: in expansion of macro 'CRYPTO_GENERIC_ADDC' 13 | 1158 | return CRYPTO_GENERIC_ADDC(x, y, carry, out_carry); 14 | | ^~~~~~~~~~~~~~~~~~~ 15 | --- 16 | crypto/internal.h | 4 ++-- 17 | 1 file changed, 2 insertions(+), 2 deletions(-) 18 | 19 | diff --git a/crypto/internal.h b/crypto/internal.h 20 | index e9da01065..68dc75ef8 100644 21 | --- a/crypto/internal.h 22 | +++ b/crypto/internal.h 23 | @@ -1144,7 +1144,7 @@ static inline uint64_t CRYPTO_rotr_u64(uint64_t value, int shift) { 24 | 25 | // CRYPTO_addc_* returns |x + y + carry|, and sets |*out_carry| to the carry 26 | // bit. |carry| must be zero or one. 27 | -#if OPENSSL_HAS_BUILTIN(__builtin_addc) 28 | +#if OPENSSL_HAS_BUILTIN(__builtin_addc) && (!defined(__GNUC__) || (defined(__GNUC__) && (__GNUC__ < 14))) 29 | 30 | #define CRYPTO_GENERIC_ADDC(x, y, carry, out_carry) \ 31 | (_Generic((x), \ 32 | @@ -1196,7 +1196,7 @@ static inline uint64_t CRYPTO_addc_u64(uint64_t x, uint64_t y, uint64_t carry, 33 | 34 | // CRYPTO_subc_* returns |x - y - borrow|, and sets |*out_borrow| to the borrow 35 | // bit. |borrow| must be zero or one. 36 | -#if OPENSSL_HAS_BUILTIN(__builtin_subc) 37 | +#if OPENSSL_HAS_BUILTIN(__builtin_subc) && (!defined(__GNUC__) || (defined(__GNUC__) && (__GNUC__ < 14))) 38 | 39 | #define CRYPTO_GENERIC_SUBC(x, y, borrow, out_borrow) \ 40 | (_Generic((x), \ 41 | -- 42 | 2.44.0 43 | 44 | -------------------------------------------------------------------------------- /patches/boringssl/0012-CMakeLists.txt-Disable-Werror-by-default.patch: -------------------------------------------------------------------------------- 1 | From 9ecab80323875e95b08b5e6f327e4d5bd5d70478 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Sat, 21 May 2022 11:47:32 +0200 4 | Subject: [PATCH] CMakeLists.txt: Disable -Werror by default 5 | 6 | Boringssl regularly fails to compile with newer GCC versions due 7 | to new warnings introduced by GCC upstream. 8 | 9 | --- 10 | CMakeLists.txt | 2 +- 11 | 1 file changed, 1 insertion(+), 1 deletion(-) 12 | 13 | diff --git a/CMakeLists.txt b/CMakeLists.txt 14 | index 1529526b..a393b7d7 100644 15 | --- a/CMakeLists.txt 16 | +++ b/CMakeLists.txt 17 | @@ -139,7 +139,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON) 18 | if(CMAKE_COMPILER_IS_GNUCXX OR CLANG) 19 | # Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration 20 | # primarily on our normal Clang one. 21 | - set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wwrite-strings -Wvla -Wshadow -Wtype-limits -Wmissing-field-initializers") 22 | + set(C_CXX_FLAGS "-Wformat=2 -Wsign-compare -Wwrite-strings -Wvla -Wshadow -Wtype-limits -Wmissing-field-initializers") 23 | if(MSVC) 24 | # clang-cl sets different default warnings than clang. It also treats -Wall 25 | # as -Weverything, to match MSVC. Instead -W3 is the alias for -Wall. 26 | -------------------------------------------------------------------------------- /patches/core/0001-Fix-inclusion-of-stdatomic.h-with-g.patch: -------------------------------------------------------------------------------- 1 | From 448fa2a3c470ff3a58135458fb34d33732600f67 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Tue, 27 Feb 2018 16:30:30 +0100 4 | Subject: [PATCH] Fix inclusion of stdatomic.h with g++ 5 | 6 | See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932#c5 7 | --- 8 | libcutils/include/cutils/atomic.h | 6 ++++++ 9 | libcutils/include/cutils/trace.h | 5 +++++ 10 | 2 files changed, 11 insertions(+) 11 | 12 | diff --git a/libcutils/include/cutils/atomic.h b/libcutils/include/cutils/atomic.h 13 | index 0c88bfedd..84606e307 100644 14 | --- a/libcutils/include/cutils/atomic.h 15 | +++ b/libcutils/include/cutils/atomic.h 16 | @@ -19,7 +19,13 @@ 17 | 18 | #include 19 | #include 20 | + 21 | +#ifdef __cplusplus 22 | +#include 23 | +using namespace std; 24 | +#else 25 | #include 26 | +#endif 27 | 28 | #ifndef ANDROID_ATOMIC_INLINE 29 | #define ANDROID_ATOMIC_INLINE static inline 30 | diff --git a/libcutils/include/cutils/trace.h b/libcutils/include/cutils/trace.h 31 | index ef426ff7b..f7d7ccc3c 100644 32 | --- a/libcutils/include/cutils/trace.h 33 | +++ b/libcutils/include/cutils/trace.h 34 | @@ -18,7 +18,12 @@ 35 | #define _LIBS_CUTILS_TRACE_H 36 | 37 | #include 38 | +#ifdef __cplusplus 39 | +#include 40 | +using namespace std; 41 | +#else 42 | #include 43 | +#endif 44 | #include 45 | #include 46 | #include 47 | -------------------------------------------------------------------------------- /patches/core/0004-fastboot-make-mke2fs_path-configurable.patch: -------------------------------------------------------------------------------- 1 | From 461112433a5e9714fbf3efe668ea42873f84cc98 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Mon, 18 Jun 2018 23:25:14 +0200 4 | Subject: [PATCH] fastboot: make mke2fs_path configurable 5 | 6 | fastboot isn't compatible with the vanilla mke2fs from e2fsprogs. 7 | 8 | See: https://bugs.archlinux.org/task/56955 9 | --- 10 | fastboot/fs.cpp | 2 +- 11 | 1 file changed, 1 insertion(+), 1 deletion(-) 12 | 13 | diff --git a/fastboot/fs.cpp b/fastboot/fs.cpp 14 | index 458a7a184..c59ed0e97 100644 15 | --- a/fastboot/fs.cpp 16 | +++ b/fastboot/fs.cpp 17 | @@ -117,7 +117,7 @@ static int generate_ext4_image(const char* fileName, long long partSize, 18 | static constexpr int block_size = 4096; 19 | const std::string exec_dir = android::base::GetExecutableDirectory(); 20 | 21 | - const std::string mke2fs_path = exec_dir + "/mke2fs"; 22 | + const std::string mke2fs_path = exec_dir + "/" + ANDROID_MKE2FS_NAME; 23 | std::vector mke2fs_args = {mke2fs_path.c_str(), "-t", "ext4", "-b"}; 24 | 25 | std::string block_size_str = std::to_string(block_size); 26 | -------------------------------------------------------------------------------- /patches/core/0009-Don-t-use-the-internal-glibc-header-sys-cdefs.h.patch: -------------------------------------------------------------------------------- 1 | From 49a3dad208220b35ca7d81b7ea7f053801ada9dd Mon Sep 17 00:00:00 2001 2 | From: John Zimmermann 3 | Date: Thu, 18 Mar 2021 12:22:51 +0100 4 | Subject: [PATCH] Don't use the internal glibc header sys/cdefs.h 5 | 6 | for file in $(ag -l '__BEGIN_DECLS|sys/cdefs.h'); do 7 | sed -i "${file}" \ 8 | -e 's/__BEGIN_DECLS/#ifdef __cplusplus\nextern "C" {\n#endif/g' \ 9 | -e 's/__END_DECLS/#ifdef __cplusplus\n}\n#endif/g' \ 10 | -e '/#include /d' 11 | done 12 | 13 | https://wiki.musl-libc.org/faq.html#Q:-When-compiling-something-against-musl,-I-get-error-messages-about-%3Ccode%3Esys/cdefs.h%3C/code%3E 14 | --- 15 | debuggerd/include/debuggerd/client.h | 1 - 16 | debuggerd/include/debuggerd/handler.h | 9 +++++--- 17 | debuggerd/util.h | 1 - 18 | fs_mgr/fs_mgr_priv_boot_config.h | 1 - 19 | init/keychords.cpp | 1 - 20 | init/reboot.cpp | 1 - 21 | libasyncio/include/asyncio/AsyncIO.h | 1 - 22 | libcutils/android_get_control_env.h | 9 +++++--- 23 | libcutils/include/cutils/android_reboot.h | 9 +++++--- 24 | libcutils/include/cutils/bitops.h | 9 +++++--- 25 | libcutils/include/cutils/klog.h | 9 +++++--- 26 | libcutils/include/cutils/partition_utils.h | 9 +++++--- 27 | libcutils/include/cutils/properties.h | 1 - 28 | libcutils/include/cutils/str_parms.h | 9 +++++--- 29 | libcutils/include/cutils/trace.h | 9 +++++--- 30 | libcutils/include/private/canned_fs_config.h | 9 +++++--- 31 | libcutils/include/private/fs_config.h | 9 +++++--- 32 | libkeyutils/include/keyutils.h | 9 +++++--- 33 | libnetutils/include/netutils/ifc.h | 9 +++++--- 34 | .../packagelistparser/packagelistparser.h | 8 +++++-- 35 | libprocessgroup/cgroup_map.h | 1 - 36 | .../cgrouprc/include/android/cgrouprc.h | 8 +++++-- 37 | .../include/processgroup/processgroup.h | 9 +++++--- 38 | libprocessgroup/task_profiles.h | 1 - 39 | libsuspend/autosuspend_ops.h | 8 +++++-- 40 | libsuspend/include/suspend/autosuspend.h | 9 +++++--- 41 | libsync/include/android/sync.h | 8 +++++-- 42 | libsync/include/ndk/sync.h | 9 +++++--- 43 | libsync/sw_sync.h | 8 +++++-- 44 | libsystem/include/system/camera.h | 9 +++++--- 45 | libsystem/include/system/radio.h | 1 - 46 | libutils/Singleton_test.h | 9 +++++--- 47 | llkd/include/llkd.h | 21 +++++++++++++------ 48 | llkd/libllkd.cpp | 1 - 49 | trusty/gatekeeper/trusty_gatekeeper_ipc.h | 8 +++++-- 50 | .../ipc/trusty_keymaster_ipc.h | 8 +++++-- 51 | .../storage/lib/include/trusty/lib/storage.h | 8 +++++-- 52 | 37 files changed, 165 insertions(+), 84 deletions(-) 53 | 54 | diff --git a/debuggerd/include/debuggerd/client.h b/debuggerd/include/debuggerd/client.h 55 | index b7284b08ec..b85b6e542e 100644 56 | --- a/debuggerd/include/debuggerd/client.h 57 | +++ b/debuggerd/include/debuggerd/client.h 58 | @@ -17,7 +17,6 @@ 59 | #pragma once 60 | 61 | #include 62 | -#include 63 | #include 64 | 65 | #include 66 | diff --git a/debuggerd/include/debuggerd/handler.h b/debuggerd/include/debuggerd/handler.h 67 | index ebb5372..07e3c1e 100644 68 | --- a/debuggerd/include/debuggerd/handler.h 69 | +++ b/debuggerd/include/debuggerd/handler.h 70 | @@ -20,11 +20,12 @@ 71 | #include 72 | #include 73 | #include 74 | -#include 75 | #include 76 | #include 77 | 78 | -__BEGIN_DECLS 79 | +#ifdef __cplusplus 80 | +extern "C" { 81 | +#endif 82 | 83 | // Forward declare these classes so not everyone has to include GWP-ASan 84 | // headers. 85 | @@ -94,4 +95,6 @@ static void __attribute__((__unused__)) debuggerd_register_handlers(struct sigac 86 | sigaction(BIONIC_SIGNAL_DEBUGGER, action, nullptr); 87 | } 88 | 89 | -__END_DECLS 90 | +#ifdef __cplusplus 91 | +} 92 | +#endif 93 | diff --git a/debuggerd/util.h b/debuggerd/util.h 94 | index 4375870..58c0816 100644 95 | --- a/debuggerd/util.h 96 | +++ b/debuggerd/util.h 97 | @@ -20,7 +20,6 @@ 98 | #include 99 | #include 100 | 101 | -#include 102 | #include 103 | 104 | std::vector get_command_line(pid_t pid); 105 | diff --git a/init/keychords.cpp b/init/keychords.cpp 106 | index adec383..40e8524 100644 107 | --- a/init/keychords.cpp 108 | +++ b/init/keychords.cpp 109 | @@ -19,7 +19,6 @@ 110 | #include 111 | #include 112 | #include 113 | -#include 114 | #include 115 | #include 116 | #include 117 | diff --git a/init/reboot.cpp b/init/reboot.cpp 118 | index 3351c4c..3bf4518 100644 119 | --- a/init/reboot.cpp 120 | +++ b/init/reboot.cpp 121 | @@ -24,7 +24,6 @@ 122 | #include 123 | #include 124 | #include 125 | -#include 126 | #include 127 | #include 128 | #include 129 | diff --git a/libasyncio/include/asyncio/AsyncIO.h b/libasyncio/include/asyncio/AsyncIO.h 130 | index 9620d2a..005fc66 100644 131 | --- a/libasyncio/include/asyncio/AsyncIO.h 132 | +++ b/libasyncio/include/asyncio/AsyncIO.h 133 | @@ -20,7 +20,6 @@ 134 | #include 135 | #include 136 | #include 137 | -#include 138 | #include 139 | #include 140 | #include 141 | diff --git a/libcutils/android_get_control_env.h b/libcutils/android_get_control_env.h 142 | index a830269..40edc2d 100644 143 | --- a/libcutils/android_get_control_env.h 144 | +++ b/libcutils/android_get_control_env.h 145 | @@ -16,11 +16,14 @@ 146 | 147 | #pragma once 148 | 149 | -#include 150 | 151 | -__BEGIN_DECLS 152 | +#ifdef __cplusplus 153 | +extern "C" { 154 | +#endif 155 | 156 | int __android_get_control_from_env(const char* prefix, const char* name) 157 | __attribute__((visibility("hidden"))); 158 | 159 | -__END_DECLS 160 | +#ifdef __cplusplus 161 | +} 162 | +#endif 163 | diff --git a/libcutils/include/cutils/android_reboot.h b/libcutils/include/cutils/android_reboot.h 164 | index 24e32d5..56a31bc 100644 165 | --- a/libcutils/include/cutils/android_reboot.h 166 | +++ b/libcutils/include/cutils/android_reboot.h 167 | @@ -16,9 +16,10 @@ 168 | 169 | #pragma once 170 | 171 | -#include 172 | 173 | -__BEGIN_DECLS 174 | +#ifdef __cplusplus 175 | +extern "C" { 176 | +#endif 177 | 178 | /* Commands */ 179 | #define ANDROID_RB_RESTART 0xDEAD0001 /* deprecated. Use RESTART2. */ 180 | @@ -40,4 +41,6 @@ __BEGIN_DECLS 181 | */ 182 | int android_reboot(unsigned cmd, int flags, const char* arg); 183 | 184 | -__END_DECLS 185 | +#ifdef __cplusplus 186 | +} 187 | +#endif 188 | diff --git a/libcutils/include/cutils/bitops.h b/libcutils/include/cutils/bitops.h 189 | index 38d2840..79193b5 100644 190 | --- a/libcutils/include/cutils/bitops.h 191 | +++ b/libcutils/include/cutils/bitops.h 192 | @@ -20,9 +20,10 @@ 193 | #include 194 | #include 195 | #include 196 | -#include 197 | 198 | -__BEGIN_DECLS 199 | +#ifdef __cplusplus 200 | +extern "C" { 201 | +#endif 202 | 203 | static inline int popcount(unsigned int x) { 204 | return __builtin_popcount(x); 205 | @@ -36,6 +37,8 @@ static inline int popcountll(unsigned long long x) { 206 | return __builtin_popcountll(x); 207 | } 208 | 209 | -__END_DECLS 210 | +#ifdef __cplusplus 211 | +} 212 | +#endif 213 | 214 | #endif /* __CUTILS_BITOPS_H */ 215 | diff --git a/libcutils/include/cutils/klog.h b/libcutils/include/cutils/klog.h 216 | index 5ae6216..8006be7 100644 217 | --- a/libcutils/include/cutils/klog.h 218 | +++ b/libcutils/include/cutils/klog.h 219 | @@ -17,11 +17,12 @@ 220 | #ifndef _CUTILS_KLOG_H_ 221 | #define _CUTILS_KLOG_H_ 222 | 223 | -#include 224 | #include 225 | #include 226 | 227 | -__BEGIN_DECLS 228 | +#ifdef __cplusplus 229 | +extern "C" { 230 | +#endif 231 | 232 | void klog_set_level(int level); 233 | 234 | @@ -29,7 +30,9 @@ void klog_write(int level, const char *fmt, ...) 235 | __attribute__ ((format(printf, 2, 3))); 236 | void klog_writev(int level, const struct iovec* iov, int iov_count); 237 | 238 | -__END_DECLS 239 | +#ifdef __cplusplus 240 | +} 241 | +#endif 242 | 243 | #define KLOG_ERROR_LEVEL 3 244 | #define KLOG_WARNING_LEVEL 4 245 | diff --git a/libcutils/include/cutils/partition_utils.h b/libcutils/include/cutils/partition_utils.h 246 | index 8bc9b48..ff1d13a 100644 247 | --- a/libcutils/include/cutils/partition_utils.h 248 | +++ b/libcutils/include/cutils/partition_utils.h 249 | @@ -17,12 +17,15 @@ 250 | #ifndef __CUTILS_PARTITION_WIPED_H__ 251 | #define __CUTILS_PARTITION_WIPED_H__ 252 | 253 | -#include 254 | 255 | -__BEGIN_DECLS 256 | +#ifdef __cplusplus 257 | +extern "C" { 258 | +#endif 259 | 260 | int partition_wiped(const char* source); 261 | 262 | -__END_DECLS 263 | +#ifdef __cplusplus 264 | +} 265 | +#endif 266 | 267 | #endif /* __CUTILS_PARTITION_WIPED_H__ */ 268 | diff --git a/libcutils/include/cutils/properties.h b/libcutils/include/cutils/properties.h 269 | index 78d8bc6..9f87212 100644 270 | --- a/libcutils/include/cutils/properties.h 271 | +++ b/libcutils/include/cutils/properties.h 272 | @@ -16,7 +16,6 @@ 273 | 274 | #pragma once 275 | 276 | -#include 277 | #include 278 | #include 279 | 280 | diff --git a/libcutils/include/cutils/str_parms.h b/libcutils/include/cutils/str_parms.h 281 | index aa1435a..160792a 100644 282 | --- a/libcutils/include/cutils/str_parms.h 283 | +++ b/libcutils/include/cutils/str_parms.h 284 | @@ -18,9 +18,10 @@ 285 | #define __CUTILS_STR_PARMS_H 286 | 287 | #include 288 | -#include 289 | 290 | -__BEGIN_DECLS 291 | +#ifdef __cplusplus 292 | +extern "C" { 293 | +#endif 294 | 295 | struct str_parms; 296 | 297 | @@ -55,6 +56,8 @@ char *str_parms_to_str(struct str_parms *str_parms); 298 | /* debug */ 299 | void str_parms_dump(struct str_parms *str_parms); 300 | 301 | -__END_DECLS 302 | +#ifdef __cplusplus 303 | +} 304 | +#endif 305 | 306 | #endif /* __CUTILS_STR_PARMS_H */ 307 | diff --git a/libcutils/include/cutils/trace.h b/libcutils/include/cutils/trace.h 308 | index 7f57637..def5aeb 100644 309 | --- a/libcutils/include/cutils/trace.h 310 | +++ b/libcutils/include/cutils/trace.h 311 | @@ -22,12 +22,13 @@ 312 | #include 313 | #include 314 | #include 315 | -#include 316 | #include 317 | #include 318 | #include 319 | 320 | -__BEGIN_DECLS 321 | +#ifdef __cplusplus 322 | +extern "C" { 323 | +#endif 324 | 325 | /** 326 | * The ATRACE_TAG macro can be defined before including this header to trace 327 | @@ -320,6 +321,8 @@ static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) 328 | } 329 | } 330 | 331 | -__END_DECLS 332 | +#ifdef __cplusplus 333 | +} 334 | +#endif 335 | 336 | #endif // _LIBS_CUTILS_TRACE_H 337 | diff --git a/libcutils/include/private/canned_fs_config.h b/libcutils/include/private/canned_fs_config.h 338 | index ad4de4c..caf4b61 100644 339 | --- a/libcutils/include/private/canned_fs_config.h 340 | +++ b/libcutils/include/private/canned_fs_config.h 341 | @@ -17,12 +17,15 @@ 342 | #pragma once 343 | 344 | #include 345 | -#include 346 | 347 | -__BEGIN_DECLS 348 | +#ifdef __cplusplus 349 | +extern "C" { 350 | +#endif 351 | 352 | int load_canned_fs_config(const char* fn); 353 | void canned_fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, 354 | unsigned* gid, unsigned* mode, uint64_t* capabilities); 355 | 356 | -__END_DECLS 357 | +#ifdef __cplusplus 358 | +} 359 | +#endif 360 | diff --git a/libcutils/include/private/fs_config.h b/libcutils/include/private/fs_config.h 361 | index 45f46e5..b4ceade 100644 362 | --- a/libcutils/include/private/fs_config.h 363 | +++ b/libcutils/include/private/fs_config.h 364 | @@ -24,14 +24,15 @@ 365 | #include 366 | #include 367 | #include 368 | -#include 369 | #include 370 | 371 | #include 372 | 373 | /* Rules for directories and files has moved to system/code/libcutils/fs_config.c */ 374 | 375 | -__BEGIN_DECLS 376 | +#ifdef __cplusplus 377 | +extern "C" { 378 | +#endif 379 | 380 | /* This API is deprecated. New users should call get_fs_config. */ 381 | void fs_config(const char* path, int dir, const char* target_out_path, unsigned* uid, unsigned* gid, 382 | @@ -56,4 +57,6 @@ struct fs_config { 383 | bool get_fs_config(const char* path, bool dir, const char* target_out_path, 384 | struct fs_config* conf); 385 | 386 | -__END_DECLS 387 | +#ifdef __cplusplus 388 | +} 389 | +#endif 390 | diff --git a/libkeyutils/include/keyutils.h b/libkeyutils/include/keyutils.h 391 | index c508f27..2c3b4b0 100644 392 | --- a/libkeyutils/include/keyutils.h 393 | +++ b/libkeyutils/include/keyutils.h 394 | @@ -31,9 +31,10 @@ 395 | 396 | #include 397 | #include 398 | -#include 399 | 400 | -__BEGIN_DECLS 401 | +#ifdef __cplusplus 402 | +extern "C" { 403 | +#endif 404 | 405 | typedef int32_t key_serial_t; 406 | 407 | @@ -55,6 +56,8 @@ long keyctl_restrict_keyring(key_serial_t keyring, const char* type, const char* 408 | 409 | long keyctl_get_security(key_serial_t key, char* buffer, size_t buflen); 410 | 411 | -__END_DECLS 412 | +#ifdef __cplusplus 413 | +} 414 | +#endif 415 | 416 | #endif 417 | diff --git a/libnetutils/include/netutils/ifc.h b/libnetutils/include/netutils/ifc.h 418 | index ee896ac..3816f33 100644 419 | --- a/libnetutils/include/netutils/ifc.h 420 | +++ b/libnetutils/include/netutils/ifc.h 421 | @@ -19,9 +19,10 @@ 422 | 423 | #include 424 | #include 425 | -#include 426 | 427 | -__BEGIN_DECLS 428 | +#ifdef __cplusplus 429 | +extern "C" { 430 | +#endif 431 | 432 | extern int ifc_init(void); 433 | extern void ifc_close(void); 434 | @@ -64,6 +65,8 @@ extern int ifc_configure(const char *ifname, in_addr_t address, 435 | 436 | extern in_addr_t prefixLengthToIpv4Netmask(int prefix_length); 437 | 438 | -__END_DECLS 439 | +#ifdef __cplusplus 440 | +} 441 | +#endif 442 | 443 | #endif /* _NETUTILS_IFC_H_ */ 444 | diff --git a/libpackagelistparser/include/packagelistparser/packagelistparser.h b/libpackagelistparser/include/packagelistparser/packagelistparser.h 445 | index e89cb54..86b6604 100644 446 | --- a/libpackagelistparser/include/packagelistparser/packagelistparser.h 447 | +++ b/libpackagelistparser/include/packagelistparser/packagelistparser.h 448 | @@ -19,7 +19,9 @@ 449 | #include 450 | #include 451 | 452 | -__BEGIN_DECLS 453 | +#ifdef __cplusplus 454 | +extern "C" { 455 | +#endif 456 | 457 | typedef struct gid_list { 458 | /** Number of gids. */ 459 | @@ -78,4 +80,6 @@ bool packagelist_parse_file(const char* path, bool (*callback)(pkg_info* info, v 460 | /** Frees the given `pkg_info`. */ 461 | void packagelist_free(pkg_info* info); 462 | 463 | -__END_DECLS 464 | +#ifdef __cplusplus 465 | +} 466 | +#endif 467 | diff --git a/libprocessgroup/cgrouprc/include/android/cgrouprc.h b/libprocessgroup/cgrouprc/include/android/cgrouprc.h 468 | index e704a36..e65aa4a 100644 469 | --- a/libprocessgroup/cgrouprc/include/android/cgrouprc.h 470 | +++ b/libprocessgroup/cgrouprc/include/android/cgrouprc.h 471 | @@ -16,10 +16,11 @@ 472 | 473 | #pragma once 474 | 475 | -#include 476 | #include 477 | 478 | -__BEGIN_DECLS 479 | +#ifdef __cplusplus 480 | +extern "C" { 481 | +#endif 482 | 483 | // For host builds, __INTRODUCED_IN is not defined. 484 | #ifndef __INTRODUCED_IN 485 | @@ -92,4 +93,6 @@ __attribute__((warn_unused_result)) const char* ACgroupController_getName(const 486 | __attribute__((warn_unused_result)) const char* ACgroupController_getPath(const ACgroupController*) 487 | __INTRODUCED_IN(29); 488 | 489 | -__END_DECLS 490 | +#ifdef __cplusplus 491 | +} 492 | +#endif 493 | diff --git a/libprocessgroup/include/processgroup/processgroup.h b/libprocessgroup/include/processgroup/processgroup.h 494 | index dbaeb93..0cc119c 100644 495 | --- a/libprocessgroup/include/processgroup/processgroup.h 496 | +++ b/libprocessgroup/include/processgroup/processgroup.h 497 | @@ -16,7 +16,6 @@ 498 | 499 | #pragma once 500 | 501 | -#include 502 | #include 503 | #include 504 | #include 505 | @@ -24,7 +23,9 @@ 506 | #include 507 | #include 508 | 509 | -__BEGIN_DECLS 510 | +#ifdef __cplusplus 511 | +extern "C" { 512 | +#endif 513 | 514 | static constexpr const char* CGROUPV2_HIERARCHY_NAME = "cgroup2"; 515 | [[deprecated]] static constexpr const char* CGROUPV2_CONTROLLER_NAME = "cgroup2"; 516 | @@ -40,7 +41,9 @@ bool SetTaskProfiles(pid_t tid, const std::vector& profiles, 517 | bool SetProcessProfiles(uid_t uid, pid_t pid, const std::vector& profiles); 518 | bool SetUserProfiles(uid_t uid, const std::vector& profiles); 519 | 520 | -__END_DECLS 521 | +#ifdef __cplusplus 522 | +} 523 | +#endif 524 | 525 | bool SetTaskProfiles(pid_t tid, std::initializer_list profiles, 526 | bool use_fd_cache = false); 527 | @@ -49,7 +52,9 @@ bool SetTaskProfiles(int tid, std::span profiles, 528 | bool SetProcessProfiles(uid_t uid, pid_t pid, std::span profiles); 529 | #endif 530 | 531 | -__BEGIN_DECLS 532 | +#ifdef __cplusplus 533 | +extern "C" { 534 | +#endif 535 | 536 | #ifndef __ANDROID_VNDK__ 537 | 538 | @@ -102,4 +107,6 @@ bool isProfileValidForProcess(const std::string& profile_name, int uid, int pid) 539 | 540 | #endif // __ANDROID_VNDK__ 541 | 542 | -__END_DECLS 543 | +#ifdef __cplusplus 544 | +} 545 | +#endif 546 | diff --git a/libstats/push_compat/statsd_writer.h b/libstats/push_compat/statsd_writer.h 547 | index f030b96..ffd38ea 100644 548 | --- a/libstats/push_compat/statsd_writer.h 549 | +++ b/libstats/push_compat/statsd_writer.h 550 | @@ -21,7 +21,9 @@ 551 | #include 552 | #include 553 | 554 | -__BEGIN_DECLS 555 | +#ifdef __cplusplus 556 | +extern "C" { 557 | +#endif 558 | 559 | /** 560 | * Internal lock should not be exposed. This is bad design. 561 | @@ -44,6 +46,8 @@ struct android_log_transport_write { 562 | void (*noteDrop)(int error, int tag); 563 | }; 564 | 565 | -__END_DECLS 566 | +#ifdef __cplusplus 567 | +} 568 | +#endif 569 | 570 | #endif // ANDROID_STATS_LOG_STATS_WRITER_H 571 | diff --git a/libsuspend/autosuspend_ops.h b/libsuspend/autosuspend_ops.h 572 | index b0024c8..ea0eafd 100644 573 | --- a/libsuspend/autosuspend_ops.h 574 | +++ b/libsuspend/autosuspend_ops.h 575 | @@ -24,8 +24,12 @@ struct autosuspend_ops { 576 | void (*set_wakeup_callback)(void (*func)(bool success)); 577 | }; 578 | 579 | -__BEGIN_DECLS 580 | +#ifdef __cplusplus 581 | +extern "C" { 582 | +#endif 583 | struct autosuspend_ops *autosuspend_wakeup_count_init(void); 584 | -__END_DECLS 585 | +#ifdef __cplusplus 586 | +} 587 | +#endif 588 | 589 | #endif 590 | diff --git a/libsuspend/include/suspend/autosuspend.h b/libsuspend/include/suspend/autosuspend.h 591 | index 21f4d61..dbbca16 100644 592 | --- a/libsuspend/include/suspend/autosuspend.h 593 | +++ b/libsuspend/include/suspend/autosuspend.h 594 | @@ -17,10 +17,11 @@ 595 | #ifndef _LIBSUSPEND_AUTOSUSPEND_H_ 596 | #define _LIBSUSPEND_AUTOSUSPEND_H_ 597 | 598 | -#include 599 | #include 600 | 601 | -__BEGIN_DECLS 602 | +#ifdef __cplusplus 603 | +extern "C" { 604 | +#endif 605 | 606 | /* 607 | * autosuspend_enable 608 | @@ -64,6 +65,8 @@ int autosuspend_force_suspend(int timeout_ms); 609 | */ 610 | void autosuspend_set_wakeup_callback(void (*func)(bool success)); 611 | 612 | -__END_DECLS 613 | +#ifdef __cplusplus 614 | +} 615 | +#endif 616 | 617 | #endif 618 | diff --git a/libsync/include/android/sync.h b/libsync/include/android/sync.h 619 | index 32bb878..59a8f9f 100644 620 | --- a/libsync/include/android/sync.h 621 | +++ b/libsync/include/android/sync.h 622 | @@ -39,11 +39,15 @@ 623 | 624 | #include "../ndk/sync.h" 625 | 626 | -__BEGIN_DECLS 627 | +#ifdef __cplusplus 628 | +extern "C" { 629 | +#endif 630 | 631 | /* timeout in msecs */ 632 | int sync_wait(int fd, int timeout); 633 | 634 | -__END_DECLS 635 | +#ifdef __cplusplus 636 | +} 637 | +#endif 638 | 639 | #endif /* __SYS_CORE_SYNC_H */ 640 | diff --git a/libsync/include/ndk/sync.h b/libsync/include/ndk/sync.h 641 | index 38ccb68..04c8e07 100644 642 | --- a/libsync/include/ndk/sync.h 643 | +++ b/libsync/include/ndk/sync.h 644 | @@ -27,11 +27,12 @@ 645 | #define ANDROID_SYNC_H 646 | 647 | #include 648 | -#include 649 | 650 | #include 651 | 652 | -__BEGIN_DECLS 653 | +#ifdef __cplusplus 654 | +extern "C" { 655 | +#endif 656 | 657 | /* Fences indicate the status of an asynchronous task. They are initially 658 | * in unsignaled state (0), and make a one-time transition to either signaled 659 | @@ -99,7 +100,9 @@ static inline struct sync_fence_info* sync_get_fence_info(const struct sync_file 660 | */ 661 | void sync_file_info_free(struct sync_file_info* info) __INTRODUCED_IN(26); 662 | 663 | -__END_DECLS 664 | +#ifdef __cplusplus 665 | +} 666 | +#endif 667 | 668 | #endif /* ANDROID_SYNC_H */ 669 | 670 | diff --git a/libsync/sw_sync.h b/libsync/sw_sync.h 671 | index fda1c4c..395c380 100644 672 | --- a/libsync/sw_sync.h 673 | +++ b/libsync/sw_sync.h 674 | @@ -19,7 +19,9 @@ 675 | #ifndef __SYS_CORE_SW_SYNC_H 676 | #define __SYS_CORE_SW_SYNC_H 677 | 678 | -__BEGIN_DECLS 679 | +#ifdef __cplusplus 680 | +extern "C" { 681 | +#endif 682 | 683 | /* 684 | * sw_sync is mainly intended for testing and should not be compiled into 685 | @@ -30,6 +32,8 @@ int sw_sync_timeline_create(void); 686 | int sw_sync_timeline_inc(int fd, unsigned count); 687 | int sw_sync_fence_create(int fd, const char *name, unsigned value); 688 | 689 | -__END_DECLS 690 | +#ifdef __cplusplus 691 | +} 692 | +#endif 693 | 694 | #endif /* __SYS_CORE_SW_SYNC_H */ 695 | diff --git a/libsystem/include/system/camera.h b/libsystem/include/system/camera.h 696 | index 2ca90c3..c42f559 100644 697 | --- a/libsystem/include/system/camera.h 698 | +++ b/libsystem/include/system/camera.h 699 | @@ -18,13 +18,14 @@ 700 | #define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H 701 | 702 | #include 703 | -#include 704 | #include 705 | #include 706 | #include 707 | #include 708 | 709 | -__BEGIN_DECLS 710 | +#ifdef __cplusplus 711 | +extern "C" { 712 | +#endif 713 | 714 | /** 715 | * A set of bit masks for specifying how the received preview frames are 716 | @@ -302,6 +303,8 @@ typedef struct camera_frame_metadata { 717 | camera_face_t *faces; 718 | } camera_frame_metadata_t; 719 | 720 | -__END_DECLS 721 | +#ifdef __cplusplus 722 | +} 723 | +#endif 724 | 725 | #endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ 726 | diff --git a/libsystem/include/system/radio.h b/libsystem/include/system/radio.h 727 | index acf3ea7..dfd254f 100644 728 | --- a/libsystem/include/system/radio.h 729 | +++ b/libsystem/include/system/radio.h 730 | @@ -20,7 +20,6 @@ 731 | #include 732 | #include 733 | #include 734 | -#include 735 | #include 736 | 737 | 738 | diff --git a/libutils/Singleton_test.h b/libutils/Singleton_test.h 739 | index c77d9ff..00bd562 100644 740 | --- a/libutils/Singleton_test.h 741 | +++ b/libutils/Singleton_test.h 742 | @@ -17,7 +17,6 @@ 743 | #ifndef ANDROID_UTILS_SINGLETON_TEST_H 744 | #define ANDROID_UTILS_SINGLETON_TEST_H 745 | 746 | -#include 747 | 748 | #include "Singleton_test.h" 749 | 750 | @@ -27,13 +26,17 @@ struct SingletonTestData : Singleton { 751 | unsigned int contents; 752 | }; 753 | 754 | -__BEGIN_DECLS 755 | +#ifdef __cplusplus 756 | +extern "C" { 757 | +#endif 758 | 759 | unsigned int singletonGetInstanceContents(); 760 | void singletonSetInstanceContents(unsigned int); 761 | bool singletonHasInstance(); 762 | 763 | -__END_DECLS 764 | +#ifdef __cplusplus 765 | +} 766 | +#endif 767 | 768 | } 769 | 770 | diff --git a/libvendorsupport/include/vendorsupport/api_level.h b/libvendorsupport/include/vendorsupport/api_level.h 771 | index 3427bc6..080389d 100644 772 | --- a/libvendorsupport/include/vendorsupport/api_level.h 773 | +++ b/libvendorsupport/include/vendorsupport/api_level.h 774 | @@ -14,9 +14,10 @@ 775 | 776 | #pragma once 777 | 778 | -#include 779 | 780 | -__BEGIN_DECLS 781 | +#ifdef __cplusplus 782 | +extern "C" { 783 | +#endif 784 | 785 | #define __ANDROID_VENDOR_API_MAX__ 1000000 786 | #define __INVALID_API_LEVEL -1 787 | @@ -62,4 +63,6 @@ int AVendorSupport_getSdkApiLevelOf(int vendorApiLevel); 788 | int AVendorSupport_getVendorApiLevel(); 789 | #endif // __ANDROID_VENDOR__ 790 | 791 | -__END_DECLS 792 | +#ifdef __cplusplus 793 | +} 794 | +#endif 795 | diff --git a/llkd/include/llkd.h b/llkd/include/llkd.h 796 | index 0822a3e..a4e3037 100644 797 | --- a/llkd/include/llkd.h 798 | +++ b/llkd/include/llkd.h 799 | @@ -22,9 +22,10 @@ 800 | #endif 801 | 802 | #include 803 | -#include 804 | 805 | -__BEGIN_DECLS 806 | +#ifdef __cplusplus 807 | +extern "C" { 808 | +#endif 809 | 810 | bool llkInit(const char* threadname); /* threadname NULL, not spawned */ 811 | unsigned llkCheckMilliseconds(void); 812 | @@ -63,17 +64,25 @@ unsigned llkCheckMilliseconds(void); 813 | #define LLK_IGNORELIST_STACK_DEFAULT "init,lmkd.llkd,llkd,keystore,keystore2,ueventd,apexd" 814 | /* clang-format on */ 815 | 816 | -__END_DECLS 817 | +#ifdef __cplusplus 818 | +} 819 | +#endif 820 | 821 | #ifdef __cplusplus 822 | -extern "C++" { /* In case this included wrapped with __BEGIN_DECLS */ 823 | +extern "C++" { /* In case this included wrapped with #ifdef __cplusplus 824 | +extern "C" { 825 | +#endif */ 826 | 827 | #include 828 | 829 | -__BEGIN_DECLS 830 | +#ifdef __cplusplus 831 | +extern "C" { 832 | +#endif 833 | /* C++ code allowed to not specify threadname argument for this C linkage */ 834 | bool llkInit(const char* threadname = nullptr); 835 | -__END_DECLS 836 | +#ifdef __cplusplus 837 | +} 838 | +#endif 839 | std::chrono::milliseconds llkCheck(bool checkRunning = false); 840 | 841 | /* clang-format off */ 842 | diff --git a/llkd/libllkd.cpp b/llkd/libllkd.cpp 843 | index 42602e9..ed348bb 100644 844 | --- a/llkd/libllkd.cpp 845 | +++ b/llkd/libllkd.cpp 846 | @@ -25,7 +25,6 @@ 847 | #include 848 | #include 849 | #include 850 | -#include // ___STRING, __predict_true() and _predict_false() 851 | #include // mlockall() 852 | #include 853 | #include // lstat() 854 | diff --git a/trusty/gatekeeper/trusty_gatekeeper_ipc.h b/trusty/gatekeeper/trusty_gatekeeper_ipc.h 855 | index f8de7f8..fa8fd40 100644 856 | --- a/trusty/gatekeeper/trusty_gatekeeper_ipc.h 857 | +++ b/trusty/gatekeeper/trusty_gatekeeper_ipc.h 858 | @@ -14,11 +14,15 @@ 859 | * limitations under the License. 860 | */ 861 | 862 | -__BEGIN_DECLS 863 | +#ifdef __cplusplus 864 | +extern "C" { 865 | +#endif 866 | 867 | int trusty_gatekeeper_connect(); 868 | int trusty_gatekeeper_call(uint32_t cmd, void *in, uint32_t in_size, uint8_t *out, 869 | uint32_t *out_size); 870 | void trusty_gatekeeper_disconnect(); 871 | 872 | -__END_DECLS 873 | +#ifdef __cplusplus 874 | +} 875 | +#endif 876 | diff --git a/trusty/keymaster/include/trusty_keymaster/ipc/trusty_keymaster_ipc.h b/trusty/keymaster/include/trusty_keymaster/ipc/trusty_keymaster_ipc.h 877 | index 16207e6..9a12458 100644 878 | --- a/trusty/keymaster/include/trusty_keymaster/ipc/trusty_keymaster_ipc.h 879 | +++ b/trusty/keymaster/include/trusty_keymaster/ipc/trusty_keymaster_ipc.h 880 | @@ -20,7 +20,9 @@ 881 | #include 882 | #include 883 | 884 | -__BEGIN_DECLS 885 | +#ifdef __cplusplus 886 | +extern "C" { 887 | +#endif 888 | 889 | const uint32_t TRUSTY_KEYMASTER_RECV_BUF_SIZE = 2 * 4096; 890 | const uint32_t TRUSTY_KEYMASTER_SEND_BUF_SIZE = 891 | @@ -35,6 +37,8 @@ keymaster_error_t translate_error(int err); 892 | keymaster_error_t trusty_keymaster_send(uint32_t command, const keymaster::Serializable& req, 893 | keymaster::KeymasterResponse* rsp); 894 | 895 | -__END_DECLS 896 | +#ifdef __cplusplus 897 | +} 898 | +#endif 899 | 900 | #endif // TRUSTY_KEYMASTER_TRUSTY_KEYMASTER_IPC_H_ 901 | diff --git a/trusty/storage/lib/include/trusty/lib/storage.h b/trusty/storage/lib/include/trusty/lib/storage.h 902 | index b8ddf67..6cac875 100644 903 | --- a/trusty/storage/lib/include/trusty/lib/storage.h 904 | +++ b/trusty/storage/lib/include/trusty/lib/storage.h 905 | @@ -21,7 +21,9 @@ 906 | 907 | #define STORAGE_MAX_NAME_LENGTH_BYTES 159 908 | 909 | -__BEGIN_DECLS 910 | +#ifdef __cplusplus 911 | +extern "C" { 912 | +#endif 913 | 914 | typedef uint32_t storage_session_t; 915 | typedef uint64_t file_handle_t; 916 | @@ -151,4 +153,6 @@ int storage_get_file_size(file_handle_t handle, storage_off_t *size); 917 | int storage_end_transaction(storage_session_t session, bool complete); 918 | 919 | 920 | -__END_DECLS 921 | +#ifdef __cplusplus 922 | +} 923 | +#endif 924 | -------------------------------------------------------------------------------- /patches/core/0011-core-include-missing-headers.patch: -------------------------------------------------------------------------------- 1 | From 56cd2b930cf01cf121bb892fc8be6a03d1c5411b Mon Sep 17 00:00:00 2001 2 | From: Biswapriyo Nath 3 | Date: Sat, 25 Feb 2023 15:13:29 +0530 4 | Subject: [PATCH] core include missing headers 5 | 6 | --- 7 | fastboot/super_flash_helper.cpp | 2 ++ 8 | 4 files changed, 6 insertions(+), 1 deletion(-) 9 | 10 | diff --git a/fastboot/super_flash_helper.cpp b/fastboot/super_flash_helper.cpp 11 | index b617ce8..647b26f 100644 12 | --- a/fastboot/super_flash_helper.cpp 13 | +++ b/fastboot/super_flash_helper.cpp 14 | @@ -20,6 +20,8 @@ 15 | 16 | #include "util.h" 17 | 18 | +#include 19 | + 20 | using android::base::borrowed_fd; 21 | using android::base::unique_fd; 22 | using android::fs_mgr::SuperImageExtent; 23 | diff --git a/fastboot/fastboot_driver_interface.h b/fastboot/fastboot_driver_interface.h 24 | index 7cb8a6b..070c8b0 100644 25 | --- a/fastboot/fastboot_driver_interface.h 26 | +++ b/fastboot/fastboot_driver_interface.h 27 | @@ -15,6 +15,8 @@ 28 | // 29 | #pragma once 30 | 31 | +#include 32 | + 33 | #include 34 | 35 | #include "android-base/unique_fd.h" 36 | -- 37 | 2.40.1 38 | 39 | -------------------------------------------------------------------------------- /patches/core/0012-Add-explicit-import-for-algorithm.patch: -------------------------------------------------------------------------------- 1 | From 1f8bbf8c3dd76401b09de9af7e94d6099589a965 Mon Sep 17 00:00:00 2001 2 | From: Christopher Fore 3 | Date: Mon, 20 Nov 2023 15:19:12 -0500 4 | Subject: [PATCH] fs_mgr: IWYU include for std::sort 5 | 6 | GCC 14 starts to no longer include by default, resulting in 7 | it needing to be explicitly declared. 8 | 9 | Test: Recompiled with GCC 14 and succeeded 10 | 11 | Change-Id: Ifc5dd58b7476ba728ae604cd2924cb68fbcab701 12 | Signed-off-by: Christopher Fore 13 | --- 14 | 15 | diff --git a/fs_mgr/liblp/include/liblp/liblp.h b/fs_mgr/liblp/include/liblp/liblp.h 16 | index 04f8987..c42dcdc 100644 17 | --- a/fs_mgr/liblp/include/liblp/liblp.h 18 | +++ b/fs_mgr/liblp/include/liblp/liblp.h 19 | @@ -20,6 +20,7 @@ 20 | #include 21 | #include 22 | 23 | +#include 24 | #include 25 | #include 26 | #include 27 | -------------------------------------------------------------------------------- /patches/extras/0001-Don-t-use-the-internal-glibc-header-sys-cdefs.h.patch: -------------------------------------------------------------------------------- 1 | From 9a9820a2a80277bfb49721c149202285fcb3500d Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Sat, 16 Oct 2021 01:14:17 +0200 4 | Subject: [PATCH] Don't use the internal glibc header sys/cdefs.h 5 | 6 | for file in $(ag -l __BEGIN_DECLS); do 7 | sed -i "${file}" \ 8 | -e 's/__BEGIN_DECLS/#ifdef __cplusplus\nextern "C" {\n#endif/g' \ 9 | -e 's/__END_DECLS/#ifdef __cplusplus\n}\n#endif/g' \ 10 | -e '/#include /d' 11 | done 12 | 13 | https://wiki.musl-libc.org/faq.html#Q:-When-compiling-something-against-musl,-I-get-error-messages-about 14 | --- 15 | .../include/android/file_descriptor_jni.h | 9 ++++++--- 16 | tests/lib/testUtil/include/testUtil.h | 8 ++++++-- 17 | 2 files changed, 12 insertions(+), 5 deletions(-) 18 | 19 | diff --git a/libatrace_rust/benchmark/src/trace_enabler.h b/libatrace_rust/benchmark/src/trace_enabler.h 20 | index 532c590..561ba6a 100644 21 | --- a/libatrace_rust/benchmark/src/trace_enabler.h 22 | +++ b/libatrace_rust/benchmark/src/trace_enabler.h 23 | @@ -16,13 +16,14 @@ 24 | 25 | #pragma once 26 | 27 | -#include 28 | 29 | // A library to enable tracing for benchmarks. 30 | // It only causes ftrace events to be emitted so that we can measure 31 | // performance and is not intended to enable tracing for meaningful results. 32 | 33 | -__BEGIN_DECLS 34 | +#ifdef __cplusplus 35 | +extern "C" { 36 | +#endif 37 | 38 | // Disable tracing for ATRACE_TAG_APP events. 39 | // Terminates the app on error and writes an error message to logd and stderr. 40 | @@ -33,4 +34,6 @@ void disable_app_atrace(); 41 | // Terminates the app on error and writes an error message to logd and stderr. 42 | void enable_atrace_for_single_app(const char* name); 43 | 44 | -__END_DECLS 45 | \ No newline at end of file 46 | +#ifdef __cplusplus 47 | +} 48 | +#endif 49 | \ No newline at end of file 50 | diff --git a/module_ndk_libs/libnativehelper/include/android/file_descriptor_jni.h b/module_ndk_libs/libnativehelper/include/android/file_descriptor_jni.h 51 | index 26529b9..083999d 100644 52 | --- a/module_ndk_libs/libnativehelper/include/android/file_descriptor_jni.h 53 | +++ b/module_ndk_libs/libnativehelper/include/android/file_descriptor_jni.h 54 | @@ -25,7 +25,6 @@ 55 | 56 | #pragma once 57 | 58 | -#include 59 | 60 | #include 61 | 62 | @@ -33,7 +32,9 @@ 63 | #define __INTRODUCED_IN(x) 64 | #endif 65 | 66 | -__BEGIN_DECLS 67 | +#ifdef __cplusplus 68 | +extern "C" { 69 | +#endif 70 | 71 | /** 72 | * Returns a new java.io.FileDescriptor. 73 | @@ -83,6 +84,8 @@ int AFileDescriptor_getFd(JNIEnv* env, jobject fileDescriptor) __INTRODUCED_IN(3 74 | */ 75 | void AFileDescriptor_setFd(JNIEnv* env, jobject fileDescriptor, int fd) __INTRODUCED_IN(31); 76 | 77 | -__END_DECLS 78 | +#ifdef __cplusplus 79 | +} 80 | +#endif 81 | 82 | /** @} */ 83 | diff --git a/tests/lib/testUtil/include/testUtil.h b/tests/lib/testUtil/include/testUtil.h 84 | index 3b75914d..bdef437d 100644 85 | --- a/tests/lib/testUtil/include/testUtil.h 86 | +++ b/tests/lib/testUtil/include/testUtil.h 87 | @@ -22,7 +22,9 @@ 88 | #include 89 | #include 90 | 91 | -__BEGIN_DECLS 92 | +#ifdef __cplusplus 93 | +extern "C" { 94 | +#endif 95 | 96 | // Time Utilities 97 | struct timespec double2ts(double amt); 98 | @@ -64,6 +66,8 @@ uint64_t testXDumpGetOffset(void); 99 | // Command Execution 100 | void testExecCmd(const char *cmd); 101 | 102 | -__END_DECLS 103 | +#ifdef __cplusplus 104 | +} 105 | +#endif 106 | 107 | #endif 108 | -------------------------------------------------------------------------------- /patches/extras/0002-libjsonpbparse-Fix-build-after-protobuf-util-Status-.patch: -------------------------------------------------------------------------------- 1 | From aba6bdbbe26285c5bee14c88a514995e4c0e99d1 Mon Sep 17 00:00:00 2001 2 | From: MoetaYuko 3 | Date: Fri, 10 Dec 2021 17:36:31 +0800 4 | Subject: [PATCH] libjsonpbparse: Fix build after protobuf util::Status 5 | refactorization 6 | 7 | --- 8 | libjsonpb/parse/jsonpb.cpp | 8 ++++++++ 9 | 1 file changed, 8 insertions(+) 10 | 11 | diff --git a/libjsonpb/parse/jsonpb.cpp b/libjsonpb/parse/jsonpb.cpp 12 | index 3a042e7..62d651d 100644 13 | --- a/libjsonpb/parse/jsonpb.cpp 14 | +++ b/libjsonpb/parse/jsonpb.cpp 15 | @@ -48,7 +48,13 @@ ErrorOr MessageToJsonString(const Message& message) { 16 | &json, options); 17 | 18 | if (!status.ok()) { 19 | +#if GOOGLE_PROTOBUF_VERSION < 3016000 20 | + return MakeError(status.error_message().as_string()); 21 | +#elif GOOGLE_PROTOBUF_VERSION < 4022000 22 | + return MakeError(status.message().as_string()); 23 | +#else 24 | return MakeError(std::string(status.message())); 25 | +#endif 26 | } 27 | return ErrorOr(std::move(json)); 28 | } 29 | @@ -61,7 +67,13 @@ ErrorOr JsonStringToMessage(const std::string& content, Message* 30 | std::string binary; 31 | auto status = JsonToBinaryString(resolver.get(), GetTypeUrl(*message), content, &binary); 32 | if (!status.ok()) { 33 | +#if GOOGLE_PROTOBUF_VERSION < 3016000 34 | + return MakeError(status.error_message().as_string()); 35 | +#elif GOOGLE_PROTOBUF_VERSION < 4022000 36 | + return MakeError(status.message().as_string()); 37 | +#else 38 | return MakeError(std::string(status.message())); 39 | +#endif 40 | } 41 | if (!message->ParseFromString(binary)) { 42 | return MakeError("Fail to parse."); 43 | -------------------------------------------------------------------------------- /patches/extras/0003-extras-libjsonpb-Fix-incompatibility-with-protobuf-v.patch: -------------------------------------------------------------------------------- 1 | From 36c605004ae1c75813181ffe4c59907016aaf9e9 Mon Sep 17 00:00:00 2001 2 | From: Biswapriyo Nath 3 | Date: Tue, 22 Apr 2025 15:12:23 +0000 4 | Subject: [PATCH] extras/libjsonpb: Fix incompatibility with protobuf v30 5 | 6 | This commit fixes the following compiler error. 7 | 8 | jsonpb.cpp:36:44: error: invalid operands to binary expression ( 9 | 'basic_string, allocator>' and 10 | 'internal::DescriptorStringView' (aka 'basic_string_view')) 11 | 36 | return std::string(kTypeUrlPrefix) + "/" + message.GetDescriptor()->full_name(); 12 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 13 | 14 | More info here https://protobuf.dev/news/2024-10-02/#descriptor-apis 15 | 16 | Change-Id: I3c76d51dfdfbe013eaa5031e6194bf5edae1be35 17 | --- 18 | libjsonpb/parse/jsonpb.cpp | 2 +- 19 | 1 file changed, 1 insertion(+), 1 deletion(-) 20 | 21 | diff --git a/libjsonpb/parse/jsonpb.cpp b/libjsonpb/parse/jsonpb.cpp 22 | index b342c2b..ebd71bf 100644 23 | --- a/libjsonpb/parse/jsonpb.cpp 24 | +++ b/libjsonpb/parse/jsonpb.cpp 25 | @@ -33,7 +33,7 @@ using google::protobuf::util::TypeResolver; 26 | static constexpr char kTypeUrlPrefix[] = "type.googleapis.com"; 27 | 28 | std::string GetTypeUrl(const Message& message) { 29 | - return std::string(kTypeUrlPrefix) + "/" + message.GetDescriptor()->full_name(); 30 | + return std::string(kTypeUrlPrefix) + "/" + std::string(message.GetDescriptor()->full_name()); 31 | } 32 | 33 | ErrorOr MessageToJsonString(const Message& message) { 34 | -- 35 | 2.49.0 36 | 37 | -------------------------------------------------------------------------------- /patches/libbase/0001-android-base-endian.h-fix-build-on-musl.patch: -------------------------------------------------------------------------------- 1 | From c57c764c290e09eac3b177848a87bf6356f76d18 Mon Sep 17 00:00:00 2001 2 | From: jershell 3 | Date: Tue, 7 Jun 2022 00:29:25 +0300 4 | Subject: [PATCH] android-base/endian.h: fix build on musl 5 | 6 | --- 7 | include/android-base/endian.h | 2 +- 8 | 1 file changed, 1 insertion(+), 1 deletion(-) 9 | 10 | diff --git a/include/android-base/endian.h b/include/android-base/endian.h 11 | index b47494b..ddfe36f 100644 12 | --- a/include/android-base/endian.h 13 | +++ b/include/android-base/endian.h 14 | @@ -25,7 +25,7 @@ 15 | 16 | #include 17 | 18 | -#elif defined(__GLIBC__) || defined(ANDROID_HOST_MUSL) 19 | +#elif defined(__GLIBC__) || defined(ANDROID_HOST_MUSL) || defined(__linux__) 20 | 21 | /* glibc and musl's are like bionic's . */ 22 | #include 23 | -------------------------------------------------------------------------------- /patches/libbase/0002-remove-glibc-internal-headers-cdefs.h.patch: -------------------------------------------------------------------------------- 1 | From 412a557f67209e17d680fae14287acef91a1aaab Mon Sep 17 00:00:00 2001 2 | From: jershell 3 | Date: Mon, 30 May 2022 15:19:59 +0300 4 | Subject: [PATCH] remove glibc internal headers cdefs.h 5 | 6 | --- 7 | include/android-base/endian.h | 2 +- 8 | include/android-base/properties.h | 1 - 9 | 2 files changed, 1 insertion(+), 2 deletions(-) 10 | 11 | diff --git a/include/android-base/endian.h b/include/android-base/endian.h 12 | index b47494b..c29845e 100644 13 | --- a/include/android-base/endian.h 14 | +++ b/include/android-base/endian.h 15 | @@ -19,7 +19,7 @@ 16 | /* A cross-platform equivalent of bionic's . */ 17 | 18 | /* For __BIONIC__ and __GLIBC__ */ 19 | -#include 20 | +#include 21 | 22 | #if defined(__BIONIC__) 23 | 24 | diff --git a/include/android-base/properties.h b/include/android-base/properties.h 25 | index 021f466..53b8ea1 100644 26 | --- a/include/android-base/properties.h 27 | +++ b/include/android-base/properties.h 28 | @@ -16,7 +16,6 @@ 29 | 30 | #pragma once 31 | 32 | -#include 33 | 34 | #include 35 | #include 36 | -------------------------------------------------------------------------------- /patches/libbase/0003-logging.h-only-activate-ostream-warnings-when-clang-.patch: -------------------------------------------------------------------------------- 1 | From 8f57183a68460bca9d57b75c4b394fc3d7b3286c Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= 3 | 4 | Date: Sat, 31 Oct 2020 19:40:34 +0700 5 | Subject: [PATCH] logging.h: only activate ostream warnings when clang is used 6 | 7 | --- 8 | include/android-base/logging.h | 2 ++ 9 | 1 file changed, 2 insertions(+) 10 | 11 | diff --git a/include/android-base/logging.h b/include/android-base/logging.h 12 | index 9064075..239cb2e 100644 13 | --- a/include/android-base/logging.h 14 | +++ b/include/android-base/logging.h 15 | @@ -467,6 +467,7 @@ namespace std { // NOLINT(cert-dcl58-cpp) 16 | // Note: to print the pointer, use "<< static_cast(string_pointer)" instead. 17 | // Note: a not-recommended alternative is to let Clang ignore the warning by adding 18 | // -Wno-user-defined-warnings to CPPFLAGS. 19 | +#ifdef __clang__ 20 | #pragma clang diagnostic push 21 | #pragma clang diagnostic ignored "-Wgcc-compat" 22 | #define OSTREAM_STRING_POINTER_USAGE_WARNING \ 23 | @@ -476,5 +477,6 @@ std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer 24 | return stream << static_cast(string_pointer); 25 | } 26 | #pragma clang diagnostic pop 27 | +#endif /* defined(__clang__) */ 28 | 29 | } // namespace std 30 | -------------------------------------------------------------------------------- /patches/libbase/0004-Don-t-use-thread-safety-annotations-with-gcc.patch: -------------------------------------------------------------------------------- 1 | From cceac8459bda753b1709499f47606d83a47c1452 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= 3 | 4 | Date: Sat, 31 Oct 2020 19:41:43 +0700 5 | Subject: [PATCH] Don't use thread safety annotations with gcc 6 | 7 | These annotations are primarily useful for detecting race conditions in 8 | code. They don't seem to have any runtime effect and are not supported 9 | by gcc. 10 | 11 | See: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html 12 | --- 13 | include/android-base/thread_annotations.h | 4 ++++ 14 | 1 file changed, 4 insertions(+) 15 | 16 | diff --git a/include/android-base/thread_annotations.h b/include/android-base/thread_annotations.h 17 | index 53fe6da..bc62f80 100644 18 | --- a/include/android-base/thread_annotations.h 19 | +++ b/include/android-base/thread_annotations.h 20 | @@ -18,7 +18,11 @@ 21 | 22 | #include 23 | 24 | +#ifdef __clang__ 25 | #define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) 26 | +#else 27 | +#define THREAD_ANNOTATION_ATTRIBUTE__(x) 28 | +#endif 29 | 30 | #define CAPABILITY(x) \ 31 | THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) 32 | -------------------------------------------------------------------------------- /patches/libbase/0006-remove-usage-of-__builtin_available.patch: -------------------------------------------------------------------------------- 1 | From eeed6a8ba037863cf96323ecc57b1368eeaddac3 Mon Sep 17 00:00:00 2001 2 | From: John Zimmermann 3 | Date: Thu, 18 Mar 2021 15:27:47 +0100 4 | Subject: [PATCH] remove usage of __builtin_available 5 | 6 | s/__builtin_available([^\)]*)/false/g 7 | --- 8 | logging.cpp | 18 +++++++++--------- 9 | 1 file changed, 9 insertions(+), 9 deletions(-) 10 | 11 | diff --git a/logging.cpp b/logging.cpp 12 | index d71a261..d07b2fb 100644 13 | --- a/logging.cpp 14 | +++ b/logging.cpp 15 | @@ -213,7 +213,7 @@ static std::recursive_mutex& TagLock() { 16 | static std::string* gDefaultTag; 17 | 18 | void SetDefaultTag(const std::string& tag) { 19 | - if (__builtin_available(android 30, *)) { 20 | + if (false) { 21 | __android_log_set_default_tag(tag.c_str()); 22 | } else { 23 | std::lock_guard lock(TagLock()); 24 | @@ -316,7 +316,7 @@ static void LogdLogChunk(LogId id, LogSeverity severity, const char* tag, const 25 | int32_t lg_id = LogIdTolog_id_t(id); 26 | int32_t priority = LogSeverityToPriority(severity); 27 | 28 | - if (__builtin_available(android 30, *)) { 29 | + if (false) { 30 | __android_log_message log_message = {sizeof(__android_log_message), lg_id, priority, tag, 31 | static_cast(nullptr), 0, message}; 32 | __android_log_logd_logger(&log_message); 33 | @@ -398,7 +398,7 @@ LogFunction SetLogger(LogFunction&& logger) { 34 | LogFunction old_logger = std::move(Logger()); 35 | Logger() = std::move(logger); 36 | 37 | - if (__builtin_available(android 30, *)) { 38 | + if (false) { 39 | __android_log_set_logger([](const struct __android_log_message* log_message) { 40 | auto log_id = log_id_tToLogId(log_message->buffer_id); 41 | auto severity = PriorityToLogSeverity(log_message->priority); 42 | @@ -414,7 +414,7 @@ AbortFunction SetAborter(AbortFunction&& aborter) { 43 | AbortFunction old_aborter = std::move(Aborter()); 44 | Aborter() = std::move(aborter); 45 | 46 | - if (__builtin_available(android 30, *)) { 47 | + if (false) { 48 | __android_log_set_aborter([](const char* abort_message) { Aborter()(abort_message); }); 49 | } 50 | return old_aborter; 51 | @@ -502,7 +502,7 @@ LogMessage::~LogMessage() { 52 | 53 | // Abort if necessary. 54 | if (data_->GetSeverity() == FATAL) { 55 | - if (__builtin_available(android 30, *)) { 56 | + if (false) { 57 | __android_log_call_aborter(msg.c_str()); 58 | } else { 59 | Aborter()(msg.c_str()); 60 | @@ -517,7 +517,7 @@ std::ostream& LogMessage::stream() { 61 | void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severity, const char* tag, 62 | const char* message) { 63 | int32_t priority = LogSeverityToPriority(severity); 64 | - if (__builtin_available(android 30, *)) { 65 | + if (false) { 66 | __android_log_message log_message = { 67 | sizeof(__android_log_message), LOG_ID_DEFAULT, priority, tag, file, line, message}; 68 | __android_log_write_log_message(&log_message); 69 | @@ -536,7 +536,7 @@ void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity severi 70 | } 71 | 72 | LogSeverity GetMinimumLogSeverity() { 73 | - if (__builtin_available(android 30, *)) { 74 | + if (false) { 75 | return PriorityToLogSeverity(__android_log_get_minimum_priority()); 76 | } else { 77 | return gMinimumLogSeverity; 78 | @@ -547,7 +547,7 @@ bool ShouldLog(LogSeverity severity, const char* tag) { 79 | // Even though we're not using the R liblog functions in this function, if we're running on Q, 80 | // we need to fall back to using gMinimumLogSeverity, since __android_log_is_loggable() will not 81 | // take into consideration the value from SetMinimumLogSeverity(). 82 | - if (__builtin_available(android 30, *)) { 83 | + if (false) { 84 | int32_t priority = LogSeverityToPriority(severity); 85 | return __android_log_is_loggable(priority, tag, ANDROID_LOG_INFO); 86 | } else { 87 | @@ -556,7 +556,7 @@ bool ShouldLog(LogSeverity severity, const char* tag) { 88 | } 89 | 90 | LogSeverity SetMinimumLogSeverity(LogSeverity new_severity) { 91 | - if (__builtin_available(android 30, *)) { 92 | + if (false) { 93 | int32_t priority = LogSeverityToPriority(new_severity); 94 | return PriorityToLogSeverity(__android_log_set_minimum_priority(priority)); 95 | } else { 96 | -------------------------------------------------------------------------------- /patches/libziparchive/0001-remove-glibc-internal-header-cdefs.h.patch: -------------------------------------------------------------------------------- 1 | From b3fe976c27a54378dfd5c90214cb29c8f8c06169 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= 3 | 4 | Date: Sat, 31 Oct 2020 19:48:45 +0700 5 | Subject: [PATCH] remove glibc internal header cdefs.h 6 | 7 | --- 8 | include/ziparchive/zip_archive.h | 1 - 9 | 1 file changed, 1 deletion(-) 10 | 11 | diff --git a/include/ziparchive/zip_archive.h b/include/ziparchive/zip_archive.h 12 | index 005d697..3f16935 100644 13 | --- a/include/ziparchive/zip_archive.h 14 | +++ b/include/ziparchive/zip_archive.h 15 | @@ -22,7 +22,6 @@ 16 | 17 | #include 18 | #include 19 | -#include 20 | #include 21 | 22 | #include 23 | -------------------------------------------------------------------------------- /patches/logging/0001-Don-t-use-the-internal-glibc-header-sys-cdefs.h.patch: -------------------------------------------------------------------------------- 1 | From 71ea766e0a45c4082e49962009342958b2c764e1 Mon Sep 17 00:00:00 2001 2 | From: John Zimmermann 3 | Date: Thu, 18 Mar 2021 15:08:33 +0100 4 | Subject: [PATCH] Don't use the internal glibc header sys/cdefs.h 5 | 6 | --- 7 | liblog/include/android/log.h | 1 - 8 | liblog/include/log/log_main.h | 9 ++++++--- 9 | liblog/logd_reader.h | 9 ++++++--- 10 | liblog/logger.h | 9 ++++++--- 11 | liblog/pmsg_reader.h | 9 ++++++--- 12 | logcat/logcat.cpp | 1 - 13 | logcat/tests/logcat_test.cpp | 1 - 14 | logd/ChattyLogBuffer.cpp | 1 - 15 | logd/LogListener.cpp | 1 - 16 | logd/LogUtils.h | 1 - 17 | logd/libaudit.h | 9 ++++++--- 18 | 11 files changed, 30 insertions(+), 21 deletions(-) 19 | 20 | diff --git a/liblog/include/android/log.h b/liblog/include/android/log.h 21 | index 5dc365a4..12de5958 100644 22 | --- a/liblog/include/android/log.h 23 | +++ b/liblog/include/android/log.h 24 | @@ -57,7 +57,6 @@ 25 | #include 26 | #include 27 | #include 28 | -#include 29 | 30 | #if !defined(__BIONIC__) && !defined(__INTRODUCED_IN) 31 | #define __INTRODUCED_IN(x) 32 | diff --git a/liblog/include/log/log_main.h b/liblog/include/log/log_main.h 33 | index 1bd1c8ae..c71bbdd4 100644 34 | --- a/liblog/include/log/log_main.h 35 | +++ b/liblog/include/log/log_main.h 36 | @@ -17,12 +17,13 @@ 37 | #pragma once 38 | 39 | #include 40 | -#include 41 | #include 42 | 43 | #include 44 | 45 | -__BEGIN_DECLS 46 | +#ifdef __cplusplus 47 | +extern "C" { 48 | +#endif 49 | 50 | /* 51 | * Normally we strip the effects of ALOGV (VERBOSE messages), 52 | @@ -375,4 +376,6 @@ int __android_log_is_loggable_len(int prio, const char* tag, size_t len, int def 53 | #pragma clang diagnostic pop 54 | #endif 55 | 56 | -__END_DECLS 57 | +#ifdef __cplusplus 58 | +} 59 | +#endif 60 | diff --git a/liblog/logd_reader.h b/liblog/logd_reader.h 61 | index 68eef027..64e400ff 100644 62 | --- a/liblog/logd_reader.h 63 | +++ b/liblog/logd_reader.h 64 | @@ -16,16 +16,19 @@ 65 | 66 | #pragma once 67 | 68 | -#include 69 | #include 70 | 71 | #include "log/log_read.h" 72 | 73 | -__BEGIN_DECLS 74 | +#ifdef __cplusplus 75 | +extern "C" { 76 | +#endif 77 | 78 | int LogdRead(struct logger_list* logger_list, struct log_msg* log_msg); 79 | void LogdClose(struct logger_list* logger_list); 80 | 81 | ssize_t SendLogdControlMessage(char* buf, size_t buf_size); 82 | 83 | -__END_DECLS 84 | +#ifdef __cplusplus 85 | +} 86 | +#endif 87 | diff --git a/liblog/logger.h b/liblog/logger.h 88 | index ddff19dd..263859db 100644 89 | --- a/liblog/logger.h 90 | +++ b/liblog/logger.h 91 | @@ -17,13 +17,14 @@ 92 | #pragma once 93 | 94 | #include 95 | -#include 96 | 97 | #include 98 | 99 | #include "uio.h" 100 | 101 | -__BEGIN_DECLS 102 | +#ifdef __cplusplus 103 | +extern "C" { 104 | +#endif 105 | 106 | struct logger_list { 107 | atomic_int fd; 108 | @@ -48,4 +49,6 @@ inline bool android_logger_is_logd(struct logger* logger) { 109 | return reinterpret_cast(logger) & LOGGER_LOGD; 110 | } 111 | 112 | -__END_DECLS 113 | +#ifdef __cplusplus 114 | +} 115 | +#endif 116 | diff --git a/liblog/pmsg_reader.h b/liblog/pmsg_reader.h 117 | index b784f9ff..88aeec9c 100644 118 | --- a/liblog/pmsg_reader.h 119 | +++ b/liblog/pmsg_reader.h 120 | @@ -16,14 +16,17 @@ 121 | 122 | #pragma once 123 | 124 | -#include 125 | #include 126 | 127 | #include "log/log_read.h" 128 | 129 | -__BEGIN_DECLS 130 | +#ifdef __cplusplus 131 | +extern "C" { 132 | +#endif 133 | 134 | int PmsgRead(struct logger_list* logger_list, struct log_msg* log_msg); 135 | void PmsgClose(struct logger_list* logger_list); 136 | 137 | -__END_DECLS 138 | +#ifdef __cplusplus 139 | +} 140 | +#endif 141 | diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp 142 | index c8fcf46..aff013e 100644 143 | --- a/logcat/logcat.cpp 144 | +++ b/logcat/logcat.cpp 145 | @@ -29,7 +29,6 @@ 146 | #include 147 | #include 148 | #include 149 | -#include 150 | #include 151 | #include 152 | #include 153 | diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp 154 | index dc1df96..c26fe1b 100644 155 | --- a/logcat/tests/logcat_test.cpp 156 | +++ b/logcat/tests/logcat_test.cpp 157 | @@ -24,7 +24,6 @@ 158 | #include 159 | #include 160 | #include 161 | -#include 162 | #include 163 | #include 164 | #include 165 | diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp 166 | index a6ab50b8..641def0f 100644 167 | --- a/logd/LogListener.cpp 168 | +++ b/logd/LogListener.cpp 169 | @@ -15,7 +15,6 @@ 170 | */ 171 | 172 | #include 173 | -#include 174 | #include 175 | #include 176 | #include 177 | diff --git a/logd/LogUtils.h b/logd/LogUtils.h 178 | index c0f62d39..5c759793 100644 179 | --- a/logd/LogUtils.h 180 | +++ b/logd/LogUtils.h 181 | @@ -16,7 +16,6 @@ 182 | 183 | #pragma once 184 | 185 | -#include 186 | #include 187 | 188 | #include 189 | diff --git a/logd/libaudit/include/libaudit.h b/logd/libaudit/include/libaudit.h 190 | index 27b08669..872d6996 100644 191 | --- a/logd/libaudit/include/libaudit.h 192 | +++ b/logd/libaudit/include/libaudit.h 193 | @@ -20,14 +20,15 @@ 194 | #pragma once 195 | 196 | #include 197 | -#include 198 | #include 199 | #include 200 | 201 | #include 202 | #include 203 | 204 | -__BEGIN_DECLS 205 | +#ifdef __cplusplus 206 | +extern "C" { 207 | +#endif 208 | 209 | #define MAX_AUDIT_MESSAGE_LENGTH 8970 210 | 211 | @@ -111,4 +112,6 @@ extern int audit_rate_limit(int fd, uint32_t limit); 212 | */ 213 | extern int audit_log_android_avc_message(int fd, const char* msg); 214 | 215 | -__END_DECLS 216 | +#ifdef __cplusplus 217 | +} 218 | +#endif 219 | -------------------------------------------------------------------------------- /patches/logging/0002-Fix-inclusion-of-stdatomic.h-with-g.patch: -------------------------------------------------------------------------------- 1 | From e878c6856f9b828a9538b7bc962c7697039e58d5 Mon Sep 17 00:00:00 2001 2 | From: John Zimmermann 3 | Date: Thu, 18 Mar 2021 15:14:03 +0100 4 | Subject: [PATCH] Fix inclusion of stdatomic.h with g++ 5 | 6 | See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932#c5 7 | --- 8 | liblog/logger.h | 5 +++++ 9 | 1 file changed, 5 insertions(+) 10 | 11 | diff --git a/liblog/logger.h b/liblog/logger.h 12 | index 263859db..46361731 100644 13 | --- a/liblog/logger.h 14 | +++ b/liblog/logger.h 15 | @@ -16,7 +16,12 @@ 16 | 17 | #pragma once 18 | 19 | +#ifdef __cplusplus 20 | +#include 21 | +using namespace std; 22 | +#else 23 | #include 24 | +#endif 25 | 26 | #include 27 | 28 | -------------------------------------------------------------------------------- /patches/logging/0004-fix-initializer-element-is-not-constant-error-when-b.patch: -------------------------------------------------------------------------------- 1 | From 0287fb7244568a5f08c0ac153dcb464df67ff140 Mon Sep 17 00:00:00 2001 2 | From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 3 | Date: Tue, 27 Feb 2018 17:37:12 +0100 4 | Subject: [PATCH] fix "initializer element is not constant"-error when building 5 | with g++ 6 | 7 | --- 8 | liblog/logprint.cpp | 6 +++--- 9 | 1 file changed, 3 insertions(+), 3 deletions(-) 10 | 11 | diff --git a/liblog/logprint.cpp b/liblog/logprint.cpp 12 | index a5c5edd0..71868a35 100644 13 | --- a/liblog/logprint.cpp 14 | +++ b/liblog/logprint.cpp 15 | @@ -884,9 +884,9 @@ static int android_log_printBinaryEvent(const unsigned char** pEventData, size_t 16 | } 17 | break; 18 | case TYPE_MONOTONIC: { 19 | - static const uint64_t minute = 60; 20 | - static const uint64_t hour = 60 * minute; 21 | - static const uint64_t day = 24 * hour; 22 | + #define minute (60) 23 | + #define hour (60 * minute) 24 | + #define day (24 * hour) 25 | 26 | /* Repaint as unsigned seconds, minutes, hours ... */ 27 | outBuf -= outCount; 28 | -------------------------------------------------------------------------------- /platform_tools_version.h.in: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | #define PLATFORM_TOOLS_VERSION "@ANDROID_VERSION@" 4 | -------------------------------------------------------------------------------- /vendor/CMakeLists.adb.txt: -------------------------------------------------------------------------------- 1 | protobuf_generate_cpp(ADB_APP_PROCESSES_PROTO_SRCS ADB_APP_PROCESSES_PROTO_HDRS 2 | adb/proto/app_processes.proto) 3 | protobuf_generate_cpp(ADB_HOST_PROTO_SRCS ADB_HOST_PROTO_HDRS 4 | adb/proto/adb_host.proto) 5 | protobuf_generate_cpp(ADB_KEY_TYPE_PROTO_SRCS ADB_KEY_TYPE_PROTO_HDRS 6 | adb/proto/key_type.proto) 7 | protobuf_generate_cpp(ADB_KNOWN_HOSTS_PROTO_SRCS ADB_KNOWN_HOSTS_PROTO_HDRS 8 | adb/proto/adb_known_hosts.proto) 9 | protobuf_generate_cpp(ADB_PAIRING_PROTO_SRCS ADB_PAIRING_PROTO_HDRS 10 | adb/proto/pairing.proto) 11 | 12 | # No fastdeploy because it requires deployagent.inc 13 | set(libadb_SOURCES 14 | adb/client/adb_client.cpp 15 | adb/client/adb_install.cpp 16 | adb/client/adb_wifi.cpp 17 | adb/client/auth.cpp 18 | adb/client/bugreport.cpp 19 | adb/client/commandline.cpp 20 | adb/client/console.cpp 21 | adb/client/file_sync_client.cpp 22 | adb/client/incremental.cpp 23 | adb/client/incremental_server.cpp 24 | adb/client/incremental_utils.cpp 25 | adb/client/line_printer.cpp 26 | adb/client/main.cpp 27 | adb/client/pairing/pairing_client.cpp 28 | adb/client/usb_libusb.cpp 29 | adb/pairing_auth/aes_128_gcm.cpp 30 | adb/pairing_auth/pairing_auth.cpp 31 | adb/pairing_connection/pairing_connection.cpp 32 | adb/services.cpp 33 | adb/socket_spec.cpp 34 | adb/sysdeps_unix.cpp 35 | adb/sysdeps/errno.cpp 36 | adb/sysdeps/posix/network.cpp 37 | ${ADB_APP_PROCESSES_PROTO_SRCS} ${ADB_APP_PROCESSES_PROTO_HDRS} 38 | ${ADB_HOST_PROTO_SRCS} ${ADB_HOST_PROTO_HDRS} 39 | ${ADB_KNOWN_HOSTS_PROTO_SRCS} ${ADB_KNOWN_HOSTS_PROTO_HDRS} 40 | ${ADB_KEY_TYPE_PROTO_SRCS} ${ADB_KEY_TYPE_PROTO_HDRS} 41 | ${ADB_PAIRING_PROTO_SRCS} ${ADB_PAIRING_PROTO_HDRS}) 42 | 43 | if(APPLE) 44 | list(APPEND libadb_SOURCES 45 | adb/client/usb_osx.cpp) 46 | else() 47 | list(APPEND libadb_SOURCES 48 | adb/client/usb_linux.cpp) 49 | endif() 50 | 51 | add_library(libadb STATIC ${libadb_SOURCES}) 52 | target_compile_definitions(libadb PRIVATE -D_GNU_SOURCE) 53 | target_compile_definitions(libadb PUBLIC -DADB_HOST=1) 54 | target_include_directories(libadb PUBLIC 55 | boringssl/include 56 | adb 57 | adb/crypto/include 58 | adb/pairing_auth/include 59 | adb/pairing_connection/include 60 | adb/tls/include 61 | core/include 62 | core/libcrypto_utils/include 63 | core/libcutils/include 64 | libbase/include 65 | libziparchive/include) 66 | 67 | if(ANDROID_TOOLS_USE_BUNDLED_LIBUSB) 68 | target_compile_definitions(libadb PUBLIC ANDROID_TOOLS_USE_BUNDLED_LIBUSB) 69 | target_include_directories(libadb PUBLIC libusb) 70 | endif() 71 | 72 | add_library(libadb_crypto_defaults STATIC 73 | adb/crypto/key.cpp 74 | adb/crypto/rsa_2048_key.cpp 75 | adb/crypto/x509_generator.cpp 76 | ${ADB_KEY_TYPE_PROTO_HDRS}) 77 | 78 | target_include_directories(libadb_crypto_defaults PUBLIC 79 | adb 80 | adb/crypto/include 81 | boringssl/include 82 | core/libcrypto_utils/include 83 | libbase/include) 84 | 85 | 86 | add_library(libadb_tls_connection_defaults STATIC 87 | adb/tls/adb_ca_list.cpp 88 | adb/tls/tls_connection.cpp) 89 | 90 | target_include_directories(libadb_tls_connection_defaults PUBLIC 91 | adb 92 | adb/tls/include 93 | boringssl/include 94 | libbase/include) 95 | 96 | add_library(liblog STATIC 97 | logging/liblog/log_event_list.cpp 98 | logging/liblog/log_event_write.cpp 99 | logging/liblog/logger_name.cpp 100 | logging/liblog/logger_read.cpp 101 | logging/liblog/logger_write.cpp 102 | logging/liblog/properties.cpp 103 | logging/liblog/logprint.cpp) 104 | 105 | target_compile_definitions(liblog PRIVATE 106 | -DLIBLOG_LOG_TAG=1006 -D_XOPEN_SOURCE=700 -DFAKE_LOG_DEVICE=1) 107 | target_include_directories(liblog PUBLIC 108 | core/include 109 | logging/liblog/include 110 | core/libcutils/include 111 | libbase/include) 112 | 113 | set(libcutils_SOURCES 114 | core/libcutils/android_get_control_file.cpp 115 | core/libcutils/ashmem-host.cpp 116 | core/libcutils/config_utils.cpp 117 | core/libcutils/fs.cpp 118 | core/libcutils/hashmap.cpp 119 | core/libcutils/iosched_policy.cpp 120 | core/libcutils/load_file.cpp 121 | core/libcutils/multiuser.cpp 122 | core/libcutils/native_handle.cpp 123 | core/libcutils/properties.cpp 124 | core/libcutils/record_stream.cpp 125 | core/libcutils/socket_inaddr_any_server_unix.cpp 126 | core/libcutils/socket_local_client_unix.cpp 127 | core/libcutils/socket_local_server_unix.cpp 128 | core/libcutils/socket_network_client_unix.cpp 129 | core/libcutils/sockets_unix.cpp 130 | core/libcutils/sockets.cpp 131 | core/libcutils/str_parms.cpp 132 | core/libcutils/strlcpy.c 133 | core/libcutils/trace-host.cpp) 134 | 135 | if (NOT APPLE AND NOT WIN32) 136 | list(APPEND libcutils_SOURCES 137 | core/libcutils/canned_fs_config.cpp 138 | core/libcutils/fs_config.cpp) 139 | endif() 140 | 141 | add_library(libcutils STATIC ${libcutils_SOURCES}) 142 | target_compile_definitions(libcutils PRIVATE -D_GNU_SOURCE) 143 | target_include_directories(libcutils PRIVATE 144 | logging/liblog/include core/libutils/include) 145 | target_include_directories(libcutils PUBLIC 146 | core/libcutils/include libbase/include) 147 | 148 | add_library(libdiagnoseusb STATIC 149 | core/diagnose_usb/diagnose_usb.cpp) 150 | target_include_directories(libdiagnoseusb PUBLIC 151 | core/diagnose_usb/include) 152 | 153 | target_include_directories(libdiagnoseusb PUBLIC 154 | core/include libbase/include) 155 | 156 | add_library(libadb_sysdeps STATIC 157 | adb/sysdeps/env.cpp) 158 | target_include_directories(libadb_sysdeps PUBLIC 159 | libbase/include 160 | adb) 161 | 162 | add_library(libcrypto STATIC 163 | core/libcrypto_utils/android_pubkey.cpp) 164 | 165 | target_include_directories(libcrypto PUBLIC 166 | core/libcrypto_utils/include boringssl/include) 167 | 168 | add_executable(adb 169 | adb/adb.cpp 170 | adb/adb_io.cpp 171 | adb/adb_listeners.cpp 172 | adb/adb_trace.cpp 173 | adb/adb_unique_fd.cpp 174 | adb/adb_utils.cpp 175 | adb/fdevent/fdevent.cpp 176 | adb/fdevent/fdevent_poll.cpp 177 | adb/fdevent/fdevent_epoll.cpp 178 | adb/shell_service_protocol.cpp 179 | adb/sockets.cpp 180 | adb/socket_spec.cpp 181 | adb/transport.cpp 182 | adb/transport_fd.cpp 183 | adb/client/transport_local.cpp 184 | adb/client/transport_usb.cpp 185 | adb/types.cpp 186 | ${ADB_KEY_TYPE_PROTO_HDRS}) 187 | 188 | target_include_directories(adb PRIVATE 189 | core/include libbase/include adb 190 | core/libcrypto_utils/include boringssl/include) 191 | target_link_libraries(adb 192 | libadb 193 | libadb_crypto_defaults 194 | libadb_tls_connection_defaults 195 | libbase 196 | libcrypto 197 | libadb_sysdeps 198 | libcutils 199 | libdiagnoseusb 200 | liblog 201 | libzip 202 | crypto 203 | ssl 204 | protobuf::libprotobuf 205 | PkgConfig::libbrotlicommon 206 | PkgConfig::libbrotlidec 207 | PkgConfig::libbrotlienc 208 | PkgConfig::liblz4 209 | Threads::Threads 210 | z 211 | PkgConfig::libzstd) 212 | 213 | if(ANDROID_TOOLS_USE_BUNDLED_LIBUSB) 214 | target_link_libraries(adb android_tools_libusb) 215 | else() 216 | target_link_libraries(adb PkgConfig::libusb-1.0) 217 | endif() 218 | 219 | if(APPLE) 220 | target_link_libraries(adb 221 | "-framework CoreFoundation" 222 | "-framework IOKit") 223 | endif() 224 | 225 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/adb/docs/user/adb.1) 226 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/adb/docs/user/adb.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 227 | endif() 228 | -------------------------------------------------------------------------------- /vendor/CMakeLists.avb.txt: -------------------------------------------------------------------------------- 1 | install(PROGRAMS avb/avbtool.py DESTINATION bin RENAME avbtool) 2 | -------------------------------------------------------------------------------- /vendor/CMakeLists.f2fstools.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | # CMakeLists.f2fstools.txt: CMake file for f2fs-tools directory 3 | 4 | set(f2fs_tools_defaults 5 | -DF2FS_MAJOR_VERSION=1 6 | -DF2FS_MINOR_VERSION=16 7 | -DF2FS_TOOLS_VERSION="1.16.0" 8 | -DF2FS_TOOLS_DATE="2023-04-11" 9 | -DWITH_ANDROID) 10 | 11 | add_library(libf2fs STATIC 12 | f2fs-tools/lib/libf2fs.c 13 | f2fs-tools/mkfs/f2fs_format.c 14 | f2fs-tools/mkfs/f2fs_format_utils.c 15 | f2fs-tools/lib/libf2fs_zoned.c 16 | f2fs-tools/lib/nls_utf8.c) 17 | 18 | target_compile_definitions(libf2fs PUBLIC 19 | ${f2fs_tools_defaults} 20 | -DWITH_BLKDISCARD) 21 | 22 | target_include_directories(libf2fs PUBLIC 23 | core/libsparse/include 24 | f2fs-tools/include) 25 | 26 | target_link_libraries(libf2fs PUBLIC 27 | libext2_uuid) 28 | 29 | add_executable(make_f2fs 30 | f2fs-tools/lib/libf2fs_io.c 31 | f2fs-tools/mkfs/f2fs_format_main.c) 32 | 33 | target_link_libraries(make_f2fs PRIVATE 34 | libf2fs libsparse z) 35 | 36 | set(fsck_main_src_files 37 | f2fs-tools/fsck/dir.c 38 | f2fs-tools/fsck/dict.c 39 | f2fs-tools/fsck/mkquota.c 40 | f2fs-tools/fsck/quotaio.c 41 | f2fs-tools/fsck/quotaio_tree.c 42 | f2fs-tools/fsck/quotaio_v2.c 43 | f2fs-tools/fsck/node.c 44 | f2fs-tools/fsck/segment.c 45 | f2fs-tools/fsck/xattr.c 46 | f2fs-tools/fsck/main.c 47 | f2fs-tools/fsck/mount.c 48 | f2fs-tools/lib/libf2fs.c 49 | f2fs-tools/lib/libf2fs_io.c 50 | f2fs-tools/lib/libf2fs_zoned.c 51 | f2fs-tools/lib/nls_utf8.c 52 | f2fs-tools/fsck/dump.c) 53 | 54 | add_executable(sload_f2fs 55 | ${fsck_main_src_files} 56 | f2fs-tools/fsck/fsck.c 57 | f2fs-tools/fsck/sload.c 58 | f2fs-tools/fsck/compress.c) 59 | 60 | target_compile_definitions(sload_f2fs PRIVATE 61 | ${f2fs_tools_defaults} 62 | -DWITH_SLOAD) 63 | 64 | target_include_directories(sload_f2fs PRIVATE 65 | f2fs-tools/include 66 | selinux/libselinux/include 67 | core/libsparse/include 68 | core/libcutils/include) 69 | 70 | target_link_libraries(sload_f2fs PRIVATE 71 | libext2_uuid libsparse libselinux libcutils z 72 | PkgConfig::libpcre2-8 73 | PkgConfig::liblz4) 74 | -------------------------------------------------------------------------------- /vendor/CMakeLists.fastboot.txt: -------------------------------------------------------------------------------- 1 | add_library(libzip STATIC 2 | libziparchive/zip_archive.cc 3 | libziparchive/zip_archive_stream_entry.cc 4 | libziparchive/zip_cd_entry_map.cc 5 | libziparchive/zip_error.cpp 6 | libziparchive/zip_writer.cc) 7 | 8 | target_compile_definitions(libzip PRIVATE -DZLIB_CONST) 9 | target_include_directories(libzip PUBLIC 10 | libziparchive/include 11 | libziparchive/incfs_support/include 12 | core/include 13 | logging/liblog/include 14 | libbase/include) 15 | 16 | add_library(libutil STATIC 17 | core/libutils/FileMap.cpp 18 | core/libutils/JenkinsHash.cpp 19 | core/libutils/LightRefBase.cpp 20 | core/libutils/NativeHandle.cpp 21 | core/libutils/Printer.cpp 22 | core/libutils/StopWatch.cpp 23 | core/libutils/SystemClock.cpp 24 | core/libutils/Threads.cpp 25 | core/libutils/Timers.cpp 26 | core/libutils/Tokenizer.cpp 27 | core/libutils/misc.cpp) 28 | 29 | target_include_directories(libutil PUBLIC 30 | core/include 31 | logging/liblog/include 32 | core/libutils/include 33 | libbase/include) 34 | 35 | add_library(libext4 STATIC 36 | extras/ext4_utils/ext4_utils.cpp 37 | extras/ext4_utils/wipe.cpp 38 | extras/ext4_utils/ext4_sb.cpp) 39 | 40 | target_include_directories(libext4 PUBLIC 41 | core/libsparse/include core/include selinux/libselinux/include 42 | extras/ext4_utils/include libbase/include) 43 | 44 | # Only add common sources from libselinux_defaults and libselinux 45 | # See the file list in selinux/libselinux/Android.bp 46 | add_library(libselinux STATIC 47 | selinux/libselinux/src/booleans.c 48 | selinux/libselinux/src/callbacks.c 49 | selinux/libselinux/src/freecon.c 50 | selinux/libselinux/src/label_backends_android.c 51 | selinux/libselinux/src/label.c 52 | selinux/libselinux/src/label_support.c 53 | selinux/libselinux/src/matchpathcon.c 54 | selinux/libselinux/src/setrans_client.c 55 | selinux/libselinux/src/sha1.c 56 | selinux/libselinux/src/label_file.c 57 | selinux/libselinux/src/regex.c) 58 | 59 | if(HAVE_STRLCPY) 60 | target_compile_definitions(libselinux PRIVATE HAVE_STRLCPY) 61 | endif() 62 | 63 | target_compile_definitions(libselinux PRIVATE 64 | -DAUDITD_LOG_TAG=1003 -D_GNU_SOURCE -DBUILD_HOST -DUSE_PCRE2 65 | -DNO_PERSISTENTLY_STORED_PATTERNS -DDISABLE_SETRANS 66 | -DDISABLE_BOOL -DNO_MEDIA_BACKEND -DNO_X_BACKEND -DNO_DB_BACKEND 67 | -DPCRE2_CODE_UNIT_WIDTH=8) 68 | target_include_directories(libselinux PUBLIC 69 | selinux/libselinux/include selinux/libsepol/include) 70 | 71 | add_library(libsepol 72 | selinux/libsepol/src/assertion.c 73 | selinux/libsepol/src/avrule_block.c 74 | selinux/libsepol/src/avtab.c 75 | selinux/libsepol/src/conditional.c 76 | selinux/libsepol/src/constraint.c 77 | selinux/libsepol/src/context.c 78 | selinux/libsepol/src/context_record.c 79 | selinux/libsepol/src/debug.c 80 | selinux/libsepol/src/ebitmap.c 81 | selinux/libsepol/src/expand.c 82 | selinux/libsepol/src/hashtab.c 83 | selinux/libsepol/src/hierarchy.c 84 | selinux/libsepol/src/kernel_to_common.c 85 | selinux/libsepol/src/mls.c 86 | selinux/libsepol/src/policydb.c 87 | selinux/libsepol/src/policydb_convert.c 88 | selinux/libsepol/src/policydb_public.c 89 | selinux/libsepol/src/services.c 90 | selinux/libsepol/src/sidtab.c 91 | selinux/libsepol/src/symtab.c 92 | selinux/libsepol/src/util.c 93 | selinux/libsepol/src/write.c 94 | selinux/libsepol/src/optimize.c) 95 | 96 | if(HAVE_REALLOCARRAY) 97 | target_compile_definitions(libsepol PRIVATE HAVE_REALLOCARRAY) 98 | endif() 99 | 100 | target_include_directories(libsepol PUBLIC 101 | selinux/libsepol/include) 102 | 103 | set(fastboot_SOURCES 104 | core/fastboot/bootimg_utils.cpp 105 | core/fastboot/fastboot.cpp 106 | core/fastboot/fastboot_driver.cpp 107 | core/fastboot/filesystem.cpp 108 | core/fastboot/fs.cpp 109 | core/fastboot/main.cpp 110 | core/fastboot/socket.cpp 111 | core/fastboot/storage.cpp 112 | core/fastboot/super_flash_helper.cpp 113 | core/fastboot/task.cpp 114 | core/fastboot/tcp.cpp 115 | core/fastboot/udp.cpp 116 | core/fastboot/vendor_boot_img_utils.cpp 117 | core/fastboot/util.cpp) 118 | 119 | if(APPLE) 120 | list(APPEND fastboot_SOURCES 121 | core/fastboot/usb_osx.cpp) 122 | else() 123 | list(APPEND fastboot_SOURCES 124 | core/fastboot/usb_linux.cpp) 125 | endif() 126 | 127 | add_executable(fastboot ${fastboot_SOURCES}) 128 | target_include_directories(fastboot PRIVATE 129 | libbase/include core/include core/adb core/libsparse/include 130 | extras/ext4_utils/include extras/f2fs_utils 131 | core/libziparchive/include mkbootimg/include/bootimg 132 | core/fs_mgr/liblp/include core/fs_mgr/libstorage_literals avb) 133 | target_compile_definitions(fastboot PRIVATE 134 | -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -DUSE_F2FS 135 | -DANDROID_MKE2FS_NAME="${ANDROID_MKE2FS_NAME}") 136 | target_link_libraries(fastboot 137 | libsparse libzip libcutils liblog liblp libutil 138 | libbase libext4 libselinux libsepol libdiagnoseusb crypto 139 | z PkgConfig::libpcre2-8 Threads::Threads dl) 140 | 141 | if(APPLE) 142 | target_link_libraries(fastboot 143 | "-framework CoreFoundation" 144 | "-framework IOKit") 145 | endif() 146 | -------------------------------------------------------------------------------- /vendor/CMakeLists.libbase.txt: -------------------------------------------------------------------------------- 1 | add_library(libbase STATIC 2 | libbase/abi_compatibility.cpp 3 | libbase/chrono_utils.cpp 4 | libbase/cmsg.cpp 5 | libbase/file.cpp 6 | libbase/hex.cpp 7 | libbase/logging.cpp 8 | libbase/mapped_file.cpp 9 | libbase/parsebool.cpp 10 | libbase/parsenetaddress.cpp 11 | libbase/posix_strerror_r.cpp 12 | libbase/process.cpp 13 | libbase/properties.cpp 14 | libbase/result.cpp 15 | libbase/stringprintf.cpp 16 | libbase/strings.cpp 17 | libbase/threads.cpp 18 | libbase/test_utils.cpp 19 | libbase/errors_unix.cpp) 20 | 21 | target_include_directories(libbase PUBLIC 22 | libbase/include core/include) 23 | target_link_libraries(libbase PUBLIC fmt::fmt liblog) 24 | -------------------------------------------------------------------------------- /vendor/CMakeLists.libufdt.txt: -------------------------------------------------------------------------------- 1 | install(PROGRAMS libufdt/utils/src/mkdtboimg.py DESTINATION bin RENAME mkdtboimg) 2 | -------------------------------------------------------------------------------- /vendor/CMakeLists.libusb.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: Apache-2.0 2 | # CMakeLists.libusb.txt: CMake file for libusb directory 3 | 4 | set(android_tools_libusb_SOURCES 5 | libusb/libusb/core.c 6 | libusb/libusb/descriptor.c 7 | libusb/libusb/hotplug.c 8 | libusb/libusb/io.c 9 | libusb/libusb/sync.c 10 | libusb/libusb/strerror.c) 11 | 12 | if(WIN32) 13 | list(APPEND android_tools_libusb_SOURCES 14 | libusb/libusb/os/events_windows.c 15 | libusb/libusb/os/threads_windows.c 16 | libusb/libusb/os/windows_common.c 17 | libusb/libusb/os/windows_usbdk.c 18 | libusb/libusb/os/windows_winusb.c) 19 | elseif(APPLE) 20 | list(APPEND android_tools_libusb_SOURCES 21 | libusb/libusb/os/events_posix.c 22 | libusb/libusb/os/darwin_usb.c 23 | libusb/libusb/os/threads_posix.c) 24 | else() 25 | list(APPEND android_tools_libusb_SOURCES 26 | libusb/libusb/os/events_posix.c 27 | libusb/libusb/os/linux_usbfs.c 28 | libusb/libusb/os/threads_posix.c) 29 | if(ANDROID_TOOLS_LIBUSB_ENABLE_UDEV) 30 | list(APPEND android_tools_libusb_SOURCES libusb/libusb/os/linux_udev.c) 31 | else() 32 | list(APPEND android_tools_libusb_SOURCES libusb/libusb/os/linux_netlink.c) 33 | endif() 34 | endif() 35 | 36 | add_library(android_tools_libusb STATIC ${android_tools_libusb_SOURCES}) 37 | 38 | target_include_directories(android_tools_libusb PRIVATE libusb/libusb libusb/libusb/os) 39 | 40 | if(WIN32) 41 | target_include_directories(android_tools_libusb PRIVATE libusb/windows) 42 | elseif(APPLE) 43 | target_include_directories(android_tools_libusb PRIVATE libusb/darwin) 44 | 45 | target_link_libraries(android_tools_libusb PRIVATE 46 | "-framework CoreFoundation" 47 | "-framework IOKit" 48 | "-framework Security" 49 | "-lobjc") 50 | else() 51 | if(ANDROID_TOOLS_LIBUSB_ENABLE_UDEV) 52 | target_compile_definitions(android_tools_libusb PRIVATE HAVE_LIBUDEV) 53 | target_link_libraries(android_tools_libusb PUBLIC PkgConfig::libudev) 54 | endif() 55 | target_include_directories(android_tools_libusb PRIVATE libusb/linux) 56 | endif() 57 | -------------------------------------------------------------------------------- /vendor/CMakeLists.mkbootimg.txt: -------------------------------------------------------------------------------- 1 | set(MKBOOTIMG_SCRIPTS_DIR ${CMAKE_INSTALL_DATADIR}/android-tools/mkbootimg) 2 | install(PROGRAMS mkbootimg/mkbootimg.py DESTINATION ${MKBOOTIMG_SCRIPTS_DIR}) 3 | add_custom_target(mkbootimg_symlink ALL COMMAND ${CMAKE_COMMAND} -E create_symlink 4 | ../${MKBOOTIMG_SCRIPTS_DIR}/mkbootimg.py 5 | ${CMAKE_CURRENT_BINARY_DIR}/mkbootimg) 6 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mkbootimg DESTINATION ${CMAKE_INSTALL_BINDIR}) 7 | install(FILES mkbootimg/gki/generate_gki_certificate.py DESTINATION ${MKBOOTIMG_SCRIPTS_DIR}/gki) 8 | install(PROGRAMS mkbootimg/unpack_bootimg.py DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME unpack_bootimg) 9 | install(PROGRAMS mkbootimg/repack_bootimg.py DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME repack_bootimg) 10 | -------------------------------------------------------------------------------- /vendor/CMakeLists.mke2fs.txt: -------------------------------------------------------------------------------- 1 | add_library(libext2_uuid STATIC 2 | e2fsprogs/lib/uuid/clear.c 3 | e2fsprogs/lib/uuid/compare.c 4 | e2fsprogs/lib/uuid/copy.c 5 | e2fsprogs/lib/uuid/gen_uuid.c 6 | e2fsprogs/lib/uuid/isnull.c 7 | e2fsprogs/lib/uuid/pack.c 8 | e2fsprogs/lib/uuid/parse.c 9 | e2fsprogs/lib/uuid/unpack.c 10 | e2fsprogs/lib/uuid/unparse.c 11 | e2fsprogs/lib/uuid/uuid_time.c) 12 | 13 | target_include_directories(libext2_uuid PUBLIC 14 | e2fsprogs/lib) 15 | 16 | add_library(libext2fs STATIC 17 | e2fsprogs/lib/blkid/cache.c 18 | e2fsprogs/lib/blkid/dev.c 19 | e2fsprogs/lib/blkid/devname.c 20 | e2fsprogs/lib/blkid/devno.c 21 | e2fsprogs/lib/blkid/getsize.c 22 | e2fsprogs/lib/blkid/llseek.c 23 | e2fsprogs/lib/blkid/probe.c 24 | e2fsprogs/lib/blkid/read.c 25 | e2fsprogs/lib/blkid/resolve.c 26 | e2fsprogs/lib/blkid/save.c 27 | e2fsprogs/lib/blkid/tag.c 28 | e2fsprogs/lib/e2p/encoding.c 29 | e2fsprogs/lib/e2p/feature.c 30 | e2fsprogs/lib/e2p/hashstr.c 31 | e2fsprogs/lib/e2p/mntopts.c 32 | e2fsprogs/lib/e2p/ostype.c 33 | e2fsprogs/lib/e2p/parse_num.c 34 | e2fsprogs/lib/e2p/uuid.c 35 | e2fsprogs/lib/et/com_err.c 36 | e2fsprogs/lib/et/error_message.c 37 | e2fsprogs/lib/et/et_name.c 38 | e2fsprogs/lib/ext2fs/alloc.c 39 | e2fsprogs/lib/ext2fs/alloc_sb.c 40 | e2fsprogs/lib/ext2fs/alloc_stats.c 41 | e2fsprogs/lib/ext2fs/alloc_tables.c 42 | e2fsprogs/lib/ext2fs/atexit.c 43 | e2fsprogs/lib/ext2fs/badblocks.c 44 | e2fsprogs/lib/ext2fs/bb_inode.c 45 | e2fsprogs/lib/ext2fs/bitmaps.c 46 | e2fsprogs/lib/ext2fs/bitops.c 47 | e2fsprogs/lib/ext2fs/blkmap64_ba.c 48 | e2fsprogs/lib/ext2fs/blkmap64_rb.c 49 | e2fsprogs/lib/ext2fs/blknum.c 50 | e2fsprogs/lib/ext2fs/block.c 51 | e2fsprogs/lib/ext2fs/bmap.c 52 | e2fsprogs/lib/ext2fs/closefs.c 53 | e2fsprogs/lib/ext2fs/crc16.c 54 | e2fsprogs/lib/ext2fs/crc32c.c 55 | e2fsprogs/lib/ext2fs/csum.c 56 | e2fsprogs/lib/ext2fs/dirblock.c 57 | e2fsprogs/lib/ext2fs/dir_iterate.c 58 | e2fsprogs/lib/ext2fs/expanddir.c 59 | e2fsprogs/lib/ext2fs/ext2_err.c 60 | e2fsprogs/lib/ext2fs/ext_attr.c 61 | e2fsprogs/lib/ext2fs/extent.c 62 | e2fsprogs/lib/ext2fs/fallocate.c 63 | e2fsprogs/lib/ext2fs/fileio.c 64 | e2fsprogs/lib/ext2fs/freefs.c 65 | e2fsprogs/lib/ext2fs/gen_bitmap64.c 66 | e2fsprogs/lib/ext2fs/gen_bitmap.c 67 | e2fsprogs/lib/ext2fs/get_num_dirs.c 68 | e2fsprogs/lib/ext2fs/getsectsize.c 69 | e2fsprogs/lib/ext2fs/getsize.c 70 | e2fsprogs/lib/ext2fs/hashmap.c 71 | e2fsprogs/lib/ext2fs/i_block.c 72 | e2fsprogs/lib/ext2fs/ind_block.c 73 | e2fsprogs/lib/ext2fs/initialize.c 74 | e2fsprogs/lib/ext2fs/inline.c 75 | e2fsprogs/lib/ext2fs/inline_data.c 76 | e2fsprogs/lib/ext2fs/inode.c 77 | e2fsprogs/lib/ext2fs/io_manager.c 78 | e2fsprogs/lib/ext2fs/ismounted.c 79 | e2fsprogs/lib/ext2fs/link.c 80 | e2fsprogs/lib/ext2fs/dirhash.c 81 | e2fsprogs/lib/ext2fs/llseek.c 82 | e2fsprogs/lib/ext2fs/lookup.c 83 | e2fsprogs/lib/ext2fs/mkdir.c 84 | e2fsprogs/lib/ext2fs/mkjournal.c 85 | e2fsprogs/lib/ext2fs/mmp.c 86 | e2fsprogs/lib/ext2fs/namei.c 87 | e2fsprogs/lib/ext2fs/newdir.c 88 | e2fsprogs/lib/ext2fs/nls_utf8.c 89 | e2fsprogs/lib/ext2fs/openfs.c 90 | e2fsprogs/lib/ext2fs/progress.c 91 | e2fsprogs/lib/ext2fs/punch.c 92 | e2fsprogs/lib/ext2fs/rbtree.c 93 | e2fsprogs/lib/ext2fs/read_bb.c 94 | e2fsprogs/lib/ext2fs/read_bb_file.c 95 | e2fsprogs/lib/ext2fs/res_gdt.c 96 | e2fsprogs/lib/ext2fs/rw_bitmaps.c 97 | e2fsprogs/lib/ext2fs/sha512.c 98 | e2fsprogs/lib/ext2fs/sparse_io.c 99 | e2fsprogs/lib/ext2fs/symlink.c 100 | e2fsprogs/lib/ext2fs/undo_io.c 101 | e2fsprogs/lib/ext2fs/unix_io.c 102 | e2fsprogs/lib/ext2fs/valid_blk.c 103 | e2fsprogs/lib/support/devname.c 104 | e2fsprogs/lib/support/dict.c 105 | e2fsprogs/lib/support/mkquota.c 106 | e2fsprogs/lib/support/parse_qtype.c 107 | e2fsprogs/lib/support/plausible.c 108 | e2fsprogs/lib/support/prof_err.c 109 | e2fsprogs/lib/support/profile.c 110 | e2fsprogs/lib/support/quotaio.c 111 | e2fsprogs/lib/support/quotaio_tree.c 112 | e2fsprogs/lib/support/quotaio_v2.c 113 | e2fsprogs/misc/create_inode.c) 114 | 115 | target_include_directories(libext2fs PRIVATE 116 | e2fsprogs/lib e2fsprogs/lib/ext2fs core/libsparse/include) 117 | 118 | target_link_libraries(libext2fs PUBLIC 119 | libext2_uuid) 120 | 121 | add_executable("${ANDROID_MKE2FS_NAME}" 122 | e2fsprogs/misc/default_profile.c 123 | e2fsprogs/misc/mke2fs.c 124 | e2fsprogs/misc/mk_hugefiles.c 125 | e2fsprogs/misc/util.c) 126 | 127 | target_link_libraries("${ANDROID_MKE2FS_NAME}" 128 | libext2fs libsparse libbase libzip liblog libutil Threads::Threads z) 129 | target_include_directories("${ANDROID_MKE2FS_NAME}" PRIVATE 130 | e2fsprogs/lib) 131 | 132 | # fails to build due to https://android-review.googlesource.com/c/platform/system/core/+/2760169 133 | if(NOT APPLE) 134 | add_executable(e2fsdroid 135 | e2fsprogs/contrib/android/e2fsdroid.c 136 | e2fsprogs/contrib/android/basefs_allocator.c 137 | e2fsprogs/contrib/android/block_range.c 138 | e2fsprogs/contrib/android/base_fs.c 139 | e2fsprogs/contrib/android/fsmap.c 140 | e2fsprogs/contrib/android/block_list.c 141 | e2fsprogs/contrib/android/perms.c) 142 | 143 | include(CheckIncludeFile) 144 | CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H) 145 | 146 | if(HAVE_SYS_TYPES_H) 147 | target_compile_definitions(e2fsdroid PUBLIC HAVE_SYS_TYPES_H) 148 | endif(HAVE_SYS_TYPES_H) 149 | 150 | target_link_libraries(e2fsdroid 151 | libext2fs libsparse libzip libcutils liblog libutil 152 | libbase libselinux libsepol z PkgConfig::libpcre2-8 pthread) 153 | target_include_directories(e2fsdroid PRIVATE 154 | e2fsprogs/lib e2fsprogs/lib/ext2fs selinux/libselinux/include 155 | core/libcutils/include e2fsprogs/misc) 156 | endif() 157 | 158 | add_executable(ext2simg 159 | e2fsprogs/contrib/android/ext2simg.c) 160 | 161 | target_link_libraries(ext2simg 162 | libext2fs libsparse libbase libzip liblog libutil z pthread) 163 | target_include_directories(ext2simg PRIVATE 164 | e2fsprogs/lib core/libsparse/include) 165 | -------------------------------------------------------------------------------- /vendor/CMakeLists.partition.txt: -------------------------------------------------------------------------------- 1 | add_library(liblp STATIC 2 | core/fs_mgr/liblp/builder.cpp 3 | core/fs_mgr/liblp/super_layout_builder.cpp 4 | core/fs_mgr/liblp/images.cpp 5 | core/fs_mgr/liblp/partition_opener.cpp 6 | core/fs_mgr/liblp/property_fetcher.cpp 7 | core/fs_mgr/liblp/reader.cpp 8 | core/fs_mgr/liblp/utility.cpp 9 | core/fs_mgr/liblp/writer.cpp) 10 | 11 | target_link_libraries(liblp PRIVATE 12 | libbase libext4 libsparse crypto z) 13 | target_include_directories(liblp PRIVATE 14 | boringssl/include) 15 | target_include_directories(liblp PUBLIC 16 | core/fs_mgr/liblp/include) 17 | 18 | protobuf_generate_cpp(DYNAMIC_PARTITIONS_DEVICE_INFO_PROTO_SRCS DYNAMIC_PARTITIONS_DEVICE_INFO_PROTO_HDRS 19 | extras/partition_tools/dynamic_partitions_device_info.proto) 20 | 21 | add_library(libjsonpbparse STATIC 22 | extras/libjsonpb/parse/jsonpb.cpp) 23 | target_link_libraries(libjsonpbparse PRIVATE libbase) 24 | target_include_directories(libjsonpbparse PUBLIC 25 | extras/libjsonpb/parse/include) 26 | 27 | add_library(liblpdump STATIC 28 | ${DYNAMIC_PARTITIONS_DEVICE_INFO_PROTO_SRCS} ${DYNAMIC_PARTITIONS_DEVICE_INFO_PROTO_HDRS} 29 | extras/partition_tools/lpdump.cc) 30 | target_link_libraries(liblpdump PRIVATE 31 | libbase libjsonpbparse liblp protobuf::libprotobuf) 32 | 33 | add_executable(lpdump 34 | extras/partition_tools/lpdump_host.cc) 35 | target_link_libraries(lpdump 36 | libbase liblpdump libsparse) 37 | 38 | add_executable(lpmake 39 | extras/partition_tools/lpmake.cc) 40 | target_link_libraries(lpmake 41 | libbase liblog liblp libsparse) 42 | 43 | add_executable(lpadd 44 | extras/partition_tools/lpadd.cc) 45 | target_link_libraries(lpadd 46 | libbase liblog liblp libsparse) 47 | 48 | add_executable(lpflash 49 | extras/partition_tools/lpflash.cc) 50 | target_link_libraries(lpflash 51 | libbase liblog liblp libsparse) 52 | 53 | add_executable(lpunpack 54 | extras/partition_tools/lpunpack.cc) 55 | target_link_libraries(lpunpack 56 | libbase liblog liblp libsparse) 57 | -------------------------------------------------------------------------------- /vendor/CMakeLists.sparse.txt: -------------------------------------------------------------------------------- 1 | add_library(libsparse STATIC 2 | core/libsparse/backed_block.cpp 3 | core/libsparse/output_file.cpp 4 | core/libsparse/sparse.cpp 5 | core/libsparse/sparse_crc32.cpp 6 | core/libsparse/sparse_err.cpp 7 | core/libsparse/sparse_read.cpp) 8 | 9 | target_include_directories(libsparse PUBLIC 10 | core/libsparse/include libbase/include) 11 | target_link_libraries(libsparse PRIVATE libbase) 12 | 13 | add_executable(simg2img 14 | core/libsparse/simg2img.cpp) 15 | target_link_libraries(simg2img 16 | libsparse z libbase) 17 | 18 | add_executable(img2simg 19 | core/libsparse/img2simg.cpp) 20 | target_link_libraries(img2simg 21 | libsparse z libbase) 22 | 23 | add_executable(append2simg 24 | core/libsparse/append2simg.cpp) 25 | target_link_libraries(append2simg 26 | libsparse z libbase) 27 | -------------------------------------------------------------------------------- /vendor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | enable_language(C CXX) 2 | include(CheckSymbolExists) 3 | 4 | # Use C11 with GNU extensions. 5 | set(CMAKE_C_STANDARD 11) 6 | set(CMAKE_C_EXTENSIONS ON) 7 | set(CMAKE_C_STANDARD_REQUIRED ON) 8 | 9 | # Use C++20 with GNU extensions. 10 | set(CMAKE_CXX_STANDARD 20) 11 | set(CMAKE_CXX_EXTENSIONS ON) 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 13 | 14 | if(APPLE) 15 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DARWIN_C_SOURCE -D__DARWIN_C_LEVEL=__DARWIN_C_FULL") 16 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_DARWIN_C_SOURCE -D__DARWIN_C_LEVEL=__DARWIN_C_FULL") 17 | endif() 18 | 19 | # Different versions of clang require a different set of flags for -ftrivial-auto-var-init 20 | # Simplify this contruct once old clang version support is dropped 21 | include(CheckCXXCompilerFlag) 22 | check_cxx_compiler_flag("-ftrivial-auto-var-init=zero" COMPILER_SUPPORTS_TRIVIAL_ZERO_INIT) 23 | if(COMPILER_SUPPORTS_TRIVIAL_ZERO_INIT) 24 | set(VAR_ZERO_INIT_FLAGS "-ftrivial-auto-var-init=zero") 25 | else() 26 | check_cxx_compiler_flag("-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang" 27 | COMPILER_REQUIRES_ENABLE_TRIVIAL_ZERO_INIT) 28 | if(COMPILER_REQUIRES_ENABLE_TRIVIAL_ZERO_INIT) 29 | set(VAR_ZERO_INIT_FLAGS "-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang") 30 | endif() 31 | endif() 32 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VAR_ZERO_INIT_FLAGS}") 33 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VAR_ZERO_INIT_FLAGS}") 34 | 35 | # Android seems to use various attributes supported by clang but not by 36 | # GCC which causes it to emit lots of warnings. Since these attributes 37 | # don't seem to effect runtime behaviour simply disable the warnings. 38 | add_compile_options(-Wno-attributes) 39 | 40 | # libfsmgr (required by fastboot) requires a 64-bit off_t for lseek. On 41 | # 32-bit glibc platforms this is not the case by default. 42 | add_compile_definitions(_FILE_OFFSET_BITS=64 _LARGEFILE64_SOURCE) 43 | 44 | set(android-vendored 45 | avb 46 | adb 47 | core 48 | extras 49 | libbase 50 | libufdt 51 | libziparchive 52 | logging 53 | mkbootimg 54 | selinux 55 | f2fs-tools 56 | e2fsprogs 57 | fmtlib 58 | boringssl) 59 | 60 | # XXX: Consider using https://cmake.org/cmake/help/v3.0/module/ExternalProject.html 61 | if(ANDROID_TOOLS_PATCH_VENDOR AND EXISTS "${ANDROID_PATCH_DIR}/") 62 | execute_process(COMMAND git submodule --quiet update) 63 | foreach(v ${android-vendored}) 64 | file(GLOB patches ${ANDROID_PATCH_DIR}/${v}/*.patch) 65 | if(patches) 66 | message(STATUS "Applying patches for: ${v}") 67 | execute_process(COMMAND git -C 68 | ${CMAKE_CURRENT_SOURCE_DIR}/${v} am ${patches} 69 | RESULT_VARIABLE ret) 70 | if(NOT "${ret}" STREQUAL "0") 71 | message(FATAL_ERROR "Couldn't apply patches for ${v}") 72 | endif() 73 | endif(patches) 74 | endforeach(v) 75 | endif() 76 | 77 | add_subdirectory(boringssl EXCLUDE_FROM_ALL) 78 | 79 | if(ANDROID_TOOLS_USE_BUNDLED_FMT) 80 | add_subdirectory(fmtlib EXCLUDE_FROM_ALL) 81 | else() 82 | find_package(fmt CONFIG REQUIRED) 83 | message(STATUS "Found fmt: ${fmt_DIR} (version ${fmt_VERSION})") 84 | endif() 85 | 86 | find_package(PkgConfig REQUIRED) 87 | pkg_check_modules(libbrotlicommon REQUIRED IMPORTED_TARGET libbrotlicommon) 88 | pkg_check_modules(libbrotlidec REQUIRED IMPORTED_TARGET libbrotlidec) 89 | pkg_check_modules(libbrotlienc REQUIRED IMPORTED_TARGET libbrotlienc) 90 | pkg_check_modules(liblz4 REQUIRED IMPORTED_TARGET liblz4) 91 | pkg_check_modules(libpcre2-8 REQUIRED IMPORTED_TARGET libpcre2-8) 92 | if(ANDROID_TOOLS_USE_BUNDLED_LIBUSB) 93 | include(CMakeLists.libusb.txt) 94 | if(ANDROID_TOOLS_LIBUSB_ENABLE_UDEV) 95 | pkg_check_modules(libudev REQUIRED IMPORTED_TARGET libudev) 96 | endif() 97 | else() 98 | pkg_check_modules(libusb-1.0 REQUIRED IMPORTED_TARGET libusb-1.0) 99 | endif() 100 | pkg_check_modules(libzstd REQUIRED IMPORTED_TARGET libzstd) 101 | 102 | find_package(Protobuf CONFIG) 103 | find_package(Protobuf REQUIRED) 104 | set(THREADS_PREFER_PTHREAD_FLAG ON) 105 | find_package(Threads REQUIRED) 106 | 107 | check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY) 108 | check_symbol_exists(reallocarray "stdlib.h" HAVE_REALLOCARRAY) 109 | 110 | include_directories(${PROTOBUF_INCLUDE_DIRS}) 111 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) 112 | 113 | include(CMakeLists.libbase.txt) 114 | include(CMakeLists.adb.txt) 115 | include(CMakeLists.sparse.txt) 116 | include(CMakeLists.fastboot.txt) 117 | include(CMakeLists.f2fstools.txt) 118 | include(CMakeLists.mke2fs.txt) 119 | include(CMakeLists.partition.txt) 120 | include(CMakeLists.mkbootimg.txt) 121 | include(CMakeLists.libufdt.txt) 122 | include(CMakeLists.avb.txt) 123 | 124 | # Targets which should be installed by `make install`. 125 | install(TARGETS 126 | "${ANDROID_MKE2FS_NAME}" 127 | adb 128 | append2simg 129 | fastboot 130 | img2simg 131 | lpadd 132 | lpdump 133 | lpflash 134 | lpmake 135 | lpunpack 136 | make_f2fs 137 | sload_f2fs 138 | simg2img 139 | ext2simg 140 | DESTINATION bin) 141 | 142 | if(NOT APPLE) 143 | install(TARGETS 144 | e2fsdroid 145 | DESTINATION bin) 146 | endif() 147 | 148 | # Install common completion files. 149 | install(FILES adb/adb.bash RENAME adb DESTINATION "${COMPLETION_COMMON_DIR}") 150 | install(FILES core/fastboot/fastboot.bash RENAME fastboot DESTINATION "${COMPLETION_COMMON_DIR}") 151 | 152 | # Install license files. 153 | # Disabled for now, see https://github.com/nmeum/android-tools/issues/30#issuecomment-855365636 154 | #set(LICENSE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/licenses/android-tools") 155 | #install(FILES core/NOTICE RENAME AOSP_LICENSE DESTINATION "${LICENSE_DIR}") 156 | -------------------------------------------------------------------------------- /version.h.in: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | // Source: https://android.googlesource.com/platform/build/soong/+/refs/heads/master/cc/libbuildversion/include/build/version.h 3 | 4 | #ifndef BUILD_VERSION_H 5 | #define BUILD_VERSION_H 6 | 7 | #include 8 | 9 | namespace android { 10 | namespace build { 11 | std::string GetBuildNumber() { 12 | return "@ANDROID_VENDOR@"; 13 | } 14 | } 15 | } 16 | 17 | #endif 18 | --------------------------------------------------------------------------------