Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
andressbarajas committed Dec 10, 2024
2 parents 1ddd8a6 + d16dd03 commit 9a04067
Show file tree
Hide file tree
Showing 48 changed files with 1,168 additions and 373 deletions.
15 changes: 15 additions & 0 deletions .github/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Source the environment setup script
if [ -f "/opt/toolchains/dc/kos/environ.sh.master" ]; then
source /opt/toolchains/dc/kos/environ.sh.master
fi

# Execute the provided command or fall back to bash
if [ "$#" -eq 0 ]; then
# No command provided, start an interactive shell
exec /bin/bash
else
# Execute the provided command
exec "$@"
fi
31 changes: 31 additions & 0 deletions .github/docker/kos-Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Define an argument for the tag
ARG tag=14.2-stable

# Use the static portion of the base image combined with the tag
FROM ghcr.io/kallistiosunchained/dc-toolchain:${tag}

# Metadata
LABEL maintainer="KallistiOS (Unchained)"

ARG REPO_BRANCH="master"

# Clone KOS & kos-ports
RUN git clone --depth=1 --branch ${REPO_BRANCH} https://github.com/KallistiOSUnchained/KallistiOS.git /opt/toolchains/dc/kos && \
git clone --depth=1 --branch ${REPO_BRANCH} https://github.com/KallistiOSUnchained/kos-ports.git /opt/toolchains/dc/kos-ports

# Set default working directory
WORKDIR /opt/toolchains/dc/kos

# Compile KOS, kos-ports, and the examples
RUN source environ.sh.master && \
make && \
make clean && \
make kos-ports_all

# Setup auto sourcing for (non)interactice shells
COPY entrypoint.sh /opt/toolchains/dc/kos/entrypoint.sh
RUN chmod 755 /opt/toolchains/dc/kos/entrypoint.sh
ENTRYPOINT ["/opt/toolchains/dc/kos/entrypoint.sh"]

# If run with no parameters just start bash
CMD ["/bin/bash"]
120 changes: 120 additions & 0 deletions .github/docker/toolchain-Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#
# Dockerfile for Sega Dreamcast Toolchains Maker (dc-chain)
#
# usage:
# - build one of the images:
# docker build -t dcchain:stable --build-arg dc_chain=stable --build-arg default_precision=m4-single -f ./toolchain-Dockerfile .
# docker build -t dcchain:legacy --build-arg dc_chain=legacy --build-arg makejobs=4 -f ./toolchain-Dockerfile .
# docker build -t dcchain:dev --build-arg dc_chain=dev --build-arg makejobs=4 --build-arg enable_objc=0 --build-arg enable_objcpp=0 -f ./toolchain-Dockerfile .
# - create and run a container, e.g. for stable:
# docker run -it --name containername dcchain:stable /bin/bash

# Stage 1
FROM alpine:latest AS build

# Metadata
LABEL maintainer="KallistiOS (Unchained)"

# Installing bare minimum for toolchain compilation
RUN apk add --no-cache \
build-base \
coreutils \
gmp-dev \
mpfr-dev \
mpc1-dev \
patch \
texinfo \
git \
curl \
wget \
bash \
flex \
bison \
gawk

# Making Sega Dreamcast toolchains
# You may adapt the KallistiOS repository URL if needed
ARG dc_chain=stable
ARG makejobs=2
ARG verbose=1
ARG enable_cpp=1
ARG enable_objc=1
ARG enable_objcpp=1
ARG enable_d=0
ARG enable_ada=0
ARG enable_rust=0
ARG enable_libgccjit=0
ARG precision_modes=m4-single-only,m4-single
ARG default_precision=m4-single-only
ARG thread_model=kos
ARG use_kos_patches=1

ARG REPO_BRANCH="master"

# Pull repo
RUN mkdir -p /opt/toolchains/dc && \
git clone --depth=1 --branch ${REPO_BRANCH} https://github.com/KallistiOSUnchained/KallistiOS.git /opt/toolchains/dc/kos

# Set working directory to the dc-chain directory for GCC builds
WORKDIR /opt/toolchains/dc/kos/utils/dc-chain

# Build SH4 GCC Compiler
RUN make build \
toolchain_profile=$dc_chain \
makejobs=$makejobs \
verbose=$verbose \
enable_cpp=$enable_cpp \
enable_objc=$enable_objc \
enable_objcpp=$enable_objcpp \
enable_d=$enable_d \
enable_ada=$enable_ada \
enable_rust=$enable_rust \
enable_libgccjit=$enable_libgccjit \
precision_modes=$precision_modes \
default_precision=$default_precision \
thread_model=$thread_model \
use_kos_patches=$use_kos_patches

# Build ARM GCC Compiler
RUN make build-arm \
makejobs=$makejobs \
verbose=$verbose

# Remove kos directory, gcc binaries are in dc directory
RUN rm -rf /opt/toolchains/dc/kos

# Stage 2: Minimal Runtime Environment
FROM alpine:latest

# Copy compiled toolchains from the build stage
COPY --from=build /opt/toolchains/dc /opt/toolchains/dc

# Create the bin directory to avoid missing directory errors
RUN mkdir -p /opt/toolchains/dc/bin

# Installing prerequisites for compiling KOS, kos-ports, utils
RUN apk add --no-cache \
build-base \
coreutils \
cmake \
git \
curl \
wget \
bash \
elfutils-dev \
libjpeg-turbo-dev \
libpng-dev \
python3 \
ruby-rake \
libisofs-dev \
meson

# Set default working directory
WORKDIR /opt/toolchains/dc

# Set entry point to bash so arg to docker run can be
# run as a command.
ENTRYPOINT ["/bin/bash", "-c", "exec \"$@\"", "bash"]

# If run with no parameters just start bash
CMD ["/bin/bash"]
147 changes: 147 additions & 0 deletions .github/workflows/gen-kos-toolchains.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Generate KOS-Toolchain Docker Images

on:
push:
branches:
- master
paths:
- 'include/**'
- 'kernel/**'
- 'addons/**'
- 'utils/**'
workflow_run:
workflows:
- Generate Toolchain Docker Images
types:
- completed

permissions:
packages: write
contents: read

jobs:
build-arm64:
runs-on: self-hosted
name: Build for ARM64
strategy:
matrix:
tag:
- "13.3-legacy"
- "14.2-stable"
- "15.0-dev"
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and Push ARM64 Docker Image
uses: docker/build-push-action@v6
with:
context: .github/docker
file: .github/docker/kos-Dockerfile
push: true
tags: |
ghcr.io/kallistiosunchained/dc-kos-toolchain:${{ matrix.tag }}-arm64
${{ secrets.DOCKER_HUB_USERNAME }}/dc-kos-toolchain:${{ matrix.tag }}-arm64
platforms: linux/arm64
build-args: |
tag=${{ matrix.tag }}
no-cache: true

build-amd64:
runs-on: ubuntu-latest
name: Build for AMD64
strategy:
matrix:
tag:
- "13.3-legacy"
- "14.2-stable"
- "15.0-dev"
needs: build-arm64
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and Push AMD64 Docker Image
uses: docker/build-push-action@v6
with:
context: .github/docker
file: .github/docker/kos-Dockerfile
push: true
tags: |
ghcr.io/kallistiosunchained/dc-kos-toolchain:${{ matrix.tag }}-amd64
${{ secrets.DOCKER_HUB_USERNAME }}/dc-kos-toolchain:${{ matrix.tag }}-amd64
platforms: linux/amd64
build-args: |
tag=${{ matrix.tag }}
no-cache: true

merge-manifest:
runs-on: ubuntu-latest
name: Merge Docker Manifests
strategy:
matrix:
tag:
- "13.3-legacy"
- "14.2-stable"
- "15.0-dev"
needs:
- build-arm64
- build-amd64
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Create and Push Docker Manifest
run: |
docker buildx imagetools create \
--tag ghcr.io/kallistiosunchained/dc-kos-toolchain:${{ matrix.tag }} \
--tag ${{ secrets.DOCKER_HUB_USERNAME }}/dc-kos-toolchain:${{ matrix.tag }} \
ghcr.io/kallistiosunchained/dc-kos-toolchain:${{ matrix.tag }}-arm64 \
ghcr.io/kallistiosunchained/dc-kos-toolchain:${{ matrix.tag }}-amd64 \
${{ secrets.DOCKER_HUB_USERNAME }}/dc-kos-toolchain:${{ matrix.tag }}-arm64 \
${{ secrets.DOCKER_HUB_USERNAME }}/dc-kos-toolchain:${{ matrix.tag }}-amd64
46 changes: 46 additions & 0 deletions .github/workflows/gen-tag-latest-kos-toolchain.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Tag Latest KOS-Toolchain

on:
workflow_dispatch:
workflow_run:
workflows:
- Generate KOS-Toolchain Docker Images
types:
- completed

permissions:
packages: write
contents: read

jobs:
tag-latest:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

# Tag latest kos-toolchains
- name: Create and Push Docker Latest Manifest
run: |
docker buildx imagetools create \
--tag ghcr.io/kallistiosunchained/dc-kos-toolchain:latest \
--tag ${{ secrets.DOCKER_HUB_USERNAME }}/dc-kos-toolchain:latest \
ghcr.io/kallistiosunchained/dc-kos-toolchain:14.2-stable-arm64 \
ghcr.io/kallistiosunchained/dc-kos-toolchain:14.2-stable-amd64 \
${{ secrets.DOCKER_HUB_USERNAME }}/dc-kos-toolchain:14.2-stable-arm64 \
${{ secrets.DOCKER_HUB_USERNAME }}/dc-kos-toolchain:14.2-stable-amd64
Loading

0 comments on commit 9a04067

Please sign in to comment.