Skip to content

Commit 575cf5f

Browse files
committed
Compile all toolchains with crosstool-NG
1 parent 3735768 commit 575cf5f

33 files changed

Lines changed: 24347 additions & 96 deletions

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
IMAGE_TAG ?= latest
33
IMAGE_NAME ?= nadavtasher/toolchains
44

5-
# Choose the image flavor
6-
IMAGE_FLAVOR ?= online
7-
85
# Export variables for usage in recipes
96
export IMAGE_TAG IMAGE_NAME
107

@@ -31,11 +28,11 @@ endif
3128

3229
.PHONY: image
3330
image:
34-
@docker buildx build $(SOURCE_DIRECTORY) --file $(SOURCE_DIRECTORY)/Dockerfile.$(IMAGE_FLAVOR) --load --tag $(IMAGE_NAME):$(IMAGE_TAG)
31+
@docker buildx build $(SOURCE_DIRECTORY) --file $(SOURCE_DIRECTORY)/Dockerfile --load --tag $(IMAGE_NAME):$(IMAGE_TAG)
3532

3633
.PHONY: release
3734
release:
38-
@docker buildx build $(SOURCE_DIRECTORY) --file $(SOURCE_DIRECTORY)/Dockerfile.$(IMAGE_FLAVOR) --push --platform linux/amd64 --tag $(IMAGE_NAME):$(IMAGE_TAG) --tag $(IMAGE_NAME):latest
35+
@docker buildx build $(SOURCE_DIRECTORY) --file $(SOURCE_DIRECTORY)/Dockerfile --push --platform linux/amd64 --tag $(IMAGE_NAME):$(IMAGE_TAG) --tag $(IMAGE_NAME):latest
3936

4037
.PHONY: run
4138
run: image

image/Dockerfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Ubuntu base version
2+
ARG UBUNTU_BASE_VERSION=24.04
3+
4+
# Use scratch as fetching image
5+
FROM ubuntu:${UBUNTU_BASE_VERSION} AS build
6+
7+
# Install build dependencies
8+
RUN apt update && \
9+
apt install -y gcc g++ gperf bison flex texinfo help2man make libncurses-dev python3-dev autoconf automake libtool libtool-bin gawk wget bzip2 xz-utils unzip patch libstdc++6 rsync && \
10+
rm -r /var/lib/apt/lists
11+
12+
# Enter build directory
13+
WORKDIR /tmp/ct-ng
14+
15+
# Default crosstool-ng version
16+
ARG CROSSTOOL_NG_VERSION=1.27.0
17+
18+
# Download crosstool-ng
19+
RUN wget -O - https://github.com/crosstool-ng/crosstool-ng/releases/download/crosstool-ng-${CROSSTOOL_NG_VERSION}/crosstool-ng-${CROSSTOOL_NG_VERSION}.tar.bz2 | tar --strip-components=1 -xj
20+
21+
# Install ct-ng globally
22+
RUN ./configure && make install
23+
24+
# Copy the build configurations
25+
COPY configurations /tmp/configurations
26+
27+
# Change to build user
28+
USER 1000:1000
29+
30+
# Loop over configuration files and compile toolchains
31+
RUN mkdir -p /tmp/tarballs; \
32+
for configuration in /tmp/configurations/*.conf; do \
33+
mkdir -p /tmp/build_$configuration; \
34+
cp $configuration /tmp/build_$configuration/.config; \
35+
ct-ng build -C /tmp/build_$configuration; \
36+
rm -rf /tmp/build_$configuration; \
37+
done;
38+
39+
# Use ubuntu as the base image
40+
FROM ubuntu:${UBUNTU_BASE_VERSION}
41+
42+
# Install build essentials
43+
RUN apt update && \
44+
apt install -y build-essential autoconf cmake libtool git qemu-user-static && \
45+
rm -r /var/lib/apt/lists
46+
47+
# Target directory for toolchains
48+
ARG TOOLCHAINS_DIRECTORY=/toolchains
49+
50+
# Change to the toolchains directory
51+
WORKDIR ${TOOLCHAINS_DIRECTORY}
52+
53+
# Mount toolchains and extract them, then create a checksums file for all toolchains
54+
RUN --mount=type=bind,from=build,source=/tmp/tarballs,target=/tmp/tarballs \
55+
for file in /tmp/tarballs/*; do \
56+
tar xf $file; \
57+
done; \
58+
sha256sum /tmp/tarballs/* > checksums
59+
60+
# Add environment variable of toolchains location
61+
ENV TOOLCHAINS_DIRECTORY=${TOOLCHAINS_DIRECTORY}
62+
63+
# Copy the resources to the container
64+
COPY --chmod=775 resources /bin
65+
66+
# Change the container entrypoint
67+
ENTRYPOINT [ "entrypoint.sh" ]
68+
69+
# Change to the build working directory
70+
WORKDIR /build

image/Dockerfile.offline

Lines changed: 0 additions & 31 deletions
This file was deleted.

image/Dockerfile.online

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)