Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Cross compile Canadian
Browse files Browse the repository at this point in the history
f
  • Loading branch information
harmless-tech committed Apr 6, 2024
1 parent f673e31 commit f0ad2a4
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 37 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Build
on:
push:
branches: [ main ]
paths: [ .github/workflows/build.yml, config/**, docker/**, scripts/**]
paths: [ .github/workflows/build.yml, cconfig/**, config/**, docker/**, scripts/**]
pull_request:
branches: [ main ]
paths: [ .github/workflows/build.yml, config/**, docker/**, scripts/**]
paths: [ .github/workflows/build.yml, cconfig/**, config/**, docker/**, scripts/**]
workflow_dispatch:

permissions: { }
Expand All @@ -16,7 +16,9 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ amd64, arm64 ]
cross:
- aarch64-linux-gnu
- x86_64-linux-gnu
target:
- aarch64-unknown-linux-musl
- armv7-unknown-linux-musleabihf
Expand All @@ -42,13 +44,15 @@ jobs:
push: false
load: true
tags: ink-toolchain:dev
platforms: linux/${{ matrix.platform }}
build-args: |
CCONFIG=x86_64-linux-gnu---${{ matrix.cross }}
platforms: linux/amd64
builder: ${{ steps.buildx.outputs.name }}
- name: Extract
run: TARGETARCH='${{ matrix.platform }}' ./scripts/extract.sh
run: ./scripts/extract.sh
- name: Artifact
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.platform }}+${{ matrix.target }}"
name: "${{ matrix.cross }}+${{ matrix.target }}"
path: |
export/*.tar.gz
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Cross compiling toolchains meant for [ink-cross-images](https://github.com/cargo

### 2024.01 (Upcoming)

#### Platform Support
#### Host Platform Support

- aarch64-unknown-linux-gnu
- x86_64-unknown-linux-gnu
- aarch64-linux-gnu
- x86_64-linux-gnu

#### Versions

Expand Down
Empty file added cconfig/.config
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions cconfig/aarch64-linux-gnu---x86_64-linux-gnu.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CT_CANADIAN=y
CT_TOOLCHAIN_TYPE="canadian"

CT_BUILD="aarch64-linux-gnu"
CT_BUILD_PREFIX="aarch64-linux-gnu-"
CT_BUILD_SUFFIX=""

CT_HOST="x86_64-linux-gnu"
CT_HOST_PREFIX="x86_64-linux-gnu-"
CT_HOST_SUFFIX=""
10 changes: 10 additions & 0 deletions cconfig/x86_64-linux-gnu---aarch64-linux-gnu.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CT_CANADIAN=y
CT_TOOLCHAIN_TYPE="canadian"

CT_BUILD="x86_64-linux-gnu"
CT_BUILD_PREFIX="x86_64-linux-gnu-"
CT_BUILD_SUFFIX=""

CT_HOST="aarch64-linux-gnu"
CT_HOST_PREFIX="aarch64-linux-gnu-"
CT_HOST_SUFFIX=""
Empty file.
2 changes: 2 additions & 0 deletions docker/aarch64-unknown-linux-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ RUN --mount=type=bind,source=./scripts/manage-apt.sh,target=/run.sh /run.sh
RUN --mount=type=bind,source=./scripts/build-crosstool.sh,target=/run.sh /run.sh

COPY ./config/${RUST_TARGET}.config /.config
ARG CCONFIG=""
COPY ./cconfig/${CCONFIG}.config /.cconfig
RUN --mount=type=bind,source=./scripts/build-cross.sh,target=/run.sh /run.sh

RUN --mount=type=bind,source=./scripts/package.sh,target=/run.sh /run.sh
Expand Down
2 changes: 2 additions & 0 deletions docker/armv7-unknown-linux-musleabihf.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ RUN --mount=type=bind,source=./scripts/manage-apt.sh,target=/run.sh /run.sh
RUN --mount=type=bind,source=./scripts/build-crosstool.sh,target=/run.sh /run.sh

COPY ./config/${RUST_TARGET}.config /.config
ARG CCONFIG=""
COPY ./cconfig/${CCONFIG}.config /.cconfig
RUN --mount=type=bind,source=./scripts/build-cross.sh,target=/run.sh /run.sh

RUN --mount=type=bind,source=./scripts/package.sh,target=/run.sh /run.sh
Expand Down
2 changes: 2 additions & 0 deletions docker/x86_64-unknown-linux-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ RUN --mount=type=bind,source=./scripts/manage-apt.sh,target=/run.sh /run.sh
RUN --mount=type=bind,source=./scripts/build-crosstool.sh,target=/run.sh /run.sh

COPY ./config/${RUST_TARGET}.config /.config
ARG CCONFIG=""
COPY ./cconfig/${CCONFIG}.config /.cconfig
RUN --mount=type=bind,source=./scripts/build-cross.sh,target=/run.sh /run.sh

RUN --mount=type=bind,source=./scripts/package.sh,target=/run.sh /run.sh
Expand Down
14 changes: 2 additions & 12 deletions scripts/build-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,10 @@ mkdir -p /tmp/build
pushd /tmp/build

mv /.config .
cat /.cconfig >> ./.config

ct-ng olddefconfig
ct-ng build

# Package
#pushd /tmp/crosstoolchains
#
#tar -czvf "$CROSS_TOOLCHAIN".tar.gz .
#
#mkdir -p /export
#mv *.tar.gz /export
#mv /export/*.tar.gz /export/export.tar.gz

#popd
#rm -rf /tmp/crosstoolchains

popd
rm -rf /temp/build
16 changes: 1 addition & 15 deletions scripts/extract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,7 @@

set -euxo pipefail

if [ -z "${TARGETARCH+x}" ]; then
case "$(uname -m)" in
x86_64|amd64)
export TARGETARCH=amd64
;;
aarch64|arm64)
export TARGETARCH=arm64
;;
*)
echo "Unsupported Arch: $TARGETARCH" && exit 1
;;
esac
fi

ID="$(docker create --pull=never --platform=linux/"$TARGETARCH" ink-toolchain:dev sh)"
ID="$(docker create --pull=never ink-toolchain:dev sh)"

docker cp "$ID":/export .

Expand Down
4 changes: 4 additions & 0 deletions scripts/manage-apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ apt install -y \
meson \
ninja-build

apt install -y \
g++-aarch64-linux-gnu \
g++-x86-64-linux-gnu

rm -rf /var/lib/apt/lists/*
1 change: 0 additions & 1 deletion scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ tar -czvf "$CROSS_TOOLCHAIN".tar.gz "$CROSS_TOOLCHAIN"

mkdir -p /export
mv "$CROSS_TOOLCHAIN".tar.gz /export
#mv /export/*.tar.gz /export/export.tar.gz

popd

0 comments on commit f0ad2a4

Please sign in to comment.