1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{6,7} )
7 CMAKE_MAKEFILE_GENERATOR="ninja"
9 inherit flag-o-matic bash-completion-r1 ninja-utils toolchain-funcs cmake-utils python-r1
14 DESCRIPTION="Android platform tools (adb, fastboot, and mkbootimg)"
15 HOMEPAGE="https://android.googlesource.com/platform/system/core.git/"
16 # See helper scripts in files/ for creating these tarballs and getting this hash.
17 BORINGSSL_SHA1="45210dd4e21ace9d28cb76b3f83303fcdd2efcce"
18 # The ninja file was created by running the ruby script from archlinux by hand and fixing the build vars.
19 # No point in depending on something large/uncommon like ruby just to generate a ninja file.
20 SRC_URI="https://git.archlinux.org/svntogit/community.git/snapshot/community-0ffb7b41d599741d100a6a00a4bb20e162cd3f90.tar.xz -> ${MY_P}-arch.tar.xz
21 https://github.com/android/platform_system_core/archive/android-${MY_PV}.tar.gz -> ${MY_P}-core.tar.gz
22 https://github.com/google/boringssl/archive/${BORINGSSL_SHA1}.tar.gz -> boringssl-${BORINGSSL_SHA1}.tar.gz
23 mirror://gentoo/${MY_P}-e2fsprogs.tar.xz https://dev.gentoo.org/~zmedico/dist/${MY_P}-e2fsprogs.tar.xz
24 mirror://gentoo/${MY_P}-extras.tar.xz https://dev.gentoo.org/~zmedico/dist/${MY_P}-extras.tar.xz
25 mirror://gentoo/${MY_P}-selinux.tar.xz https://dev.gentoo.org/~zmedico/dist/${MY_P}-selinux.tar.xz
26 mirror://gentoo/${MY_P}-f2fs-tools.tar.xz https://dev.gentoo.org/~zmedico/dist/${MY_P}-f2fs-tools.tar.xz
27 mirror://gentoo/${MY_P}.ninja.xz https://dev.gentoo.org/~zmedico/dist/${MY_P}.ninja.xz"
29 # The entire source code is Apache-2.0, except for fastboot which is BSD-2.
30 LICENSE="Apache-2.0 BSD-2"
32 KEYWORDS="amd64 ~arm x86 ~x86-linux"
34 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
36 DEPEND="sys-libs/zlib:=
40 python? ( ${PYTHON_DEPS} )"
45 CMAKE_USE_DIR="${S}/boringssl"
52 pushd "${dir}" >/dev/null || die
54 if [[ ${dir} != ./* ]] ; then
61 unpack_into "${MY_P}-arch.tar.xz" arch
62 unpack_into "${MY_P}-core.tar.gz" core
63 unpack_into "${MY_P}-e2fsprogs.tar.xz" ./e2fsprogs
64 unpack_into "${MY_P}-extras.tar.xz" extras
65 unpack_into "${MY_P}-f2fs-tools.tar.xz" ./f2fs-tools
66 unpack_into "${MY_P}-selinux.tar.xz" ./selinux
67 unpack_into boringssl-${BORINGSSL_SHA1}.tar.gz boringssl
69 unpack "${MY_P}.ninja.xz"
70 mv "${MY_P}.ninja" "build.ninja" || die
72 # Avoid depending on gtest just for its prod headers when boringssl bundles it.
73 ln -s ../../boringssl/third_party/googletest/include/gtest core/include/ || die
77 sed -e 's:elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386"):\0\n set(ARCH "x86")\nelseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i586"):' \
78 -i "${S}"/boringssl/CMakeLists.txt || die #668792
81 eapply "${WORKDIR}"/arch/trunk/fix_build_core.patch
82 eapply "${FILESDIR}"/android-tools-8.1.0_p1-build.patch
84 cd "${S}"/selinux || die
85 eapply "${WORKDIR}"/arch/trunk/fix_build_selinux.patch
87 cd "${S}"/e2fsprogs || die
88 eapply "${WORKDIR}"/arch/trunk/fix_build_e2fsprogs.patch
91 sed -e 's|^#include <sys/cdefs.h>$|/*\0*/|' \
92 -e 's|^__BEGIN_DECLS$|#ifdef __cplusplus\nextern "C" {\n#endif|' \
93 -e 's|^__END_DECLS$|#ifdef __cplusplus\n}\n#endif|' \
94 -i ext4_utils/include/ext4_utils/ext4_crypt{,_init_extensions}.h || die #580686
100 -e "s|^(CC =).*|\\1 $(tc-getCC)|g" \
101 -e "s|^(CXX =).*|\\1 $(tc-getCXX)|g" \
102 -e "s|^(CFLAGS =).*|\\1 ${CFLAGS}|g" \
103 -e "s|^(CPPFLAGS =).*|\\1 ${CPPFLAGS}|g" \
104 -e "s|^(CXXFLAGS =).*|\\1 ${CXXFLAGS}|g" \
105 -e "s|^(LDFLAGS =).*|\\1 ${LDFLAGS}|g" \
106 -e "s|^(PKGVER =).*|\\1 ${MY_PV}|g" \
107 -i build.ninja || die
109 # The pregenerated ninja file expects the build/ dir.
110 BUILD_DIR="${CMAKE_USE_DIR}/build"
111 cmake-utils_src_prepare
117 cmake-utils_src_configure
121 # We only need a few libs from boringssl.
122 cmake-utils_src_compile libcrypto.a libssl.a
128 dobin adb e2fsdroid ext2simg fastboot mke2fs.android
129 dodoc core/adb/*.{txt,TXT} core/fastboot/README.md
130 use python && python_foreach_impl python_doexe core/mkbootimg/mkbootimg
131 newbashcomp arch/trunk/bash_completion.fastboot fastboot