Skip to content

Commit 9f1ba33

Browse files
committed
WIP
1 parent dba55f3 commit 9f1ba33

File tree

5 files changed

+328
-124
lines changed

5 files changed

+328
-124
lines changed

build-raspberrypi/Dockerfile

Lines changed: 269 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RUN mkdir -p $YADOMS_BUILD_TOOLS_PATH
1818
RUN mkdir -p $YADOMS_DEPS
1919
RUN mkdir -p $RPI_SYSROOT
2020

21+
COPY toolchain-rpi2.cmake ${YADOMS_DEPS}/toolchain-rpi2.cmake
2122

2223
#############################################################
2324
## Install all needed packages
@@ -38,13 +39,14 @@ RUN cat /etc/*-release
3839
# gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf cmake \
3940
# pkg-config ca-certificates wget coreutils bzip2 \
4041
# && rm -rf /var/lib/apt/lists/*
41-
RUN apt-get update \
42-
&& apt-get install -q -y --no-install-recommends \
43-
build-essential gcc g++ \
42+
#TODO regrouper toutes ces lignes :
43+
RUN apt-get update
44+
RUN apt-get install -q -y --no-install-recommends \
45+
build-essential gcc g++ autoconf automake libtool \
4446
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf cmake \
4547
ca-certificates wget coreutils bzip2 python3 python3-venv python3-pip \
46-
perl \
47-
&& rm -rf /var/lib/apt/lists/*
48+
perl swig unzip
49+
RUN rm -rf /var/lib/apt/lists/*
4850
# TODO besoin ? && apt-get dist-upgrade -q -y \
4951
# TODO besoin ? pkg-config-arm-linux-gnueabihf
5052

@@ -54,6 +56,7 @@ RUN apt-get update \
5456
RUN cmake --version
5557

5658

59+
5760
#############################################################
5861
## Download and extract minimal RaspberryPi sysroot (created by extract-sysroot-raspberrypi docker)
5962
#############################################################
@@ -104,6 +107,7 @@ RUN rm -Rf boost_$boost_version \
104107
#############################################################
105108
## OpenSSL (cross compile only)
106109
#############################################################
110+
#TODO tester version plus récente
107111
ARG openssl_version=1.1.1k
108112
WORKDIR $YADOMS_DEPS
109113
RUN wget --no-check-certificate --no-verbose https://www.openssl.org/source/openssl-1.1.1k.tar.gz \
@@ -114,26 +118,43 @@ RUN make CC="arm-linux-gnueabihf-gcc" AR="arm-linux-gnueabihf-ar" RANLIB="arm-li
114118
&& make install > /dev/null
115119
WORKDIR $YADOMS_DEPS
116120
RUN rm -Rf openssl-${openssl_version} && rm openssl-${openssl_version}.tar.gz > /dev/null
117-
#TODO virer ligne qui suit
118-
RUN ls $YADOMS_DEPS/openssl-rpi2-armhf
119121

122+
#TODO mettre dans le readme : pour debugger le build, appeler ça :
123+
# export BUILDKIT_PROGRESS=plain
124+
# Pour builder :
125+
# clear && docker build -t build_for_raspberrypi --progress plain .
120126

121-
# OpenSSL (both cross compile and for host)
122-
#TODO remettre
123-
# ARG openssl_version=1.1.1k
124-
# RUN cd $YADOMS_DEPS \
125-
# && wget --no-check-certificate --no-verbose https://www.openssl.org/source/openssl-$openssl_version.tar.gz > /dev/null\
126-
# && tar xzf openssl-$openssl_version.tar.gz && cd openssl-$openssl_version > /dev/null\
127-
# && ./Configure linux-generic32 --prefix=$YADOMS_DEPS/openssl --cross-compile-prefix=$YADOMS_BUILD_TOOLS_PATH/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf- > /dev/null\
128-
# && make CC="arm-linux-gnueabihf-gcc" AR="arm-linux-gnueabihf-ar" RANLIB="arm-linux-gnueabihf-ranlib" > /dev/null\
129-
# && make install > /dev/null\
130-
# && cd .. && rm -Rf openssl-$openssl_version \
131-
# && tar xzf openssl-$openssl_version.tar.gz && cd openssl-$openssl_version > /dev/null\
132-
# && ./config && make && make install\
133-
# && cd .. && rm -Rf openssl-$openssl_version && rm $YADOMS_DEPS/openssl-$openssl_version.tar.gz
134127

128+
#############################################################
129+
## Poco
130+
#############################################################
131+
ARG poco_version=1.11.8p2
132+
WORKDIR $YADOMS_DEPS
133+
RUN wget --no-check-certificate --no-verbose http://pocoproject.org/releases/poco-${poco_version}/poco-${poco_version}-all.tar.gz \
134+
&& tar xzf poco-${poco_version}-all.tar.gz > /dev/null
135+
WORKDIR $YADOMS_DEPS/poco-${poco_version}-all/
136+
RUN echo 'TOOL = arm-linux-gnueabihf' > build/config/RaspberryPI \
137+
&& cat build/config/ARM-Linux >> build/config/RaspberryPI \
138+
&& echo 'STATICOPT_CC = -fPIC' >> build/config/RaspberryPI \
139+
&& echo 'STATICOPT_CXX = -fPIC' >> build/config/RaspberryPI
140+
RUN ./configure \
141+
--static \
142+
--config=RaspberryPI \
143+
--prefix=$YADOMS_DEPS/poco-rpi2-armhf \
144+
--no-samples \
145+
--no-tests \
146+
--omit=CppUnit,CppUnit/WinTestRunner,Data,Data/SQLite,Data/ODBCData/MySQL,MongoDB,PageCompiler,PageCompiler/File2Page \
147+
--include-path=$YADOMS_DEPS/openssl-rpi2-armhf/include \
148+
--library-path=$YADOMS_DEPS/openssl-rpi2-armhf/lib
149+
RUN make \
150+
&& make install
151+
RUN cp VERSION $YADOMS_DEPS/poco-rpi2-armhf
152+
WORKDIR $YADOMS_DEPS
153+
RUN rm -Rf poco-${poco_version}-all/ \
154+
&& rm poco-${poco_version}-all.tar.gz
155+
156+
135157

136-
137158
# Poco (1.11.8p2 is the last version compatible with current toolchain based on GCC 4.9.3)
138159
#TODO remettre
139160
# ARG poco_version=1.11.8p2
@@ -151,6 +172,48 @@ RUN ls $YADOMS_DEPS/openssl-rpi2-armhf
151172
# && rm $YADOMS_DEPS/poco-$poco_version-all.tar.gz
152173

153174

175+
176+
#############################################################
177+
## Protobuf
178+
#############################################################
179+
# Protobuf (Host)
180+
ARG protobuf_version=3.15.8
181+
WORKDIR $YADOMS_DEPS
182+
RUN wget --no-verbose https://github.com/google/protobuf/releases/download/v${protobuf_version}/protobuf-cpp-${protobuf_version}.tar.gz \
183+
&& tar xzf protobuf-cpp-${protobuf_version}.tar.gz
184+
RUN cp -R protobuf-${protobuf_version} protobuf-${protobuf_version}-host
185+
WORKDIR $YADOMS_DEPS/protobuf-${protobuf_version}-host
186+
RUN mkdir build
187+
WORKDIR $YADOMS_DEPS/protobuf-${protobuf_version}-host/build
188+
RUN cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../cmake
189+
RUN make \
190+
&& make install \
191+
&& ldconfig
192+
193+
# Protobuf (Pi)
194+
WORKDIR $YADOMS_DEPS/protobuf-${protobuf_version}
195+
RUN ./autogen.sh
196+
RUN ./configure \
197+
--enable-shared=no \
198+
--host=arm-linux \
199+
CC=arm-linux-gnueabihf-gcc \
200+
CXX=arm-linux-gnueabihf-g++ \
201+
AR=arm-linux-gnueabihf-ar \
202+
STRIP=arm-linux-gnueabihf-strip \
203+
RANLIB=arm-linux-gnueabihf-ranlib \
204+
--prefix=$YADOMS_DEPS/protobuf-rpi2-armhf \
205+
--with-protoc=protoc \
206+
--with-pic
207+
RUN make \
208+
&& make install
209+
210+
# Cleanup
211+
WORKDIR $YADOMS_DEPS
212+
RUN rm -Rf protobuf-${protobuf_version} \
213+
&& rm -Rf protobuf-${protobuf_version}-host \
214+
&& rm protobuf-cpp-${protobuf_version}.tar.gz
215+
216+
154217
# Protobuf (Host)
155218
#TODO remettre
156219
# ARG protobuf_version=3.15.8
@@ -162,6 +225,8 @@ RUN ls $YADOMS_DEPS/openssl-rpi2-armhf
162225
# && cd build \
163226
# && cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../cmake && make && make install \
164227
# && ldconfig > /dev/null
228+
229+
165230
# Protobuf (Pi)
166231
#TODO remettre
167232
# RUN mv protobuf-$protobuf_version $YADOMS_DEPS/protobuf-$protobuf_version \
@@ -173,9 +238,28 @@ RUN ls $YADOMS_DEPS/openssl-rpi2-armhf
173238
# && cd .. && rm -Rf $YADOMS_DEPS/protobuf-protobuf_version
174239

175240

176-
# Swig
177-
#TODO remettre
241+
242+
243+
# TODO désactivé car on utilise le Swig installé (de apt-get)
244+
# #############################################################
245+
# ## Swig
246+
# #############################################################
178247
# ARG swig_version=4.0.2
248+
# WORKDIR $YADOMS_DEPS
249+
# RUN wget --no-check-certificate --no-verbose http://prdownloads.sourceforge.net/swig/swig-${swig_version}.tar.gz \
250+
# && tar xzf swig-${swig_version}.tar.gz
251+
# WORKDIR $YADOMS_DEPS/swig-${swig_version}
252+
# RUN ./configure \
253+
# && make \
254+
# && make install
255+
# WORKDIR $YADOMS_DEPS
256+
# RUN rm -f swig-${swig_version}/Source/Modules/*.o \
257+
# && rm -Rf swig-${swig_version}/Examples \
258+
# && rm -Rf swig-${swig_version}/Docs \
259+
# && rm swig-${swig_version}.tar.gz
260+
261+
262+
179263
# RUN cd $YADOMS_DEPS \
180264
# && echo "http://prdownloads.sourceforge.net/swig/swig-$swig_version.tar.gz" \
181265
# && wget --no-check-certificate --no-verbose http://prdownloads.sourceforge.net/swig/swig-$swig_version.tar.gz > /dev/null\
@@ -190,6 +274,42 @@ RUN ls $YADOMS_DEPS/openssl-rpi2-armhf
190274
# && rm -Rf swig-$swig_version/Docs \
191275
# && rm $YADOMS_DEPS/swig-$swig_version.tar.gz
192276

277+
278+
279+
280+
#############################################################
281+
## Python
282+
#############################################################
283+
ARG python3_version=3.13.7
284+
WORKDIR $YADOMS_DEPS
285+
RUN wget --no-check-certificate --no-verbose https://www.python.org/ftp/python/${python3_version}/Python-${python3_version}.tar.xz \
286+
&& tar xf Python-${python3_version}.tar.xz
287+
WORKDIR $YADOMS_DEPS/Python-${python3_version}
288+
RUN CC=arm-linux-gnueabihf-gcc \
289+
CXX=arm-linux-gnueabihf-g++ \
290+
AR=arm-linux-gnueabihf-ar \
291+
RANLIB=arm-linux-gnueabihf-ranlib \
292+
./configure \
293+
--host=arm-linux-gnueabihf \
294+
--target=arm-linux-gnueabihf \
295+
--build=x86_64-linux-gnu \
296+
--disable-ipv6 ac_cv_file__dev_ptmx=no \
297+
ac_cv_file__dev_ptc=no \
298+
ac_cv_have_long_long_format=yes \
299+
--enable-shared \
300+
--without-pymalloc \
301+
--with-openssl=$YADOMS_DEPS/openssl-rpi2-armhf \
302+
--with-build-python
303+
RUN make HOSTPYTHON=/usr/local/bin/python3 \
304+
BLDSHARED="arm-linux-gnueabihf-gcc -shared" \
305+
CROSS-COMPILE=arm-linux-gnueabihf- \
306+
CROSS_COMPILE_TARGET=yes \
307+
HOSTARCH=arm-linux \
308+
BUILDARCH=arm-linux-gnueabihf
309+
WORKDIR $YADOMS_DEPS
310+
RUN rm Python-${python3_version}.tar.xz
311+
312+
193313

194314
# Python 3.7 (Host)
195315
#TODO remettre
@@ -242,6 +362,104 @@ RUN ls $YADOMS_DEPS/openssl-rpi2-armhf
242362
# && make install > /dev/null\
243363
# && cd ../.. && rm -Rf gammu-1.40.*
244364

365+
366+
#############################################################
367+
## OpenCV
368+
#############################################################
369+
ARG opencv_version=4.5.2
370+
WORKDIR $YADOMS_DEPS
371+
RUN wget --no-verbose --no-check-certificate https://github.com/opencv/opencv/archive/${opencv_version}.zip \
372+
&& unzip ${opencv_version}.zip
373+
WORKDIR $YADOMS_DEPS/opencv-${opencv_version}
374+
RUN mkdir build
375+
WORKDIR $YADOMS_DEPS/opencv-${opencv_version}/build
376+
RUN cmake -DCC_RPI_GCC=arm-linux-gnueabihf-gcc \
377+
-DCC_RPI_GXX=arm-linux-gnueabihf-g++ \
378+
-DBUILD_SHARED_LIBS=OFF \
379+
-DCMAKE_TOOLCHAIN_FILE=$YADOMS_DEPS/toolchain-rpi2.cmake \
380+
-DWITH_EIGEN:BOOL="0" \
381+
-DWITH_IMGCODEC_HDR:BOOL="0" \
382+
-DBUILD_opencv_ts:BOOL="0" \
383+
-DBUILD_opencv_video:BOOL="0" \
384+
-DWITH_TIFF:BOOL="0" \
385+
-DBUILD_PACKAGE:BOOL="0" \
386+
-DBUILD_opencv_features2d:BOOL="0" \
387+
-DBUILD_ITT:BOOL="0" \
388+
-Dthunder:BOOL="0" \
389+
-Dlzw:BOOL="0" \
390+
-DCV_TRACE:BOOL="0" \
391+
-DWITH_MSMF:BOOL="0" \
392+
-DWITH_FFMPEG:BOOL="0" \
393+
-DWITH_IMGCODEC_PXM:BOOL="0" \
394+
-DWITH_MSMF_DXVA:BOOL="0" \
395+
-DCPACK_SOURCE_ZIP:BOOL="0" \
396+
-Dpackbits:BOOL="0" \
397+
-DBUILD_opencv_apps:BOOL="0" \
398+
-DBUILD_PROTOBUF:BOOL="0" \
399+
-DBUILD_opencv_objdetect:BOOL="0" \
400+
-DBUILD_IPP_IW:BOOL="0" \
401+
-DBUILD_opencv_videoio:BOOL="0" \
402+
-DBUILD_PERF_TESTS:BOOL="0" \
403+
-Dmdi:BOOL="0" \
404+
-DWITH_1394:BOOL="0" \
405+
-DINSTALL_PDB:BOOL="0" \
406+
-DWITH_OPENCL:BOOL="0" \
407+
-DM_LIBRARY:FILEPATH="M_LIBRARY-NOTFOUND" \
408+
-DUSE_WIN32_FILEIO:BOOL="1" \
409+
-DCPACK_SOURCE_7Z:BOOL="0" \
410+
-DBUILD_opencv_stitching:BOOL="0" \
411+
-Dccitt:BOOL="0" \
412+
-DVIDEOIO_ENABLE_STRICT_PLUGIN_CHECK:BOOL="0" \
413+
-DWITH_IPP:BOOL="0" \
414+
-DBUILD_opencv_dnn:BOOL="0" \
415+
-DWITH_ITT:BOOL="0" \
416+
-DCPACK_BINARY_NSIS:BOOL="0" \
417+
-DBUILD_opencv_photo:BOOL="0" \
418+
-DBUILD_opencv_calib3d:BOOL="0" \
419+
-DWITH_QUIRC:BOOL="0" \
420+
-DWITH_WEBP:BOOL="0" \
421+
-DBUILD_opencv_python_bindings_generator:BOOL="0" \
422+
-DWITH_PROTOBUF:BOOL="0" \
423+
-DBUILD_JASPER:BOOL="1" \
424+
-DWITH_OPENCLAMDBLAS:BOOL="0" \
425+
-DBUILD_JAVA:BOOL="0" \
426+
-DWITH_VTK:BOOL="0" \
427+
-DBUILD_opencv_java_bindings_generator:BOOL="0" \
428+
-DBUILD_opencv_highgui:BOOL="0" \
429+
-DWITH_ARITH_DEC:BOOL="0" \
430+
-DWITH_IMGCODEC_SUNRASTER:BOOL="0" \
431+
-DWITH_ADE:BOOL="0" \
432+
-DBUILD_OPENEXR:BOOL="0" \
433+
-DWITH_OPENEXR:BOOL="0" \
434+
-DWITH_OPENCLAMDFFT:BOOL="0" \
435+
-DVIDEOIO_ENABLE_PLUGINS:BOOL="0" \
436+
-DWITH_DSHOW:BOOL="0" \
437+
-DOPENCV_DNN_OPENCL:BOOL="0" \
438+
-DWITH_LAPACK:BOOL="0" \
439+
-DWITH_IMGCODEC_PFM:BOOL="0" \
440+
-Dlogluv:BOOL="0" \
441+
-DINSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL:BOOL="0" \
442+
-DBUILD_opencv_ml:BOOL="0" \
443+
-DOPENCV_ENABLE_MEMALIGN:BOOL="0" \
444+
-DBUILD_opencv_python_tests:BOOL="0" \
445+
-DCV_ENABLE_INTRINSICS:BOOL="0" \
446+
-DOPENCL_FOUND:BOOL="0" \
447+
-DWITH_OPENCL_D3D11_NV:BOOL="0" \
448+
-Dnext:BOOL="0" \
449+
-DBUILD_opencv_gapi:BOOL="0" \
450+
-DBUILD_opencv_flann:BOOL="0" \
451+
-DBUILD_TESTS:BOOL="0" \
452+
-DWITH_DIRECTX:BOOL="0" \
453+
-DCMAKE_BUILD_TYPE=Release \
454+
-DCMAKE_INSTALL_PREFIX=$YADOMS_DEPS/opencv-rpi2-armhf \
455+
..
456+
RUN make \
457+
&& make install
458+
WORKDIR $YADOMS_DEPS
459+
RUN rm -Rf opencv-${opencv_version}* \
460+
&& rm -f ${opencv_version}.zip
461+
462+
245463
# Opencv
246464
#TODO remettre
247465
# ARG opencv_version=4.5.2
@@ -260,9 +478,10 @@ RUN ls $YADOMS_DEPS/openssl-rpi2-armhf
260478
# && cd ../.. && rm -Rf opencv-$opencv_version* && rm -f $opencv_version.zip
261479

262480
#TODO remettre
263-
# COPY libudev.tar.gz $YADOMS_DEPS
264-
# RUN cd $YADOMS_DEPS \
265-
# && tar xf libudev.tar.gz
481+
WORKDIR $YADOMS_DEPS
482+
COPY libudev.tar.gz .
483+
RUN tar xf libudev.tar.gz
484+
RUN rm libudev.tar.gz
266485

267486

268487

@@ -297,10 +516,30 @@ RUN ls $YADOMS_DEPS/openssl-rpi2-armhf
297516
# && echo 'SET(COTIRE_USE_UNITY ON)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
298517
# && echo 'set(CC_RPI_ROOT "'$YADOMS_BUILD_TOOLS_PATH'/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt
299518

519+
RUN echo 'Configuring Yadoms CMakeListsUserConfig.txt' \
520+
&& echo 'set(COTIRE_USE ON)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
521+
&& echo 'set(COTIRE_USE_UNITY ON)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
522+
&& echo 'set(DEBUG_WITH_GCC OFF)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
523+
&& echo 'set(BOOST_ROOT "$YADOMS_DEPS/boost-rpi2-armhf")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
524+
&& echo 'set(POCO_ROOT "$YADOMS_DEPS/poco-rpi2-armhf")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
525+
&& echo 'set(PROTOBUF_ROOT "$YADOMS_DEPS/protobuf-rpi2-armhf")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
526+
&& echo 'set(PROTOBUF_PROTOC_EXECUTABLE "protoc")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
527+
&& echo 'set(PROTOBUF_INSTALLED_TO_CUSTOM_DIRECTORY ON)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
528+
&& echo 'set(OPENSSL_ROOT "$YADOMS_DEPS/openssl-rpi2-armhf")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
529+
&& echo 'set(PYTHON_USE_PKGCONFIG OFF)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
530+
&& echo 'set(PYTHON_USE_SOURCES ON)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
531+
&& echo 'set(Python3_ManualSetup ON)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
532+
&& echo 'set(Python3_EXECUTABLE "/usr/local/bin/python3")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
533+
&& echo "set(Python3_LIBRARIES \"\$YADOMS_DEPS/Python-${python3_version}/libpython$(echo ${python3_version} | awk -F. '{print $1 "." $2}').a\")" >> CMakeListsUserConfig.txt \
534+
&& echo 'set(Python3_INCLUDE_DIRS "$YADOMS_DEPS/Python-${python3_version}")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
535+
&& echo 'set(USE_PGSQL_DATABASE OFF)' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
536+
&& echo 'set(OPENCV_ROOT "$YADOMS_DEPS/opencv-rpi2-armhf")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt \
537+
&& echo 'set(LIBUDEV_ROOT "$YADOMS_DEPS/libudev")' >> $YADOMS_DEPS/CMakeListsUserConfig.txt
538+
539+
300540
#For debug purpose only
301-
#TODO remettre
302-
# RUN cat $YADOMS_DEPS/CMakeListsUserConfig.txt
541+
RUN cat $YADOMS_DEPS/CMakeListsUserConfig.txt
303542

304543
#TODO remettre
305-
# COPY raspberrypi.yadoms.cmake $YADOMS_DEPS/raspberrypi.cmake
306-
# COPY entrypoint_docker.sh /entrypoint_docker.sh
544+
#TODO à virer ? COPY raspberrypi.yadoms.cmake $YADOMS_DEPS/raspberrypi.cmake
545+
COPY entrypoint_docker.sh /entrypoint_docker.sh

0 commit comments

Comments
 (0)