Skip to content

Commit

Permalink
Merge pull request #28 from Decompollaborate/develop
Browse files Browse the repository at this point in the history
2.3.8
  • Loading branch information
AngheloAlf committed Mar 25, 2024
2 parents ded5b55 + c0b7128 commit c478ac1
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8

- name: Install Dependencies
run: |
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.4.0] - 2024-03-25

### Added

- Add `endian` argument to `doFirstDiff`.
- Add `--endian` option to `first_diff` script.

### Removed

- Dropped Python 3.7 support.
- Python 3.8 is the minimum supported version now.

## [2.3.7] - 2024-02-27

### Fixed
Expand Down Expand Up @@ -331,6 +343,7 @@ Full changes: <https://github.com/Decompollaborate/mapfile_parser/compare/702a73
- Initial release

[unreleased]: https://github.com/Decompollaborate/mapfile_parser/compare/master...develop
[2.4.0]: https://github.com/Decompollaborate/mapfile_parser/compare/2.3.7...2.4.0
[2.3.7]: https://github.com/Decompollaborate/mapfile_parser/compare/2.3.6...2.3.7
[2.3.6]: https://github.com/Decompollaborate/mapfile_parser/compare/2.3.5...2.3.6
[2.3.5]: https://github.com/Decompollaborate/mapfile_parser/compare/2.3.4...2.3.5
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "mapfile_parser"
version = "2.3.7"
version = "2.4.0"
edition = "2021"
authors = ["Anghelo Carvajal <[email protected]>"]
description = "Map file parser library focusing decompilation projects"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you use a `requirements.txt` file in your repository, then you can add
this library with the following line:

```txt
mapfile_parser>=2.3.7,<3.0.0
mapfile_parser>=2.4.0,<3.0.0
```

#### Development version
Expand Down Expand Up @@ -74,7 +74,7 @@ cargo add mapfile_parser
Or add the following line manually to your `Cargo.toml` file:

```toml
mapfile_parser = "2.3.5"
mapfile_parser = "2.4.0"
```

## Versioning and changelog
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[mypy]
python_version = 3.7
python_version = 3.8
check_untyped_defs = True
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

[project]
name = "mapfile_parser"
version = "2.3.7"
version = "2.4.0"
description = "Map file parser library focusing decompilation projects"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
dependencies = [
"requests"
]
Expand Down
2 changes: 1 addition & 1 deletion src/mapfile_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from __future__ import annotations

__version_info__ = (2, 3, 7)
__version_info__ = (2, 4, 0)
__version__ = ".".join(map(str, __version_info__))
__author__ = "Decompollaborate"

Expand Down
15 changes: 11 additions & 4 deletions src/mapfile_parser/frontends/first_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import argparse
from pathlib import Path
from typing import Callable
from typing import Callable, Literal

from .. import mapfile
from .. import utils


def doFirstDiff(mapPath: Path, expectedMapPath: Path, romPath: Path, expectedRomPath: Path, diffCount: int=5, mismatchSize: bool=False, addColons: bool=True, bytesConverterCallback:Callable[[bytes, mapfile.MapFile],str|None]|None=None) -> int:
def doFirstDiff(mapPath: Path, expectedMapPath: Path, romPath: Path, expectedRomPath: Path, diffCount: int=5, mismatchSize: bool=False, addColons: bool=True, bytesConverterCallback:Callable[[bytes, mapfile.MapFile],str|None]|None=None, endian: Literal["big", "little"] ="big") -> int:
if not mapPath.exists():
print(f"{mapPath} must exist")
return 1
Expand Down Expand Up @@ -45,6 +45,10 @@ def doFirstDiff(mapPath: Path, expectedMapPath: Path, romPath: Path, expectedRom
expectedMapFile = mapfile.MapFile()
expectedMapFile.readMapFile(expectedMapPath)

endian_diff = 0
if endian == "little":
endian_diff = 3

map_search_diff: set[str] = set()
diffs = 0
shift_cap = 1000
Expand Down Expand Up @@ -74,7 +78,7 @@ def doFirstDiff(mapPath: Path, expectedMapPath: Path, romPath: Path, expectedRom

if (
len(map_search_diff) < diffCount
and builtRom[i] >> 2 != expectedRom[i] >> 2
and builtRom[i+endian_diff] >> 2 != expectedRom[i+endian_diff] >> 2
):
vromInfo = builtMapFile.findSymbolByVramOrVrom(i)
if vromInfo is not None:
Expand Down Expand Up @@ -133,7 +137,9 @@ def processArguments(args: argparse.Namespace):
diffCount: int = args.count
mismatchSize: bool = args.mismatch_size

exit(doFirstDiff(mapPath, expectedMapPath, romPath, expectedRomPath, diffCount, mismatchSize))
endian = args.endian

exit(doFirstDiff(mapPath, expectedMapPath, romPath, expectedRomPath, diffCount, mismatchSize, endian=endian))


def addSubparser(subparser: argparse._SubParsersAction[argparse.ArgumentParser]):
Expand All @@ -146,5 +152,6 @@ def addSubparser(subparser: argparse._SubParsersAction[argparse.ArgumentParser])

parser.add_argument("-c", "--count", type=int, default=5, help="find up to this many instruction difference(s)")
parser.add_argument("-m", "--mismatch-size", help="Do not exit early if the ROM sizes does not match", action="store_true")
parser.add_argument("-e", "--endian", help="Specify endianness of the binary", choices=["big", "little"], default="big")

parser.set_defaults(func=processArguments)

0 comments on commit c478ac1

Please sign in to comment.