File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed
Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 1+ # ==========================================
2+ # Stage 1: build toolchain
3+ # ==========================================
4+ FROM ubuntu:20.04 AS builder
5+
6+ ARG COMPILER
7+ ENV COMPILER=${COMPILER}
8+
9+ ENV DEBIAN_FRONTEND=noninteractive
10+
11+ RUN apt update && apt -y install \
12+ gcc g++ make libncurses5-dev byacc flex texinfo patch tar unzip lzip \
13+ libelf-dev perl libexpat1-dev curl xz-utils sudo
14+
15+ # Copy only the selected subdirectory
16+ COPY ${COMPILER} /project/${COMPILER}
17+
18+ WORKDIR /project/${COMPILER}
19+
20+ RUN ./download.sh && ./install-script.sh -j$(nproc)
21+
22+ WORKDIR /opt
23+ RUN tar -zcvf arm-miosix-eabi-${COMPILER}.tar.gz arm-miosix-eabi
24+
25+ # ==========================================
26+ # Stage 2: export artifact
27+ # ==========================================
28+ FROM scratch AS export
29+ ARG COMPILER
30+ COPY --from=builder /opt/arm-miosix-eabi-${COMPILER}.tar.gz /
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euo pipefail
3+
4+ # Script must be run from the compiler directory.
5+ SCRIPT_DIR=" $( cd " $( dirname " $0 " ) " && pwd) "
6+ cd " $SCRIPT_DIR "
7+
8+ list_compilers () {
9+ find . -maxdepth 1 -type d -name " gcc-*" -printf " %f\n" | sort
10+ }
11+
12+ # Select compiler
13+ if [[ $# -ge 1 ]]; then
14+ COMPILER=" $1 "
15+ else
16+ echo " Available compilers:"
17+ list_compilers
18+ echo " "
19+ read -p " Select compiler: " COMPILER
20+ fi
21+
22+ # Validate
23+ if [[ ! -d " $COMPILER " ]]; then
24+ echo " Error: directory '$COMPILER ' does not exist."
25+ exit 1
26+ fi
27+
28+ echo " Using compiler: $COMPILER "
29+ echo " "
30+
31+ # Build using Dockerfile in this directory
32+ docker build \
33+ --build-arg COMPILER=" $COMPILER " \
34+ --output " $SCRIPT_DIR " \
35+ -t toolchain-builder:" $COMPILER " \
36+ " $SCRIPT_DIR "
You can’t perform that action at this time.
0 commit comments