|
| 1 | +FROM ubuntu:latest as build |
| 2 | + |
| 3 | +ENV TZ=Europe/Rome |
| 4 | +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ |
| 5 | + apt-get update && \ |
| 6 | + apt-get install -y \ |
| 7 | + build-essential \ |
| 8 | + # Intall clang compiler used by macos |
| 9 | + clang \ |
| 10 | + cmake \ |
| 11 | + curl \ |
| 12 | + dh-autoreconf \ |
| 13 | + git \ |
| 14 | + gperf \ |
| 15 | + # various libs required to compile osxcross |
| 16 | + libxml2-dev \ |
| 17 | + libssl-dev \ |
| 18 | + libz-dev \ |
| 19 | + # Install Windows cross-tools |
| 20 | + mingw-w64 \ |
| 21 | + p7zip-full \ |
| 22 | + pkg-config \ |
| 23 | + tar \ |
| 24 | + && rm -rf /var/lib/apt/lists/* |
| 25 | +# Install toolchains in /opt |
| 26 | +RUN curl downloads.arduino.cc/tools/internal/toolchains.tar.gz | tar -xz "opt" |
| 27 | + # install proper arm toolchains (already present in the toolchains.tar.gz archive) |
| 28 | + # curl -L 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.xz' | tar -xJC /opt && \ |
| 29 | + # curl -L 'https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz' | tar -xJC /opt |
| 30 | + |
| 31 | +RUN cd /opt/osxcross \ |
| 32 | + git pull \ |
| 33 | + # use a specific version of osxcross (it does not have tags) |
| 34 | + git checkout da2c3d4ff604458a931b08b3af800c5a454136de \ |
| 35 | + UNATTENDED=1 SDK_VERSION=10.15 ./build.sh |
| 36 | +# Set toolchains paths |
| 37 | +# arm-linux-gnueabihf-gcc -> linux_arm |
| 38 | +# aarch64-linux-gnu-gcc -> linux_arm64 |
| 39 | +# x86_64-ubuntu16.04-linux-gnu-gcc -> linux_amd64 |
| 40 | +# i686-ubuntu16.04-linux-gnu-gcc -> linux_386 |
| 41 | +# o64-clang -> darwin_amd64 |
| 42 | +ENV PATH=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/:/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/:/opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin/:/opt/i686-ubuntu16.04-linux-gnu/bin/:/opt/osxcross/target/bin/:$PATH |
| 43 | + |
| 44 | +WORKDIR /workdir |
| 45 | + |
| 46 | +# Handle libusb and libudev compilation and merging |
| 47 | +COPY deps/ /opt/lib/ |
| 48 | +# compiler name is arm-linux-gnueabihf-gcc '-gcc' is added by ./configure |
| 49 | +RUN CROSS_COMPILE=x86_64-ubuntu16.04-linux-gnu /opt/lib/build_libs.sh && \ |
| 50 | + CROSS_COMPILE=arm-linux-gnueabihf /opt/lib/build_libs.sh && \ |
| 51 | + CROSS_COMPILE=aarch64-linux-gnu /opt/lib/build_libs.sh && \ |
| 52 | + CROSS_COMPILE=i686-ubuntu16.04-linux-gnu /opt/lib/build_libs.sh && \ |
| 53 | + CROSS_COMPILE=i686-w64-mingw32 /opt/lib/build_libs.sh && \ |
| 54 | + # CROSS_COMPILER is used to override the compiler |
| 55 | + CROSS_COMPILER=o64-clang CROSS_COMPILE=x86_64-apple-darwin13 /opt/lib/build_libs.sh |
| 56 | + |
| 57 | +FROM ubuntu:latest |
| 58 | +# Copy all the installed toolchains and compiled libs |
| 59 | +COPY --from=build /opt /opt |
| 60 | +ENV TZ=Europe/Rome |
| 61 | +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ |
| 62 | + apt-get update && \ |
| 63 | + apt-get install -y \ |
| 64 | + build-essential \ |
| 65 | + # Intall clang compiler used by macos |
| 66 | + clang \ |
| 67 | + cmake \ |
| 68 | + dh-autoreconf \ |
| 69 | + git \ |
| 70 | + gperf \ |
| 71 | + # Install Windows cross-tools |
| 72 | + mingw-w64 \ |
| 73 | + pkg-config \ |
| 74 | + tar \ |
| 75 | + && rm -rf /var/lib/apt/lists/* |
| 76 | +# Set toolchains paths |
| 77 | +# arm-linux-gnueabihf-gcc -> linux_arm |
| 78 | +# aarch64-linux-gnu-gcc -> linux_arm64 |
| 79 | +# x86_64-ubuntu16.04-linux-gnu-gcc -> linux_amd64 |
| 80 | +# i686-ubuntu16.04-linux-gnu-gcc -> linux_386 |
| 81 | +# o64-clang -> darwin_amd64 |
| 82 | +ENV PATH=/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/:/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/:/opt/x86_64-ubuntu16.04-linux-gnu-gcc/bin/:/opt/i686-ubuntu16.04-linux-gnu/bin/:/opt/osxcross/target/bin/:$PATH |
| 83 | + |
| 84 | +WORKDIR /workdir |
| 85 | + |
| 86 | +ENTRYPOINT ["/bin/bash"] |
0 commit comments