From 4bd3047d3fbac6ebe9678a519a6c1b3d7679c4e9 Mon Sep 17 00:00:00 2001 From: Darek Konopka <69826267+DRK-512@users.noreply.github.com> Date: Tue, 24 Jan 2023 18:59:02 -0500 Subject: [PATCH 1/8] Update Makefile make setup implemented --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dbf54f56b56..9db5d04579f 100644 --- a/Makefile +++ b/Makefile @@ -179,7 +179,17 @@ $(ELF_SHIFT): $(DOL) $(DOL_SHIFT): $(ELF_SHIFT) | tools $(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL) @cp -v $(DOL_SHIFT) $(DOL) - + +setup: + @if [ ! -d tools/mwcc_compiler/ ]; then \ + mkdir tools/mwcc_compiler/ ; \ + wget https://cdn.discordapp.com/attachments/727918646525165659/917185027656286218/GC_WII_COMPILERS.zip -P tools/mwcc_compiler/ ; \ + unzip tools/mwcc_compiler/GC_WII_COMPILERS.zip "GC/*" -d tools/mwcc_compiler/ ; \ + mv tools/mwcc_compiler/GC/* tools/mwcc_compiler/ ; \ + rm tools/mwcc_compiler/GC_WII_COMPILERS.zip ; \ + rmdir tools/mwcc_compiler/GC ; \ + fi + shift: dirs $(DOL_SHIFT) game: shift From 4a524883e57e0f8c88994610475d472c3ede91cb Mon Sep 17 00:00:00 2001 From: Darek Konopka <69826267+DRK-512@users.noreply.github.com> Date: Tue, 24 Jan 2023 18:59:50 -0500 Subject: [PATCH 2/8] Update README.md Updated README to use make setup --- README.md | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7816d0cdc20..3b5ee01f687 100644 --- a/README.md +++ b/README.md @@ -22,23 +22,15 @@ Project Setup git clone https://github.com/zeldaret/tp ``` -2. Setup compiler directory +2. Setup compiler ```bash -mkdir -p tools/mwcc_compiler/ +make setup ``` -3. Download [GC_WII_COMPILERS.zip](https://cdn.discordapp.com/attachments/727918646525165659/917185027656286218/GC_WII_COMPILERS.zip). +3. Place a copy of NTSC-U GCN Twilight Princess in the root directory and call it `gz2e01.iso` (find this on your own) -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 +4. Setup the project ```bash ./tp setup @@ -140,4 +132,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 +``` From c6c01426f1f931599ed7a1f6072cde80d3e7c232 Mon Sep 17 00:00:00 2001 From: Darek Konopka <69826267+DRK-512@users.noreply.github.com> Date: Tue, 24 Jan 2023 19:00:33 -0500 Subject: [PATCH 3/8] Update README.md README uses make setup instead of manual setup --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b5ee01f687..7188e07c902 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Project Setup git clone https://github.com/zeldaret/tp ``` -2. Setup compiler +2. Setup the compiler ```bash make setup From efeb260726a08603a4c74659930b55e1dfc122e8 Mon Sep 17 00:00:00 2001 From: DRK-512 Date: Tue, 24 Jan 2023 22:50:19 -0500 Subject: [PATCH 4/8] setup moved from makefile to tp --- Makefile | 10 ---------- README.md | 10 ++-------- tools/tp.py | 29 +++++++++++++++++++++-------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 9db5d04579f..ec42d513499 100644 --- a/Makefile +++ b/Makefile @@ -180,16 +180,6 @@ $(DOL_SHIFT): $(ELF_SHIFT) | tools $(ELF2DOL) $< $@ $(SDATA_PDHR) $(SBSS_PDHR) $(TARGET_COL) @cp -v $(DOL_SHIFT) $(DOL) -setup: - @if [ ! -d tools/mwcc_compiler/ ]; then \ - mkdir tools/mwcc_compiler/ ; \ - wget https://cdn.discordapp.com/attachments/727918646525165659/917185027656286218/GC_WII_COMPILERS.zip -P tools/mwcc_compiler/ ; \ - unzip tools/mwcc_compiler/GC_WII_COMPILERS.zip "GC/*" -d tools/mwcc_compiler/ ; \ - mv tools/mwcc_compiler/GC/* tools/mwcc_compiler/ ; \ - rm tools/mwcc_compiler/GC_WII_COMPILERS.zip ; \ - rmdir tools/mwcc_compiler/GC ; \ - fi - shift: dirs $(DOL_SHIFT) game: shift diff --git a/README.md b/README.md index 7188e07c902..cea9ab8b7ff 100644 --- a/README.md +++ b/README.md @@ -22,15 +22,9 @@ Project Setup git clone https://github.com/zeldaret/tp ``` -2. Setup the compiler +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 -make setup -``` - -3. Place a copy of NTSC-U GCN Twilight Princess in the root directory and call it `gz2e01.iso` (find this on your own) - -4. Setup the project +3. Then run the setup script ```bash ./tp setup diff --git a/tools/tp.py b/tools/tp.py index 35ca7bb12a1..19c0869937d 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(): From 327965d1b789817e2b1953b399e2e67e8a7a7f18 Mon Sep 17 00:00:00 2001 From: DRK-512 Date: Wed, 25 Jan 2023 01:15:00 -0500 Subject: [PATCH 5/8] Fixed requirements --- tools/requirements.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/requirements.txt b/tools/requirements.txt index 3bd1bb7a620..238ee376668 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -9,4 +9,7 @@ watchdog python-Levenshtein cxxfilt oead -pyelftools \ No newline at end of file +pyelftools +requests +zipfile +shutil From 1397efac6fc001a226abda03647c0ae3ab18181f Mon Sep 17 00:00:00 2001 From: DRK-512 Date: Wed, 25 Jan 2023 01:18:46 -0500 Subject: [PATCH 6/8] requires caught up to main --- tools/requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/requirements.txt b/tools/requirements.txt index 238ee376668..67935ac5793 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -1,6 +1,5 @@ rich click -yaz0 GitPython hexdump colorama @@ -8,7 +7,6 @@ ansiwrap watchdog python-Levenshtein cxxfilt -oead pyelftools requests zipfile From 3e673a8a4522141e0fcd77693e727b8c38f5666a Mon Sep 17 00:00:00 2001 From: Darek Konopka <69826267+DRK-512@users.noreply.github.com> Date: Wed, 25 Jan 2023 01:41:09 -0500 Subject: [PATCH 7/8] python-requests added to docker --- .devcontainer/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 1504ede58d8..83ee0111877 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -19,4 +19,5 @@ 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 +RUN pip3 install requests From b016e68d7364e729cb79cf32c006edf569ff951c Mon Sep 17 00:00:00 2001 From: DRK-512 Date: Wed, 25 Jan 2023 17:49:49 -0500 Subject: [PATCH 8/8] Undo Docker --- .devcontainer/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 83ee0111877..b9431173807 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -20,4 +20,3 @@ 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 -RUN pip3 install requests