From b2de35d2006e4870895d6a00adb5f76c27eaf3b4 Mon Sep 17 00:00:00 2001 From: angie Date: Mon, 25 Mar 2024 18:21:07 -0300 Subject: [PATCH 1/3] Add endian to `first_diff` --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- README.md | 4 ++-- pyproject.toml | 2 +- src/mapfile_parser/__init__.py | 2 +- src/mapfile_parser/frontends/first_diff.py | 15 +++++++++++---- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ae0c94..2f738ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `endian` argument to `doFirstDiff`. +- Add `--endian` option to `first_diff` script. + ## [2.3.7] - 2024-02-27 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 0c43567..3841809 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "mapfile_parser" -version = "2.3.7" +version = "2.3.8" edition = "2021" authors = ["Anghelo Carvajal "] description = "Map file parser library focusing decompilation projects" diff --git a/README.md b/README.md index 14da536..4b36908 100644 --- a/README.md +++ b/README.md @@ -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.3.8,<3.0.0 ``` #### Development version @@ -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.3.8" ``` ## Versioning and changelog diff --git a/pyproject.toml b/pyproject.toml index c03e756..fb57d91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "mapfile_parser" -version = "2.3.7" +version = "2.3.8" description = "Map file parser library focusing decompilation projects" readme = "README.md" requires-python = ">=3.7" diff --git a/src/mapfile_parser/__init__.py b/src/mapfile_parser/__init__.py index f60efd7..55816c3 100644 --- a/src/mapfile_parser/__init__.py +++ b/src/mapfile_parser/__init__.py @@ -5,7 +5,7 @@ from __future__ import annotations -__version_info__ = (2, 3, 7) +__version_info__ = (2, 3, 8) __version__ = ".".join(map(str, __version_info__)) __author__ = "Decompollaborate" diff --git a/src/mapfile_parser/frontends/first_diff.py b/src/mapfile_parser/frontends/first_diff.py index c00f6b5..4480bd4 100644 --- a/src/mapfile_parser/frontends/first_diff.py +++ b/src/mapfile_parser/frontends/first_diff.py @@ -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 @@ -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 @@ -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: @@ -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]): @@ -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) From 6426b93421baeddcbf46209374bb36d2160da434 Mon Sep 17 00:00:00 2001 From: angie Date: Mon, 25 Mar 2024 18:21:31 -0300 Subject: [PATCH 2/3] version bump --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f738ff..a0a2ae1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.3.8] - 2024-03-25 + ### Added - Add `endian` argument to `doFirstDiff`. @@ -336,6 +338,7 @@ Full changes: Date: Mon, 25 Mar 2024 18:25:45 -0300 Subject: [PATCH 3/3] drop python 3.7 --- .github/workflows/mypy.yml | 4 ++-- CHANGELOG.md | 9 +++++++-- Cargo.toml | 2 +- README.md | 4 ++-- mypy.ini | 2 +- pyproject.toml | 4 ++-- src/mapfile_parser/__init__.py | 2 +- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index a607bcb..90d3e15 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -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: | diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a2ae1..96dca4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [2.3.8] - 2024-03-25 +## [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 @@ -338,7 +343,7 @@ Full changes: "] description = "Map file parser library focusing decompilation projects" diff --git a/README.md b/README.md index 4b36908..ad1cdb8 100644 --- a/README.md +++ b/README.md @@ -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.8,<3.0.0 +mapfile_parser>=2.4.0,<3.0.0 ``` #### Development version @@ -74,7 +74,7 @@ cargo add mapfile_parser Or add the following line manually to your `Cargo.toml` file: ```toml -mapfile_parser = "2.3.8" +mapfile_parser = "2.4.0" ``` ## Versioning and changelog diff --git a/mypy.ini b/mypy.ini index 316145e..3a3ba44 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,3 +1,3 @@ [mypy] -python_version = 3.7 +python_version = 3.8 check_untyped_defs = True diff --git a/pyproject.toml b/pyproject.toml index fb57d91..526aedc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,10 +3,10 @@ [project] name = "mapfile_parser" -version = "2.3.8" +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" ] diff --git a/src/mapfile_parser/__init__.py b/src/mapfile_parser/__init__.py index 55816c3..0042ee5 100644 --- a/src/mapfile_parser/__init__.py +++ b/src/mapfile_parser/__init__.py @@ -5,7 +5,7 @@ from __future__ import annotations -__version_info__ = (2, 3, 8) +__version_info__ = (2, 4, 0) __version__ = ".".join(map(str, __version_info__)) __author__ = "Decompollaborate"