diff options
author | Ron Evans <[email protected]> | 2018-11-08 16:46:22 +0100 |
---|---|---|
committer | Ayke van Laethem <[email protected]> | 2018-11-15 12:53:10 +0100 |
commit | ae3535945c0afdedbdcd28a831a4902020b1c6d0 (patch) | |
tree | db9391bf7521baf8ee0a4817922d70b80c6afc70 /Dockerfile | |
parent | 668c1741c3d290ed63ff8270acde62f5ac4004ab (diff) | |
download | tinygo-ae3535945c0afdedbdcd28a831a4902020b1c6d0.tar.gz tinygo-ae3535945c0afdedbdcd28a831a4902020b1c6d0.zip |
all: add support to Dockerfile for AVR and ARM targets
Signed-off-by: Ron Evans <[email protected]>
Diffstat (limited to 'Dockerfile')
-rw-r--r-- | Dockerfile | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/Dockerfile b/Dockerfile index 09486d666..03c495af7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM golang:latest +# TinyGo base stage just installs LLVM 7 and the TinyGo compiler itself. +FROM golang:latest AS tinygo-base RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \ echo "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-7 main" >> /etc/apt/sources.list && \ @@ -13,15 +14,68 @@ RUN cd /go/src/github.com/aykevl/tinygo/ && \ dep ensure --vendor-only && \ go install /go/src/github.com/aykevl/tinygo/ -FROM golang:latest +ENTRYPOINT ["/go/bin/tinygo"] + +# tinygo-wasm stage installs the needed dependencies to compile TinyGo programs for WASM. +FROM tinygo-base AS tinygo-wasm -COPY --from=0 /go/bin/tinygo /go/bin/tinygo -COPY --from=0 /go/src/github.com/aykevl/tinygo/src /go/src/github.com/aykevl/tinygo/src -COPY --from=0 /go/src/github.com/aykevl/tinygo/targets /go/src/github.com/aykevl/tinygo/targets +COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/src /go/src/github.com/aykevl/tinygo/src +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/targets /go/src/github.com/aykevl/tinygo/targets RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \ echo "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-7 main" >> /etc/apt/sources.list && \ apt-get update && \ apt-get install -y libllvm7 lld-7 -ENTRYPOINT ["/go/bin/tinygo"] +# tinygo-avr stage installs the needed dependencies to compile TinyGo programs for AVR microcontrollers. +FROM tinygo-base AS tinygo-avr + +COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/src /go/src/github.com/aykevl/tinygo/src +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/targets /go/src/github.com/aykevl/tinygo/targets +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/Makefile /go/src/github.com/aykevl/tinygo/ +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/tools /go/src/github.com/aykevl/tinygo/tools +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/lib /go/src/github.com/aykevl/tinygo/lib + +RUN cd /go/src/github.com/aykevl/tinygo/ && \ + apt-get update && \ + apt-get install -y apt-utils python3 make binutils-avr gcc-avr avr-libc && \ + make gen-device-avr && \ + apt-get remove -y python3 make && \ + apt-get autoremove -y && \ + apt-get clean + +# tinygo-arm stage installs the needed dependencies to compile TinyGo programs for ARM microcontrollers. +FROM tinygo-base AS tinygo-arm + +COPY --from=tinygo-base /go/bin/tinygo /go/bin/tinygo +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/src /go/src/github.com/aykevl/tinygo/src +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/targets /go/src/github.com/aykevl/tinygo/targets +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/Makefile /go/src/github.com/aykevl/tinygo/ +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/tools /go/src/github.com/aykevl/tinygo/tools +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/lib /go/src/github.com/aykevl/tinygo/lib + +RUN cd /go/src/github.com/aykevl/tinygo/ && \ + apt-get update && \ + apt-get install -y apt-utils python3 make gcc-arm-none-eabi clang-7 && \ + make gen-device-nrf && make gen-device-stm32 && \ + apt-get remove -y python3 make && \ + apt-get autoremove -y && \ + apt-get clean + +# tinygo-all stage installs the needed dependencies to compile TinyGo programs for all platforms. +FROM tinygo-wasm AS tinygo-all + +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/Makefile /go/src/github.com/aykevl/tinygo/ +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/tools /go/src/github.com/aykevl/tinygo/tools +COPY --from=tinygo-base /go/src/github.com/aykevl/tinygo/lib /go/src/github.com/aykevl/tinygo/lib + +RUN cd /go/src/github.com/aykevl/tinygo/ && \ + apt-get update && \ + apt-get install -y apt-utils python3 make gcc-arm-none-eabi clang-7 binutils-avr gcc-avr avr-libc && \ + make gen-device && \ + apt-get remove -y python3 make && \ + apt-get autoremove -y && \ + apt-get clean + |