From 4d065df37636a39a35abb414162d9ad98c6228ff Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 9 Jan 2018 21:44:42 +0100 Subject: [PATCH] build: add possibility to build ARM toolchain from source --- Dockerfile | 15 +++++++++++---- Dockerfile.gcc_source | 41 +++++++++++++++++++++++++++++++++++++++++ build-docker.sh | 7 +++++++ 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.gcc_source diff --git a/Dockerfile b/Dockerfile index 18b21a3b..3788ad73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,14 +5,21 @@ FROM debian:9 # install build tools and dependencies RUN apt-get update && apt-get install -y \ - build-essential wget git python3-pip \ - gcc-multilib + build-essential wget git python3-pip gcc-multilib -# download and setup toolchain +# download toolchain ENV TOOLCHAIN_SHORTVER=7-2017q4 ENV TOOLCHAIN_LONGVER=gcc-arm-none-eabi-7-2017-q4-major -RUN cd /opt && wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/$TOOLCHAIN_SHORTVER/$TOOLCHAIN_LONGVER-linux.tar.bz2 && tar xfj $TOOLCHAIN_LONGVER-linux.tar.bz2 +ENV TOOLCHAIN_FLAVOR=linux +ENV TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/$TOOLCHAIN_SHORTVER/$TOOLCHAIN_LONGVER-$TOOLCHAIN_FLAVOR.tar.bz2 + +# extract toolchain + +RUN cd /opt && wget $TOOLCHAIN_URL && tar xfj $TOOLCHAIN_LONGVER-$TOOLCHAIN_FLAVOR.tar.bz2 + +# setup toolchain + ENV PATH=/opt/$TOOLCHAIN_LONGVER/bin:$PATH # install python tools diff --git a/Dockerfile.gcc_source b/Dockerfile.gcc_source new file mode 100644 index 00000000..4a77d013 --- /dev/null +++ b/Dockerfile.gcc_source @@ -0,0 +1,41 @@ +# initialize from the image + +FROM debian:9 + +# install build tools and dependencies + +RUN apt-get update && apt-get install -y \ + build-essential wget git python3-pip gcc-multilib \ + autoconf autogen bison dejagnu flex flip gawk git gperf gzip nsis openssh-client p7zip-full perl python-dev libisl-dev tcl tofrodos zip + +# download toolchain + +ENV TOOLCHAIN_SHORTVER=7-2017q4 +ENV TOOLCHAIN_LONGVER=gcc-arm-none-eabi-7-2017-q4-major +ENV TOOLCHAIN_FLAVOR=src +ENV TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/$TOOLCHAIN_SHORTVER/$TOOLCHAIN_LONGVER-$TOOLCHAIN_FLAVOR.tar.bz2 + +# extract toolchain + +RUN cd /opt && wget $TOOLCHAIN_URL && tar xfj $TOOLCHAIN_LONGVER-$TOOLCHAIN_FLAVOR.tar.bz2 + +# build toolchain + +RUN cd /opt/$TOOLCHAIN_LONGVER && ./install-sources.sh --skip_steps=mingw32,manual +RUN cd /opt/$TOOLCHAIN_LONGVER && ./build-prerequisites.sh --skip_steps=mingw32,manual +RUN cd /opt/$TOOLCHAIN_LONGVER && ./build-toolchain.sh --skip_steps=mingw32,manual + +# setup toolchain + +ENV PATH=/opt/$TOOLCHAIN_LONGVER/bin:$PATH + +# install python tools + +RUN pip3 install click pyblake2 scons +RUN pip3 install --no-deps git+https://github.com/trezor/python-trezor.git@master + +# workarounds for weird default install + +RUN ln -s python3 /usr/bin/python +RUN ln -s dist-packages /usr/local/lib/python3.5/site-packages +ENV LC_ALL=C.UTF-8 LANG=C.UTF-8 diff --git a/build-docker.sh b/build-docker.sh index 3dc664a0..c4e8a829 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -5,6 +5,13 @@ IMAGE=trezor-core-build TAG=${1:-master} docker build -t $IMAGE . + +# use the following line instead of the above line +# if you want to compile ARM toolchain from source +# warning: very long compilation time! + +# docker build -t $IMAGE -f Dockerfile.gcc_source . + docker run -t -v $(pwd)/build-docker:/build:z $IMAGE /bin/sh -c "\ git clone https://github.com/trezor/trezor-core && \ cd trezor-core && \