Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 1 | # 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 Xiuli | cc4850d | 2018-06-12 00:01:49 +0800 | [diff] [blame] | 17 | FROM ubuntu:18.04 |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 18 | ARG UID=1000 |
| 19 | |
Pan Xiuli | f6f3ab0 | 2018-06-05 18:43:26 +0800 | [diff] [blame] | 20 | # Set up proxy from host |
| 21 | COPY apt.conf /etc/apt/ |
| 22 | ARG host_http_proxy |
| 23 | ARG host_https_proxy |
| 24 | ENV http_proxy $host_http_proxy |
| 25 | ENV https_proxy $host_https_proxy |
| 26 | |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 27 | RUN 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 Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 39 | libssl-dev \ |
| 40 | libtool \ |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 41 | libtool-bin \ |
| 42 | pkg-config \ |
| 43 | software-properties-common \ |
| 44 | sudo \ |
| 45 | texinfo \ |
| 46 | udev \ |
Pan Xiuli | f862862 | 2018-08-07 14:09:59 +0800 | [diff] [blame] | 47 | wget \ |
| 48 | unzip |
| 49 | |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 50 | |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 51 | # Use ToT alsa utils for the latest topology patches. |
Pan Xiuli | f6f3ab0 | 2018-06-05 18:43:26 +0800 | [diff] [blame] | 52 | RUN 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 && \ |
| 60 | cd /root/alsa-build/alsa-lib && ./gitcompile && make install && \ |
| 61 | cd /root/alsa-build/alsa-utils && ./gitcompile && make install && \ |
| 62 | cd /root/ && rm -rf alsa-build |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 63 | |
Pan Xiuli | 03a514d | 2018-06-12 00:01:48 +0800 | [diff] [blame] | 64 | # Set up sof user |
| 65 | RUN useradd --create-home -d /home/sof -u $UID -G sudo sof && \ |
| 66 | echo "sof:test0000" | chpasswd && adduser sof sudo |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 67 | ENV HOME /home/sof |
| 68 | |
Pan Xiuli | 18082e3 | 2018-06-12 00:01:50 +0800 | [diff] [blame] | 69 | # build cross compiler |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 70 | USER sof |
Pan Xiuli | f862862 | 2018-08-07 14:09:59 +0800 | [diff] [blame] | 71 | RUN 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 Xiuli | b0affc1 | 2018-06-12 17:12:39 +0800 | [diff] [blame] | 74 | mkdir -p /home/sof/work/ && \ |
Pan Xiuli | f862862 | 2018-08-07 14:09:59 +0800 | [diff] [blame] | 75 | 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 Xiuli | b0affc1 | 2018-06-12 17:12:39 +0800 | [diff] [blame] | 80 | sed -i 's#${CT_TOP_DIR}\/builds#\/home\/sof\/work#g' .config && \ |
Pan Xiuli | f862862 | 2018-08-07 14:09:59 +0800 | [diff] [blame] | 81 | # 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 Xiuli | b0affc1 | 2018-06-12 17:12:39 +0800 | [diff] [blame] | 83 | ./ct-ng distclean ; \ |
Pan Xiuli | 18082e3 | 2018-06-12 00:01:50 +0800 | [diff] [blame] | 84 | done && \ |
Pan Xiuli | f862862 | 2018-08-07 14:09:59 +0800 | [diff] [blame] | 85 | cd /home/sof/ && rm -rf xtensa-overlay && rm -rf crosstool-ng |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 86 | |
Pan Xiuli | 18082e3 | 2018-06-12 00:01:50 +0800 | [diff] [blame] | 87 | ENV PATH="/home/sof/work/xtensa-byt-elf/bin:${PATH}" |
| 88 | ENV PATH="/home/sof/work/xtensa-hsw-elf/bin:${PATH}" |
Pan Xiuli | f862862 | 2018-08-07 14:09:59 +0800 | [diff] [blame] | 89 | ENV PATH="/home/sof/work/xtensa-apl-elf/bin:${PATH}" |
Pan Xiuli | 18082e3 | 2018-06-12 00:01:50 +0800 | [diff] [blame] | 90 | ENV PATH="/home/sof/work/xtensa-cnl-elf/bin:${PATH}" |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 91 | |
Pan Xiuli | 18082e3 | 2018-06-12 00:01:50 +0800 | [diff] [blame] | 92 | RUN 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 Xiuli | f862862 | 2018-08-07 14:09:59 +0800 | [diff] [blame] | 94 | for arch in byt hsw apl cnl; do \ |
Pan Xiuli | 18082e3 | 2018-06-12 00:01:50 +0800 | [diff] [blame] | 95 | ./configure --target=xtensa-${arch}-elf \ |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 96 | --prefix=/home/sof/work/xtensa-root && \ |
Pan Xiuli | 18082e3 | 2018-06-12 00:01:50 +0800 | [diff] [blame] | 97 | make && \ |
| 98 | make install && \ |
| 99 | make distclean; \ |
| 100 | done && \ |
Pan Xiuli | b0affc1 | 2018-06-12 17:12:39 +0800 | [diff] [blame] | 101 | cd /home/sof/ && rm -rf newlib-xtensa.git |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 102 | |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 103 | |
| 104 | # Create direcroties for the host machines sof/soft directories to be mounted. |
Pan Xiuli | 03a514d | 2018-06-12 00:01:48 +0800 | [diff] [blame] | 105 | RUN mkdir -p /home/sof/work/sof.git && \ |
| 106 | mkdir -p /home/sof/work/soft.git |
| 107 | |
Dylan Reid | e3dfa4e | 2018-04-25 09:48:41 -0700 | [diff] [blame] | 108 | |
| 109 | USER sof |
| 110 | WORKDIR /home/sof/work/sof.git/ |