From 97c07eda2723b4367d73edf45359b28b6e9f8bff Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 8 Sep 2022 13:22:44 -0400 Subject: [PATCH] Add dep tracking & use WiBo in CI (#47) * Add dep tracking & use WiBo in CI * Create empty tools/mwcc_compiler * Disable UPDATE_README in CI --- .github/workflows/build.yml | 31 ++++++++++++++------ .gitignore | 3 +- Makefile | 32 ++++++++++++++++----- tools/mwcc_compiler/.gitkeep | 0 tools/transform-dep.py | 56 ++++++++++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 17 deletions(-) create mode 100644 tools/mwcc_compiler/.gitkeep create mode 100755 tools/transform-dep.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d1436dc6..8abfd0e52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,17 +11,30 @@ jobs: env: WINEPREFIX: ${{github.workspace}}/.wine steps: - - name: Install devkitPro + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout WiBo + uses: actions/checkout@v3 + with: + repository: decompals/WiBo + path: tools/WiBo + - name: Install dependencies run: | sudo dpkg --add-architecture i386 sudo apt-get update - sudo apt-get -y install build-essential wine32 - sudo chown $(whoami) "$GITHUB_WORKSPACE" - - uses: actions/checkout@v3 - - name: Download compilers - run: | + sudo apt-get -y install build-essential gcc-multilib g++-multilib libc6:i386 curl -L https://cdn.discordapp.com/attachments/727918646525165659/917185027656286218/GC_WII_COMPILERS.zip \ | bsdtar -xvf- -C tools --exclude Wii - mv tools/GC tools/mwcc_compiler - - name: make - run: MAPGENFLAG=1 UPDATE_README=0 make -j$(nproc) + mv tools/GC/* tools/mwcc_compiler/ + - name: Build WiBo + working-directory: tools/WiBo + run: | + cmake -B build + cmake --build build + - name: Build + run: make -j$(nproc) WINE=./tools/WiBo/build/wibo MAPGENFLAG=1 UPDATE_README=0 + - name: Upload map + uses: actions/upload-artifact@v2 + with: + name: pikmin2UP.MAP + path: build/*/pikmin2UP.MAP diff --git a/.gitignore b/.gitignore index 74495d5c7..ca57fcbd4 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,8 @@ include/*.s build/ -tools/mwcc_compiler/ +tools/mwcc_compiler/* +!tools/mwcc_compiler/.gitkeep decomp/ errors.txt output.asm diff --git a/Makefile b/Makefile index bdc57d17c..4e8713a8b 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,11 @@ O_FILES := $(GROUP_0_FILES) $(JSYSTEM) $(DOLPHIN)\ ifeq ($(EPILOGUE_PROCESS),1) E_FILES := $(EPILOGUE_UNSCHEDULED) endif +DEPENDS := $(O_FILES:.o=.d) +DEPENDS += $(E_FILES:.o=.d) +# If a specific .o file is passed as a target, also process its deps +DEPENDS += $(MAKECMDGOALS:.o=.d) + #------------------------------------------------------------------------------- # Tools #------------------------------------------------------------------------------- @@ -88,11 +93,17 @@ ifeq ($(WINDOWS),1) CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp.exe -P PYTHON := python else - WINE ?= wine + WIBO := $(shell command -v wibo 2> /dev/null) + ifdef WIBO + WINE ?= wibo + else + WINE ?= wine + endif # Disable wine debug output for cleanliness export WINEDEBUG ?= -all # Default devkitPPC path DEVKITPPC ?= /opt/devkitpro/devkitPPC + DEPENDS := $(DEPENDS:.d=.d.unix) AS := $(DEVKITPPC)/bin/powerpc-eabi-as CPP := $(DEVKITPPC)/bin/powerpc-eabi-cpp -P PYTHON := python3 @@ -105,6 +116,7 @@ LD := $(WINE) tools/mwcc_compiler/$(MWLD_VERSION)/mwldeppc.exe ELF2DOL := tools/elf2dol SHA1SUM := sha1sum +TRANSFORM_DEP := tools/transform-dep.py FRANK := tools/franklite.py # Options @@ -120,7 +132,7 @@ ifeq ($(VERBOSE),0) # this set of LDFLAGS generates no warnings. LDFLAGS := $(MAPGEN) -fp hard -nodefaults -w off endif -CFLAGS := -Cpp_exceptions off -enum int -inline auto -proc gekko -RTTI off -fp hard -fp_contract on -rostr -O4,p -use_lmw_stmw on -common on -sdata 8 -sdata2 8 -nodefaults -DVERNUM=$(VERNUM) $(INCLUDES) +CFLAGS := -Cpp_exceptions off -enum int -inline auto -proc gekko -RTTI off -fp hard -fp_contract on -rostr -O4,p -use_lmw_stmw on -common on -sdata 8 -sdata2 8 -nodefaults -MMD -DVERNUM=$(VERNUM) $(INCLUDES) ifeq ($(VERBOSE),0) # this set of ASFLAGS generates no warnings. @@ -163,7 +175,7 @@ $(BUILD_DIR)/src/Dolphin/OSCache.o: CFLAGS += -str noreadonly $(BUILD_DIR)/src/Dolphin/GBA.o: CFLAGS += -str noreadonly # This is inline-deferred for some reason -$(BUILD_DIR)/src/Dolphin/mbstring.o: CFLAGS := -Cpp_exceptions off -enum int -inline deferred -proc gekko -RTTI off -fp hard -fp_contract on -rostr -O4,p -use_lmw_stmw on -common on -sdata 8 -sdata2 8 -nodefaults -DVERNUM=$(VERNUM) $(INCLUDES) +$(BUILD_DIR)/src/Dolphin/mbstring.o: CFLAGS := -Cpp_exceptions off -enum int -inline deferred -proc gekko -RTTI off -fp hard -fp_contract on -rostr -O4,p -use_lmw_stmw on -common on -sdata 8 -sdata2 8 -nodefaults -MMD -DVERNUM=$(VERNUM) $(INCLUDES) # Disable common BSS pool $(DOLPHIN): CFLAGS += -common off @@ -232,21 +244,27 @@ $(ELF): $(O_FILES) $(LDSCRIPT) $(QUIET) $(LD) $(LDFLAGS) -o $@ -lcf $(LDSCRIPT) @build/o_files endif +%.d.unix: %.d $(TRANSFORM_DEP) + @echo Processing $< + $(QUIET) $(PYTHON) $(TRANSFORM_DEP) $< $@ + +-include $(DEPENDS) + $(BUILD_DIR)/%.o: %.s @echo Assembling $< $(QUIET) $(AS) $(ASFLAGS) -o $@ $< $(BUILD_DIR)/%.o: %.c @echo "Compiling " $< - $(QUIET) $(CC) $(CFLAGS) -c -o $@ $< + $(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $< $(BUILD_DIR)/%.o: %.cp @echo "Compiling " $< - $(QUIET) $(CC) $(CFLAGS) -c -o $@ $< - + $(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $< + $(BUILD_DIR)/%.o: %.cpp @echo "Compiling " $< - $(QUIET) $(CC) $(CFLAGS) -c -o $@ $< + $(QUIET) $(CC) $(CFLAGS) -c -o $(dir $@) $< ifeq ($(EPILOGUE_PROCESS),1) $(EPILOGUE_DIR)/%.o: %.c $(BUILD_DIR)/%.o diff --git a/tools/mwcc_compiler/.gitkeep b/tools/mwcc_compiler/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/tools/transform-dep.py b/tools/transform-dep.py new file mode 100755 index 000000000..eabcc2b19 --- /dev/null +++ b/tools/transform-dep.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +import argparse +import os + +wineprefix = os.path.join(os.environ['HOME'], '.wine') +if 'WINEPREFIX' in os.environ: + wineprefix = os.environ['WINEPREFIX'] +winedevices = os.path.join(wineprefix, 'dosdevices') + +def import_d_file(in_file) -> str: + out_text = '' + + with open(in_file) as file: + for idx, line in enumerate(file): + if idx == 0: + if line.endswith(' \\\n'): + out_text += line[:-3].replace('\\', '/') + " \\\n" + else: + out_text += line.replace('\\', '/') + else: + suffix = '' + if line.endswith(' \\\n'): + suffix = ' \\' + path = line.lstrip()[:-3] + else: + path = line.strip() + # lowercase drive letter + path = path[0].lower() + path[1:] + # use $WINEPREFIX/dosdevices to resolve path + path = os.path.realpath(os.path.join(winedevices, path.replace('\\', '/'))) + out_text += "\t" + path + suffix + "\n" + + return out_text + +def main(): + parser = argparse.ArgumentParser( + description="""Transform a .d file from Wine paths to normal paths""" + ) + parser.add_argument( + "d_file", + help="""Dependency file in""", + ) + parser.add_argument( + "d_file_out", + help="""Dependency file out""", + ) + args = parser.parse_args() + + output = import_d_file(args.d_file) + + with open(args.d_file_out, "w", encoding="UTF-8") as f: + f.write(output) + + +if __name__ == "__main__": + main()