-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.crosstool-ng-rpi
128 lines (111 loc) · 4.37 KB
/
Dockerfile.crosstool-ng-rpi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
## base image
FROM abeimler/simple-cppbuilder:base AS base
ARG extra_libraries
ARG processor="x86_64"
ARG triplet_host="x64-linux"
ARG vcpkg_target_triplet="arm-linux"
ARG cross_triple="armv8-rpi4-linux-gnueabihf"
ARG cmake="cmake"
ARG make="ninja"
ARG cmake_generator="Ninja Multi-Config"
ARG cmake_toolchain_file="/home/cmake/rpi-toolchain.cmake"
# Install packages available from standard repos
RUN pacman-db-upgrade && \
pacman -S --noconfirm --needed \
wget curl pkg-config zip unzip tar go git help2man python unzip wget audit rsync && \
pacman -S --noconfirm \
gcc automake autoconf ${extra_libraries} \
cmake make ninja && \
pacman -Scc --noconfirm
# install multiarch stuff
#RUN echo '' >> /etc/pacman.conf && echo '[multilib]' >> /etc/pacman.conf && echo 'Include = /etc/pacman.d/mirrorlist' >> /etc/pacman.conf
#ARG lib32_extra_libraries=""
#USER yay
#RUN yay -Syu --noconfirm && yay -S --noconfirm \
# lib32-gcc-libs ${lib32_extra_libraries} && \
# yay -Scc --noconfirm && \
# rm -rf /home/yay/.cache/*
#USER root
# install crosstool-ng
ARG crosstool_dir="/home/cross/crosstool-ng"
ENV CT_ALLOW_BUILD_AS_ROOT_SURE 1
#COPY ./config/crosstool/crosstool-ng.config.rpi $cross_root/.config
RUN useradd -m -G root -s /bin/bash cross && passwd -d cross && echo "cross ALL=(ALL) ALL" >> /etc/sudoers
#RUN mkdir -p $crosstool_dir && chown cross:root $crosstool_dir
RUN git clone --depth 1 https://github.com/crosstool-ng/crosstool-ng $crosstool_dir
WORKDIR $crosstool_dir
RUN chown -R cross:root . && chmod -R 775 .
USER cross
RUN ./bootstrap && \
./configure --enable-local && \
make
RUN ./ct-ng ${cross_triple} && \
./ct-ng build
USER root
WORKDIR /
ARG cross_root="/home/cross/x-tools/${cross_triple}"
ENV TOOLCHAIN_PATH $cross_root
ENV PATH="${TOOLCHAIN_PATH}/bin:${PATH}"
ARG cc="${cross_triple}-gcc"
ARG cxx="${cross_triple}-g++"
# set default compiler
ENV CC $cc
ENV CXX $cxx
ENV CMAKE $cmake
ENV MAKE $make
# cross compiler settings
ENV PROCESSOR $processor
ENV CROSS_TRIPLET $cross_triple
ENV TARGET_TRIPLET $vcpkg_target_triplet
ENV CROSS_CMAKE $cmake
ENV CROSS_MAKE $make
ENV CROSS "${cross_triple}-"
ENV CROSS_TOOLCHAIN $cmake_toolchain_file
# get raspberrypi pi firmware
ARG raspberrypi_firmware_repo="https://github.com/raspberrypi/firmware.git"
ARG raspberrypi_firmware_branch="master"
ARG raspberrypi_firmware_source_dir="/home/raspberrypi"
RUN git clone --depth 1 -b $raspberrypi_firmware_branch $raspberrypi_firmware_repo $raspberrypi_firmware_source_dir
RUN mkdir -p /opt/vc && cp -rf ${raspberrypi_firmware_source_dir}/opt/vc/* /opt/vc
ENV RASPBERRYPI_FIRMWARE_DIR $raspberrypi_firmware_source_dir
# get raspberrypi pi tools (deprecated)
#ARG raspberrypi_tools_repo="https://github.com/raspberrypi/tools.git"
#ARG raspberrypi_tools_branch="master"
#ARG raspberrypi_tools_source_dir="/home/raspberrypi-tools"
#RUN git clone --depth 1 -b $raspberrypi_tools_branch $raspberrypi_tools_repo $raspberrypi_tools_source_dir
#ENV RASPBERRYPI_TOOLS_DIR $raspberrypi_tools_source_dir
# compiler env settings
#RUN cp ${crosstool_dir}/bash-completion/ct-ng /etc/bash_completion.d/ct-ng
RUN mkdir -p /home/cross && touch /home/cross/.bashrc
ARG setup_env_script="/home/cross/.bashrc"
ARG setup_env_script_args=""
ENV SETUP_ENV_SCRIPT $setup_env_script
ENV SETUP_ENV_SCRIPT_ARGS $setup_env_script_args
RUN echo "source \"$SETUP_ENV_SCRIPT $SETUP_ENV_SCRIPT_ARGS\"" >> /root/.bash_profile && \
. $setup_env_script $setup_env_script_args
ENV CMAKE $CROSS_CMAKE
ENV MAKE $CROSS_MAKE
# install vcpkg
ENV VCPKG_DEFAULT_HOST_TRIPLET $triplet_host
ENV VCPKG_DEFAULT_TRIPLET $vcpkg_target_triplet
ENV VCPKG_DISABLE_METRICS 1
RUN git clone --depth 1 https://github.com/Microsoft/vcpkg.git && \
./vcpkg/bootstrap-vcpkg.sh -disableMetrics
ENV VCPKG_ROOT "/home/project/vcpkg"
# build script settings
ENV TARGET "all"
ENV BUILD_TYPE "Release"
ENV CMAKE_GENERATOR $cmake_generator
ENV VCPKG_TOOLCHAIN_FILE "/home/project/vcpkg/scripts/buildsystems/vcpkg.cmake"
ENV TOOLCHAIN_FILE "/home/project/vcpkg/scripts/buildsystems/vcpkg.cmake"
ENV CHAINLOAD_TOOLCHAIN_FILE $cmake_toolchain_file
ENV CMAKE_ARGS ""
# setup project env
WORKDIR /home/project
COPY ./cmake /home/cmake
COPY ./scripts/docker-build.rpi.sh ./docker-build.sh
COPY ./taskfiles/*.yml /home/taskfiles/
COPY ./taskfiles/TaskfileCross.yml /home/taskfiles/Taskfile.yml
ENV PROJECT_DIR /home/project
WORKDIR /home/project
RUN mkdir build