Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker cross-platform compiler #102

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/build-and-publish-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and Publish Docker

on:
workflow_dispatch:
inputs:
image:
default: "hldtux/ndevkit"
description: "Docker image name"

jobs:
build:
name: ngdevkit ${{ github.event.inputs.image }}
runs-on: ubuntu-latest
environment: DockerHub

steps:

# Checkout
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
path: .

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and Deploy
run: |
make IMAGE=${{ github.event.inputs.image }} -f Makefile.docker docker push
echo "https://hub.docker.com/r/${{ github.event.inputs.image }}"

28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update -y && apt install -y autoconf autoconf-archive automake gcc curl zip unzip \
libsdl2-dev python3-pygame libreadline-dev git
# make sure you have src packages enabled for dependency information
RUN echo "deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted" > /etc/apt/sources.list.d/ngdevkit.list
RUN echo "deb-src http://archive.ubuntu.com/ubuntu/ focal universe" >> /etc/apt/sources.list.d/ngdevkit.list
RUN apt update -y
# install build-dependency packages
RUN export GCC_VERSION_PKG=`apt-cache depends gcc | awk '/Depends.*gcc/ {print $2}'` \
&& echo "GCC_VERSION_PKG=$GCC_VERSION_PKG" \
&& apt build-dep -y $GCC_VERSION_PKG \
&& apt build-dep -y --arch-only sdcc
# optional: install GLEW for OpenGL+GLSL shaders in GnGeo
RUN apt install -y libglew-dev
# dependencies for the example ROMs
RUN apt install -y imagemagick sox libsox-fmt-mp3

## Building the toolchain
WORKDIR /ngdevkit
COPY . .
RUN autoreconf -iv \
&& ./configure --prefix=$PWD/local \
&& make \
&& make install

# ngdevkit-gngeo
RUN make shellinit >> ~/.bashrc
19 changes: 19 additions & 0 deletions Makefile.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Remote image
IMAGE=hldtux/ndevkit
# Local image
# make IMAGE=ndevkit -f Makefile.docker
# or
#IMAGE=ndevkit
TAG=latest
# Forcing amd64 arch
DOCKER_DEFAULT_PLATFORM=linux/amd64

docker:
docker build . -t ${IMAGE}

shell: docker
docker run -it --rm -v `pwd`:/tmp/workdir -w /tmp/workdir ${IMAGE} bash

push:
docker push ${IMAGE}:${TAG}

25 changes: 25 additions & 0 deletions README-docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Building ngdevkit from source on any platform that supports Docker

## Pre-requisite

* Docker

### Shell
The following command will let access the container that contains the embedded devkit and the current folder at /tmp/workdir. So, you will be able to make the build your on rom easily without any local dependency

```shell
make -f Makefile.docker shell
```

### Push
To avoid waiting the image creating you can push the finished one as following

```shell
make -f Makefile.docker USER=<YOUR_DOCKERHUB_USER> push
```

Congratulations! You are now ready to experiment with the devkit.
Please follow the [main README](README.md) for additional information
on how to download and build the example ROMs, run the emulator or
run the debugger.

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ is now deprecated in favour of the native MSYS2 environment. Likewise,
we no longer build nightly packages for MSYS2's mingw64 subsystem,
ucrt64 is the only supported subsystem for ngdevkit.

#### Docker

```shell
make -f Makefile.docker shell
```

### Build the included examples

The devkit comes with a series of examples to demonstrate how to use
Expand All @@ -134,6 +140,11 @@ For macOS, make sure you use brew's python3 and gmake:
./configure
gmake

For any platform that supports docker

```shell
make -f Makefile.docker shell
```

### Running the emulator

Expand Down