<commit_before>FROM alpine:3.8 AS build
LABEL maintainer="<NAME> <<EMAIL>>"

RUN wget https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip \
    && unzip android-ndk-r17b-linux-x86_64.zip \
    && rm android-ndk-r17b-linux-x86_64.zip
ENV ANDROID_NDK_HOME="/android-ndk-r17b"

RUN apk add --no-cache \
    # needed by the ndk
    bash coreutils python \
    # needed to build gcc
    build-base gcc-gnat zlib-dev

WORKDIR /ada-android

RUN $ANDROID_NDK_HOME/build/tools/make-standalone-toolchain.sh \
    --arch=arm \
    --platform=android-14 \
    --stl=libc++ \
    --install-dir=./ndk-chain

ARG GCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-6.4.0/gcc-6.4.0.tar.xz
ARG BINUTILS_URL=https://ftp.gnu.org/gnu/binutils/binutils-2.28.tar.bz2

# Download and extract binutils and gcc
RUN wget $GCC_URL $BINUTILS_URL \
    && tar xf gcc-* \
    && tar xf binutils-* \
    && rm *.tar.* \
    && mv binutils-* binutils \
    && mv gcc-* gcc \
    && cd gcc \
    && ./contrib/download_prerequisites

# https://developer.android.com/ndk/guides/abis#v7a
# Since Android 5.0, only PIE executables are supported.
# PIE doesn't work on 4.0 and earlier; static linking solves that.
ARG CONFIGURE_ARGS="\
    --prefix=/ada-android/toolchain \
    --target=arm-linux-androideabi \
    --with-sysroot=/ada-android/ndk-chain/sysroot \
    --with-float=soft \
    --with-fpu=vfpv3-d16 \
    --with-arch=armv7-a \
    --enable-languages=ada \
    --enable-threads=posix \
    --enable-shared \
    --enable-default-pie \
    --disable-tls \
    --enable-initfini-array \
    --disable-nls \
    --enable-plugins \
    --disable-werror \
    --with-system-zlib \
    --disable-gdb \
    CFLAGS_FOR_TARGET=-D__ANDROID_API__=14"

# Build binutils
RUN cd binutils \
    && mkdir build \
    && cd build \
    && ../configure $CONFIGURE_ARGS \
    && make -j$(nproc) \
    && make install

# Build gcc
COPY ada-musl.patch /ada-android/
RUN cd gcc \
    && patch -p1 -i ../ada-musl.patch \
    && mkdir build \
    && cd build \
    && ../configure $CONFIGURE_ARGS \
    && make -j$(nproc) \
    && make install

RUN strip $(find toolchain/bin toolchain/libexec -type f) || true

FROM alpine:3.8
COPY --from=build /ada-android/toolchain/ /usr/
COPY --from=build /ada-android/ndk-chain/sysroot/usr/lib/ \
                  /usr/arm-linux-androideabi/lib/armv7-a/
ENV LD_LIBRARY_PATH=/usr/x86_64-pc-linux-gnu/arm-linux-androideabi/lib<commit_msg>docker: add maintainer label to final image<commit_after>FROM alpine:3.8 AS build
LABEL maintainer="<NAME> <<EMAIL>>"

RUN wget https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip \
    && unzip android-ndk-r17b-linux-x86_64.zip \
    && rm android-ndk-r17b-linux-x86_64.zip
ENV ANDROID_NDK_HOME="/android-ndk-r17b"

RUN apk add --no-cache \
    # needed by the ndk
    bash coreutils python \
    # needed to build gcc
    build-base gcc-gnat zlib-dev

WORKDIR /ada-android

RUN $ANDROID_NDK_HOME/build/tools/make-standalone-toolchain.sh \
    --arch=arm \
    --platform=android-14 \
    --stl=libc++ \
    --install-dir=./ndk-chain

ARG GCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-6.4.0/gcc-6.4.0.tar.xz
ARG BINUTILS_URL=https://ftp.gnu.org/gnu/binutils/binutils-2.28.tar.bz2

# Download and extract binutils and gcc
RUN wget $GCC_URL $BINUTILS_URL \
    && tar xf gcc-* \
    && tar xf binutils-* \
    && rm *.tar.* \
    && mv binutils-* binutils \
    && mv gcc-* gcc \
    && cd gcc \
    && ./contrib/download_prerequisites

# https://developer.android.com/ndk/guides/abis#v7a
# Since Android 5.0, only PIE executables are supported.
# PIE doesn't work on 4.0 and earlier; static linking solves that.
ARG CONFIGURE_ARGS="\
    --prefix=/ada-android/toolchain \
    --target=arm-linux-androideabi \
    --with-sysroot=/ada-android/ndk-chain/sysroot \
    --with-float=soft \
    --with-fpu=vfpv3-d16 \
    --with-arch=armv7-a \
    --enable-languages=ada \
    --enable-threads=posix \
    --enable-shared \
    --enable-default-pie \
    --disable-tls \
    --enable-initfini-array \
    --disable-nls \
    --enable-plugins \
    --disable-werror \
    --with-system-zlib \
    --disable-gdb \
    CFLAGS_FOR_TARGET=-D__ANDROID_API__=14"

# Build binutils
RUN cd binutils \
    && mkdir build \
    && cd build \
    && ../configure $CONFIGURE_ARGS \
    && make -j$(nproc) \
    && make install

# Build gcc
COPY ada-musl.patch /ada-android/
RUN cd gcc \
    && patch -p1 -i ../ada-musl.patch \
    && mkdir build \
    && cd build \
    && ../configure $CONFIGURE_ARGS \
    && make -j$(nproc) \
    && make install

RUN strip $(find toolchain/bin toolchain/libexec -type f) || true

FROM alpine:3.8
LABEL maintainer="<NAME> <<EMAIL>>"
COPY --from=build /ada-android/toolchain/ /usr/
COPY --from=build /ada-android/ndk-chain/sysroot/usr/lib/ \
                  /usr/arm-linux-androideabi/lib/armv7-a/
ENV LD_LIBRARY_PATH=/usr/x86_64-pc-linux-gnu/arm-linux-androideabi/lib
{'fraction_non_alphanumeric': 0.15910931174089069, 'fraction_numerical': 0.02145748987854251, 'mean_word_length': 2.388888888888889, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '62483', 'n_tokens_mistral': 2005, 'n_tokens_neox': 1878, 'n_words': 348}