Skip to content

Commit

Permalink
try using asdf to build nim
Browse files Browse the repository at this point in the history
  • Loading branch information
elcritch committed Jul 24, 2024
1 parent 7e1e42f commit 2c5e031
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/esp-idf-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
strategy:
matrix:
version: ["5.0", "4.4"]
nim: ["1.6.20", "2.0.8"]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -84,9 +85,11 @@ jobs:
push: true
# platforms: linux/amd64,linux/arm64,linux/arm
platforms: linux/amd64,linux/arm64
tags: ghcr.io/embeddednim/esp-idf:${{ matrix.version }}-${{ env.DATE }},ghcr.io/embeddednim/esp-idf:${{ matrix.version }}-latest
tags: ghcr.io/embeddednim/esp-idf:${{ matrix.version }}-${{ matrix.nim }}-${{ env.DATE }},ghcr.io/embeddednim/esp-idf:${{ matrix.version }}-${{ matrix.nim }}-latest
build-args: |
IDF_CLONE_BRANCH_OR_TAG=release/v${{ matrix.version }}
IDF_VERSION=${{ matrix.version }}
NIM_VERSION=${{ matrix.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
secrets: |
Expand Down
36 changes: 19 additions & 17 deletions esp-idf/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM espressif/idf:release-v4.4 as base
ARG IDF_VERSION=4.4
ARG NIM_VERSION=1.6.20

FROM espressif/idf:release-v${IDF_VERSION} as base

ARG DEBIAN_FRONTEND=noninteractive

Expand All @@ -8,16 +11,25 @@ RUN : \
zsh \
bison \
psmisc \
build-essential \
cmake \
vim \
gcc \
iputils-ping \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*

# Ccache is installed, enable it by default
ENV IDF_CCACHE_ENABLE=1

RUN : \
&& git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.8.1

RUN : \
&& echo '. /opt/esp/idf/export.sh' >> /etc/bash.bashrc \
&& echo '. /opt/esp/idf/export.sh' >> /etc/zsh/zshrc
&& echo '. /opt/esp/idf/export.sh' >> /etc/zsh/zshrc \
&& echo '. $HOME/.asdf/asdf.sh' >> /etc/bash.bashrc \
&& echo '. $HOME/.asdf/asdf.sh' >> /etc/zsh/zshrc

ARG TARGETPLATFORM
ARG TARGETOS
Expand All @@ -30,18 +42,8 @@ ENV CACHE_NONCE=1

RUN : \
&& cd $HOME/ \
&& case ${TARGETARCH} in \
"arm64") TARCH=arm64 ;; \
"amd64") TARCH=x64 ;; \
"arm") TARCH=arm ;; \
"386") TARCH=x32 ;; \
*) TARCH=${TARGETARCH} ;; \
esac \
&& NIM_PLATFORM=${TARGETOS}_${TARCH} \
&& env \
&& wget https://github.com/nim-lang/nightlies/releases/download/latest-version-1-6/${NIM_PLATFORM}.tar.xz \
&& tar xf ${NIM_PLATFORM}.tar.xz \
&& mv nim-* /usr/local/ \
&& for b in atlas nim nimble nim_dbg nim-gdb nimgrep nimpretty nimsuggest testament; \
do ln -sf /usr/local/nim-*/bin/$b /usr/local/bin/; \
done
&& echo "IDF_VERSION: " ${IDF_VERSION} \
&& echo "NIM: " ${NIM_VERSION} \
&& asdf plugin-add nim \
&& asdf install nim ${NIM_VERSION} \
&& echo "done"

0 comments on commit 2c5e031

Please sign in to comment.