From c75a604a194fbb18b07b33691aae3537c4736e4e Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 11:14:23 -0300 Subject: [PATCH 01/18] Run unit_tests on windows and macos --- .github/workflows/unit_tests.yml | 26 ++++++++++++++++++++++++-- test/basic_app/build/basic_app.bin | Bin 0 -> 4416 bytes 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 test/basic_app/build/basic_app.bin diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 7f0e1d06..af11419d 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -6,22 +6,44 @@ on: jobs: unit_tests: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os.runner }} + strategy: + fail-fast: false + matrix: + os: [ + { + name: linux, + runner: ubuntu-latest + }, + { + name: windows, + runner: windows-latest + }, + { + name: macos, + runner: macos-latest + }, + ] + steps: - name: Checkout uses: actions/checkout@v4 - name: Install dependencies + if: matrix.os.name == 'linux' run: sudo apt-get install -y build-essential make binutils-mips-linux-gnu python3 python3-pip wget - name: Install Python dependencies run: python3 -m pip install -U -r requirements.txt - - name: Build basic_app + - name: Build `basic_app` on ${{ matrix.os.name }} + if: matrix.os.name == 'linux' + # Linux CI checks if any of the test C code has changed without updating the generated binary run: | make -C test/basic_app clean make -C test/basic_app download_kmc make -C test/basic_app all + git diff --exit-code test/basic_app/build/basic_app.bin - name: Run the test run: python3 test.py diff --git a/test/basic_app/build/basic_app.bin b/test/basic_app/build/basic_app.bin new file mode 100755 index 0000000000000000000000000000000000000000..6bc57623a44e6eec4447e2f43ab6ca15bea56fab GIT binary patch literal 4416 zcmeI0u};G<5Qcxpahm}N3w4OZ5{pP(U}nis2$dLsMok9BNGyzuj9%C(@d|waq&`7` zM`7&9$X4!xBeie9aF%}mXX||W^^NxDM-u>t9`OgwjA$(m{1Wb@f=)~(QR zS69=$UO5N>As_^VfDjM@LO=)z0U;m+gn$qb0{@f1c)k5uy#spr?TW}_acSby5{Yeb z%!&IuOi~AJeW5+_2a}?-Zc$Q0i-h|Us63A_3_b{Mg2%yi@F=)q2dwK|e{S3>=lMc1 zUbD8F)dxnD(H=nU=0sjX70To7#Pm5i#~J78=FmHuWy7qL@9| Date: Sun, 23 Feb 2025 11:27:40 -0300 Subject: [PATCH 02/18] Setup venv since macos really wants venv --- .github/workflows/unit_tests.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index af11419d..bf3bcba6 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -31,10 +31,15 @@ jobs: - name: Install dependencies if: matrix.os.name == 'linux' - run: sudo apt-get install -y build-essential make binutils-mips-linux-gnu python3 python3-pip wget + run: sudo apt-get install -y build-essential make binutils-mips-linux-gnu python3 python3-pip python3-venv wget + + - name: Setup Python venv + run: | + python3 -m venv .venv - name: Install Python dependencies - run: python3 -m pip install -U -r requirements.txt + run: | + .venv/bin/python3 -m pip install -U -r requirements.txt - name: Build `basic_app` on ${{ matrix.os.name }} if: matrix.os.name == 'linux' @@ -46,4 +51,5 @@ jobs: git diff --exit-code test/basic_app/build/basic_app.bin - name: Run the test - run: python3 test.py + run: | + .venv/bin/python3 test.py From f77c75a0069e7d2f4a76cd3a744b4ae3597a1eae Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 11:32:28 -0300 Subject: [PATCH 03/18] windows venv path is different for some reason --- .github/workflows/unit_tests.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index bf3bcba6..9c76430c 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -13,15 +13,18 @@ jobs: os: [ { name: linux, - runner: ubuntu-latest + runner: ubuntu-latest, + python_venv: .venv/bin/python3, }, { - name: windows, - runner: windows-latest + name: macos, + runner: macos-latest, + python_venv: .venv/bin/python3, }, { - name: macos, - runner: macos-latest + name: windows, + runner: windows-latest, + python_venv: .venv/Scripts/python3, }, ] @@ -39,7 +42,7 @@ jobs: - name: Install Python dependencies run: | - .venv/bin/python3 -m pip install -U -r requirements.txt + ${{ matrix.os.python_venv }} -m pip install -U -r requirements.txt - name: Build `basic_app` on ${{ matrix.os.name }} if: matrix.os.name == 'linux' @@ -52,4 +55,4 @@ jobs: - name: Run the test run: | - .venv/bin/python3 test.py + ${{ matrix.os.python_venv }} test.py From ead1bace02db83fcb124bf861f695bcb465f6f41 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:02:12 -0300 Subject: [PATCH 04/18] Enable `ld_dependencies` and `create_asm_dependencies` on the basic_app yaml Also reduce some paths and change compiler to KMC --- test/basic_app/expected/.splache | Bin 847 -> 892 bytes .../asm/nonmatchings/main/func_80000400.s | 3 -- .../asm/nonmatchings/main/func_800004A0.s | 3 -- test/basic_app/expected/basic_app.d | 21 ++++++++++++++ test/basic_app/expected/basic_app.ld | 20 +++++++------- test/basic_app/expected/src/main.c | 6 ++-- test/basic_app/splat.yaml | 26 ++++++++++-------- test/test_gen_expected.sh | 4 ++- 8 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 test/basic_app/expected/basic_app.d diff --git a/test/basic_app/expected/.splache b/test/basic_app/expected/.splache index 4bf620c10a486ff18f91e8c8cda5c65579339312..b54ddfbd9816894834d73a8b5650dabef7471523 100644 GIT binary patch delta 310 zcmZ9Gze)o^5Qkl(M@&RP&`64;5X9=P2-X&s;xi0;yK~9F=5D>&fQ@KrvCVPoBjgG4 zAijl9Vc{wlM5p@k%{PDElh0)KviJ7T+xe-daOH;pm335=3=qD-K`t4=O1B7ppRFMm zn(1Ws?!LJhH+1oQmZn+0BBQe?k^*UMno}8kA5GECjsFSYWIachMk9KXmz~#(F#@jD z7Q`6*kxRs>Sxnemf8oaoT2LCeB+D*J9MJ#pP`xnbC3Z!wMt= iuZn^m!>d1z+cjD&HI|ByBO0k1rNgK#|FkwAg2We2gmQ%d delta 277 zcmeyvcAhQ0fn}--GXogZPSNP$j*rhTD9OyvD~^w!0utaT$Vn_o%P-2E(!-o*W-_IR zBRM~}ATuYm2q@t0>$mLX~kA7vyA?=mQ0S!o@|&sKOK9iD?Q!R3MDVNtx2am7JKI u0ket^qGGZlqa3?5lL%R Date: Sun, 23 Feb 2025 12:06:57 -0300 Subject: [PATCH 05/18] Fix silly paths on CI --- .github/workflows/unit_tests.yml | 4 +++- test.py => test/test.py | 0 2 files changed, 3 insertions(+), 1 deletion(-) rename test.py => test/test.py (100%) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 9c76430c..16f6c259 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -6,6 +6,7 @@ on: jobs: unit_tests: + name: unit_tests on ${{ matrix.os.name }} runs-on: ${{ matrix.os.runner }} strategy: fail-fast: false @@ -54,5 +55,6 @@ jobs: git diff --exit-code test/basic_app/build/basic_app.bin - name: Run the test + working-directory: test/basic_app run: | - ${{ matrix.os.python_venv }} test.py + ../../${{ matrix.os.python_venv }} ../test.py diff --git a/test.py b/test/test.py similarity index 100% rename from test.py rename to test/test.py From ea4aae30ee881d41a2681787240879a47744aaf3 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:10:37 -0300 Subject: [PATCH 06/18] Fix?? --- .github/workflows/mypy.yml | 2 +- test/test.py | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 5fa2fb67..2448d0bb 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -51,4 +51,4 @@ jobs: run: mypy --show-column-numbers --hide-error-context create_config.py - name: mypy test - run: mypy --show-column-numbers --hide-error-context test.py + run: mypy --show-column-numbers --hide-error-context test/test.py diff --git a/test/test.py b/test/test.py index d584652e..dfd59414 100755 --- a/test/test.py +++ b/test/test.py @@ -1,20 +1,19 @@ #!/usr/bin/env python3 -from spimdisasm.common import FileSectionType - -from src.splat.scripts.split import * -import unittest -import io +import difflib import filecmp +import io import pathlib -from src.splat.util import symbols, options import spimdisasm -from src.splat.segtypes.common.rodata import CommonSegRodata -from src.splat.segtypes.common.code import CommonSegCode -from src.splat.segtypes.common.c import CommonSegC -from src.splat.segtypes.common.bss import CommonSegBss -from src.splat import __version__ -import difflib +import unittest + +from splat import __version__ +from splat.scripts.split import * +from splat.util import symbols, options +from splat.segtypes.common.rodata import CommonSegRodata +from splat.segtypes.common.code import CommonSegCode +from splat.segtypes.common.c import CommonSegC +from splat.segtypes.common.bss import CommonSegBss class Testing(unittest.TestCase): @@ -188,7 +187,7 @@ def test_add_symbol_to_spim_section(self): vram=0x40000000, filename="test", words=[], - sectionType=FileSectionType.Text, + sectionType=spimdisasm.common.FileSectionType.Text, segmentVromStart=0x0, overlayCategory=None, ) From c616dd599e17a8a2f6e5881888619f0b0fb3b5ce Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:24:38 -0300 Subject: [PATCH 07/18] CI FIX??? --- .github/workflows/unit_tests.yml | 3 +-- test/basic_app/expected/basic_app.d | 2 +- test/basic_app/expected/src/main.c | 6 +++--- test/test_gen_expected.sh | 4 +--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 16f6c259..897e5c3c 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -55,6 +55,5 @@ jobs: git diff --exit-code test/basic_app/build/basic_app.bin - name: Run the test - working-directory: test/basic_app run: | - ../../${{ matrix.os.python_venv }} ../test.py + ${{ matrix.os.python_venv }} test/test.py diff --git a/test/basic_app/expected/basic_app.d b/test/basic_app/expected/basic_app.d index e0492c4d..6e5b2a01 100644 --- a/test/basic_app/expected/basic_app.d +++ b/test/basic_app/expected/basic_app.d @@ -1,4 +1,4 @@ -split/build/basic_app_target.elf: \ +test/basic_app/split/build/basic_app_target.elf: \ build/asm/header.o \ build/assets/dummy_ipl3.o \ build/src/main.o \ diff --git a/test/basic_app/expected/src/main.c b/test/basic_app/expected/src/main.c index 0eca7bdf..9fde5634 100644 --- a/test/basic_app/expected/src/main.c +++ b/test/basic_app/expected/src/main.c @@ -1,7 +1,7 @@ #include "common.h" -INCLUDE_RODATA("split/asm/nonmatchings/main", D_80000510); +INCLUDE_RODATA("test/basic_app/split/asm/nonmatchings/main", D_80000510); -INCLUDE_ASM("split/asm/nonmatchings/main", func_80000400); +INCLUDE_ASM("test/basic_app/split/asm/nonmatchings/main", func_80000400); -INCLUDE_ASM("split/asm/nonmatchings/main", func_800004A0); +INCLUDE_ASM("test/basic_app/split/asm/nonmatchings/main", func_800004A0); diff --git a/test/test_gen_expected.sh b/test/test_gen_expected.sh index 2e6cdc3f..20a3e85b 100755 --- a/test/test_gen_expected.sh +++ b/test/test_gen_expected.sh @@ -7,9 +7,7 @@ export SPIMDISASM_ASM_GENERATED_BY="False" # Ensure we start from a clean state rm -rf test/basic_app/split -cd test/basic_app -python3 -m splat split splat.yaml --use-cache -cd ../.. +python3 -m splat split test/basic_app/splat.yaml --use-cache rm -rf test/basic_app/expected cp -r test/basic_app/split test/basic_app/expected From 52b5d5c57ceb9375b891ec0cbaee2ae15305df05 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:27:12 -0300 Subject: [PATCH 08/18] ciiiiiiiii --- .github/workflows/mypy.yml | 6 +++--- .github/workflows/unit_tests.yml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 2448d0bb..ae421286 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -26,6 +26,9 @@ jobs: - name: mypy splat lib run: mypy --show-column-numbers --hide-error-context src/splat + - name: mypy test + run: mypy --show-column-numbers --hide-error-context test/test.py + mypy_programs_checks: runs-on: ubuntu-latest name: mypy splat programs @@ -49,6 +52,3 @@ jobs: - name: mypy create_config run: mypy --show-column-numbers --hide-error-context create_config.py - - - name: mypy test - run: mypy --show-column-numbers --hide-error-context test/test.py diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 897e5c3c..2cf10bb9 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -44,6 +44,7 @@ jobs: - name: Install Python dependencies run: | ${{ matrix.os.python_venv }} -m pip install -U -r requirements.txt + ${{ matrix.os.python_venv }} -m pip install -e . - name: Build `basic_app` on ${{ matrix.os.name }} if: matrix.os.name == 'linux' From d7a0ace2167abbf3419ea97d64322f14705d3ae4 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:30:27 -0300 Subject: [PATCH 09/18] idk --- .github/workflows/unit_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 2cf10bb9..50297a5f 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -57,4 +57,4 @@ jobs: - name: Run the test run: | - ${{ matrix.os.python_venv }} test/test.py + ${{ matrix.os.python_venv }} test/test.py || (tree test/basic_app && false) From 8166fbed0a7d5e69e9458d2849adc94593258228 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:34:26 -0300 Subject: [PATCH 10/18] Stuff is hardcoded and I don't care enough to figure out how to fix it --- .github/workflows/mypy.yml | 7 ++++--- .github/workflows/unit_tests.yml | 2 +- test/test.py => test.py | 14 +++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) rename test/test.py => test.py (97%) diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index ae421286..8bef31a1 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -22,13 +22,11 @@ jobs: pip install mypy pip install -r requirements.txt pip install types-PyYAML + pip install -e . - name: mypy splat lib run: mypy --show-column-numbers --hide-error-context src/splat - - name: mypy test - run: mypy --show-column-numbers --hide-error-context test/test.py - mypy_programs_checks: runs-on: ubuntu-latest name: mypy splat programs @@ -52,3 +50,6 @@ jobs: - name: mypy create_config run: mypy --show-column-numbers --hide-error-context create_config.py + + - name: mypy test + run: mypy --show-column-numbers --hide-error-context test.py diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 50297a5f..70406666 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -57,4 +57,4 @@ jobs: - name: Run the test run: | - ${{ matrix.os.python_venv }} test/test.py || (tree test/basic_app && false) + ${{ matrix.os.python_venv }} test.py diff --git a/test/test.py b/test.py similarity index 97% rename from test/test.py rename to test.py index dfd59414..2227d433 100755 --- a/test/test.py +++ b/test.py @@ -7,13 +7,13 @@ import spimdisasm import unittest -from splat import __version__ -from splat.scripts.split import * -from splat.util import symbols, options -from splat.segtypes.common.rodata import CommonSegRodata -from splat.segtypes.common.code import CommonSegCode -from splat.segtypes.common.c import CommonSegC -from splat.segtypes.common.bss import CommonSegBss +from src.splat import __version__ +from src.splat.scripts.split import * +from src.splat.util import symbols, options +from src.splat.segtypes.common.rodata import CommonSegRodata +from src.splat.segtypes.common.code import CommonSegCode +from src.splat.segtypes.common.c import CommonSegC +from src.splat.segtypes.common.bss import CommonSegBss class Testing(unittest.TestCase): From 6ee58a3a430633793008501175434f38818854b6 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:43:58 -0300 Subject: [PATCH 11/18] maybe? --- test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index 2227d433..22de534d 100755 --- a/test.py +++ b/test.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 -import difflib -import filecmp +import unittest import io +import filecmp import pathlib import spimdisasm -import unittest +import difflib from src.splat import __version__ from src.splat.scripts.split import * From 9ce524798f89baacaea4a63d93db761bd2eb70fd Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:48:15 -0300 Subject: [PATCH 12/18] I'm dumb --- test/basic_app/.gitignore | 7 ++++--- .../expected/build/test/basic_app/split/src/main.asmproc.d | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 test/basic_app/expected/build/test/basic_app/split/src/main.asmproc.d diff --git a/test/basic_app/.gitignore b/test/basic_app/.gitignore index df3d40d8..7703c914 100644 --- a/test/basic_app/.gitignore +++ b/test/basic_app/.gitignore @@ -1,3 +1,4 @@ -build/ -split/ -gcc-2.7.2/ +/build/ +/split/ +/gcc-2.7.2/ +!/expected/ diff --git a/test/basic_app/expected/build/test/basic_app/split/src/main.asmproc.d b/test/basic_app/expected/build/test/basic_app/split/src/main.asmproc.d new file mode 100644 index 00000000..4ec280ec --- /dev/null +++ b/test/basic_app/expected/build/test/basic_app/split/src/main.asmproc.d @@ -0,0 +1,7 @@ +test/basic_app/split/build/test/basic_app/split/src/main.o: \ + test/basic_app/split/asm/nonmatchings/main/D_80000510.s \ + test/basic_app/split/asm/nonmatchings/main/func_80000400.s \ + test/basic_app/split/asm/nonmatchings/main/func_800004A0.s +test/basic_app/split/asm/nonmatchings/main/D_80000510.s: +test/basic_app/split/asm/nonmatchings/main/func_80000400.s: +test/basic_app/split/asm/nonmatchings/main/func_800004A0.s: From 3f35641148d9ae0ec01b52cd95062cd0944fbbb0 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 12:58:23 -0300 Subject: [PATCH 13/18] Ensure Windows uses posix paths on dependency files and the linker script --- src/splat/segtypes/common/c.py | 8 ++++---- src/splat/segtypes/linker_entry.py | 8 ++++---- test.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/splat/segtypes/common/c.py b/src/splat/segtypes/common/c.py index 344ecc69..ed49737f 100644 --- a/src/splat/segtypes/common/c.py +++ b/src/splat/segtypes/common/c.py @@ -477,7 +477,7 @@ def create_asm_dependencies_file( o_path = build_path / c_path.with_suffix(".o") else: o_path = build_path / c_path.with_suffix(c_path.suffix + ".o") - f.write(f"{o_path}:") + f.write(f"{o_path.as_posix()}:") depend_list = [] for entry in symbols_entries: if entry.function is not None: @@ -488,7 +488,7 @@ def create_asm_dependencies_file( outpath.parent.mkdir(parents=True, exist_ok=True) depend_list.append(outpath) - f.write(f" \\\n {outpath}") + f.write(f" \\\n {outpath.as_posix()}") else: for rodata_sym in entry.rodataSyms: rodata_name = rodata_sym.getName() @@ -498,9 +498,9 @@ def create_asm_dependencies_file( outpath.parent.mkdir(parents=True, exist_ok=True) depend_list.append(outpath) - f.write(f" \\\n {outpath}") + f.write(f" \\\n {outpath.as_posix()}") f.write("\n") for depend_file in depend_list: - f.write(f"{depend_file}:\n") + f.write(f"{depend_file.as_posix()}:\n") diff --git a/src/splat/segtypes/linker_entry.py b/src/splat/segtypes/linker_entry.py index 492071ff..5d8758f1 100644 --- a/src/splat/segtypes/linker_entry.py +++ b/src/splat/segtypes/linker_entry.py @@ -522,18 +522,18 @@ def save_symbol_header(self): ) def save_dependencies_file(self, output_path: Path, target_elf_path: Path): - output = f"{target_elf_path}:" + output = f"{target_elf_path.as_posix()}:" for entry in self.dependencies_entries: if entry.object_path is None: continue - output += f" \\\n {entry.object_path}" + output += f" \\\n {entry.object_path.as_posix()}" output += "\n" for entry in self.dependencies_entries: if entry.object_path is None: continue - output += f"{entry.object_path}:\n" + output += f"{entry.object_path.as_posix()}:\n" write_file_if_different(output_path, output) def _writeln(self, line: str): @@ -561,7 +561,7 @@ def _write_symbol(self, symbol: str, value: Union[str, int]): self.header_symbols.add(symbol) def _write_object_path_section(self, object_path: Path, section: str): - self._writeln(f"{object_path}({section});") + self._writeln(f"{object_path.as_posix()}({section});") def _begin_segment( self, segment: Segment, seg_name: str, noload: bool, is_first: bool diff --git a/test.py b/test.py index 22de534d..2227d433 100755 --- a/test.py +++ b/test.py @@ -1,11 +1,11 @@ #!/usr/bin/env python3 -import unittest -import io +import difflib import filecmp +import io import pathlib import spimdisasm -import difflib +import unittest from src.splat import __version__ from src.splat.scripts.split import * From d03ed60a3d53d11b16b2146381eba3924dca80d4 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 13:04:36 -0300 Subject: [PATCH 14/18] changelog --- CHANGELOG.md | 5 +++++ README.md | 2 +- pyproject.toml | 2 +- src/splat/__init__.py | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f984274c..037e15ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # splat Release Notes +### 0.32.4 + +- Fix splat on Windows not using forward slashes on generated paths. +- Setup CI to be run on Windows and Macos too. + ### 0.32.3 - Fix "unrecognized YAML option" error if disassemble_all is provided via CLI and as a YAML option. diff --git a/README.md b/README.md index 173fda12..738250e4 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The brackets corresponds to the optional dependencies to install while installin If you use a `requirements.txt` file in your repository, then you can add this library with the following line: ```txt -splat64[mips]>=0.32.3,<1.0.0 +splat64[mips]>=0.32.4,<1.0.0 ``` ### Optional dependencies diff --git a/pyproject.toml b/pyproject.toml index eed84dad..85703ccb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "splat64" # Should be synced with src/splat/__init__.py -version = "0.32.3" +version = "0.32.4" description = "A binary splitting tool to assist with decompilation and modding projects" readme = "README.md" license = {file = "LICENSE"} diff --git a/src/splat/__init__.py b/src/splat/__init__.py index 46c1a9ed..76ff8112 100644 --- a/src/splat/__init__.py +++ b/src/splat/__init__.py @@ -1,7 +1,7 @@ __package_name__ = __name__ # Should be synced with pyproject.toml -__version__ = "0.32.3" +__version__ = "0.32.4" __author__ = "ethteck" from . import util as util From d8d0f2c6d5b2376a416d32c9c68f83a9ec61f7f1 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 13:59:24 -0300 Subject: [PATCH 15/18] fix? --- test.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test.py b/test.py index 2227d433..debfdaf4 100755 --- a/test.py +++ b/test.py @@ -21,30 +21,30 @@ def compare_files(self, test_path, ref_path): with io.open(test_path) as test_f, io.open(ref_path) as ref_f: self.assertListEqual(list(test_f), list(ref_f)) - def get_same_files(self, dcmp, out): + def get_same_files(self, dcmp: filecmp.dircmp, out: List[Tuple[Path, Path, Path]]): for name in dcmp.same_files: - out.append((name, dcmp.left, dcmp.right)) + out.append((Path(name), Path(dcmp.left), Path(dcmp.right))) for sub_dcmp in dcmp.subdirs.values(): self.get_same_files(sub_dcmp, out) - def get_diff_files(self, dcmp, out): + def get_diff_files(self, dcmp: filecmp.dircmp, out: List[Tuple[Path, Path, Path]]): for name in dcmp.diff_files: - out.append((name, dcmp.left, dcmp.right)) + out.append((Path(name), Path(dcmp.left), Path(dcmp.right))) for sub_dcmp in dcmp.subdirs.values(): self.get_diff_files(sub_dcmp, out) - def get_left_only_files(self, dcmp, out): + def get_left_only_files(self, dcmp: filecmp.dircmp, out: List[Tuple[Path, Path, Path]]): for name in dcmp.left_only: - out.append((name, dcmp.left, dcmp.right)) + out.append((Path(name), Path(dcmp.left), Path(dcmp.right))) for sub_dcmp in dcmp.subdirs.values(): self.get_left_only_files(sub_dcmp, out) - def get_right_only_files(self, dcmp, out): + def get_right_only_files(self, dcmp: filecmp.dircmp, out: List[Tuple[Path, Path, Path]]): for name in dcmp.right_only: - out.append((name, dcmp.left, dcmp.right)) + out.append((Path(name), Path(dcmp.left), Path(dcmp.right))) for sub_dcmp in dcmp.subdirs.values(): self.get_right_only_files(sub_dcmp, out) @@ -57,16 +57,16 @@ def test_basic_app(self): "test/basic_app/split", "test/basic_app/expected", [".gitkeep"] ) - diff_files: List[Tuple[str, str, str]] = [] + diff_files: List[Tuple[Path, Path, Path]] = [] self.get_diff_files(comparison, diff_files) - same_files: List[Tuple[str, str, str]] = [] + same_files: List[Tuple[Path, Path, Path]] = [] self.get_same_files(comparison, same_files) - left_only_files: List[Tuple[str, str, str]] = [] + left_only_files: List[Tuple[Path, Path, Path]] = [] self.get_left_only_files(comparison, left_only_files) - right_only_files: List[Tuple[str, str, str]] = [] + right_only_files: List[Tuple[Path, Path, Path]] = [] self.get_right_only_files(comparison, right_only_files) print("same_files", same_files) From 9a1c64540cc0c31a1e85548dd94f339bb47bf634 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 14:04:11 -0300 Subject: [PATCH 16/18] Perform LF normalization on Windows --- .gitattributes | 2 ++ test.py | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..dfe07704 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/test.py b/test.py index debfdaf4..1180dec7 100755 --- a/test.py +++ b/test.py @@ -21,30 +21,30 @@ def compare_files(self, test_path, ref_path): with io.open(test_path) as test_f, io.open(ref_path) as ref_f: self.assertListEqual(list(test_f), list(ref_f)) - def get_same_files(self, dcmp: filecmp.dircmp, out: List[Tuple[Path, Path, Path]]): + def get_same_files(self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]]): for name in dcmp.same_files: - out.append((Path(name), Path(dcmp.left), Path(dcmp.right))) + out.append((name, dcmp.left, dcmp.right)) for sub_dcmp in dcmp.subdirs.values(): self.get_same_files(sub_dcmp, out) - def get_diff_files(self, dcmp: filecmp.dircmp, out: List[Tuple[Path, Path, Path]]): + def get_diff_files(self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]]): for name in dcmp.diff_files: - out.append((Path(name), Path(dcmp.left), Path(dcmp.right))) + out.append((name, dcmp.left, dcmp.right)) for sub_dcmp in dcmp.subdirs.values(): self.get_diff_files(sub_dcmp, out) - def get_left_only_files(self, dcmp: filecmp.dircmp, out: List[Tuple[Path, Path, Path]]): + def get_left_only_files(self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]]): for name in dcmp.left_only: - out.append((Path(name), Path(dcmp.left), Path(dcmp.right))) + out.append((name, dcmp.left, dcmp.right)) for sub_dcmp in dcmp.subdirs.values(): self.get_left_only_files(sub_dcmp, out) - def get_right_only_files(self, dcmp: filecmp.dircmp, out: List[Tuple[Path, Path, Path]]): + def get_right_only_files(self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]]): for name in dcmp.right_only: - out.append((Path(name), Path(dcmp.left), Path(dcmp.right))) + out.append((name, dcmp.left, dcmp.right)) for sub_dcmp in dcmp.subdirs.values(): self.get_right_only_files(sub_dcmp, out) @@ -57,16 +57,16 @@ def test_basic_app(self): "test/basic_app/split", "test/basic_app/expected", [".gitkeep"] ) - diff_files: List[Tuple[Path, Path, Path]] = [] + diff_files: List[Tuple[str, str, str]] = [] self.get_diff_files(comparison, diff_files) - same_files: List[Tuple[Path, Path, Path]] = [] + same_files: List[Tuple[str, str, str]] = [] self.get_same_files(comparison, same_files) - left_only_files: List[Tuple[Path, Path, Path]] = [] + left_only_files: List[Tuple[str, str, str]] = [] self.get_left_only_files(comparison, left_only_files) - right_only_files: List[Tuple[Path, Path, Path]] = [] + right_only_files: List[Tuple[str, str, str]] = [] self.get_right_only_files(comparison, right_only_files) print("same_files", same_files) From 4a4fefac3a24300e2d1918523541f2601692b72b Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 14:08:05 -0300 Subject: [PATCH 17/18] ??? --- .gitattributes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index dfe07704..d168646e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ -# Auto detect text files and perform LF normalization -* text=auto +# Force LF on everyfile +* text eol=lf From b125e37ff3a4613f18afb3a1fecbb101ea9c5d74 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Sun, 23 Feb 2025 14:11:20 -0300 Subject: [PATCH 18/18] More endline normalization? --- src/splat/segtypes/common/c.py | 4 ++-- src/splat/segtypes/linker_entry.py | 2 +- test.py | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/splat/segtypes/common/c.py b/src/splat/segtypes/common/c.py index 2adbafba..a072478a 100644 --- a/src/splat/segtypes/common/c.py +++ b/src/splat/segtypes/common/c.py @@ -451,7 +451,7 @@ def create_c_file( c_lines += self.get_c_lines_for_rodata_sym(rodata_sym, asm_out_dir) c_path.parent.mkdir(parents=True, exist_ok=True) - with c_path.open("w") as f: + with c_path.open("w", newline=options.opts.c_newline) as f: f.write("\n".join(c_lines)) log.write(f"Wrote {self.name} to {c_path}") @@ -475,7 +475,7 @@ def create_asm_dependencies_file( dep_path = build_path / c_path.with_suffix(".asmproc.d") dep_path.parent.mkdir(parents=True, exist_ok=True) - with dep_path.open("w") as f: + with dep_path.open("w", newline=options.opts.c_newline) as f: if options.opts.use_o_as_suffix: o_path = build_path / c_path.with_suffix(".o") else: diff --git a/src/splat/segtypes/linker_entry.py b/src/splat/segtypes/linker_entry.py index 5d8758f1..4a4974b8 100644 --- a/src/splat/segtypes/linker_entry.py +++ b/src/splat/segtypes/linker_entry.py @@ -51,7 +51,7 @@ def write_file_if_different(path: Path, new_content: str): if old_content != new_content: path.parent.mkdir(parents=True, exist_ok=True) - with path.open("w") as f: + with path.open("w", newline=options.opts.c_newline) as f: f.write(new_content) diff --git a/test.py b/test.py index 1180dec7..303e391c 100755 --- a/test.py +++ b/test.py @@ -35,14 +35,18 @@ def get_diff_files(self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]]): for sub_dcmp in dcmp.subdirs.values(): self.get_diff_files(sub_dcmp, out) - def get_left_only_files(self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]]): + def get_left_only_files( + self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]] + ): for name in dcmp.left_only: out.append((name, dcmp.left, dcmp.right)) for sub_dcmp in dcmp.subdirs.values(): self.get_left_only_files(sub_dcmp, out) - def get_right_only_files(self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]]): + def get_right_only_files( + self, dcmp: filecmp.dircmp, out: List[Tuple[str, str, str]] + ): for name in dcmp.right_only: out.append((name, dcmp.left, dcmp.right))