Skip to content

Commit

Permalink
Merge pull request #20 from Decompollaborate/develop
Browse files Browse the repository at this point in the history
2.3.1
  • Loading branch information
AngheloAlf committed Dec 24, 2023
2 parents ff3d522 + 565e547 commit e4afed5
Show file tree
Hide file tree
Showing 22 changed files with 1,437 additions and 483 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/maturin_upload_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ name: Upload to PyPI

on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -102,11 +97,31 @@ jobs:
name: wheels
path: dist

check_clippy_python_bindings:
name: Check clippy for Python bindings
runs-on: ubuntu-latest

steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Setup clippy
run: rustup component add clippy

- name: Run clippy
run: cargo clippy --all-targets --features python_bindings -- -D warnings

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
needs: [linux, windows, macos, sdist, check_clippy_python_bindings]
steps:
- uses: actions/download-artifact@v3
with:
Expand Down
54 changes: 48 additions & 6 deletions .github/workflows/publish_crate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: Build and upload Rust crate
on: [push, pull_request]

jobs:
build_rust:
name: Build Rust stuff and run Rust tests
check_fmt:
name: Check format
runs-on: ubuntu-latest

steps:
Expand All @@ -21,18 +21,60 @@ jobs:
- name: Check format
run: cargo fmt --check

check_clippy:
name: Check clippy
runs-on: ubuntu-latest

steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Setup clippy
run: rustup component add clippy

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
run: cargo clippy --all-targets -- -D warnings

- name: Build Rust package
run: cargo build --release --workspace
run_tests:
name: Run tests
runs-on: ubuntu-latest

steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Build Rust tests
- name: Run tests
run: cargo test --workspace

publish:
name: Publish
runs-on: ubuntu-latest

steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Build Rust package
run: cargo build --release --workspace

- name: Publish dry run
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
run: cargo publish --dry-run
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ name: Tests cases
on: [push, pull_request]

jobs:
tests_cases:
name: Tests cases
check_if_output_files_changed:
name: Check if output files changed
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -38,3 +39,28 @@ jobs:
echo "Changed files: ${{ steps.tests_changes.outputs.changed_files }}"
echo "Please install the latest changes, run \`python3 tests/update_outputs.py\`, check the changes are desirable and commit the result"
exit 1
check_progress_nonmatchings:
name: Check progress by NON_MATCHING symbols
runs-on: ubuntu-latest

steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Setup requirements
run: |
python3 -m pip install -U -r requirements.txt
python3 -m pip install -U maturin
- name: Install local mapfile_parser
run: python3 -m pip install .

- name: Update tests outputs
run: python3 tests/check_progress_nonmatchings.py
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.3.1] - 2023-12-23

### Added

- Add a few utility methods to `ProgressStats`.

### Changed

- `pyo3` is no longer needed to use this crate as Rust-only library.
- Updated Rust dependencies.

## [2.3.0] - 2023-11-05

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

[unreleased]: https://github.com/Decompollaborate/mapfile_parser/compare/master...develop
[2.3.1]: https://github.com/Decompollaborate/mapfile_parser/compare/2.3.0...2.3.1
[2.3.0]: https://github.com/Decompollaborate/mapfile_parser/compare/2.2.1...2.3.0
[2.2.1]: https://github.com/Decompollaborate/mapfile_parser/compare/2.2.0...2.2.1
[2.2.0]: https://github.com/Decompollaborate/mapfile_parser/compare/2.1.5...2.2.0
Expand Down
10 changes: 4 additions & 6 deletions 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.0"
version = "2.3.1"
edition = "2021"
authors = ["Anghelo Carvajal <[email protected]>"]
description = "Map file parser library focusing decompilation projects"
Expand All @@ -22,11 +22,9 @@ path = "src/rs/lib.rs"
crate-type = ["cdylib", "staticlib", "rlib"]

[dependencies]
regex = "1.9.5"
# pyo3 = { version = "0.19.0", optional = true }
pyo3 = { version = "0.19.0", optional = false }
regex = "1.10.2"
pyo3 = { version = "0.20.0", optional = true }
lazy_static = "1.4.0"

[features]
python_bindings = []
# python_bindings = ["dep:pyo3"]
python_bindings = ["dep:pyo3"]
16 changes: 2 additions & 14 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.0,<3.0.0
mapfile_parser>=2.3.1,<3.0.0
```

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

```toml
mapfile_parser = "2.3.0"
```

#### System-wide dependencies

Due to how intrusive `pyo3` is (and even impossible to disable via Cargo
features), Python development files are required to build and use the Rust
version of this library

To install those dependencies on a Debian/Ubuntu Linux distro:

```bash
sudo apt install libpython3-dev
mapfile_parser = "2.3.1"
```

## Versioning and changelog
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[project]
name = "mapfile_parser"
version = "2.3.0"
version = "2.3.1"
description = "Map file parser library focusing decompilation projects"
readme = "README.md"
requires-python = ">=3.7"
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, 0)
__version_info__ = (2, 3, 1)
__version__ = ".".join(map(str, __version_info__))
__author__ = "Decompollaborate"

Expand Down
4 changes: 2 additions & 2 deletions src/mapfile_parser/frontends/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def processArguments(args: argparse.Namespace):
asmPath: Path = args.asmpath
nonmatchingsPath: Path = args.nonmatchingspath
pathIndex: int = args.path_index
debugging: bool = args.debugging
debugging: bool = args.debugging #! @deprecated

exit(doProgress(mapPath, asmPath, nonmatchingsPath, pathIndex=pathIndex, debugging=debugging))

Expand All @@ -43,6 +43,6 @@ def addSubparser(subparser: argparse._SubParsersAction[argparse.ArgumentParser])
parser.add_argument("asmpath", help="Path to asm folder", type=Path)
parser.add_argument("nonmatchingspath", help="Path to nonmatchings folder", type=Path)
parser.add_argument("-i", "--path-index", help="Specify the index to start reading the file paths. Defaults to 2", type=int, default=2)
parser.add_argument("-d", "--debugging", help="Enable debugging prints", action="store_true")
parser.add_argument("-d", "--debugging", help="Enable debugging prints. This option is deprecated", action="store_true")

parser.set_defaults(func=processArguments)
22 changes: 22 additions & 0 deletions src/mapfile_parser/mapfile_parser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,30 @@ class ProgressStats:
@property
def total(self) -> int: ...

def undecompedPercentage(self) -> float:
...

def decompedPercentage(self) -> float:
...

def undecompedPercentageTotal(self, totalStats: ProgressStats) -> float:
...

def decompedPercentageTotal(self, totalStats: ProgressStats) -> float:
...

def getAsFrogressEntry(self, name: str) -> dict[str, int]: ...

@staticmethod
def getHeaderAsStr() -> str:
...

@staticmethod
def printHeader() -> None: ...

def getEntryAsStr(self, category: str, totalStats: ProgressStats) -> str:
...

def print(self, category: str, totalStats: ProgressStats) -> None: ...


Expand All @@ -67,7 +86,9 @@ class Symbol:
def getVramStr(self) -> str: ...
def getSizeStr(self) -> str: ...
def getVromStr(self) -> str: ...
def getAlignStr(self) -> str: ...

def serializeName(self, humanReadable: bool=True) -> str|int|None: ...
def serializeVram(self, humanReadable: bool=True) -> str|int|None: ...
def serializeSize(self, humanReadable: bool=True) -> str|int|None: ...
def serializeVrom(self, humanReadable: bool=True) -> str|int|None: ...
Expand All @@ -84,6 +105,7 @@ class Symbol:

def __eq__(self, other) -> bool: ...
def __hash__(self): ...
def __repr__(self): ...


class File:
Expand Down
34 changes: 0 additions & 34 deletions src/mapfile_parser/mapfile_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,6 @@
from .mapfile_parser import MapFile as MapFile


def __symbolrs_serializeVram(self: Symbol, humanReadable: bool=True) -> str|int|None:
if humanReadable:
return f"0x{self.vram:08X}"
return self.vram

def __symbolrs_serializeSize(self: Symbol, humanReadable: bool=True) -> str|int|None:
if self.size is None:
return None
if humanReadable:
return f"0x{self.size:X}"
return self.size

def __symbolrs_serializeVrom(self: Symbol, humanReadable: bool=True) -> str|int|None:
if self.vrom is None:
return None
if humanReadable:
return f"0x{self.vrom:06X}"
return self.vrom

def __symbolrs_toJson(self: Symbol, humanReadable: bool=True) -> dict[str, Any]:
result: dict[str, Any] = {
"name": self.name,
"vram": self.serializeVram(humanReadable=humanReadable),
"size": self.serializeSize(humanReadable=humanReadable),
"vrom": self.serializeVrom(humanReadable=humanReadable),
}
return result

Symbol.serializeVram = __symbolrs_serializeVram # type: ignore
Symbol.serializeSize = __symbolrs_serializeSize # type: ignore
Symbol.serializeVrom = __symbolrs_serializeVrom # type: ignore
Symbol.toJson = __symbolrs_toJson # type: ignore


@property # type: ignore
def __filers_filepath(self: File) -> Path:
return Path(self._filepath_internal)
Expand Down
Loading

0 comments on commit e4afed5

Please sign in to comment.