xref: /aosp_15_r20/external/openthread/etc/docker/android-trusty/Dockerfile (revision cfb92d1480a9e65faed56933e9c12405f45898b4)
1#
2#  Copyright (c) 2020, The OpenThread Authors.
3#  All rights reserved.
4#
5#  Redistribution and use in source and binary forms, with or without
6#  modification, are permitted provided that the following conditions are met:
7#  1. Redistributions of source code must retain the above copyright
8#     notice, this list of conditions and the following disclaimer.
9#  2. Redistributions in binary form must reproduce the above copyright
10#     notice, this list of conditions and the following disclaimer in the
11#     documentation and/or other materials provided with the distribution.
12#  3. Neither the name of the copyright holder nor the
13#     names of its contributors may be used to endorse or promote products
14#     derived from this software without specific prior written permission.
15#
16#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26#  POSSIBILITY OF SUCH DAMAGE.
27#
28
29#
30# Ubuntu 14.04 with tools required to run OpenThread Android check
31#
32
33FROM ubuntu:14.04
34
35ENV DEBIAN_FRONTEND noninteractive
36ENV ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
37ENV OPT_BIN=/opt/bin
38ENV PATH=$OPT_BIN:$PATH
39ENV ANDROID_NDK_PATH=/opt/ndk-bundle
40
41WORKDIR /build
42
43RUN apt-get -y update && apt-get --no-install-recommends install -y \
44        gcc-multilib \
45        g++-multilib \
46        git \
47        make \
48        python \
49        unzip \
50        wget
51
52RUN wget https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip \
53        && unzip android-ndk-r17c-linux-x86_64.zip > /dev/null \
54        && mv android-ndk-r17c $ANDROID_NDK_PATH \
55        && rm android-ndk-r17c-linux-x86_64.zip
56
57# Android build system
58RUN mkdir build && cd build && git init && git pull --depth 1 https://android.googlesource.com/platform/build 2db32730e79cafcf13e1f898a7bee7f82b0449d6
59RUN ln -s build/core/main.mk Makefile
60
61RUN mkdir /opt/bin
62
63# Workarounds for java checking
64RUN printf '#!/bin/sh\n\
65echo java version \\"1.6\\"'\
66> $OPT_BIN/java \
67    && printf '#!/bin/sh\n\
68echo javac \\"1.6\\"'\
69> $OPT_BIN/javac \
70    && chmod a+x $OPT_BIN/java $OPT_BIN/javac \
71    && mkdir -p /usr/lib/jvm/java-6-openjdk-amd64/lib/ \
72    && touch /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar
73
74# Files for building ndk
75# The default libstdc++.so does not contain full stl implementation, see https://developer.android.com/ndk/guides/cpp-support
76RUN mkdir -p system/core/include/arch/linux-arm \
77    && touch system/core/include/arch/linux-arm/AndroidConfig.h \
78    && mkdir -p system/core/include/arch/linux-x86 \
79    && touch system/core/include/arch/linux-x86/AndroidConfig.h \
80    && mkdir -p bionic/libc/ \
81    && cp -r "$ANDROID_NDK_PATH"/sysroot/usr/include bionic/libc/include \
82    && mv bionic/libc/include/arm-linux-androideabi/asm bionic/libc/include/asm \
83    && mkdir -p out/target/product/generic/obj/ \
84    && cp -r "$ANDROID_NDK_PATH"/platforms/android-27/arch-arm/usr/lib out/target/product/generic/obj/ \
85    && mkdir -p bionic/libstdc++ \
86    && cp -r "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/include bionic/libstdc++ \
87    && cp -r "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/* bionic/libstdc++/include \
88    && cp "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so out/target/product/generic/obj/lib/libstdc++.so \
89    && printf "TARGET_PRODUCT := generic\n\
90TARGET_BUILD_VARIANT := eng\n\
91TARGET_BUILD_TYPE := release\n\
92TARGET_TOOLS_PREFIX := $ANDROID_NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-"\
93> buildspec.mk
94
95RUN rm -rf "$ANDROID_NDK_PATH"/platforms
96RUN rm -rf "$ANDROID_NDK_PATH"/prebuilt
97RUN rm -rf "$ANDROID_NDK_PATH"/shader-tools
98RUN rm -rf "$ANDROID_NDK_PATH"/sources
99RUN rm -rf "$ANDROID_NDK_PATH"/sysroot
100RUN rm -rf "$ANDROID_NDK_PATH"/simpleperf
101RUN cd "$ANDROID_NDK_PATH"/toolchains && rm -rf aarch64-linux-android-4.9 llvm mips64el-linux-android-4.9 mipsel-linux-android-4.9 x86-4.9 x86_64-4.9
102RUN apt-get purge -y unzip wget git && apt-get -y autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*
103
104CMD ["bash"]
105
106