-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerfile_raspberrypi
58 lines (47 loc) · 2.51 KB
/
dockerfile_raspberrypi
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
FROM ubuntu
LABEL description="this image is rapsberry pi ubuntu cross compilation environment, which installed necessary tool chain. Also with build azure iot sdks c."
#those packages are necessary for building azure iot sdk
RUN apt-get update
RUN apt-get install -y \
build-essential \
cmake \
curl \
git \
libcurl4-openssl-dev \
libssl-dev \
make \
pkg-config \
uuid-dev \
valgrind
#RUN sh -c "echo 'deb http://ppa.launchpad.net/aziotsdklinux/ppa-azureiot/ubuntu vivid main' >> /etc/apt/sources.list"
#RUN sh -c "echo 'deb-src http://ppa.launchpad.net/aziotsdklinux/ppa-azureiot/ubuntu vivid main' >> /etc/apt/sources.list"
#RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FDA6A393E4C2257F
#RUN apt-get install -y azure-iot-sdk-c-dev
RUN git clone https://github.com/yungez/rpitools.git
RUN git clone --recursive https://github.com/Azure/azure-iot-sdk-c.git
ENV RPI_ROOT ${PWD}/rpitools/raspbian-jessie-sysroot
RUN PATH=$PATH:./rpitools/arm-linux-gnueabihf/bin
# copy build script
COPY build.sh /
# build azure iot sdks
# generate toolchain-file
RUN echo 'INCLUDE(CMakeForceCompiler) \n\
SET(CMAKE_SYSTEM_NAME Linux) # this one is important \n\
SET(CMAKE_SYSTEM_VERSION 1) # this one not so much \n\
# this is the location of the amd64 toolchain targeting the Raspberry Pi \n\
SET(CMAKE_C_COMPILER $ENV{RPI_ROOT}/../arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc) \n\
# this is the file system root of the target \n\
SET(CMAKE_FIND_ROOT_PATH $ENV{RPI_ROOT}) \n\
# search for programs ls in the build host directories \n\
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) \n\
# for libraries and headers in the target directories \n\
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) \n\
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)' > toolchain-file-rpi.cmake
RUN ./azure-iot-sdk-c/build_all/linux/build.sh --toolchain-file ./toolchain-file-rpi.cmake -cl --sysroot=$RPI_ROOT
RUN echo 'alias gcc="arm-linux-gnueabihf-gcc --sysroot=$RPI_ROOT"' >> ~/.bashrc
ENV CC ${PWD}/rpitools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
ENV CXX ${PWD}/rpitools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
RUN echo clone iot-hub-c-raspberrypi-getting-started
RUN git clone -b develop --recursive https://github.com/Azure-samples/iot-hub-c-raspberrypi-getting-started.git
RUN echo build iot-hub-c-raspberrypi-getting-started
CMD cd iot-hub-c-raspberrypi-getting-started/.misc && ./build.sh --toolchain-file ./toolchain-rpi.cmake -cl --sysroot=$RPI_ROOT&& make