From 568443b0208a80fea7dc318a8fd3400c111cbaf2 Mon Sep 17 00:00:00 2001 From: Yanis <35189056+Yanis42@users.noreply.github.com> Date: Wed, 5 Jun 2024 19:14:29 +0200 Subject: [PATCH] Add support for Windows (#159) * add support for windows * add crlf warning * add note for WSL * add git attributes from dtk template * review --- .gitattributes | 13 +++++++++++++ README.md | 15 +++++++++++++-- tools/asm_processor/compile.sh | 11 +++++++++-- tools/project.py | 2 ++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..47d4301 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,13 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Explicitly declare text files +*.py text + +# Enforce platform-specific encodings +*.bat text eol=crlf +*.sh text eol=lf +*.sha1 text eol=lf + +# decomp-toolkit writes files with LF +config/**/*.txt text eol=lf diff --git a/README.md b/README.md index ae4c84b..92fef0b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ You will need the following dependencies: * wine (for macOS or non-x86 Linux) * clang-format (optional) -#### Ubuntu/Debian +#### Ubuntu/Debian/Windows (WSL) You can install the dependencies with the following commands: @@ -44,6 +44,17 @@ brew install git ninja python3 brew install --cask --no-quarantine gcenx/wine/wine-crossover ``` +#### Windows (Native) + +You will need the following dependencies: +- [ninja.exe](https://github.com/ninja-build/ninja/releases/latest) +- Python (make sure to add it to your PATH during the installation) +- [Git for Windows](https://www.git-scm.com/downloads) + +You need to add ``C:\Program Files\Git\bin`` to your system's PATH (not the user one) in order to execute bash scripts properly. + +To get objdiff to work properly you also need to add the path to the folder containing ``ninja.exe`` to the system's PATH. + ### Instructions 1. Clone the repo using `git clone https://github.com/zeldaret/oot-gc`. @@ -61,7 +72,7 @@ brew install --cask --no-quarantine gcenx/wine/wine-crossover You can use [Dolphin](https://dolphin-emu.org) to perform both of these extraction steps: right click on the file you want to extract from, select `Properties`, and go to the `Filesystem` tab. -3. Run `python3 configure.py`. +3. Run `python3 configure.py`. (Note: on Windows you might need to run ``python configure.py``.) 4. Run `ninja` to build the `ce-j` version, or run `ninja ` to build another version. diff --git a/tools/asm_processor/compile.sh b/tools/asm_processor/compile.sh index 6c7c6c4..5af6608 100755 --- a/tools/asm_processor/compile.sh +++ b/tools/asm_processor/compile.sh @@ -2,6 +2,13 @@ set -euo pipefail +# bash scripts are executed with sh.exe, installed with Git for Windows, which is using MSYS +OS=$(uname -o) +PYTHON="python3" +if [ "$OS" == "Msys" ]; then + PYTHON="python" +fi + CC="$1" shift AS="$1" @@ -18,9 +25,9 @@ trap "rm -rf $TEMP" EXIT STEM=$(basename "$IN") STEM="${STEM%.*}" -tools/asm_processor/asm_processor.py "$IN" > "$TEMP/$STEM.c" +$PYTHON tools/asm_processor/asm_processor.py "$IN" > "$TEMP/$STEM.c" $CC "$TEMP/$STEM.c" -c -o "$TEMP" -tools/asm_processor/asm_processor.py "$IN" --post-process "$TEMP/$STEM.o" --assembler "$AS" --asm-prelude include/macros.inc +$PYTHON tools/asm_processor/asm_processor.py "$IN" --post-process "$TEMP/$STEM.o" --assembler "$AS" --asm-prelude include/macros.inc # Remove sections that don't work with our reloc hacks build/binutils/powerpc-eabi-objcopy --remove-section .mwcats.text --remove-section .comment "$TEMP/$STEM.o" "$OUT" # Copy depfile, replacing the first line with the correct input/output files diff --git a/tools/project.py b/tools/project.py index 577b6e7..ca7d844 100644 --- a/tools/project.py +++ b/tools/project.py @@ -422,6 +422,8 @@ def generate_build_ninja( mwcc_implicit.append(transform_dep) mwcc_sjis_implicit.append(transform_dep) mwcc_asm_processor_implicit.append(transform_dep) + else: + mwcc_asm_processor_cmd = "sh " + mwcc_asm_processor_cmd n.comment("Link ELF file") n.rule(