Skip to content

Commit 253f22b

Browse files
committed
Revamp and modernize - v1.3
1 parent e569fc1 commit 253f22b

File tree

7 files changed

+106
-50
lines changed

7 files changed

+106
-50
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jobs:
66
steps:
77
- uses: actions/checkout@v4
88
- name: Build
9-
run: docker run --rm -v ${{ github.workspace }}:/gba aaaronic/gba-compiler:1.2
10-
- name: Upload Project.gba
9+
run: docker run --rm -v ${{ github.workspace }}:/gba aaaronic/gba-compiler:1.3
10+
- name: Upload my_project.gba
1111
uses: actions/upload-artifact@v4
1212
with:
13-
name: Project.gba
14-
path: ${{ github.workspace }}/Project.gba
13+
name: my_project.gba
14+
path: ${{ github.workspace }}/my_project.gba

.vscode/tasks.json

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,38 @@
22
// See https://go.microsoft.com/fwlink/?LinkId=733558
33
// for the documentation about the tasks.json format
44
"version": "2.0.0",
5+
"windows": {
6+
"options": {
7+
"shell": {
8+
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
9+
"args": ["-NoProfile", "-Command"]
10+
}
11+
}
12+
},
513
"tasks": [
614
{
7-
"label": "build run",
15+
"label": "run",
816
"type": "shell",
9-
// add the mGBA.exe exact path to the relevant line(s) below, before "./Project.gba"!
10-
// Make sure there is a space between the exact path and "./Project.gba".
1117
"windows": {
12-
"command": "C:/Users/AaronHansen/Desktop/mGBA.exe ./Project.gba"
18+
"command": "C:/Users/AaronHansen/Desktop/mGBA-0.10.5-win64/mGBA.exe ./my_project.gba"
19+
// Add the mGBA.exe exact path to the above line inside the quotes before the space in " ./Project.gba"!
20+
// (use double-backslash "\\" or "/" between folders),
21+
// Make sure there is a space between the exact path and "./my_project.gba".
1322
},
1423
"osx": {
15-
"command": "open -a /Users/aaronhansen/Downloads/mGBA.app ./Project.gba"
24+
"command": "open -a /Applications/mGBA.app ./my_project.gba"
25+
// Add the mGBA.app exact path to the above line,
26+
// in between "open -a" and " ./Project.gba"!
27+
// Make sure there is a space before/after the path the exact path and "./my_project.gba".
28+
},
29+
"linux":{
30+
"command": "You're on your own, but the above should be close."
1631
},
1732
"problemMatcher": [],
18-
"dependsOn": ["build"],
33+
"dependsOn": [
34+
"build"
35+
],
36+
"dependsOrder": "sequence",
1937
"group": {
2038
"kind": "build",
2139
"isDefault": true
@@ -24,14 +42,20 @@
2442
{
2543
"label": "build",
2644
"type": "shell",
27-
"command": "docker run --rm -it -v \"${PWD}:/gba\" aaaronic/gba-compiler:1.2",
45+
"command": "docker run --rm -it -v \"${PWD}:/gba\" aaaronic/gba-compiler:1.3",
2846
"problemMatcher": []
2947
},
3048
{
3149
"label": "clean",
3250
"type": "shell",
33-
"command": "docker run --rm -it -v \"${PWD}:/gba\" aaaronic/gba-compiler:1.2 bash -c 'cd /gba && make clean'",
51+
"command": "docker run --rm -it -v \"${PWD}:/gba\" aaaronic/gba-compiler:1.3 clean",
52+
"problemMatcher": []
53+
},
54+
{
55+
"label": "audio",
56+
"type": "shell",
57+
"command": "docker run --rm -it -v \"${PWD}:/gba\" aaaronic/gba-compiler:1.3 audio",
3458
"problemMatcher": []
3559
}
3660
]
37-
}
61+
}

Dockerfile

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,44 @@
1-
FROM debian:stretch
1+
FROM debian:trixie-slim AS wav2c_builder
22

3-
MAINTAINER Aaron Hansen <[email protected]>
3+
LABEL maintainer="Aaron Hansen <[email protected]>"
44
# Copied/adapted from https://github.com/devkitPro/docker/blob/master/devkitarm/Dockerfile
55

66
ENV DEBIAN_FRONTEND=noninteractive
77

8+
WORKDIR /wav2c
9+
10+
RUN apt-get update && \
11+
apt-get install -y build-essential wget unzip
12+
13+
RUN wget https://github.com/aaaronic/wav2c/archive/refs/heads/master.zip && \
14+
unzip -j master.zip && \
15+
make
16+
17+
FROM debian:trixie-slim
18+
819
RUN apt-get update && \
9-
apt-get install -y apt-utils vim && \
10-
apt-get install -y --no-install-recommends sudo ca-certificates pkg-config curl wget bzip2 xz-utils make git bsdtar doxygen gnupg && \
20+
apt-get install -y --no-install-recommends apt-utils && \
21+
apt-get install -y --no-install-recommends sudo ca-certificates wget && \
1122
apt-get clean
1223

13-
RUN wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.2/devkitpro-pacman.deb && \
14-
dpkg -i devkitpro-pacman.deb && \
15-
rm devkitpro-pacman.deb && \
16-
dkp-pacman -Scc --noconfirm
24+
RUN ln -s /proc/self/mounts /etc/mtab
25+
26+
RUN wget https://apt.devkitpro.org/install-devkitpro-pacman && \
27+
chmod +x ./install-devkitpro-pacman && \
28+
sudo yes | ./install-devkitpro-pacman && \
29+
apt-get clean
1730

1831
ENV DEVKITPRO=/opt/devkitpro
1932
ENV PATH=${DEVKITPRO}/tools/bin:$PATH
2033

21-
RUN dkp-pacman -Syyu --noconfirm gba-dev && \
22-
dkp-pacman -Scc --noconfirm
34+
RUN dkp-pacman -Syyu --noconfirm --needed gba-dev && \
35+
yes | dkp-pacman -Scc
2336
ENV DEVKITARM=${DEVKITPRO}/devkitARM
24-
RUN mkdir /gba
25-
COPY wav2c /usr/local/bin
37+
38+
ADD entrypoint.sh /usr/local/bin
39+
ADD Makefile /usr/default/Makefile
40+
COPY --from=wav2c_builder /wav2c/wav2c /usr/local/bin
41+
2642
VOLUME ["/gba"]
27-
CMD cd /gba && make
43+
WORKDIR /gba
44+
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PRODUCT_NAME = Project
1+
PRODUCT_NAME = my_project
22

33
# You probably won't need to touch anything below here!!!
44
# The one exception is the cleanup stuff.
@@ -56,12 +56,12 @@ build : $(ROM_NAME)
5656

5757
# --- Build .elf file into .gba ROM file
5858
$(ROM_NAME) : $(ELF_NAME)
59-
$(OBJCOPY) $(OBJCOPYFLAGS) $(ELF_NAME) $(ROM_NAME)
59+
$(OBJCOPY) $(OBJCOPYFLAGS) $^ $(ROM_NAME)
6060
$(GBAFIX) $(ROM_NAME)
6161

6262
# --- Build .o files into .elf file
6363
$(ELF_NAME) : $(OBJECTS)
64-
$(LD) $(OBJECTS) $(LDFLAGS) -o $@
64+
$(LD) $^ $(LDFLAGS) -o $@
6565

6666
# -- Build .asm files into .o files
6767
$(ASMOBJECTS) : %.o : %.asm
@@ -79,7 +79,7 @@ $(AUDIOHEADERS) : %.h : %.c
7979

8080

8181
clean:
82-
$(RM) $(ROM_NAME) $(ELF_NAME) $(BIN_NAME)
82+
$(RM) $(ROM_NAME) $(ELF_NAME) $(BIN_NAME).sav
8383
$(RM) $(AUDIOOBJECTS) $(AUDIOHEADERS)
8484
$(RM) *.o *.i *.s
8585

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Docker GBA Complier
22
Windows people have had a particularly rough time getting up and running with GBA development.
33
Since installing cygwin + devkitPro, updating system paths, and updating the Makefile to match
4-
has proven difficult time and time again, this Dockerfile + Makefile represents an attempt to
5-
unify things cross-platform in a less brittle way.
4+
has proven difficult time and time again, this Dockerfile (+ default Makefile) represents an
5+
attempt to unify things cross-platform in a less brittle way.
6+
7+
If you're using the latest version, note that the `gcc` version included in the 1.3+ container
8+
is significantly stricter than the older version. `-fpermissive` and similar options may need
9+
to be added to the `CFLAGS` definition in your fork of the example Makefile.
610

711
## Requirements
812
Docker for Desktop: https://www.docker.com/products/docker-desktop/
@@ -11,65 +15,61 @@ Note: Even if you can't get Docker running locally, I now have instructions for
1115

1216

1317
## Building your own Docker Container (not required)
14-
Ths following `docker build` command is only required if you plan to create your own version of this docker container. The one in this repo is available on Docker Hub as aaaronic/gba-compiler:1.2.
18+
Ths following `docker build` command is only required if you plan to create your own version of this docker container. The one in this repo is available on Docker Hub as `aaaronic/gba-compiler:1.3`.
1519

1620
Once docker is installed, you could choose to do a one-time build of the Dockerfile on your machine (*from the folder containing the `Dockerfile`*):
1721

1822
```
1923
docker build . -t gba-compiler
2024
```
2125
A few minutes later, you should have a docker image named gba-compiler that you should not
22-
need to rebuild (hopefully ever again). It might spend a long time on the "Generating pacman
23-
keyring master key..." step).
26+
need to rebuild (hopefully ever again).
2427

2528
## Running a GBA project build (aka, compiling your GBA project)
26-
1. The provided Makefile needs to be in your GBA project's directory (next to all your `.h` and
27-
`.c` files).
28-
- You should (hopefully) not need to change much about the Makefile aside from the
29-
`PRODUCT_NAME` line. It defaults to "Project", which leads to your resulting `.gba` file
30-
being named `Project.gba`. Feel free to change it to anything _without spaces or special characters_ (ex: "BouncingBox"). You can always rename the resulting file after the compilation instead.
31-
29+
1. Run from your GBA project's directory (with all your `.h` and `.c` files).i
30+
- You can optionally provide your own Makefile (ideally based on the one in this repo)
3231
2. Run the docker image we built above with the following special sauce:
3332

3433
```
35-
docker run --rm -it -v ${PWD}:/gba aaaronic/gba-compiler:1.2
34+
docker run --rm -it -v ${PWD}:/gba aaaronic/gba-compiler:1.3
3635
```
3736
or, alternatively (if you chose to do your own `docker build` locally):
3837
```
3938
docker run --rm -it -v ${PWD}:/gba gba-compiler
4039
```
4140

42-
If the compilation succeeded, you should now see a `Project.gba` (or whatever you renamed it
43-
to) in your project's folder.
41+
If the compilation succeeded, you should now see a `my_project.gba` (or whatever you renamed it
42+
to) in your non-default Makefile.
4443

4544
## Setting it and forgetting it for a project in Visual Studio Code
4645
Copy the included `.vscode` folder (containing `tasks.json`) into your project folder.
47-
Update `tasks.json`'s "build" command to point to your visualboyadvance-m installation:
46+
Update `tasks.json`'s "build" command to point to your mGBA installation:
4847

4948
Windows example:
5049
```
51-
"command": "C:/Users/Aaron/Desktop/visualboyadvance-m.exe ./Project.gba",
50+
"command": "C:/Users/Aaron/Desktop/mGBA.exe ./my_project.gba",
5251
```
5352
Mac Example:
5453
```
55-
"command": "open /path/to/visualboyadvance-m.app ./Project.gba",
54+
"command": "open -a /Applications/mGBA.app ./my_project.gba",
5655
```
5756

58-
Note: If you've renamed `Project.gba`, you should fix that part of the command as well.
57+
Note: If you've renamed `my_project.gba`, you should fix that part of the command as well.
5958
Also Note: if you did a local `docker build` and want to use that image,
6059
update the docker commands for build and clean accordingly (basically
61-
just remove the "aaaronic/" and the ":1.0").
60+
just remove the "aaaronic/" and the ":1.3").
6261

6362
Once that's all set up and happy, the Terminal -> Run Build Task... command in the menu
6463
should now compile your project and open the emulator with the result (if the compile
6564
succeeds).
6665

6766
Terminal -> Run Task should provide 3 options:
68-
- **build run**: build and run the project
67+
- **run**: build and run the project
6968
- **build**: just build the project (but don't run anything).
7069
- **clean**: remove all the intermediate files from builds so the next build is _from
7170
scratch_. This is helpful if something buggy is going on or if you've only changed header
7271
files and aren't seeing your expected changes in the build.
72+
- **audio**: convert .wav files (8-bit format) to .c / .h files.
7373

7474
## Acknowledgements
7575
The provided Dockerfile is a fork/combination of the Dockerfiles provided by devkitPro:

entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
# entrypoint.sh
3+
4+
CLEANUP_MAKEFILE=
5+
if [[ ! -f /gba/Makefile ]]; then
6+
echo "Using default Makefile"
7+
cp /usr/default/Makefile /gba
8+
CLEANUP_MAKEFILE=1
9+
fi
10+
11+
make "$@"
12+
13+
if [[ -n "$CLEANUP_MAKEFILE" ]]; then
14+
rm /gba/Makefile
15+
fi

wav2c

-17.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)