Skip to content

Commit f9bdb1d

Browse files
authored
Docker Support for OSX (zeldaret#91)
* Makefile machinery work * Updating Jenkinsfile * Initial setup for OSX repo support * Adding ido7 to repo * Makefile reversion * Iniital Dockerfile * Docker stuff * fixbaserom cleanup * Attempting to fix fixbaserom * baserom_original -> input * Revert "baserom_original -> input" This reverts commit d919946. * Spiffing up readme for OSX
1 parent 4d3d264 commit f9bdb1d

File tree

22 files changed

+1354
-21
lines changed

22 files changed

+1354
-21
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ baserom/
2424
out.txt
2525

2626
# Tool artifacts
27-
tools/ido7.1_compiler/*
2827
tools/mipspro7.2_compiler/
2928
tools/overlayhelpers/batchdisasm/output/*
3029
tools/overlayhelpers/batchdisasm/output2/*
@@ -44,4 +43,4 @@ tools/asmsplitter/c/*
4443
*.ci8.png
4544

4645
#Per-user configuration
47-
.python-version
46+
.python-version

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ubuntu:18.04 as build
2+
3+
RUN apt-get update && \
4+
apt-get install -y \
5+
binutils-mips-linux-gnu \
6+
build-essential \
7+
pkg-config \
8+
python3 \
9+
python3-pip \
10+
wget \
11+
git \
12+
unzip
13+
14+
RUN wget \
15+
https://github.com/n64decomp/qemu-irix/releases/download/v2.11-deb/qemu-irix-2.11.0-2169-g32ab296eef_amd64.deb \
16+
-O qemu.deb && \
17+
echo 8170f37cf03a08cc2d7c1c58f10d650ea0d158f711f6916da9364f6d8c85f741 qemu.deb | sha256sum --check && \
18+
dpkg -i qemu.deb && \
19+
rm qemu.deb
20+
21+
RUN python3 -m pip install --user colorama ansiwrap attrs watchdog python-Levenshtein
22+
23+
RUN mkdir /oot
24+
WORKDIR /oot

Jenkinsfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pipeline {
66
steps {
77
echo 'Setting up...'
88
sh 'cp /usr/local/etc/roms/baserom_oot.z64 baserom_original.z64'
9-
sh 'cp -r /usr/local/etc/ido/ido7.1_compiler tools/ido7.1_compiler'
10-
sh 'chmod +x -R tools/ido*'
119
sh 'make -j`nproc` setup'
1210
}
1311
}

makefile renamed to Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ LD := $(MIPS_BINUTILS_PREFIX)ld
2222
OBJCOPY := $(MIPS_BINUTILS_PREFIX)objcopy
2323
OBJDUMP := $(MIPS_BINUTILS_PREFIX)objdump
2424

25-
# Be sure to grab ido7.1_compiler and put it in tools/ first.
2625
CC := $(QEMU_IRIX) -L tools/ido7.1_compiler tools/ido7.1_compiler/usr/bin/cc
2726
CC_OLD := $(QEMU_IRIX) -L tools/ido5.3_compiler tools/ido5.3_compiler/usr/bin/cc
2827

@@ -149,7 +148,7 @@ build/asm/%.o: asm/%.s
149148
$(AS) $(ASFLAGS) $^ -o $@
150149

151150
build/data/%.o: data/%.s
152-
iconv --to EUC-JP $^ | $(AS) $(ASFLAGS) -o $@
151+
iconv --from UTF-8 --to EUC-JP $^ | $(AS) $(ASFLAGS) -o $@
153152

154153
#build/assets/%.o: assets/%.s
155154
# $(AS) $(ASFLAGS) $^ -o $@
@@ -175,7 +174,7 @@ build/src/overlays/%.o: src/overlays/%.c
175174
@$(OBJDUMP) -d $@ > $(@:.o=.s)
176175

177176
build/asm/overlays/%.o: asm/overlays/%.s
178-
iconv --to EUC-JP $^ | $(AS) $(ASFLAGS) -o $@
177+
iconv --from UTF-8 --to EUC-JP $^ | $(AS) $(ASFLAGS) -o $@
179178

180179
build/src/%.o: src/%.c
181180
$(CC) -c $(CFLAGS) $(OPTIMIZATION) -o $@ $^

README_OSX.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Developing on OSX
2+
3+
#### Requirements
4+
* Docker Desktop (for OSX)
5+
* docker-sync (`gem install docker-sync`)
6+
* a set-up baserom (see general setup guide / wiki for more details)
7+
8+
#### Build the docker image
9+
`docker build . -t oot`
10+
11+
#### Start docker-sync and the development container
12+
13+
`docker-sync-stack start`
14+
15+
After a lot of waiting, you'll see something like "Attaching to oot_oot_1". This means the container is ready.
16+
17+
#### Log into the container to begin working
18+
Note: this will be done in another tab while you leave the docker-sync tab going.
19+
20+
To get the container id, use `docker container ls` and use the ID from the container with image oot:latest in the following command
21+
22+
`docker exec-it <CONTAINER-ID> /bin/bash` You're in.
23+
24+
Run `make setup` followed by `make`, and you're off to the races!
25+
26+
#### When done working
27+
Type Ctrl+c on the docker-cync tab to close the container and docker-sync.

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "3"
2+
services:
3+
oot:
4+
volumes:
5+
- oot-sync:/oot:nocopy
6+
image: "oot:latest"
7+
tty: true
8+
9+
volumes:
10+
oot-sync:
11+
external: true

docker-sync.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "2"
2+
3+
syncs:
4+
oot-sync:
5+
src: '.'

fixbaserom.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
1-
import os.path
21
from os import path
32
import sys
43
import struct
54
import hashlib
65

76

7+
def get_str_hash(byte_array):
8+
return str(hashlib.md5(byte_array).hexdigest())
9+
10+
11+
# If the baserom exists and is correct, we don't need to change anything
12+
if path.exists("baserom.z64"):
13+
with open("baserom.z64", mode="rb") as file:
14+
fileContent = bytearray(file.read())
15+
if get_str_hash(fileContent) == "f0b7f35375f9cc8ca1b2d59d78e35405":
16+
print("Found valid baserom - exiting early")
17+
sys.exit(0)
18+
819
# Determine if we have a ROM file
920
romFileName = ""
10-
if (path.exists("baserom_original.z64")):
21+
if path.exists("baserom_original.z64"):
1122
romFileName = "baserom_original.z64"
12-
elif (path.exists("baserom_original.n64")):
23+
elif path.exists("baserom_original.n64"):
1324
romFileName = "baserom_original.n64"
1425

1526
# Read in the original ROM
16-
if (romFileName != ""):
27+
if romFileName != "":
1728
print("File '" + romFileName + "' found.")
18-
with open(romFileName, mode='rb') as file:
29+
with open(romFileName, mode="rb") as file:
1930
fileContent = bytearray(file.read())
2031

2132
# Check if ROM needs to be byte swapped
22-
if (fileContent[0] == 0x40):
23-
# Byte Swap ROM
33+
if fileContent[0] == 0x40:
34+
# Byte Swap ROM
2435
# TODO: This is pretty slow at the moment. Look into optimizing it later...
2536
print("ROM needs to be byte swapped...")
2637
i = 0
27-
while (i < len(fileContent)):
38+
while i < len(fileContent):
2839
tmp = struct.unpack_from("BBBB", fileContent, i)
2940
struct.pack_into("BBBB", fileContent, i + 0, tmp[3], tmp[2], tmp[1], tmp[0])
3041
i += 4
3142

3243
perc = float(i) / float(len(fileContent))
3344

34-
if (i % (1024 * 1024 * 4) == 0):
45+
if i % (1024 * 1024 * 4) == 0:
3546
print(str(perc * 100) + "%")
3647

3748
print("Byte swapping done.")
@@ -48,10 +59,10 @@
4859
strippedContent[0x3E] = 0x50
4960

5061
# Check to see if the ROM is a "vanilla" Debug ROM
51-
md5Hash = hashlib.md5(bytes(strippedContent)).hexdigest()
52-
53-
if (str(md5Hash) != "f0b7f35375f9cc8ca1b2d59d78e35405"):
54-
print("Error: Expected a hash of f0b7f35375f9cc8ca1b2d59d78e35405 but got " + str(md5Hash) + ". The baserom has probably been tampered, find a new one")
62+
str_hash = get_str_hash(bytearray(strippedContent))
63+
if str_hash != "f0b7f35375f9cc8ca1b2d59d78e35405":
64+
print("Error: Expected a hash of f0b7f35375f9cc8ca1b2d59d78e35405 but got " + str_hash + ". " +
65+
"The baserom has probably been tampered, find a new one")
5566
sys.exit(1)
5667

5768
# Write out our new ROM
@@ -60,4 +71,3 @@
6071
file.write(bytes(strippedContent))
6172

6273
print("Done!")
63-

tools/ido7.1_compiler/lib/cpp

53 KB
Binary file not shown.
1.72 MB
Binary file not shown.

0 commit comments

Comments
 (0)