blob: ffc68aa49639f8bfc1b5de23d5184c25eedad6c0 [file] [log] [blame]
Dylan Reide3dfa4e2018-04-25 09:48:41 -07001# Copyright 2018 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4#
5# Defines a docker image that can build sound open firmware
6#
7# Usage:
8# check out sof
9# build docker image:
10# docker build --build-arg UID=$(id -u) -t sof .
11# docker run -it -v <insert sof dir here>:/home/sof/workdir -v <soft git dir>:/home/sof/work/soft.git --user `id -u` sof
12#
13# For incremental builds:
14# docker run -it -v <insert sof dir here>:/home/sof/work/sof.git -v <soft git dir>:/home/sof/work/soft.git --user `id -u` sof ./incremental.sh
15#
16
Pan Xiulicc4850d2018-06-12 00:01:49 +080017FROM ubuntu:18.04
Dylan Reide3dfa4e2018-04-25 09:48:41 -070018ARG UID=1000
19
Pan Xiulif6f3ab02018-06-05 18:43:26 +080020# Set up proxy from host
21COPY apt.conf /etc/apt/
22ARG host_http_proxy
23ARG host_https_proxy
24ENV http_proxy $host_http_proxy
25ENV https_proxy $host_https_proxy
26
Dylan Reide3dfa4e2018-04-25 09:48:41 -070027RUN apt-get -y update && \
28 apt-get install -y \
29 autoconf \
30 bison \
31 build-essential \
32 flex \
33 gawk \
34 gettext \
35 git \
36 gperf \
37 help2man \
38 libncurses5-dev \
Dylan Reide3dfa4e2018-04-25 09:48:41 -070039 libssl-dev \
40 libtool \
Dylan Reide3dfa4e2018-04-25 09:48:41 -070041 libtool-bin \
42 pkg-config \
43 software-properties-common \
44 sudo \
45 texinfo \
46 udev \
Pan Xiulif8628622018-08-07 14:09:59 +080047 wget \
48 unzip
49
Dylan Reide3dfa4e2018-04-25 09:48:41 -070050
Dylan Reide3dfa4e2018-04-25 09:48:41 -070051# Use ToT alsa utils for the latest topology patches.
Pan Xiulif6f3ab02018-06-05 18:43:26 +080052RUN mkdir -p /root/alsa-build && cd /root/alsa-build && \
53 if [ "x$http_proxy" = "x" ]; then \
54 git clone git://git.alsa-project.org/alsa-lib.git && \
55 git clone git://git.alsa-project.org/alsa-utils.git ; \
56 else \
57 git clone http://git.alsa-project.org/http/alsa-lib.git && \
58 git clone http://git.alsa-project.org/http/alsa-utils.git; \
59 fi && \
60cd /root/alsa-build/alsa-lib && ./gitcompile && make install && \
61cd /root/alsa-build/alsa-utils && ./gitcompile && make install && \
62cd /root/ && rm -rf alsa-build
Dylan Reide3dfa4e2018-04-25 09:48:41 -070063
Pan Xiuli03a514d2018-06-12 00:01:48 +080064# Set up sof user
65RUN useradd --create-home -d /home/sof -u $UID -G sudo sof && \
66echo "sof:test0000" | chpasswd && adduser sof sudo
Dylan Reide3dfa4e2018-04-25 09:48:41 -070067ENV HOME /home/sof
68
Pan Xiuli18082e32018-06-12 00:01:50 +080069# build cross compiler
Dylan Reide3dfa4e2018-04-25 09:48:41 -070070USER sof
Pan Xiulif8628622018-08-07 14:09:59 +080071RUN cd /home/sof && git clone https://github.com/thesofproject/xtensa-overlay.git && \
72 cd xtensa-overlay && git checkout sof-gcc8.1 && cd ../ && \
73 git clone https://github.com/thesofproject/crosstool-ng.git && \
Pan Xiulib0affc12018-06-12 17:12:39 +080074 mkdir -p /home/sof/work/ && \
Pan Xiulif8628622018-08-07 14:09:59 +080075 cd crosstool-ng && git checkout sof-gcc8.1 && \
76 ./bootstrap && ./configure --prefix=`pwd` && make && make install && \
77 for arch in byt hsw apl cnl; do \
78 cp config-${arch}-gcc8.1-gdb8.1 .config && \
79# replace the build dist to save space
Pan Xiulib0affc12018-06-12 17:12:39 +080080 sed -i 's#${CT_TOP_DIR}\/builds#\/home\/sof\/work#g' .config && \
Pan Xiulif8628622018-08-07 14:09:59 +080081# gl_cv_func_getcwd_path_max=yes is used to avoid too-long confdir3/confdir3/...
82 gl_cv_func_getcwd_path_max=yes ./ct-ng build && \
Pan Xiulib0affc12018-06-12 17:12:39 +080083 ./ct-ng distclean ; \
Pan Xiuli18082e32018-06-12 00:01:50 +080084 done && \
Pan Xiulif8628622018-08-07 14:09:59 +080085 cd /home/sof/ && rm -rf xtensa-overlay && rm -rf crosstool-ng
Dylan Reide3dfa4e2018-04-25 09:48:41 -070086
Pan Xiuli18082e32018-06-12 00:01:50 +080087ENV PATH="/home/sof/work/xtensa-byt-elf/bin:${PATH}"
88ENV PATH="/home/sof/work/xtensa-hsw-elf/bin:${PATH}"
Pan Xiulif8628622018-08-07 14:09:59 +080089ENV PATH="/home/sof/work/xtensa-apl-elf/bin:${PATH}"
Pan Xiuli18082e32018-06-12 00:01:50 +080090ENV PATH="/home/sof/work/xtensa-cnl-elf/bin:${PATH}"
Dylan Reide3dfa4e2018-04-25 09:48:41 -070091
Pan Xiuli18082e32018-06-12 00:01:50 +080092RUN cd /home/sof && git clone https://github.com/jcmvbkbc/newlib-xtensa.git newlib-xtensa.git && \
93 cd newlib-xtensa.git && git checkout -b xtensa origin/xtensa && \
Pan Xiulif8628622018-08-07 14:09:59 +080094 for arch in byt hsw apl cnl; do \
Pan Xiuli18082e32018-06-12 00:01:50 +080095 ./configure --target=xtensa-${arch}-elf \
Dylan Reide3dfa4e2018-04-25 09:48:41 -070096 --prefix=/home/sof/work/xtensa-root && \
Pan Xiuli18082e32018-06-12 00:01:50 +080097 make && \
98 make install && \
99 make distclean; \
100 done && \
Pan Xiulib0affc12018-06-12 17:12:39 +0800101 cd /home/sof/ && rm -rf newlib-xtensa.git
Dylan Reide3dfa4e2018-04-25 09:48:41 -0700102
Dylan Reide3dfa4e2018-04-25 09:48:41 -0700103
104# Create direcroties for the host machines sof/soft directories to be mounted.
Pan Xiuli03a514d2018-06-12 00:01:48 +0800105RUN mkdir -p /home/sof/work/sof.git && \
106 mkdir -p /home/sof/work/soft.git
107
Dylan Reide3dfa4e2018-04-25 09:48:41 -0700108
109USER sof
110WORKDIR /home/sof/work/sof.git/