summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakaRikka <38417346+TakaRikka@users.noreply.github.com>2023-01-25 15:34:06 -0800
committerGitHub <noreply@github.com>2023-01-25 15:34:06 -0800
commit7343cc7d3fab528dac67ea42b3143e91c68f38fc (patch)
tree66bf60a5b88128d257de622db9f14947c63ed4f7
parent6f973eb07af23579e9040ba4282246ce4a307342 (diff)
parentb016e68d7364e729cb79cf32c006edf569ff951c (diff)
Merge pull request #255 from DRK-512/master
Automated setup implementation
-rw-r--r--.devcontainer/Dockerfile2
-rw-r--r--Makefile2
-rw-r--r--README.md20
-rw-r--r--tools/requirements.txt5
-rw-r--r--tools/tp.py29
5 files changed, 30 insertions, 28 deletions
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index 1504ede58d..b943117380 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -19,4 +19,4 @@ RUN sudo ./install-devkitpro-pacman
RUN sudo dkp-pacman -Syu --noconfirm
WORKDIR /etc
RUN sudo ln -sf /proc/self/mounts mtab
-RUN sudo dkp-pacman -S --noconfirm gamecube-dev wii-dev \ No newline at end of file
+RUN sudo dkp-pacman -S --noconfirm gamecube-dev wii-dev
diff --git a/Makefile b/Makefile
index 450ced509b..fe9759de1c 100644
--- a/Makefile
+++ b/Makefile
@@ -180,7 +180,7 @@ $(ELF_SHIFT): $(DOL)
$(DOL_SHIFT): $(ELF_SHIFT) | tools
$(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL)
@cp -v $(DOL_SHIFT) $(DOL)
-
+
shift: dirs $(DOL_SHIFT)
game: shift
diff --git a/README.md b/README.md
index 7816d0cdc2..cea9ab8b7f 100644
--- a/README.md
+++ b/README.md
@@ -22,23 +22,9 @@ Project Setup
git clone https://github.com/zeldaret/tp
```
-2. Setup compiler directory
+2. Place a copy of NTSC-U GCN Twilight Princess in the root directory and call it `gz2e01.iso` (find this on your own)
-```bash
-mkdir -p tools/mwcc_compiler/
-```
-
-3. Download [GC_WII_COMPILERS.zip](https://cdn.discordapp.com/attachments/727918646525165659/917185027656286218/GC_WII_COMPILERS.zip).
-
-4. Extract `GC_WII_COMPILERS.zip` into the previously created `mwcc_compiler` directory
-
-```bash
-unzip GC_WII_COMPILERS.zip "GC/*" -d tools/mwcc_compiler/ && mv tools/mwcc_compiler/GC/* tools/mwcc_compiler/ && rmdir tools/mwcc_compiler/GC
-```
-
-5. Place a copy of NTSC-U GCN Twilight Princess in the root directory and call it `gz2e01.iso` (find this on your own)
-
-6. Setup the project
+3. Then run the setup script
```bash
./tp setup
@@ -140,4 +126,4 @@ tp/
├── include_link.mk # Makefiles to include in the main Makefile.
├── obj_files.mk # Object files to include in the main Makefile.
└── tp # Bash script used to call the main tp python script in tools directory.
-``` \ No newline at end of file
+```
diff --git a/tools/requirements.txt b/tools/requirements.txt
index 0fa5c69d63..6062e07974 100644
--- a/tools/requirements.txt
+++ b/tools/requirements.txt
@@ -7,4 +7,7 @@ ansiwrap
watchdog
python-Levenshtein
cxxfilt
-pyelftools \ No newline at end of file
+pyelftools
+requests
+zipfile
+shutil \ No newline at end of file
diff --git a/tools/tp.py b/tools/tp.py
index 35ca7bb12a..19c0869937 100644
--- a/tools/tp.py
+++ b/tools/tp.py
@@ -28,6 +28,9 @@ try:
import libarc
import io
import extract_game_assets
+ import requests
+ import zipfile
+ import shutil
from rich.logging import RichHandler
from rich.console import Console
@@ -145,19 +148,29 @@ def setup(debug: bool, game_path: Path, tools_path: Path):
sys.exit(1)
#
- text = Text("--- Patching compiler")
+ text = Text("--- Fetching compiler")
text.stylize("bold magenta")
CONSOLE.print(text)
compilers = tools_path.joinpath("mwcc_compiler")
if not compilers.exists() or not compilers.is_dir():
- LOG.error(
- (
- f"Unable to find MWCC compilers: missing directory '{compilers}'\n"
- f"Check the README for instructions on how to obtain the compilers"
- )
- )
- sys.exit(1)
+ os.mkdir(compilers)
+ r = requests.get('https://cdn.discordapp.com/attachments/727918646525165659/917185027656286218/GC_WII_COMPILERS.zip')
+ z = zipfile.ZipFile(io.BytesIO(r.content))
+ z.extractall(compilers)
+ gc_path = compilers.joinpath("GC")
+
+ allfiles = os.listdir(gc_path)
+ for f in allfiles:
+ src_path = os.path.join(gc_path, f)
+ dst_path = os.path.join(compilers, f)
+ shutil.move(src_path, dst_path)
+ os.rmdir(gc_path)
+
+ #
+ text = Text("--- Patching compiler")
+ text.stylize("bold magenta")
+ CONSOLE.print(text)
c27 = compilers.joinpath("2.7")
if not c27.exists() or not c27.is_dir():