Skip to content

Commit

Permalink
Add matchings_path option to be used alongside disassemble_all (#374
Browse files Browse the repository at this point in the history
)

* add matchings_path to be used alongside disassemble_all

* OK unit test

* run black on src

* run black on test.py

* changelog

* Make splitting logic more clear
  • Loading branch information
Drahsid authored Jun 6, 2024
1 parent da07fcb commit 5534df0
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# splat Release Notes

### 0.24.4

* New yaml option: `matchings_path`
* Determines the path to the asm matchings directory
* This is used alongside `disassemble_all` to organize matching functions from nonmatching functions

### 0.24.3

* New yaml option: `ld_align_segment_start`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.24.3,<1.0.0
splat64[mips]>=0.24.4,<1.0.0
```

### Optional dependencies
Expand Down
3 changes: 3 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ Determines the path to the asm data directory

Determines the path to the asm nonmatchings directory

### matchings_path

Determines the path to the asm matchings directory (used alongside `disassemble_all` to organize matching functions from nonmatching functions)

### cache_path
Path to splat cache
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "splat64"
# Should be synced with src/splat/__init__.py
version = "0.24.3"
version = "0.24.4"
description = "A binary splitting tool to assist with decompilation and modding projects"
readme = "README.md"
license = {file = "LICENSE"}
Expand Down
2 changes: 1 addition & 1 deletion src/splat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__package_name__ = __name__

# Should be synced with pyproject.toml
__version__ = "0.24.3"
__version__ = "0.24.4"
__author__ = "ethteck"

from . import util as util
Expand Down
14 changes: 13 additions & 1 deletion src/splat/segtypes/common/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ def scan(self, rom_bytes: bytes):
def split(self, rom_bytes: bytes):
if self.rom_start != self.rom_end:
asm_out_dir = options.opts.nonmatchings_path / self.dir
matching_asm_out_dir = options.opts.matchings_path / self.dir
asm_out_dir.mkdir(parents=True, exist_ok=True)
matching_asm_out_dir.mkdir(parents=True, exist_ok=True)

self.print_file_boundaries()

Expand Down Expand Up @@ -226,7 +228,17 @@ def split(self, rom_bytes: bytes):
)
assert func_sym is not None

self.create_c_asm_file(entry, asm_out_dir, func_sym)
if (
not entry.function.getName() in self.global_asm_funcs
and options.opts.disassemble_all
and not is_new_c_file
):
self.create_c_asm_file(
entry, matching_asm_out_dir, func_sym
)
else:
self.create_c_asm_file(entry, asm_out_dir, func_sym)

else:
for spim_rodata_sym in entry.rodataSyms:
if (
Expand Down
3 changes: 3 additions & 0 deletions src/splat/util/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class SplatOpts:
data_path: Path
# Determines the path to the asm nonmatchings directory
nonmatchings_path: Path
# Determines the path to the asm matchings directory (used alongside `disassemble_all` to organize matching functions from nonmatching functions)
matchings_path: Path
# Determines the path to the cache file (used when supplied --use-cache via the CLI)
cache_path: Path
# Tells splat to consider `hasm` files to be relative to `src_path` instead of `asm_path`.
Expand Down Expand Up @@ -402,6 +404,7 @@ def parse_endianness() -> Literal["big", "little"]:
asm_path=asm_path,
data_path=p.parse_path(asm_path, "data_path", "data"),
nonmatchings_path=p.parse_path(asm_path, "nonmatchings_path", "nonmatchings"),
matchings_path=p.parse_path(asm_path, "matchings_path", "matchings"),
cache_path=p.parse_path(base_path, "cache_path", ".splache"),
hasm_in_src_path=p.parse_opt("hasm_in_src_path", bool, False),
create_undefined_funcs_auto=p.parse_opt(
Expand Down
4 changes: 3 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def test_basic_app(self):
spimdisasm.common.GlobalConfig.ASM_GENERATED_BY = False
main(["test/basic_app/splat.yaml"], None, False)

comparison = filecmp.dircmp("test/basic_app/split", "test/basic_app/expected")
comparison = filecmp.dircmp(
"test/basic_app/split", "test/basic_app/expected", [".gitkeep"]
)

diff_files: List[Tuple[str, str, str]] = []
self.get_diff_files(comparison, diff_files)
Expand Down
Empty file.

0 comments on commit 5534df0

Please sign in to comment.